/* Spelling Bee — English Room Games */
:root {
  --bg: #1d2452;
  --bg-2: #252d63;
  --ink: #fff8e7;
  --muted: #b9c0ea;
  --muted-2: #8790c4;
  --line: rgba(255, 255, 255, .14);
  --gold: #ffc93c;
  --gold-dark: #c99a1c;
  --hex: #3a4378;
  --hex-hover: #4a5390;
  --green: #3bb273;
  --display: 'Fredoka', 'Nunito', sans-serif;
  --body: 'Nunito', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body); color: var(--ink); background-color: var(--bg);
  background-image:
    radial-gradient(700px 400px at 50% 0%, rgba(255, 201, 60, .12), transparent 70%),
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%),
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%);
  background-size: auto, 64px 64px, 64px 64px;
  background-position: 0 0, 0 0, 32px 32px;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--line); background: rgba(20, 26, 64, .8); }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; font: 700 26px var(--display); white-space: nowrap; }
.brand .site { font-size: 11.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); text-decoration: none; white-space: nowrap; }
.brand .site:hover { color: var(--gold); }
.spacer { flex: 1; }
.iconbtn { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.05); color: var(--muted); cursor: pointer; text-decoration: none; }
.iconbtn:hover { color: var(--ink); border-color: var(--gold); }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn[aria-pressed="false"] .wave { display: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(320px, 460px) minmax(280px, 400px); gap: 28px; justify-content: center; align-items: start; padding: 16px 16px 30px; }
.play { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.modebar { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.seg { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 3px; background: rgba(0,0,0,.25); border: 1px solid var(--line); padding: 3px; border-radius: 999px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 16px; font-weight: 800; font-size: .95rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--bg); }
.modeinfo { margin: 0; font-size: .9rem; font-weight: 700; color: var(--muted); }

/* rank bar */
.rank { width: 100%; display: flex; align-items: center; gap: 12px; }
.rank-name { font: 700 1.15rem var(--display); min-width: 108px; color: var(--gold); }
.track { flex: 1; position: relative; height: 22px; display: flex; align-items: center; justify-content: space-between; }
.track::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: var(--hex); transform: translateY(-50%); }
.track .bar { position: absolute; left: 0; top: 50%; height: 4px; background: var(--gold); transform: translateY(-50%); border-radius: 2px; transition: width .4s; }
.track .dot { position: relative; width: 10px; height: 10px; border-radius: 50%; background: var(--hex); z-index: 1; }
.track .dot.on { background: var(--gold); }
.track .dot.now { width: 24px; height: 24px; display: grid; place-items: center; font: 700 .72rem var(--display); color: var(--bg); background: var(--gold); box-shadow: 0 0 0 4px rgba(255, 201, 60, .25); }
.points { font: 700 1.1rem var(--display); min-width: 40px; text-align: right; }

/* typed word */
.entry { min-height: 52px; display: flex; align-items: center; justify-content: center; font: 700 2.2rem var(--display); letter-spacing: .08em; text-transform: uppercase; }
.entry .c { color: var(--gold); }
.entry .x { color: var(--muted-2); }
.entry .caret { display: inline-block; width: 3px; height: 1.1em; background: var(--gold); margin-left: 3px; animation: blink 1s steps(1) infinite; }
.entry.shake { animation: shake .4s; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* honeycomb */
.hive { position: relative; width: min(300px, 82vw); aspect-ratio: 1 / 1.03; }
.hex {
  position: absolute; width: 33.5%; height: 29%;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: var(--hex); border: 0; cursor: pointer;
  font: 700 clamp(1.6rem, 7vw, 2.2rem) var(--display); text-transform: uppercase; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, transform .08s;
  touch-action: manipulation;
}
.hex:hover { background: var(--hex-hover); }
.hex:active, .hex.press { transform: scale(.92); }
.hex.centre { background: var(--gold); color: var(--bg); }
.hex.centre:hover { background: #ffd35e; }
.hex span { transition: opacity .2s; }
.hive.mixing .hex:not(.centre) span { opacity: 0; }

.controls { display: flex; gap: 10px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.07); border-radius: 999px; padding: 11px 22px; font-weight: 800; font-size: 1.02rem; cursor: pointer; min-height: 46px; }
.btn:hover { background: rgba(255,255,255,.13); }
.btn.round { width: 50px; height: 50px; padding: 0; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--gold); color: var(--bg); border-color: transparent; box-shadow: 0 4px 0 var(--gold-dark); font-family: var(--display); font-weight: 600; font-size: 1.12rem; border-radius: 12px; }
.btn.primary:hover { background: #ffd35e; }
.btn.wide { width: 100%; margin-top: 14px; }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.06); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: .92rem; cursor: pointer; }
.pill:hover:not(:disabled) { border-color: var(--gold); }
.pill:disabled { opacity: .4; cursor: not-allowed; }
.pill svg { width: 17px; height: 17px; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hint-text { margin: 0; padding: 8px 14px; border-radius: 12px; background: rgba(255, 201, 60, .1); border: 1px dashed rgba(255, 201, 60, .55); text-align: center; max-width: 380px; }
.hint-text b { color: var(--gold); letter-spacing: .06em; }
.linkbtn { background: none; border: 0; color: var(--gold); font-weight: 800; cursor: pointer; padding: 4px; }
.linkbtn:hover { text-decoration: underline; }

/* found words */
.panel { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.found-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; background: none; border: 0; text-align: left; font: 600 1.1rem var(--display); cursor: default; }
.found-head svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; display: none; }
.found-body { padding: 0 16px 16px; }
.found { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 18px; }
.found li { break-inside: avoid; padding: 5px 0; border-bottom: 1px solid var(--line); font-weight: 800; text-transform: capitalize; cursor: pointer; }
.found li:hover { color: var(--gold); }
.found li.pangram { color: var(--gold); }
.found li.pangram::after { content: ' \2605'; }
.found li.missed { color: var(--muted-2); font-weight: 700; }
.found li.new { animation: newword .6s; }
@keyframes newword { from { background: rgba(255, 201, 60, .35); } }
.empty { color: var(--muted-2); margin: 4px 0 0; font-size: .92rem; }
.reveal { margin-top: 12px; text-align: right; }

/* toasts */
.toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: var(--ink); color: var(--bg); font-weight: 800; font-size: 1.05rem; padding: 9px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: toastIn .15s ease-out; transition: opacity .3s; text-align: center; }
.toast.good { background: var(--green); color: #fff; font: 700 1.2rem var(--display); }
.toast.big { background: var(--gold); font: 700 1.4rem var(--display); }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 40, .75); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 14px; }
.card { position: relative; width: min(480px, 100%); max-height: calc(100dvh - 28px); overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 22px; box-shadow: 0 30px 70px rgba(0,0,0,.5); }
.card h2 { margin: 0 0 6px; font: 700 1.9rem var(--display); }
.card h3 { margin: 16px 0 6px; font: 600 1.15rem var(--display); color: var(--gold); }
.card p { line-height: 1.5; margin: 0 0 8px; }
.card .big { font-size: 1.1rem; }
.gold { color: var(--gold); }
.steps { padding-left: 20px; margin: 4px 0; line-height: 1.55; }
.close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 10px 12px 24px; }
  .panel { order: -1; }
  .found-head { cursor: pointer; padding: 11px 14px; font-size: 1rem; }
  .found-head svg { display: block; transition: transform .2s; }
  .panel:not(.open) .found-body { display: none; }
  .panel.open .found-head svg { transform: rotate(180deg); }
  .entry { font-size: 1.9rem; min-height: 44px; }
}
@media (max-width: 480px) {
  .brand .site { display: none; }
  .brand h1 { font-size: 22px; }
  .seg button { padding: 6px 12px; font-size: .88rem; }
  .rank-name { min-width: 92px; font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
