/* ===== Word Master – design tokens ===== */
:root {
  --navy-950: #060a1f; --navy-900: #0a1030; --navy-800: #111a45; --navy-700: #18245c; --royal: #1d3fbf; --royal-2: #2f5bff;
  --gold: #f5b942; --gold-2: #ffd27a; --electric: #3fb7ff;
  --ok: #22c38e; --bad: #ff5d6c; --warn: #ffb020;
  --radius: 18px; --radius-sm: 12px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Georgia", "Times New Roman", serif;
  --ease: cubic-bezier(.2,.8,.2,1);
}
[data-theme="dark"] {
  --bg: radial-gradient(1200px 600px at 10% -10%, #1a2a7a 0%, transparent 60%), radial-gradient(900px 500px at 110% 10%, #2a1a5e 0%, transparent 55%), var(--navy-950);
  --surface: rgba(20, 30, 80, .55); --surface-2: rgba(28, 42, 104, .6); --surface-solid: #111a45; --line: rgba(160, 180, 255, .14);
  --text: #eef2ff; --muted: #9aa6d6; --dim: #6c78aa; --shadow: 0 10px 40px rgba(0, 0, 0, .35); --input: rgba(8, 14, 44, .7);
}
[data-theme="light"] {
  --bg: radial-gradient(1200px 600px at 10% -10%, #dfe7ff 0%, transparent 60%), radial-gradient(900px 500px at 110% 10%, #efe6ff 0%, transparent 55%), #f3f5fb;
  --surface: #ffffff; --surface-2: #f4f6fc; --surface-solid: #ffffff; --line: #e1e6f3;
  --text: #0d1640; --muted: #56618c; --dim: #8a93b5; --shadow: 0 8px 30px rgba(20, 40, 120, .08); --input: #f7f8fd;
}
[data-accent="gold"] { --accent: var(--gold); --accent-2: var(--gold-2); --accent-ink: #2a1c00; }
[data-accent="blue"] { --accent: var(--electric); --accent-2: #8fd6ff; --accent-ink: #001a2c; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); background: var(--bg); background-attachment: fixed; color: var(--text); -webkit-font-smoothing: antialiased; font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-family: var(--display); font-size: clamp(26px, 4vw, 36px); letter-spacing: -.01em; }
h2 { font-size: 20px; } h3 { font-size: 16px; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.center { text-align: center; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ===== layout ===== */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 16px; border-right: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(18px); display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand .logo { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--royal), var(--royal-2)); color: var(--gold); font-family: var(--display); font-weight: 700; font-size: 22px; box-shadow: 0 6px 20px rgba(47, 91, 255, .4); overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.brand b { display: block; font-family: var(--display); font-size: 18px; letter-spacing: .02em; }
.brand span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.nav a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 600; transition: .2s var(--ease); }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: linear-gradient(90deg, rgba(47, 91, 255, .25), transparent); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav .ico { width: 22px; text-align: center; }
.side .foot { margin-top: auto; }
.main { padding: 28px clamp(16px, 3vw, 40px) 90px; max-width: 1280px; width: 100%; animation: page .35s var(--ease); }
@keyframes page { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.mobile-nav { display: none; }

/* ===== cards & surfaces ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.card.pad-lg { padding: 28px; }
.card.hero { background: linear-gradient(135deg, var(--royal) 0%, #3b2aa8 55%, #12195a 100%); color: #fff; border: 0; position: relative; overflow: hidden; }
.card.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(245, 185, 66, .35), transparent 70%); }
.card.hero .muted { color: rgba(255, 255, 255, .75); }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.kpi .value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.kpi .ico { font-size: 20px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--muted); }
.chip.gold { background: rgba(245, 185, 66, .15); color: var(--accent); border-color: rgba(245, 185, 66, .35); }
.chip.ok { background: rgba(34, 195, 142, .15); color: var(--ok); border-color: rgba(34, 195, 142, .3); }
.chip.bad { background: rgba(255, 93, 108, .14); color: var(--bad); border-color: rgba(255, 93, 108, .3); }
.chip.blue { background: rgba(47, 91, 255, .18); color: #8fa8ff; border-color: rgba(47, 91, 255, .35); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--royal-2)); display: grid; place-items: center; font-weight: 800; color: var(--accent-ink); overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 88px; height: 88px; font-size: 32px; }

/* ===== buttons & inputs ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 700; cursor: pointer; transition: transform .15s var(--ease), background .2s, box-shadow .2s; white-space: nowrap; }
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border: 0; }
.btn.royal { background: linear-gradient(135deg, var(--royal), var(--royal-2)); color: #fff; border: 0; }
.btn.danger { background: rgba(255, 93, 108, .14); color: var(--bad); border-color: rgba(255, 93, 108, .35); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.lg { padding: 15px 26px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.icon { padding: 9px; width: 40px; height: 40px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--input); color: var(--text); outline: none; transition: border .2s, box-shadow .2s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245, 185, 66, .2); }
textarea.input { min-height: 90px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--royal-2); }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s var(--ease); }
.switch input:checked + span { background: var(--royal-2); }
.switch input:checked + span::after { transform: translateX(20px); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface-solid); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }

/* ===== progress ===== */
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--royal-2), var(--accent)); transition: width .6s var(--ease); }
.bar.thin { height: 6px; }
.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .lbl { position: absolute; text-align: center; }
.ring .lbl b { display: block; font-size: 26px; font-weight: 800; }

/* ===== auth ===== */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .art { padding: 60px; display: flex; flex-direction: column; justify-content: center; gap: 22px; background: linear-gradient(150deg, #0a1030, #1d3fbf 70%, #3b2aa8); color: #fff; position: relative; overflow: hidden; }
.auth .art h1 { font-size: clamp(34px, 5vw, 56px); }
.auth .art .tiles { display: flex; gap: 8px; flex-wrap: wrap; }
.auth .art .tile { width: 52px; height: 58px; border-radius: 10px; background: #fff; color: #0a1030; display: grid; place-items: center; font-family: var(--display); font-size: 28px; font-weight: 700; box-shadow: 0 6px 0 #c9cfe8; animation: tile 3s var(--ease) infinite alternate; }
.auth .art .tile.g { background: var(--gold); box-shadow: 0 6px 0 #b8861f; }
@keyframes tile { to { transform: translateY(-6px); } }
.auth .panel { display: grid; place-items: center; padding: 30px; }
.auth .box { width: 100%; max-width: 420px; }

/* ===== dashboard ===== */
.levelcard { position: relative; overflow: hidden; cursor: pointer; transition: transform .2s var(--ease), border-color .2s; }
.levelcard:hover { transform: translateY(-3px); border-color: var(--accent); }
.levelcard.locked { cursor: not-allowed; opacity: .6; }
.levelcard .num { font-family: var(--display); font-size: 40px; font-weight: 700; color: var(--accent); line-height: 1; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); text-align: center; }
.badge .em { font-size: 30px; filter: grayscale(1); opacity: .35; }
.badge.got .em { filter: none; opacity: 1; }
.badge b { font-size: 12px; }
.quick { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 20px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: .2s var(--ease); text-align: left; }
.quick:hover { transform: translateY(-3px); border-color: var(--accent); }
.quick .em { font-size: 28px; }

/* ===== quiz ===== */
.quiz { max-width: 920px; margin: 0 auto; }
.quiz-top { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.lives { font-size: 20px; letter-spacing: 2px; }
.qcard { padding: clamp(20px, 4vw, 36px); }
.qtext { font-size: clamp(19px, 2.6vw, 25px); font-weight: 700; line-height: 1.35; margin: 12px 0 22px; }
.qmedia { font-size: 96px; text-align: center; line-height: 1.1; margin: 4px 0 16px; }
.qmedia img { max-height: 240px; border-radius: 14px; }
.opts { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.opt { display: flex; gap: 14px; align-items: center; padding: 16px 18px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface-2); cursor: pointer; text-align: left; font-weight: 600; font-size: 16px; transition: .18s var(--ease); min-height: 64px; }
.opt:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
.opt .k { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-solid); border: 1px solid var(--line); font-weight: 800; flex: none; color: var(--muted); }
.opt.sel { border-color: var(--royal-2); background: rgba(47, 91, 255, .18); }
.opt.right { border-color: var(--ok); background: rgba(34, 195, 142, .16); }
.opt.right .k { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: rgba(255, 93, 108, .14); animation: shake .35s; }
.opt.wrong .k { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt.gone { opacity: .2; pointer-events: none; text-decoration: line-through; }
.opt:disabled { cursor: default; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.match-row { display: grid; grid-template-columns: 180px 1fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.match-row b { font-size: 16px; }
.textans { font-size: 22px; letter-spacing: .15em; text-transform: uppercase; text-align: center; font-weight: 800; padding: 16px; }
.feedback { margin-top: 18px; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line); animation: page .3s var(--ease); }
.feedback.ok { background: rgba(34, 195, 142, .12); border-color: rgba(34, 195, 142, .4); }
.feedback.bad { background: rgba(255, 93, 108, .1); border-color: rgba(255, 93, 108, .35); }
.feedback.neutral { background: var(--surface-2); }
.hintbox { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: rgba(245, 185, 66, .12); border: 1px dashed rgba(245, 185, 66, .5); }
.qnav { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.qnav button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; font-size: 12px; cursor: pointer; color: var(--muted); position: relative; }
.qnav button.cur { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 2px rgba(245, 185, 66, .3); }
.qnav button.ans { background: rgba(47, 91, 255, .25); color: var(--text); }
.qnav button.ok { background: rgba(34, 195, 142, .3); color: var(--text); }
.qnav button.bad { background: rgba(255, 93, 108, .3); color: var(--text); }
.qnav button.skp { background: rgba(255, 176, 32, .2); }
.qnav button.mk::after { content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; margin-top: 18px; }
.timer { display: flex; align-items: center; gap: 8px; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.overlay { position: fixed; inset: 0; background: rgba(4, 8, 26, .82); backdrop-filter: blur(8px); display: grid; place-items: center; z-index: 50; animation: page .2s; }
.pop { animation: pop .5s var(--ease); }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }

/* ===== tables ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.lb-me { background: rgba(245, 185, 66, .1) !important; }
.rank { font-weight: 800; font-size: 16px; width: 44px; }

/* ===== modal, toast, states ===== */
.modal-bg { position: fixed; inset: 0; background: rgba(4, 8, 26, .7); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 60; padding: 16px; animation: page .2s; }
.modal { width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.modal.wide { max-width: 860px; }
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 80; max-width: calc(100vw - 40px); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 600; animation: page .25s var(--ease); max-width: 380px; }
.toast.ok { border-left: 4px solid var(--ok); } .toast.bad { border-left: 4px solid var(--bad); } .toast.gold { border-left: 4px solid var(--accent); }
.boot, .state { display: grid; place-items: center; min-height: 40vh; text-align: center; gap: 12px; color: var(--muted); }
.boot { min-height: 100vh; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; min-height: 90px; }
@keyframes sk { to { background-position: -200% 0; } }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.chart { width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 11px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall 2.6s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.banner { padding: 12px 16px; border-radius: 12px; background: rgba(245, 185, 66, .14); border: 1px solid rgba(245, 185, 66, .4); font-weight: 600; }

/* ===== responsive ===== */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface-solid); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; font-size: 10px; color: var(--muted); font-weight: 700; padding: 4px 6px; gap: 2px; }
  .mobile-nav a.active { color: var(--accent); }
  .mobile-nav .ico { font-size: 20px; }
  .g3 { grid-template-columns: 1fr 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth .art { padding: 34px 24px; }
}
@media (max-width: 620px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: 1fr 1fr; }
  .opts { grid-template-columns: 1fr; }
  .match-row { grid-template-columns: 1fr; }
  .main { padding-top: 18px; }
  .kpi .value { font-size: 22px; }
  .qmedia { font-size: 72px; }
  .hide-sm { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.card .state { min-height: 170px; }
.split { grid-template-columns: 1.5fr 1fr; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.table-wrap table { min-width: 640px; }
.main { min-width: 0; }
