
:root {
  --bg: #f9f9f9;
  --fg: #333;
  --muted: #666;
  --accent: #ff9f1c;  /* playful orange */
  --brand: #17a2b8;   /* header/footer brand color */
  --card: #fff;
  --shadow: 0 4px 14px rgba(0,0,0,.08);
  --radius: 14px;
  --gap: 20px;
  --maxw: 1400px; /* container width target for 4 columns */
  --ok: #1a7f37;
  --err: #b00020;
  --tab: #ececec;
  --tabActive: #ffd9ad;
}
* { box-sizing: border-box; }

/* Header with HahuBet brand color */
header {
  text-align: center;
  padding: 28px 16px 12px;
  background-color: var(--brand);
  color: #fff;
}
header h1, header .subtitle { color: #fff; }

body {
  margin: 0;
  color: var(--fg);
  background: var(--bg);
  font-family: 'Nunito','Noto Sans Ethiopic',system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
}

h1 { margin: 0 0 6px; font-size: clamp(1.6rem, 2.6vw, 2.3rem); }
.subtitle { font-size: clamp(.95rem, 1.2vw, 1.05rem); margin: 0 0 10px; }

/* Main grid: 4 columns on large screens */
.container {
  display: grid;
  grid-template-columns: 1fr; /* mobile */
  gap: var(--gap);
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px 32px;
}
@media (min-width: 1100px) {
  .container { grid-template-columns: repeat(4, 1fr); }
}

.series, .practice {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Titles: default 16px orange; ሀ/ለ/ሐ/መ doubled (32px) */
.series-title {
  font-size: 32px; font-weight: 700; color: var(--accent); margin: 0 0 12px;
}


/* Series list vertical */
.boxes { display: flex; flex-direction: column; gap: 14px; }

/* Practice spans all 4 columns */
@media (min-width: 1100px) { .practice { grid-column: 1 / 5; } }

/* Tabs */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tab { background: var(--tab); border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 800; cursor: pointer; }
.tab.active { background: var(--tabActive); }
.panel { display: block; }
.panel[hidden] { display: none; }

/* === PRACTICE LAYOUT RULES === */
/* Default grid for any practice ".boxes" unless overridden below */
.practice .boxes { display: grid; grid-template-columns: 1fr; gap: 12px; }

/* Answer (Typing), Listening, Matching => 3 columns (≥900px) */
@media (min-width: 900px) {
  #typing-boxes,
  #listening-boxes,
  #matching-boxes { grid-template-columns: repeat(3, 1fr); }
}

/* Pictures practice: questions grid = 1 column on mobile, 2 columns on larger screens (prevent overflow) */
#pictures-boxes {
  display: grid;
  grid-template-columns: 1fr;    /* mobile: 1 per row */
  gap: 12px;
}
@media (min-width: 800px) {
  #pictures-boxes { grid-template-columns: repeat(2, minmax(0, 1fr)); } /* tablet/desktop: 2 per row */
}

/* Handwriting: two columns (left controls, right canvas); stack on small screens */
.hand-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .hand-grid { grid-template-columns: 320px 1fr; } }

/* === Series row styling === */
.box {
  display: flex; align-items: center; gap: 14px; background: #f6f6f6; border: 0; border-radius: 10px;
  padding: 12px; cursor: pointer; flex-wrap: nowrap; width: 100%; text-align: left;
  transition: transform .06s ease, box-shadow .12s ease;
}
.box:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.icon-img { width: 135px; height: 135px; object-fit: contain; border-radius: 8px; background: #fff; flex: 0 0 135px; }
.icon-fallback {
  width: 135px; height: 135px; display: flex; align-items: center; justify-content: center; font-weight: 900;
  font-size: 3.6rem; color: var(--accent); background: #fff; border-radius: 8px; flex: 0 0 135px;
}
.box.uses-letter-media .word-block .letter { display: none; }
.word-block { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.letter { font-weight: 900; font-size: 1.8rem; color: var(--accent); line-height: 1.15; }
.word { font-size: 1.1rem; color: #333; line-height: 1.25; }
.translation { font-size: 1rem; color: var(--muted); line-height: 1.25; }

/* === Typing (Answer) row === */
.practice-row {
  display: grid; grid-template-columns: auto auto 1fr auto; gap: 10px; align-items: center;
  background: #f6f6f6; border-radius: 10px; padding: 10px;
}
.practice-letter { font-weight: 900; font-size: 1.6rem; color: var(--accent); min-width: 2.5ch; text-align: center; }
.practice-audio, .mc-audio {
  border: none; border-radius: 8px; padding: 8px 10px; background: #fff; color: #333; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.practice-input, .match-select, .hand-select, .hand-range {
  padding: 8px 10px; border-radius: 8px; border: 1px solid #ccc; width: 100%; font-family: inherit; font-size: 1rem;
}
.status { font-weight: 700; min-width: 2ch; text-align: center; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn { padding: 10px 14px; border: none; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.btn.secondary { background: #333; color: #fff; }
.result { margin-top: 8px; font-weight: 800; }

/* === Listening MCQ === */
.mc-row { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; background: #f6f6f6; border-radius: 10px; padding: 12px; }
.options { display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 600px) { .options { grid-template-columns: repeat(2, 1fr); } } /* internal two-column at tablet */

.opt { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.opt input { accent-color: var(--accent); }
.opt.correct { border-color: var(--ok); }
.opt.wrong   { border-color: var(--err); }

/* === Pictures practice (the “picture matching”) === */
.pic-row, .pic-card { width: 100%; }  /* guard against overflow */
.pic-row { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; background: #f6f6f6; border-radius: 10px; padding: 12px; }
.pic-letter { font-weight: 900; font-size: 1.6rem; color: var(--accent); min-width: 2.5ch; text-align: center; }
.pic-options { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .pic-options { grid-template-columns: repeat(2, minmax(200px, 1fr)); } } /* two-column choices */
.pic-card {
  position: relative; background: #fff; border: 2px solid #ddd; border-radius: 10px; padding: 10px;
  display: grid; grid-template-columns: minmax(160px, 40%) 1fr; align-items: center; gap: 12px; cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.pic-card img { width: 100%; height: 158px; object-fit: contain; background: #fff; border-radius: 6px; }
.pic-fallback {
  width: 100%; height: 158px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 4.6rem;
  color: var(--accent); background: #fff; border-radius: 6px; user-select: none;
}
.pic-caption { font-size: 1rem; color: #333; text-align: left; }
.pic-card input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pic-card.selected { border-color: #2a76f6; box-shadow: 0 0 0 3px rgba(42,118,246,.15); }
.pic-card.correct  { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(26,127,55,.15); }
.pic-card.wrong    { border-color: var(--err); box-shadow: 0 0 0 3px rgba(176,0,32,.12); }

/* === Handwriting === */
.hand-controls { background: #f6f6f6; border-radius: 10px; padding: 12px; display: grid; gap: 10px; align-content: start; }
.hand-label { font-weight: 700; color: #333; }
.hand-toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.hand-canvas-wrap { background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: 8px; }
.hand-canvas { display: block; width: 100%; height: auto; max-width: 600px; border-radius: 8px; background: #fff; touch-action: none; }
.hand-progress { font-weight: 800; color: #333; }
.hand-mini { font-size: .92rem; color: #666; }

@media print {
  body { background: #fff; }
  .container { gap: 12px; }
  .series, .practice { box-shadow: none; border: 1px solid #ddd; }
  .practice-audio, .mc-audio, .btn { display: none; }
}
