@font-face {
  font-family: 'Gochi Hand';
  src: url('/assets/fonts/GochiHand-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
/* ===== Engliplay - base styles ===== */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Karla:wght@400;500;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --primary: #5B7CFA;
  --primary-dark: #4867D8;
  --secondary: #6FAF9A;
  --accent: #E07A5F;
  --bg: #FAFBFC;
  --surface: rgba(255,255,255,0.88);
  --text: #263238;
  --text-muted: #6B7680;
  --border: #E5E9EE;
  --tint: #F3F6FA;
  --success-bg: #EAF6F0;
  --success-text: #43856D;
  --error-bg: #FFF0ED;
  --error-text: #C75D4A;
  --radius: 16px;
  --shadow: 0 2px 8px rgba(30,45,65,0.06);
  --shadow-hover: 0 8px 24px rgba(30,45,65,0.10);
  --stamp-shadow: 0 4px 14px rgba(91,124,250,0.18);

  --font-display: 'Fredoka', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Karla', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }

.container { max-width: 1140px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header / Nav ---------- */
.site-header {
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); box-shadow: 0 2px 12px rgba(30,45,65,0.04);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; gap: 16px; }
.logo { font-size: 1.4rem; font-weight: 700; font-family: var(--font-display); color: var(--primary-dark); letter-spacing: -0.01em; }
.main-nav { display: flex; gap: 22px; flex: 1; justify-content: center; }
.main-nav a { color: var(--text); font-weight: 600; position: relative; }
.main-nav a::after {
  content: ""; display: block; height: 2px; width: 0; background: var(--accent);
  transition: width .2s ease; margin-top: 3px;
}
.main-nav a:hover { color: var(--primary); }
.main-nav a:hover::after { width: 100%; }
.nav-actions { display: flex; gap: 10px; align-items: center; }
.nav-toggle {
  display: none; background: none; border: none; font-size: 1.6rem; cursor: pointer;
  color: var(--text); padding: 6px 10px; line-height: 1;
}
.nav-mobile-only { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  min-height: 44px;
  border-radius: 14px;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.72);
  box-shadow: var(--stamp-shadow);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(30,45,65,0.12); }
.btn:active { transform: translateY(0); box-shadow: 0 3px 8px rgba(30,45,65,0.08); }
.btn-primary { background: rgba(91,124,250,0.92); color: #fff; border-color: rgba(91,124,250,0.25); }
.btn-primary:hover { background: rgba(72,103,216,0.95); }
.btn-outline { background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: rgba(91,124,250,0.10); color: var(--primary-dark); }
.btn-ghost { background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn-ghost:hover { transform: none; box-shadow: none; background: var(--tint); }
.btn-lg { padding: 14px 32px; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ---------- Flash messages ---------- */
.flash { padding: 12px 18px; border-radius: 10px; margin: 16px 0; font-weight: 600; border-left: 4px solid transparent; }
.flash-success { background: var(--success-bg); color: var(--success-text); border-left-color: var(--success-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); border-left-color: var(--accent); }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 70px 20px 30px; }
.hero p { color: var(--text-muted); max-width: 560px; margin: 0 auto 24px; font-size: 1.1rem; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  max-width: 900px; margin: 40px auto; padding: 0 20px;
}
.stat-card {
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 20px; text-align: center;
}
.stat-num { display: block; font-size: 1.8rem; font-weight: 800; color: var(--primary); font-family: var(--font-display); }
.stat-label { color: var(--text-muted); font-size: .9rem; }

/* ---------- Sections / cards ---------- */
.section { padding: 40px 20px; max-width: 1140px; margin: 0 auto; }
.section.narrow { max-width: 620px; }
.section.center { text-align: center; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; margin-top: 20px; }

.class-card, .class-card-detailed, .game-card, .feature-card {
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 24px; transition: box-shadow .15s ease, border-color .15s ease;
}
.class-card:hover, .class-card-detailed:hover, .game-card:hover, .feature-card:hover {
  box-shadow: var(--shadow-hover); border-color: rgba(91,124,250,0.30);
}
.class-card { text-align: center; color: var(--text); display: block; }
.class-card-badge {
  width: 46px; height: 46px; border-radius: 50%; background: var(--secondary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; margin: 0 auto 12px; font-family: var(--font-display);
}
.class-card-detailed { text-align: center; }
.class-card-detailed p { color: var(--text-muted); margin: 8px 0 16px; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-top: 20px; }
.feature-icon { font-size: 2rem; display: block; margin-bottom: 10px; }
.feature-card p { color: var(--text-muted); }

.highlight-section { background: linear-gradient(180deg, transparent, rgba(243,246,250,0.72) 45%, transparent); border-radius: 24px; }

/* ---------- Forms ---------- */
.auth-form { display: flex; flex-direction: column; gap: 16px; text-align: left; margin-top: 20px; }
.auth-form label { font-weight: 700; font-size: .95rem; display: flex; flex-direction: column; gap: 6px; }
.auth-form input, .auth-form select {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 1rem; font-family: inherit;
}
.auth-form input:focus, .auth-form select:focus { outline: none; border-color: var(--primary); }
.center-note { text-align: center; margin-top: 18px; color: var(--text-muted); }

.login-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0; }
.login-choice-card {
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 30px 16px; text-align: center; color: var(--text); transition: border-color .15s ease, box-shadow .15s ease;
}
.login-choice-card:hover { box-shadow: var(--shadow-hover); border-color: rgba(91,124,250,0.30); }

.role-toggle { display: flex; justify-content: center; gap: 10px; margin: 20px 0; }
.role-toggle a {
  padding: 8px 20px; border-radius: 8px; border: 1px solid var(--border); color: var(--text-muted); font-weight: 700;
}
.role-toggle a.active { border-color: var(--primary); color: var(--primary); background: var(--tint); }

/* ---------- Dashboards ---------- */
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin: 24px 0; }
.dash-stat-card {
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 18px; text-align: center;
}
.dash-stat-num { display: block; font-size: 1.6rem; font-weight: 800; color: var(--primary); font-family: var(--font-display); }
.dash-stat-label { color: var(--text-muted); font-size: .85rem; }
.admin-stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.dash-actions { margin: 10px 0 30px; }
.dash-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; margin-top: 20px; }
.dash-col h2 { font-size: 1.15rem; }
.empty-state { color: var(--text-muted); background: var(--tint); padding: 14px 16px; border-radius: 10px; }
.plain-list, .badge-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.plain-list li, .badge-list li { background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 10px; padding: 10px 14px; border: 1px solid var(--border); }

/* ---------- Footer ---------- */
.site-footer { text-align: center; padding: 30px 20px; color: var(--text-muted); }

/* ---------- Admin ---------- */
.admin-subnav { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 8px; }
.admin-subnav a { padding: 8px 16px; border-radius: 8px; background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--border); font-weight: 600; color: var(--text); }
.admin-subnav a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.admin-grade-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.admin-grade-tabs a { padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: .9rem; }
.admin-grade-tabs a.active { border-color: var(--primary); color: var(--primary); background: var(--tint); }

.admin-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

.admin-filter-form { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
.admin-filter-form select, .admin-filter-form input[type="text"] {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); font-family: inherit;
}

.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.admin-table th, .admin-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: .92rem; }
.admin-table th { background: var(--tint); font-weight: 700; }
.admin-table tr:last-child td { border-bottom: none; }

.badge-pill {
  display: inline-block; padding: 4px 12px; border-radius: 8px; font-size: .75rem; font-weight: 700;
  border: 1.5px dashed currentColor; cursor: pointer; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: .04em;
}
.badge-live { background: var(--success-bg); color: var(--success-text); }
.badge-hidden { background: var(--tint); color: var(--text-muted); }

.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-danger { background: var(--error-bg); color: var(--error-text); border-color: var(--error-text); }
.btn-danger:hover { background: #f6d3cb; }
.inline-form { display: inline; }

.pagination { display: flex; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.pagination a { padding: 6px 13px; border-radius: 8px; border: 1px solid var(--border); color: var(--text); font-weight: 600; }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox-label input { width: auto; }
.muted { color: var(--text-muted); font-size: .92rem; }

/* ---------- Units / Words / Sentences (student) ---------- */
.unit-card { background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 20px; display: block; color: var(--text); position: relative; transition: border-color .15s ease, box-shadow .15s ease; }
.unit-card:hover { box-shadow: var(--shadow-hover); border-color: rgba(91,124,250,0.30); }
.unit-card.unit-completed { border: 2px solid var(--secondary); }

.unit-subnav { display: flex; gap: 10px; margin: 18px 0; }
.unit-subnav a, .unit-subnav span { padding: 8px 18px; border-radius: 8px; font-weight: 700; }
.unit-subnav a { background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--border); color: var(--text); }
.unit-subnav span.active { background: var(--primary); color: #fff; }

.word-card { background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 20px; text-align: center; }
.word-card-image { height: 100px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.word-card-image img { max-height: 100px; max-width: 100%; border-radius: 10px; object-fit: cover; }
.word-card-placeholder { font-size: 2.4rem; opacity: .4; display: flex; align-items: center; justify-content: center; height: 100%; }
.word-meaning { color: var(--primary-dark); font-weight: 700; }
.word-phonetic { color: var(--text-muted); font-style: italic; font-size: .9rem; }
.word-example { font-size: .88rem; color: var(--text-muted); margin-top: 10px; }

.sentence-list { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.sentence-card { background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 18px 22px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.sentence-en { font-weight: 700; font-size: 1.05rem; margin: 0; }
.sentence-tr { margin: 2px 0 0; }
.sentence-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: right; }

.word-card-learned { border: 2px solid var(--secondary); }
.learned-badge { align-self: center; }

/* ---------- Games ---------- */
.game-section { max-width: 900px; }
.game-hud { display: flex; gap: 20px; font-weight: 800; font-size: 1.1rem; margin: 10px 0 20px; font-family: var(--font-mono); letter-spacing: .02em; }
.game-root { min-height: 200px; }

.game-result-overlay {
  position: fixed; inset: 0; background: rgba(31, 42, 34, 0.55); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.game-result-box {
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); padding: 32px; max-width: 420px; width: 100%;
  text-align: center; box-shadow: var(--shadow-hover); border: 1px solid var(--border);
}
.result-xp { font-weight: 800; color: var(--primary); font-size: 1.1rem; margin: 10px 0; font-family: var(--font-mono); }
#result-badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }

.game-card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 20px; }
.game-card-tile {
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 22px; text-align: center; color: var(--text); transition: border-color .15s ease, box-shadow .15s ease;
}
.game-card-tile:hover { box-shadow: var(--shadow-hover); border-color: rgba(91,124,250,0.30); }
.game-card-tile .feature-icon { font-size: 2.2rem; }

/* Hangman */
.hangman-word { font-size: 2rem; letter-spacing: 8px; font-weight: 800; text-align: center; margin: 20px 0; font-family: var(--font-mono); }
.hangman-keyboard { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 500px; margin: 0 auto; }
.hangman-keyboard button { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-weight: 700; cursor: pointer; }
.hangman-keyboard button:disabled { opacity: .35; cursor: default; }
.hangman-figure { text-align: center; font-size: 3rem; margin-bottom: 10px; }
.hangman-meaning { text-align: center; color: var(--text-muted); margin-bottom: 10px; }

/* Word matching / memory */
.match-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; max-width: 700px; margin: 0 auto; }
.match-item {
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 10px; border: 1px solid var(--border); padding: 14px; margin-bottom: 10px;
  cursor: pointer; text-align: center; font-weight: 700; border: 2px solid transparent;
}
.match-item.selected { border-color: var(--primary); }
.match-item.correct { border-color: var(--secondary); background: var(--success-bg); }
.match-item.wrong { border-color: var(--error-text); background: var(--error-bg); }
.match-item.matched { opacity: .35; pointer-events: none; }

.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; max-width: 560px; margin: 0 auto; }
.memory-card {
  aspect-ratio: 1; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.6rem; cursor: pointer; font-weight: 800; font-family: var(--font-display); text-align: center; padding: 6px; box-shadow: var(--shadow);
}
.memory-card.flipped { background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--text); border: 2px solid var(--primary); }
.memory-card.matched { background: var(--success-bg); color: var(--success-text); border: 2px solid var(--secondary); }

/* Letter tiles (word hunt / word creation) */
.letter-cloud { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 560px; margin: 16px auto; }
.letter-tile {
  width: 46px; height: 46px; border-radius: 8px; background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--border);
  font-weight: 800; font-family: var(--font-display); font-size: 1.2rem; cursor: pointer;
}
.letter-tile:disabled { opacity: .3; cursor: default; }
.build-slot {
  min-height: 50px; display: flex; gap: 6px; justify-content: center; align-items: center; margin-bottom: 16px;
  border-bottom: 3px dashed var(--border); padding-bottom: 8px; max-width: 500px; margin-left: auto; margin-right: auto;
}
.build-slot span { min-width: 40px; text-align: center; font-size: 1.3rem; font-weight: 800; font-family: var(--font-mono); border-bottom: 2px solid var(--primary); }
.word-target-meaning { text-align: center; font-size: 1.2rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 4px; }

/* Wordsearch */
.wordsearch-wrap { display: flex; gap: 30px; flex-wrap: wrap; justify-content: center; }
.wordsearch-grid {
  display: grid; gap: 2px; user-select: none;
  --ws-cell: 32px;
  grid-template-columns: repeat(var(--cols), var(--ws-cell));
}
.wordsearch-cell {
  width: var(--ws-cell); height: var(--ws-cell); display: flex; align-items: center; justify-content: center;
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 4px; font-weight: 700; font-family: var(--font-mono); cursor: pointer; font-size: .95rem;
}
.wordsearch-cell.selecting { background: var(--tint); }
.wordsearch-cell.found { background: var(--success-bg); color: var(--success-text); }
.wordsearch-list { list-style: none; padding: 0; min-width: 160px; }
.wordsearch-list li { padding: 6px 0; font-weight: 700; }
.wordsearch-list li.found { text-decoration: line-through; color: var(--text-muted); }

/* Sentence ordering */
.sentence-build-area { min-height: 60px; border: 2px dashed var(--border); border-radius: 10px; padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; max-width: 700px; margin: 16px auto; }
.word-chip {
  background: var(--primary); color: #fff; padding: 8px 16px; border-radius: 8px; font-weight: 700; font-family: var(--font-display); cursor: pointer; border: none;
}
.word-chip.outline { background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: var(--text); border: 1px solid var(--border); }
.sentence-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 700px; margin: 0 auto; }

/* Grammar games */
.grammar-sentence { font-size: 1.3rem; text-align: center; margin: 24px 0; line-height: 2; }
.grammar-sentence .g-word { cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.grammar-sentence .g-word:hover { background: var(--tint); }
.grammar-tf-buttons { display: flex; gap: 14px; justify-content: center; margin-top: 20px; }

/* Picture puzzle */
.puzzle-image { max-width: 320px; max-height: 240px; display: block; margin: 0 auto 20px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.puzzle-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; max-width: 600px; margin: 0 auto; }

/* Hero builder */
.hero-stage { text-align: center; }
.hero-avatar { font-size: 5rem; margin: 10px 0; }
.hero-hp-bar { max-width: 320px; margin: 0 auto 20px; height: 18px; background: var(--border); border-radius: 999px; overflow: hidden; }
.hero-hp-fill { height: 100%; background: linear-gradient(90deg, var(--secondary), var(--primary)); transition: width .3s ease; }
.hero-question { text-align: center; font-size: 1.4rem; font-weight: 800; margin: 16px 0; font-family: var(--font-display); }

/* Interactive story */
.story-text { font-size: 1.15rem; line-height: 1.8; background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 24px; margin-bottom: 20px; }
.story-choices { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- Responsive: tablet ---------- */
@media (max-width: 1024px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .memory-grid { max-width: 460px; }
}

/* ---------- Responsive: phone ---------- */
@media (max-width: 780px) {
  .header-inner { padding: 10px 16px; }
  .main-nav { display: none; }
  .nav-toggle { display: block; }
  .nav-actions { display: none; }

  .main-nav.open {
    display: flex; flex-direction: column; align-items: stretch; gap: 0;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: var(--shadow-hover);
    padding: 8px 0; border-top: 1px solid var(--border);
  }
  .main-nav.open a {
    padding: 14px 24px; border-bottom: 1px solid var(--border); font-size: 1.05rem;
  }
  .main-nav.open a:last-child { border-bottom: none; }
  .nav-mobile-only { display: block; }

  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .login-choice-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.25rem; }
  .form-row { grid-template-columns: 1fr; }
  .admin-table { display: block; overflow-x: auto; white-space: nowrap; }
  .sentence-card { flex-direction: column; align-items: flex-start; }
  .sentence-meta { align-items: flex-start; text-align: left; }

  /* Touch-friendly buttons everywhere */
  .btn { padding: 12px 22px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { padding: 10px 16px; min-height: 40px; }
  button.badge-pill { min-height: 40px; padding: 8px 16px; }

  /* Games */
  .game-hud { font-size: 1rem; gap: 14px; }
  .hangman-word { font-size: 1.5rem; letter-spacing: 4px; }
  .hangman-keyboard button { width: 34px; height: 40px; font-size: .9rem; }
  .match-columns { gap: 12px; }
  .match-item { padding: 10px; font-size: .9rem; }
  .memory-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 340px; }
  .memory-card { font-size: 1.2rem; }
  .letter-tile { width: 40px; height: 44px; font-size: 1.05rem; }
  .build-slot span { min-width: 32px; font-size: 1.1rem; }
  .wordsearch-wrap { flex-direction: column; align-items: center; }
  .wordsearch-grid { --ws-cell: 24px; max-width: 100%; overflow-x: auto; padding-bottom: 8px; font-size: .8rem; }
  .word-chip { padding: 10px 14px; font-size: .9rem; }
  .grammar-sentence { font-size: 1.05rem; line-height: 1.9; }
  .grammar-tf-buttons { flex-direction: column; align-items: stretch; }
  .grammar-tf-buttons .btn { width: 100%; }
  .puzzle-image { max-width: 100%; }
  .story-choices .btn { flex: 1 1 45%; }
}

@media (max-width: 420px) {
  .memory-grid { grid-template-columns: repeat(3, 1fr); max-width: 280px; }
  .hangman-keyboard button { width: 30px; height: 38px; font-size: .8rem; }
  .dash-stats, .admin-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Trace the Word ---------- */
.trace-word-stage { text-align: center; }
.trace-canvas {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #fff;
  touch-action: none;
  max-width: 100%;
  cursor: crosshair;
  margin: 16px 0;
}
.trace-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 10px; }
.trace-status { margin-top: 14px; min-height: 28px; font-weight: 700; font-family: var(--font-mono); }
.trace-status.ok { color: var(--success-text); }
.trace-status.err { color: var(--error-text); }

@media (max-width: 780px) {
  .trace-canvas { width: 100%; height: auto; }
}