/* ClivEdu design system.
   Night sky ink + aurora. Accent colour is user-pickable (--accent). */
:root {
  --accent: #7b6cff;
  --mint: #2fd3b5;
  --coral: #ff7a6b;
  --gold: #ffc65c;
  --sky: #4db8ff;

  --font-display: 'Bricolage Grotesque', 'Segoe UI Variable Display', system-ui, sans-serif;
  --font-body: 'Figtree', 'Segoe UI Variable Text', system-ui, sans-serif;
  --font-read: 'Literata', Georgia, 'Times New Roman', serif;

  --r-card: 26px;
  --r-ctl: 14px;
  --r-chip: 999px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --nav-space: 128px;
}

/* ---------- themes ---------- */
:root, :root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0b0920;
  --bg-2: #130f33;
  --ink: #f1eeff;
  --muted: #a7a1cf;
  --faint: #6f6a9c;
  --glass: rgba(20, 16, 52, .58);
  --glass-strong: rgba(24, 19, 62, .86);
  --line: rgba(190, 180, 255, .16);
  --shadow: 0 24px 60px -24px rgba(2, 0, 20, .8);
  --on-accent: #0b0920;
}
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #eeebff;
  --bg-2: #f8f6ff;
  --ink: #1a1640;
  --muted: #5a5586;
  --faint: #8c88b3;
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .9);
  --line: rgba(60, 50, 140, .14);
  --shadow: 0 24px 50px -26px rgba(50, 40, 130, .45);
  --on-accent: #ffffff;
}
@media (prefers-color-scheme: light) {
  :root[data-theme='auto'] {
    color-scheme: light;
    --bg: #eeebff; --bg-2: #f8f6ff; --ink: #1a1640; --muted: #5a5586; --faint: #8c88b3;
    --glass: rgba(255, 255, 255, .62); --glass-strong: rgba(255, 255, 255, .9);
    --line: rgba(60, 50, 140, .14); --shadow: 0 24px 50px -26px rgba(50, 40, 130, .45); --on-accent: #fff;
  }
}
/* Reading mode: quiet paper, serif text, no moving background */
:root[data-reading='on'] {
  --font-body: var(--font-read);
  --bg: #1d1b22; --bg-2: #232029; --ink: #e9e4d8; --muted: #b3ac9c; --glass: rgba(35, 32, 41, .96); --glass-strong: #26232d; --line: rgba(233, 228, 216, .14);
}
:root[data-reading='on'][data-theme='light'] { --bg: #f4efe3; --bg-2: #f8f4ea; --ink: #2a2620; --muted: #6a6254; --glass: rgba(250, 246, 236, .97); --glass-strong: #faf6ec; --line: rgba(60, 50, 30, .16); }
@media (prefers-color-scheme: light) {
  :root[data-reading='on'][data-theme='auto'] { --bg: #f4efe3; --bg-2: #f8f4ea; --ink: #2a2620; --muted: #6a6254; --glass: rgba(250, 246, 236, .97); --glass-strong: #faf6ec; --line: rgba(60, 50, 30, .16); }
}
:root[data-reading='on'] body { font-size: 1.12rem; line-height: 1.8; }
:root[data-reading='on'] #bg, :root[data-reading='on'] #words { opacity: 0; }
:root[data-reading='on'] .glass { backdrop-filter: none; }
:root[data-reading='on'] #view { max-width: 760px; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 1rem; line-height: 1.55;
  transition: background-color .5s var(--ease), color .5s var(--ease);
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.05; margin: 0; letter-spacing: -.02em; font-weight: 700; font-variation-settings: 'wdth' 90; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
::selection { background: color-mix(in oklab, var(--accent) 55%, transparent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#bg, #words { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; transition: opacity .6s; }
#words { z-index: 1; }
#app { position: relative; z-index: 2; min-height: 100vh; }
#view:focus, #view:focus-visible { outline: none; }
#view { max-width: 1180px; margin: 0 auto; padding: 84px 20px var(--nav-space); }
.page-enter > * { animation: rise .7s var(--ease) both; }
.page-enter > *:nth-child(2) { animation-delay: .06s; } .page-enter > *:nth-child(3) { animation-delay: .12s; } .page-enter > *:nth-child(4) { animation-delay: .18s; } .page-enter > *:nth-child(5) { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---------- surfaces ---------- */
.glass { background: var(--glass); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3); border: 1px solid var(--line); box-shadow: var(--shadow); }
.card { border-radius: var(--r-card); padding: 22px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 0; min-width: 0; }
.stack { display: grid; gap: 14px; }
.between { justify-content: space-between; }

/* ---------- type ---------- */
.display { font-size: clamp(2.6rem, 8vw, 6.2rem); line-height: .95; letter-spacing: -.045em; }
.h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); }
.h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
.h3 { font-size: 1.15rem; letter-spacing: -.01em; }
.lede { font-size: 1.12rem; color: var(--muted); max-width: 56ch; }
.small { font-size: .88rem; }
.page-head { display: grid; gap: 10px; margin-bottom: 26px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid var(--line); background: var(--glass); border-radius: var(--r-ctl);
  padding: 11px 18px; font-weight: 600; transition: transform .25s var(--spring), background .2s, border-color .2s, box-shadow .3s;
  text-decoration: none; backdrop-filter: blur(10px);
}
.btn:hover { transform: translateY(-2px); border-color: color-mix(in oklab, var(--accent) 60%, var(--line)); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; box-shadow: 0 10px 30px -10px var(--accent); }
.btn.primary:hover { box-shadow: 0 14px 34px -8px var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--coral); }
.btn.sm { padding: 7px 12px; font-size: .88rem; border-radius: 11px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.iconbtn { width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r-chip); border: 1px solid var(--line); background: var(--glass); font-size: .85rem; font-weight: 600; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
button.chip { transition: transform .2s var(--spring), background .2s; }
button.chip:hover { transform: translateY(-1px); }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: .92rem; }
input, textarea, select {
  font: inherit; color: var(--ink); background: color-mix(in oklab, var(--bg) 60%, transparent);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 25%, transparent); }
textarea { resize: vertical; min-height: 90px; }
input[type='color'] { padding: 3px; height: 44px; cursor: pointer; }
input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--accent); }
.hint { font-size: .84rem; color: var(--muted); }
.error { color: var(--coral); font-size: .92rem; }

/* switch */
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .25s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .3s var(--spring); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 3px; }

/* segmented */
.seg { display: inline-flex; padding: 4px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 600; transition: background .2s, color .2s; }
.seg button[aria-pressed='true'] { background: var(--accent); color: var(--on-accent); }

/* ---------- top bar ---------- */
#top { position: fixed; top: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; pointer-events: none; }
#top > * { pointer-events: auto; }
.mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; letter-spacing: -.03em; }
.mark i { width: 30px; height: 30px; border-radius: 50%; background: conic-gradient(from 200deg, var(--accent), var(--mint), var(--coral), var(--accent)); display: block; box-shadow: 0 0 24px -2px var(--accent); animation: spin 14s linear infinite; position: relative; }
.mark i::after { content: ''; position: absolute; inset: 8px; border-radius: 50%; background: var(--bg); }
@keyframes spin { to { transform: rotate(360deg); } }
.topright { display: flex; gap: 8px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.35rem; flex: none; position: relative; border: 0; }
.avatar[data-frame='ring'] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent); }
.avatar[data-frame='glow'] { box-shadow: 0 0 22px 3px currentColor; }
.avatar[data-frame='dash'] { outline: 2px dashed var(--ink); outline-offset: 3px; }
.avatar.lg { width: 96px; height: 96px; font-size: 3rem; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.dot { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--coral); color: #fff; font-size: .72rem; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--bg); }

/* ---------- the orbit dial (navigation) ---------- */
#dial { position: fixed; left: 50%; bottom: 22px; z-index: 40; width: 0; height: 0; }
.orb {
  position: absolute; left: -34px; bottom: 0; width: 68px; height: 68px; border-radius: 50%; border: 0; padding: 0;
  background: radial-gradient(circle at 30% 25%, color-mix(in oklab, var(--accent) 70%, #fff), var(--accent) 55%, color-mix(in oklab, var(--accent) 60%, #000));
  box-shadow: 0 14px 40px -8px var(--accent), inset 0 2px 6px rgba(255,255,255,.35);
  display: grid; place-items: center; z-index: 3; transition: transform .5s var(--spring);
}
.orb::before { content: ''; position: absolute; inset: -9px; border-radius: 50%; border: 1.5px dashed color-mix(in oklab, var(--accent) 70%, transparent); animation: spin 18s linear infinite; }
.orb:hover { transform: scale(1.07); }
.orb svg { width: 28px; height: 28px; color: var(--on-accent); transition: transform .5s var(--spring); }
#dial.open .orb svg { transform: rotate(135deg); }
.orb-label { position: absolute; bottom: 86px; left: 0; transform: translateX(-50%); white-space: nowrap; padding: 6px 14px; border-radius: 99px; font-weight: 700; font-size: .88rem; transition: opacity .25s, transform .4s var(--ease); }
#dial.open .orb-label { opacity: 0; transform: translateX(-50%) translateY(10px); pointer-events: none; }
.scrim { position: fixed; inset: 0; background: color-mix(in oklab, var(--bg) 55%, transparent); backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity .4s; z-index: -1; }
#dial.open .scrim { opacity: 1; pointer-events: auto; }
.petal {
  position: absolute; left: -32px; bottom: 2px; width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--glass-strong); display: grid; place-items: center; text-decoration: none; text-align: center;
  transform: translate(0, 0) scale(.2); opacity: 0; pointer-events: none; z-index: 2;
  transition: transform .55s var(--spring), opacity .25s, background .2s;
  transition-delay: calc((5 - var(--i)) * 18ms);
  box-shadow: var(--shadow);
}
.petal svg { width: 26px; height: 26px; }
.petal b { color: var(--ink); position: absolute; top: 70px; font-size: .78rem; font-weight: 700; white-space: nowrap; opacity: 0; transition: opacity .3s .15s; }
#dial.open .petal { opacity: 1; pointer-events: auto; transform: translate(var(--x), var(--y)) scale(1); transition-delay: calc(var(--i) * 40ms); }
#dial.open .petal b { opacity: 1; }
.petal:hover, .petal:focus-visible { background: var(--accent); color: var(--on-accent); }
.petal[aria-current='page'] { background: var(--accent); color: var(--on-accent); }
.petal .dot { top: -4px; right: -4px; }

/* ---------- page-open transition ---------- */
#iris { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; pointer-events: none; visibility: hidden; background: radial-gradient(circle at 30% 20%, color-mix(in oklab, var(--accent) 55%, var(--bg)), var(--bg) 70%); clip-path: circle(0 at 50% 100%); }
#iris .w { text-align: center; padding: 0 24px; }
#iris .w b { display: block; font-family: var(--font-display); font-size: clamp(2.6rem, 10vw, 6rem); letter-spacing: -.04em; font-weight: 800; }
#iris .w b span { display: inline-block; opacity: 0; transform: translateY(30px) rotate(6deg); }
#iris .w small { display: block; margin-top: 8px; font-size: 1.1rem; color: var(--muted); opacity: 0; }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 16px; font-weight: 600; animation: rise .4s var(--spring) both; text-align: center; }
.toast.good { border-color: var(--mint); } .toast.bad { border-color: var(--coral); }

/* ---------- modal & palette ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; background: color-mix(in oklab, var(--bg) 60%, transparent); backdrop-filter: blur(10px); animation: fade .25s both; }
.modal > .sheet { width: min(680px, 100%); max-height: 88vh; overflow: auto; border-radius: 28px; padding: 26px; background: var(--glass-strong); border: 1px solid var(--line); box-shadow: var(--shadow); animation: pop .45s var(--spring) both; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(20px) scale(.96); } }
.pal-input { font-size: 1.2rem; padding: 16px 18px; }
.pal-list { display: grid; gap: 4px; margin-top: 10px; max-height: 50vh; overflow: auto; }
.pal-item { text-align: left; border: 0; background: transparent; padding: 11px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; }
.pal-item[aria-selected='true'], .pal-item:hover { background: color-mix(in oklab, var(--accent) 22%, transparent); }
.pal-item small { color: var(--muted); margin-left: auto; }

/* ---------- home ---------- */
.hero { min-height: 62vh; display: grid; align-content: center; gap: 22px; padding-top: 4vh; }
.hello { font-family: var(--font-display); font-weight: 700; display: flex; gap: .3em; align-items: baseline; flex-wrap: wrap; }
.hello .lang { display: inline-block; color: var(--accent); min-width: 2ch; }
.hero .display .glyph { display: inline-block; transition: transform .5s var(--spring), color .3s; cursor: default; }
.hero .display .glyph:hover { transform: translateY(-.12em) rotate(-6deg); color: var(--accent); }
.star-card { position: relative; border-radius: 34px; padding: 26px 28px; max-width: 560px; overflow: hidden; }
.star-card::before { content: ''; position: absolute; width: 220px; height: 220px; right: -60px; top: -80px; background: radial-gradient(circle, var(--accent), transparent 65%); opacity: .45; filter: blur(8px); }
.star-card .word { font-family: var(--font-display); font-size: clamp(2.2rem, 5vw, 3.2rem); font-weight: 800; letter-spacing: -.035em; }
.doors { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); margin-top: 34px; }
.door { position: relative; overflow: hidden; border-radius: 30px; padding: 26px; min-height: 220px; text-decoration: none; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; transition: transform .5s var(--spring), border-color .3s; isolation: isolate; }
.door:hover { transform: translateY(-6px) rotate(-.4deg); border-color: var(--tint, var(--accent)); }
.door::before { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(circle at 80% 10%, color-mix(in oklab, var(--tint) 55%, transparent), transparent 60%); transition: transform .8s var(--ease); }
.door:hover::before { transform: scale(1.3); }
.door .big { position: absolute; right: 18px; top: 8px; font-size: 5.6rem; line-height: 1; transition: transform .6s var(--spring); filter: drop-shadow(0 12px 18px rgba(0,0,0,.3)); }
.door:hover .big { transform: scale(1.12) rotate(8deg); }
.door.a { grid-column: span 7; min-height: 280px; } .door.b { grid-column: span 5; } .door.c { grid-column: span 5; } .door.d { grid-column: span 7; }
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-top: 22px; }
.stat { padding: 18px 20px; border-radius: 22px; display: grid; gap: 2px; }
.stat b { font-family: var(--font-display); font-size: 2rem; letter-spacing: -.03em; }

/* ---------- lessons ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.lesson { position: relative; display: grid; gap: 10px; padding: 22px; border-radius: var(--r-card); text-decoration: none; transition: transform .45s var(--spring), border-color .3s; overflow: hidden; cursor: pointer; }
.lesson:hover { transform: translateY(-5px); border-color: var(--accent); }
.lesson .em { font-size: 2.4rem; line-height: 1; transition: transform .5s var(--spring); }
.lesson:hover .em { transform: scale(1.2) rotate(-8deg); }
.lesson .fav { position: absolute; top: 14px; right: 14px; }
.lock { display: inline-flex; gap: 6px; align-items: center; font-size: .82rem; font-weight: 700; }
.fav-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); display: grid; place-items: center; transition: transform .3s var(--spring); }
.fav-btn:hover { transform: scale(1.15); }
.fav-btn[aria-pressed='true'] { color: var(--coral); border-color: var(--coral); }
.fav-btn[aria-pressed='true'] svg { fill: currentColor; }
.fav-btn svg { width: 18px; height: 18px; }
.notes { display: grid; gap: 12px; }
.note { padding: 16px 18px; border-radius: 20px; border-left: 4px solid var(--accent); }
.note .ex { margin-top: 6px; font-style: italic; color: var(--mint); }

/* presentation viewer */
.deck { border-radius: 28px; overflow: hidden; position: relative; background: #000; aspect-ratio: 16 / 9; display: grid; place-items: center; box-shadow: var(--shadow); border: 1px solid var(--line); }
.deck canvas, .deck img { max-width: 100%; max-height: 100%; display: block; }
.deck.full { position: fixed; inset: 0; z-index: 85; border-radius: 0; aspect-ratio: auto; }
.deck-bar { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 8px; align-items: center; justify-content: space-between; z-index: 2; }
.deck-bar.top { top: 12px; bottom: auto; }
.deck-bar .pill { padding: 8px 14px; border-radius: 99px; font-weight: 700; }
.deck-fade { position: absolute; inset: auto 0 0 0; height: 48%; z-index: 1; background: linear-gradient(transparent, rgba(8, 6, 28, .96) 70%); display: grid; place-items: end center; padding: 20px; text-align: center; }
.deck-fade .stack { justify-items: center; max-width: 440px; }
.deck .loading { color: #fff; opacity: .8; }

/* ---------- vocab galaxy ---------- */
.galaxy-wrap { position: relative; border-radius: 32px; overflow: hidden; height: clamp(460px, calc(100vh - 300px), 760px); border: 1px solid var(--line); background: color-mix(in oklab, var(--bg) 70%, transparent); }
.galaxy-wrap canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.galaxy-wrap canvas:active { cursor: grabbing; }
.gal-hud { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; pointer-events: none; }
.gal-hud > * { pointer-events: auto; }
.gal-legend { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 14px; font-size: .8rem; padding: 8px 14px; border-radius: 99px; }
.gal-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.wordcard { position: absolute; right: 14px; bottom: 14px; width: min(380px, calc(100% - 28px)); border-radius: 26px; padding: 22px; transform: translateY(24px) scale(.96); opacity: 0; pointer-events: none; transition: transform .5s var(--spring), opacity .3s; z-index: 5; }
.wordcard.show { transform: none; opacity: 1; pointer-events: auto; }
.wordcard .w { font-family: var(--font-display); font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.wordcard .pos { font-style: italic; color: var(--muted); }
.wordcard .ex { margin-top: 8px; padding-left: 12px; border-left: 3px solid var(--mint); color: var(--muted); }
.boxes { display: flex; gap: 5px; margin: 10px 0; }
.boxes i { height: 6px; flex: 1; border-radius: 4px; background: var(--line); transition: background .3s; }
.boxes i.on { background: var(--mint); }
.saved-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.saved-word { padding: 14px 16px; border-radius: 18px; display: grid; gap: 4px; }

/* ---------- games ---------- */
.game-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.game { padding: 24px; border-radius: 28px; display: grid; gap: 10px; text-align: left; transition: transform .45s var(--spring), border-color .3s; }
.game:hover { transform: translateY(-5px) rotate(-.5deg); border-color: var(--accent); }
.game .em { font-size: 2.8rem; }
.arena { min-height: 60vh; display: grid; align-content: start; gap: 18px; }
.timer { height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; }
.timer i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--accent), var(--coral)); transform-origin: left; }
.q-word { font-family: var(--font-display); font-size: clamp(2rem, 6vw, 4rem); font-weight: 800; letter-spacing: -.04em; line-height: 1.05; text-align: center; }
.opts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.opt { padding: 18px 20px; border-radius: 20px; text-align: left; font-weight: 600; border: 1px solid var(--line); background: var(--glass); transition: transform .3s var(--spring), background .25s, border-color .25s; }
.opt:hover { transform: translateY(-3px); border-color: var(--accent); }
.opt.right { background: color-mix(in oklab, var(--mint) 35%, transparent); border-color: var(--mint); animation: bump .5s var(--spring); }
.opt.wrong { background: color-mix(in oklab, var(--coral) 30%, transparent); border-color: var(--coral); animation: shake .4s; }
@keyframes bump { 50% { transform: scale(1.04); } } @keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.tiles { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; min-height: 64px; }
.tile { width: 58px; height: 64px; border-radius: 16px; display: grid; place-items: center; font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; text-transform: uppercase; background: var(--glass-strong); border: 1px solid var(--line); transition: transform .3s var(--spring), background .2s; box-shadow: var(--shadow); }
.tile.slot { background: transparent; border-style: dashed; box-shadow: none; }
button.tile:hover { transform: translateY(-4px) rotate(-3deg); background: var(--accent); color: var(--on-accent); }
.match { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.match .col { display: grid; gap: 10px; align-content: start; }
.mcard { padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--glass); text-align: left; font-weight: 600; transition: transform .3s var(--spring), background .25s, opacity .4s; }
.mcard.sel { background: var(--accent); color: var(--on-accent); transform: scale(1.03); }
.mcard.done { opacity: .28; pointer-events: none; transform: scale(.96); }
.mcard.bad { animation: shake .4s; border-color: var(--coral); }
.scoreline { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; justify-content: center; }
.bigscore { font-family: var(--font-display); font-weight: 800; font-size: 4rem; letter-spacing: -.05em; }
/* host arena (projector view) */
.arena-screen { border-radius: 36px; padding: clamp(18px, 3vw, 34px); min-height: 42vh; display: grid; align-content: center; justify-items: center; gap: 18px; text-align: center; }
.arena-screen .clue { font-family: var(--font-display); font-size: clamp(1.6rem, 4.4vw, 3.2rem); font-weight: 700; line-height: 1.15; max-width: 22ch; letter-spacing: -.03em; }
.arena-screen .answer { font-family: var(--font-display); font-weight: 800; font-size: clamp(2.6rem, 9vw, 7rem); letter-spacing: -.05em; color: var(--accent); animation: pop .6s var(--spring); }
.teams { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.team { border-radius: 24px; padding: 14px 16px; display: grid; gap: 4px; text-align: center; border: 2px solid var(--tc); background: color-mix(in oklab, var(--tc) 14%, var(--glass)); transition: transform .35s var(--spring); }
.team:hover { transform: translateY(-3px); }
.team .pts { font-family: var(--font-display); font-weight: 800; font-size: 2.6rem; letter-spacing: -.04em; line-height: 1; }
.team .pts.bump { animation: bump .5s var(--spring); }
.team-actions { display: flex; gap: 6px; justify-content: center; }
.fullscreen-fix { position: fixed; inset: 0; z-index: 70; padding: 22px 20px 40px; overflow: auto; background: color-mix(in oklab, var(--bg) 78%, transparent); backdrop-filter: blur(18px); }
.podium { display: flex; gap: 14px; align-items: flex-end; justify-content: center; margin: 24px 0; }
.podium div { width: 120px; border-radius: 20px 20px 0 0; display: grid; align-content: start; justify-items: center; padding-top: 12px; gap: 4px; background: color-mix(in oklab, var(--tc) 40%, var(--glass)); border: 2px solid var(--tc); border-bottom: 0; animation: rise .8s var(--ease) both; }

/* ---------- profile ---------- */
.profile-top { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; padding: 26px; border-radius: 32px; }
.tabs { display: flex; gap: 6px; margin: 22px 0 18px; flex-wrap: wrap; }
.emoji-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; }
.emoji-pick button { font-size: 1.6rem; padding: 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); transition: transform .25s var(--spring); }
.emoji-pick button:hover { transform: scale(1.18); }
.emoji-pick button[aria-pressed='true'] { background: var(--accent); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 3px solid transparent; transition: transform .25s var(--spring); }
.swatch:hover { transform: scale(1.15); } .swatch[aria-pressed='true'] { border-color: var(--ink); }
.bars { display: flex; gap: 8px; align-items: flex-end; height: 120px; }
.bars div { flex: 1; display: grid; gap: 6px; align-items: end; justify-items: center; height: 100%; font-size: .78rem; color: var(--muted); }
.bars i { display: block; width: 100%; border-radius: 10px 10px 4px 4px; background: linear-gradient(var(--accent), var(--mint)); min-height: 4px; transform-origin: bottom; animation: grow .9s var(--ease) both; }
@keyframes grow { from { transform: scaleY(0); } }
.ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.ring::after { content: ''; position: absolute; inset: 10px; border-radius: 50%; background: var(--glass-strong); }
.ring b { position: relative; z-index: 1; font-family: var(--font-display); font-size: 1.6rem; }
.hw { display: grid; gap: 8px; padding: 18px 20px; border-radius: 22px; border-left: 4px solid var(--gold); }
.hw.done { border-left-color: var(--mint); opacity: .7; }
.hw.late { border-left-color: var(--coral); }
.badge { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 16px 10px; border-radius: 20px; width: 128px; }
.badge .em { font-size: 2.2rem; } .badge.locked { filter: grayscale(1); opacity: .45; }
.badges { display: flex; gap: 12px; flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th, .table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; }
.setting { display: flex; gap: 16px; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border: 0; }
.setting > div:first-child { display: grid; gap: 2px; }
.share-img { width: 100%; max-width: 520px; border-radius: 24px; box-shadow: var(--shadow); }

/* ---------- auth ---------- */
.auth { display: grid; place-items: center; min-height: 60vh; }
.auth .card { width: min(460px, 100%); padding: 30px; }
.divider { display: flex; gap: 12px; align-items: center; color: var(--faint); font-size: .85rem; } .divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.empty { text-align: center; padding: 40px 20px; display: grid; gap: 10px; justify-items: center; }
.empty .em { font-size: 3rem; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 95; }
kbd { font-family: inherit; font-size: .78rem; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line); background: var(--glass); }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  :root { --nav-space: 150px; }
  #view { padding-top: 76px; }
  .door.a, .door.b, .door.c, .door.d { grid-column: span 12; min-height: 180px; }
  .match { gap: 8px; } .tile { width: 46px; height: 54px; font-size: 1.5rem; }
  .petal { width: 56px; height: 56px; left: -28px; } .petal svg { width: 22px; height: 22px; }
  .petal b { top: 60px; font-size: .7rem; }
  .mark span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
:root[data-motion='calm'] *, :root[data-motion='calm'] *::before { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
@media print { #bg, #words, #dial, #top { display: none; } }

/* default icon size inside buttons (icons given an explicit size keep it) */
.btn svg:not([width]), .fav-btn svg:not([width]) { width: 20px; height: 20px; flex: none; }
