/* ============================================================
   PALABRA QUEST — Design System
   Theme: "Midnight Saffron" — deep ink navy, glass surfaces,
   warm saffron primary, mint + lavender secondaries.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --font-display: 'Outfit', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg-0: #070a14;
  --bg-1: #0b1020;
  --bg-2: #111733;
  --bg-3: #182043;

  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --surface-3: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text: #eef1ff;
  --text-2: #b7bdd9;
  --muted: #8089ad;
  --muted-2: #5a6285;

  --c-amber: #f6c453;
  --c-amber-2: #f28d35;
  --c-mint: #38d9c4;
  --c-mint-2: #1fb8a6;
  --c-lav: #a78bfa;
  --c-lav-2: #7c5cf0;
  --c-rose: #ff5c7a;
  --c-rose-2: #e0335a;
  --c-sky: #60a5fa;
  --c-lime: #a3e635;

  --grad-primary: linear-gradient(135deg, #f6c453 0%, #f28d35 100%);
  --grad-mint: linear-gradient(135deg, #38d9c4 0%, #2a9df4 100%);
  --grad-lav: linear-gradient(135deg, #a78bfa 0%, #6366f1 100%);
  --grad-rose: linear-gradient(135deg, #ff5c7a 0%, #ff8a5c 100%);
  --grad-text: linear-gradient(90deg, #f6c453, #ff8a5c 50%, #a78bfa);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --glow-amber: 0 0 0 1px rgba(246, 196, 83, 0.35), 0 8px 30px rgba(246, 196, 83, 0.25);
  --glow-mint: 0 0 0 1px rgba(56, 217, 196, 0.35), 0 8px 30px rgba(56, 217, 196, 0.25);
  --glow-rose: 0 0 0 1px rgba(255, 92, 122, 0.4), 0 8px 30px rgba(255, 92, 122, 0.3);

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 140ms;
  --t-med: 260ms;
  --t-slow: 480ms;

  --header-h: 68px;
  --container: 1120px;

  color-scheme: dark;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--c-mint); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; margin: 0 0 var(--sp-3); letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 var(--sp-4); }
:focus-visible { outline: 2px solid var(--c-amber); outline-offset: 3px; border-radius: 6px; }
::selection { background: rgba(246, 196, 83, 0.35); }

/* ---------- Background ---------- */
.bg-aurora {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(900px 600px at 15% -10%, rgba(124, 92, 240, 0.28), transparent 60%),
    radial-gradient(800px 500px at 110% 10%, rgba(56, 217, 196, 0.18), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(242, 141, 53, 0.16), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 70%);
}
.bg-aurora::after {
  content: ''; position: absolute; inset: 0; opacity: 0.35;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
}

/* ---------- Layout ---------- */
.container { width: min(100% - 2 * var(--sp-5), var(--container)); margin-inline: auto; }
.page { padding: var(--sp-8) 0 var(--sp-16); animation: page-in var(--t-slow) var(--ease) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-head p { color: var(--text-2); margin: 0; max-width: 60ch; }
.eyebrow { font-family: var(--font-display); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--c-amber); margin-bottom: var(--sp-2); }
.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.center { text-align: center; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.75rem; }
.mono { font-family: var(--font-mono); }
.grad-text { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  background: rgba(7, 10, 20, 0.6); border-bottom: 1px solid var(--border);
}
.site-header .container { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.brand { display: flex; align-items: center; gap: var(--sp-3); font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--grad-primary); display: grid; place-items: center; color: #1a1200; font-weight: 900; box-shadow: var(--glow-amber); font-size: 1.1rem; }
.nav { display: flex; align-items: center; gap: var(--sp-1); }
.nav a { color: var(--text-2); padding: 8px 14px; border-radius: var(--r-pill); font-weight: 500; font-size: 0.95rem; transition: background var(--t-fast), color var(--t-fast); }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--surface-3); color: var(--text); }
.header-tools { display: flex; align-items: center; gap: var(--sp-2); }
.xp-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.xp-pill .lvl { width: 24px; height: 24px; border-radius: 50%; background: var(--grad-primary); color: #1a1200; display: grid; place-items: center; font-size: 0.75rem; font-weight: 800; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--r-md); font-weight: 600; font-size: 0.95rem;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
  user-select: none; -webkit-user-select: none; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad-primary); color: #1a1200; border-color: transparent; box-shadow: var(--glow-amber); }
.btn-primary:hover { background: var(--grad-primary); filter: brightness(1.06); }
.btn-mint { background: var(--grad-mint); color: #03201c; border-color: transparent; box-shadow: var(--glow-mint); }
.btn-mint:hover { background: var(--grad-mint); filter: brightness(1.06); }
.btn-lav { background: var(--grad-lav); color: #fff; border-color: transparent; }
.btn-lav:hover { background: var(--grad-lav); filter: brightness(1.08); }
.btn-danger { background: var(--grad-rose); color: #fff; border-color: transparent; box-shadow: var(--glow-rose); }
.btn-danger:hover { background: var(--grad-rose); filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-outline { background: transparent; border-color: var(--border-strong); }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; border-radius: 10px; }
.btn-lg { padding: 16px 28px; font-size: 1.05rem; border-radius: 16px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-6); box-shadow: var(--shadow-sm); position: relative;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.card-glass { background: linear-gradient(160deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)); }
.card-hover { transition: transform var(--t-med) var(--ease), border-color var(--t-med), box-shadow var(--t-med); }
.card-hover:hover { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.card-pad-sm { padding: var(--sp-4); }
.card-title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; margin-bottom: 4px; }
.card-sub { color: var(--muted); font-size: 0.9rem; }

/* Game cards (home grid) */
.game-card { display: flex; flex-direction: column; gap: var(--sp-4); min-height: 230px; overflow: hidden; color: inherit; }
.game-card:hover { text-decoration: none; }
.game-card::before { content: ''; position: absolute; inset: -40% -20% auto auto; width: 220px; height: 220px; border-radius: 50%; background: var(--accent, var(--c-amber)); opacity: 0.12; filter: blur(50px); transition: opacity var(--t-med); }
.game-card:hover::before { opacity: 0.24; }
.game-card .icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.7rem; background: var(--surface-2); border: 1px solid var(--border); }
.game-card .game-name { font-family: var(--font-display); font-size: 1.35rem; font-weight: 800; }
.game-card .game-tag { color: var(--text-2); font-size: 0.95rem; flex: 1; }
.game-card .game-cta { display: flex; align-items: center; justify-content: space-between; color: var(--accent, var(--c-amber)); font-weight: 600; font-size: 0.9rem; }
.game-card .game-cta .arrow { transition: transform var(--t-fast); }
.game-card:hover .game-cta .arrow { transform: translateX(4px); }

/* ---------- Inputs ---------- */
.input {
  width: 100%; padding: 14px 16px; border-radius: var(--r-md); background: rgba(0,0,0,0.25);
  border: 1px solid var(--border-strong); color: var(--text); font-size: 1.05rem; outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder { color: var(--muted-2); }
.input:focus { border-color: var(--c-amber); box-shadow: 0 0 0 4px rgba(246,196,83,0.15); }
.input-lg { font-size: 1.5rem; padding: 18px 20px; text-align: center; font-family: var(--font-display); font-weight: 600; letter-spacing: 0.01em; border-radius: var(--r-lg); }
.input.is-correct { border-color: var(--c-mint); box-shadow: 0 0 0 4px rgba(56,217,196,0.18); }
.input.is-wrong { border-color: var(--c-rose); box-shadow: 0 0 0 4px rgba(255,92,122,0.18); animation: shake var(--t-slow) var(--ease); }
.input.is-accent { border-color: var(--c-amber); box-shadow: 0 0 0 4px rgba(246,196,83,0.2); animation: shake var(--t-slow) var(--ease); }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.select { appearance: none; padding: 10px 36px 10px 14px; border-radius: 12px; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23b7bdd9' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center; border: 1px solid var(--border); color: var(--text); }
.select option { background: var(--bg-2); }

/* Toggle switch */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 0.9rem; color: var(--text-2); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track { width: 42px; height: 24px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); position: relative; transition: background var(--t-fast); }
.toggle .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform var(--t-fast) var(--ease); }
.toggle input:checked + .track { background: var(--c-mint-2); }
.toggle input:checked + .track::after { transform: translateX(18px); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); font-size: 0.82rem; font-weight: 600; color: var(--text-2); transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast); }
.chip.is-on, .chip[aria-pressed="true"] { background: rgba(246,196,83,0.15); color: var(--c-amber); border-color: rgba(246,196,83,0.45); }
.chip-mint { background: rgba(56,217,196,0.15); color: var(--c-mint); border-color: rgba(56,217,196,0.4); }
.chip-rose { background: rgba(255,92,122,0.15); color: var(--c-rose); border-color: rgba(255,92,122,0.4); }
.chip-lav { background: rgba(167,139,250,0.15); color: var(--c-lav); border-color: rgba(167,139,250,0.4); }
.chip-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Accent bar ---------- */
.accent-bar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.accent-key {
  min-width: 40px; height: 40px; padding: 0 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--text);
  transition: transform var(--t-fast) var(--ease-bounce), background var(--t-fast), border-color var(--t-fast);
}
.accent-key:hover { background: var(--surface-3); border-color: var(--border-strong); transform: translateY(-2px); }
.accent-key:active { transform: scale(0.92); }
.accent-hint { font-size: 0.75rem; color: var(--muted); text-align: center; margin-top: 8px; }
.kbd { display: inline-block; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--border-strong); border-bottom-width: 2px; font-family: var(--font-mono); font-size: 0.75em; color: var(--text); vertical-align: middle; }

/* ---------- Progress bars & meters ---------- */
.bar { height: 10px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--grad-primary); transition: width var(--t-med) var(--ease); }
.bar-mint .bar-fill { background: var(--grad-mint); }
.bar-lav .bar-fill { background: var(--grad-lav); }
.bar-rose .bar-fill { background: var(--grad-rose); }
.bar-lg { height: 16px; }
.energy-bar { height: 18px; border-radius: 999px; background: rgba(0,0,0,0.4); border: 1px solid var(--border-strong); overflow: hidden; position: relative; }
.energy-bar .bar-fill { background: linear-gradient(90deg, #38d9c4, #a3e635 60%, #f6c453); box-shadow: 0 0 14px rgba(163,230,53,0.5); transition: width 120ms linear, background var(--t-med); }
.energy-bar.is-low .bar-fill { background: linear-gradient(90deg, #ff5c7a, #ff8a5c); box-shadow: 0 0 14px rgba(255,92,122,0.6); animation: pulse 0.8s ease-in-out infinite; }
.energy-bar::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 10%, rgba(0,0,0,0.25) 10% calc(10% + 2px)); pointer-events: none; }

/* Mastery dots (0–5) */
.mastery { display: inline-flex; gap: 3px; }
.mastery i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); display: block; }
.mastery i.on { background: var(--c-amber); box-shadow: 0 0 6px rgba(246,196,83,0.6); }
.mastery.m-max i.on { background: var(--c-mint); box-shadow: 0 0 6px rgba(56,217,196,0.6); }

/* Ring (SVG) */
.ring { position: relative; width: 120px; height: 120px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ring-bg { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 10; }
.ring .ring-fg { fill: none; stroke: url(#ringGrad); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset var(--t-slow) var(--ease); }
.ring .ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; }

/* ---------- HUD ---------- */
.hud { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; padding: 12px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); }
.hud-item { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9rem; }
.hud-item .label { margin: 0; }
.hud-item .val { font-family: var(--font-display); font-size: 1.15rem; font-weight: 800; }
.hud-spacer { flex: 1; }
.streak-flame { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: rgba(242,141,53,0.15); color: var(--c-amber-2); font-weight: 700; }

/* ---------- Quiz widget ---------- */
.quiz { display: flex; flex-direction: column; gap: var(--sp-4); }
.quiz-kind { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.quiz-prompt { font-family: var(--font-display); font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 800; line-height: 1.2; }
.quiz-prompt .sub { display: block; font-size: 0.95rem; font-weight: 500; color: var(--text-2); margin-top: 6px; font-family: var(--font-body); }
.quiz-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quiz-option {
  padding: 16px 18px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; text-align: left; color: var(--text);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), border-color var(--t-fast);
}
.quiz-option:hover:not(:disabled) { background: var(--surface-3); border-color: var(--border-strong); transform: translateY(-2px); }
.quiz-option .key { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: rgba(0,0,0,0.3); font-size: 0.75rem; margin-right: 10px; color: var(--muted); font-family: var(--font-mono); }
.quiz-option.is-correct { background: rgba(56,217,196,0.18); border-color: var(--c-mint); color: #d9fff9; }
.quiz-option.is-wrong { background: rgba(255,92,122,0.18); border-color: var(--c-rose); animation: shake var(--t-slow) var(--ease); }
.quiz-option:disabled { cursor: default; }
.quiz-letters { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.quiz-letter {
  width: 52px; height: 60px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; color: var(--text);
  transition: transform var(--t-fast) var(--ease-bounce), background var(--t-fast), border-color var(--t-fast);
}
.quiz-letter.is-space { width: 24px; background: transparent; border-color: transparent; cursor: default; }
.quiz-letter:hover:not(:disabled):not(.is-space) { background: var(--surface-3); transform: translateY(-3px); border-color: var(--border-strong); }
.quiz-letter.is-correct { background: rgba(56,217,196,0.2); border-color: var(--c-mint); }
.quiz-letter.is-wrong { background: rgba(255,92,122,0.2); border-color: var(--c-rose); animation: shake var(--t-slow) var(--ease); }
.quiz-letter.is-missed { background: rgba(246,196,83,0.2); border-color: var(--c-amber); }
.quiz-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.quiz-feedback { padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); animation: pop var(--t-med) var(--ease-bounce); }
.quiz-feedback.ok { border-color: rgba(56,217,196,0.5); background: rgba(56,217,196,0.1); }
.quiz-feedback.accent { border-color: rgba(246,196,83,0.5); background: rgba(246,196,83,0.1); }
.quiz-feedback.bad { border-color: rgba(255,92,122,0.5); background: rgba(255,92,122,0.1); }
.quiz-feedback .fb-title { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; margin-bottom: 4px; }
.quiz-feedback .fb-answer { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; letter-spacing: 0.02em; }
.quiz-feedback .fb-note { color: var(--text-2); font-size: 0.9rem; margin-top: 4px; }
.diff { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; letter-spacing: 0.04em; }
.diff .d-ok { color: var(--text-2); }
.diff .d-bad { color: var(--c-rose); text-decoration: line-through; text-decoration-thickness: 2px; }
.diff .d-fix { color: var(--c-mint); background: rgba(56,217,196,0.18); border-radius: 4px; padding: 0 2px; }
.diff .d-accent { color: var(--c-amber); background: rgba(246,196,83,0.2); border-radius: 4px; padding: 0 2px; }
.accent-char { color: var(--c-amber); font-weight: 800; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(4, 6, 14, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: grid; place-items: center; padding: var(--sp-4); animation: fade-in var(--t-med) both; }
.modal { width: min(100%, 560px); max-height: calc(100vh - 2 * var(--sp-4)); overflow: auto; background: linear-gradient(170deg, var(--bg-3), var(--bg-2)); border: 1px solid var(--border-strong); border-radius: var(--r-xl); padding: var(--sp-6); box-shadow: var(--shadow-lg); animation: pop var(--t-med) var(--ease-bounce) both; }
.modal-lg { width: min(100%, 720px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.modal-head h3 { margin: 0; }
.modal-close { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); background: var(--surface-2); }
.modal-close:hover { color: var(--text); background: var(--surface-3); }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(100% - 32px, 420px); }
.toast { padding: 12px 18px; border-radius: 14px; background: var(--bg-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow-md); font-weight: 600; font-size: 0.95rem; animation: toast-in var(--t-med) var(--ease-bounce) both; text-align: center; }
.toast.ok { border-color: rgba(56,217,196,0.5); }
.toast.bad { border-color: rgba(255,92,122,0.5); }
.toast.warn { border-color: rgba(246,196,83,0.5); }
.toast.out { animation: toast-out var(--t-med) var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* ---------- Game screen framing ---------- */
.game-shell { display: flex; flex-direction: column; gap: var(--sp-4); }
.game-topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.game-title { display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; }
.game-title .icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); font-size: 1.2rem; }
.game-stage { position: relative; border-radius: var(--r-xl); overflow: hidden; border: 1px solid var(--border-strong); background: var(--bg-1); box-shadow: var(--shadow-md); }
.game-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--sp-5); background: rgba(7,10,20,0.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade-in var(--t-med) both; z-index: 5; }
.game-overlay .panel { width: min(100%, 520px); text-align: center; background: linear-gradient(170deg, var(--bg-3), var(--bg-2)); border: 1px solid var(--border-strong); border-radius: var(--r-xl); padding: var(--sp-8) var(--sp-6); box-shadow: var(--shadow-lg); animation: pop var(--t-med) var(--ease-bounce) both; max-height: 100%; overflow: auto; }
.game-overlay .panel h2 { margin-bottom: 8px; }
.game-overlay .panel .big { font-family: var(--font-display); font-size: 3rem; font-weight: 900; line-height: 1; margin: var(--sp-3) 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: var(--sp-5) 0; }
.stat { padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.stat .stat-val { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; }
.stat .stat-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* Touch controls (shared by action games) */
.touch-controls { display: none; gap: 12px; justify-content: space-between; padding: 8px 4px 0; user-select: none; -webkit-user-select: none; touch-action: none; }
.touch-controls .tc-group { display: flex; gap: 10px; }
.touch-btn { width: 64px; height: 64px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border-strong); font-size: 1.5rem; display: grid; place-items: center; color: var(--text); -webkit-tap-highlight-color: transparent; }
.touch-btn:active, .touch-btn.is-down { background: rgba(246,196,83,0.25); border-color: var(--c-amber); }
@media (pointer: coarse) { .touch-controls { display: flex; } }

/* ---------- Word tiles / lists ---------- */
.word-row { display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.word-row .es { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.word-row .en { color: var(--text-2); }
.word-row:hover { border-color: var(--border-strong); }

/* ---------- Animations ---------- */
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
.anim-pop { animation: pop var(--t-med) var(--ease-bounce) both; }
.anim-shake { animation: shake var(--t-slow) var(--ease); }
.anim-float { animation: float 3s ease-in-out infinite; }

/* Confetti canvas */
.confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 300; }

/* ---------- Footer ---------- */
.site-footer { padding: var(--sp-10) 0; color: var(--muted); font-size: 0.85rem; text-align: center; border-top: 1px solid var(--border); margin-top: var(--sp-10); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  :root { --header-h: 60px; }
  .site-header .container { gap: var(--sp-2); }
  .nav { gap: 0; }
  .nav a { padding: 6px 8px; font-size: 0.84rem; }
  .header-tools { gap: 4px; }
  .xp-pill { padding: 4px 8px 4px 5px; font-size: 0.78rem; gap: 5px; }
  .xp-pill .lvl { width: 20px; height: 20px; font-size: 0.68rem; }
  .btn-icon { width: 36px; height: 36px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .nav a { padding: 8px 10px; font-size: 0.88rem; }
  .brand span.brand-text { display: none; }
  .card { padding: var(--sp-5); }
  .quiz-options { grid-template-columns: 1fr; }
  .quiz-letter { width: 44px; height: 52px; font-size: 1.35rem; }
  .word-row { grid-template-columns: 1fr; gap: 4px; }
  .modal { padding: var(--sp-5); border-radius: var(--r-lg); }
  .page { padding-top: var(--sp-5); }
}
@media (max-width: 400px) {
  .container { width: min(100% - 2 * var(--sp-3), var(--container)); }
  .nav a { padding: 6px 7px; font-size: 0.8rem; }
  .xp-pill .xp-text { display: none; }
  .xp-pill { padding: 3px; }
  .brand-mark { width: 32px; height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Home hero ---------- */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--sp-8); align-items: center; padding: var(--sp-6) 0 var(--sp-2); }
.hero h1 { margin-bottom: var(--sp-4); }
.hero-text p { font-size: 1.1rem; max-width: 52ch; }
.hero-stats { animation: pop var(--t-slow) var(--ease-bounce) both; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }
