/* Snake — English Room Games */
:root {
  --bg: #0f2a22;
  --bg-2: #163a2f;
  --ink: #f1fff8;
  --muted: #a9d8c3;
  --muted-2: #74a892;
  --line: rgba(255, 255, 255, .14);
  --green: #57e3a3;
  --gold: #ffc93c;
  --gold-dark: #c99a1c;
  --red: #ff6b6b;
  --display: 'Fredoka', 'Nunito', sans-serif;
  --body: 'Nunito', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--body); color: var(--ink); background: radial-gradient(900px 600px at 50% 0%, #1d4a3b, var(--bg) 70%); background-color: var(--bg); display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
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)); background: rgba(0,0,0,.25); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; font: 700 26px var(--display); }
.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: 2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn[aria-pressed="false"] .wave { display: none; }
.pill-stat { padding: 5px 14px; border-radius: 999px; background: rgba(0,0,0,.3); border: 1px solid var(--line); font: 700 1.2rem var(--display); color: var(--gold); min-width: 64px; text-align: center; }
.lives { display: flex; gap: 3px; }
.lives svg { width: 22px; height: 22px; }
.lives .lost { opacity: .2; }

/* play area */
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 10px 10px 8px; gap: 10px; }
.wordbar { display: flex; align-items: center; gap: 12px; flex-shrink: 0; min-height: 58px; }
.wordbar .label { font: 600 1.1rem var(--display); color: var(--muted); }
.target { display: flex; gap: 6px; }
.target span {
  width: 44px; height: 52px; display: grid; place-items: center; border-radius: 10px;
  font: 700 1.8rem var(--display); text-transform: uppercase;
  background: rgba(0,0,0,.25); border: 2px solid var(--line); color: var(--ink);
  transition: background .15s, transform .15s;
}
.target span.next { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 201, 60, .25); }
.target span.got { background: var(--green); border-color: var(--green); color: #0b3324; transform: translateY(-3px); }
.target span.blank { color: transparent; }
.target.done span { animation: hop .5s ease-in-out both; }
.target.done span:nth-child(2) { animation-delay: .06s; } .target.done span:nth-child(3) { animation-delay: .12s; } .target.done span:nth-child(4) { animation-delay: .18s; }
.target.done span:nth-child(5) { animation-delay: .24s; } .target.done span:nth-child(6) { animation-delay: .3s; } .target.done span:nth-child(7) { animation-delay: .36s; } .target.done span:nth-child(8) { animation-delay: .42s; }
@keyframes hop { 40% { transform: translateY(-14px); } }
.target.wrong { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.listen { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.08); display: grid; place-items: center; cursor: pointer; }
.listen:hover { border-color: var(--gold); }
.listen svg { width: 22px; height: 22px; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.board-wrap { position: relative; flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
#board { display: block; border-radius: 16px; box-shadow: 0 0 0 4px rgba(87, 227, 163, .25), 0 18px 40px rgba(0,0,0,.4); touch-action: none; }
#board.hurt { animation: hurt .45s; }
@keyframes hurt { 30% { box-shadow: 0 0 0 8px rgba(255, 107, 107, .8), 0 18px 40px rgba(0,0,0,.4); } }
.banner { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); text-align: center; font: 700 clamp(1.7rem, 5vw, 2.8rem)/1.15 var(--display); color: var(--gold); text-shadow: 0 4px 0 rgba(0,0,0,.45); pointer-events: none; animation: pop .45s ease-out; width: 90%; }
.banner small { display: block; font-size: .5em; color: var(--ink); margin-top: 6px; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.4); opacity: 0; } }

/* arrow buttons on touch screens */
.pad { display: grid; grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(2, 54px); gap: 6px; flex-shrink: 0; }
.pad button { border: 0; border-radius: 14px; background: rgba(255,255,255,.1); display: grid; place-items: center; touch-action: manipulation; }
.pad button:active { background: rgba(87, 227, 163, .45); }
.pad svg { width: 30px; height: 30px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pad [data-d="up"] { grid-column: 2; grid-row: 1; }
.pad [data-d="left"] { grid-column: 1; grid-row: 2; }
.pad [data-d="down"] { grid-column: 2; grid-row: 2; }
.pad [data-d="right"] { grid-column: 3; grid-row: 2; }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(5, 20, 15, .78); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 14px; }
.card { width: min(500px, 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,.55); }
.card.small { width: min(380px, 100%); }
.card.center { text-align: center; }
.card h2 { margin: 0 0 6px; font: 700 2rem var(--display); }
.card h3 { margin: 16px 0 6px; font: 600 1.1rem var(--display); color: var(--gold); }
.card p { line-height: 1.5; margin: 0 0 10px; }
.card .big { font-size: 1.08rem; }
.kicker { font: 600 .8rem var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.kicker a { color: inherit; text-decoration: none; }
.label-up { display: block; font: 600 .8rem var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice button { text-align: left; padding: 11px 14px; border-radius: 14px; cursor: pointer; border: 2px solid var(--line); background: rgba(0,0,0,.25); }
.choice button b { display: block; font-size: 1.05rem; }
.choice button span { color: var(--muted); font-size: .88rem; }
.choice button[aria-pressed="true"] { border-color: var(--green); background: rgba(87, 227, 163, .12); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: rgba(0,0,0,.25); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px 6px; font-weight: 800; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--gold); color: #1d2452; }
.best { color: var(--gold); font-weight: 800; margin: 8px 0 0 !important; min-height: 1.4em; }
.howto { padding-left: 20px; margin: 8px 0; line-height: 1.55; }
.note { color: var(--muted-2); font-size: .85rem; margin-top: 12px !important; text-align: center; }
.hint { color: var(--muted); font-size: .9rem; margin-top: 8px !important; }
.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: 12px; padding: 11px 16px; font-weight: 800; font-size: 1rem; cursor: pointer; min-height: 44px; }
.btn:hover { background: rgba(255,255,255,.13); }
.btn.primary { background: var(--gold); color: #1d2452; border-color: transparent; box-shadow: 0 4px 0 var(--gold-dark); font-family: var(--display); font-weight: 600; font-size: 1.15rem; }
.btn.primary:hover { background: #ffd35e; }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-dark); }
.btn.wide { width: 100%; margin-top: 10px; }
.linkbtn { background: none; border: 0; color: var(--gold); font-weight: 800; cursor: pointer; margin-top: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 4px; }
.stats div { background: rgba(0,0,0,.25); border-radius: 12px; padding: 10px 4px; }
.stats b { display: block; font: 700 1.5rem var(--display); color: var(--gold); }
.stats span { color: var(--muted); font-size: .8rem; font-weight: 700; }
.stats .newbest { grid-column: 1 / -1; background: rgba(87, 227, 163, .2); font-weight: 800; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chips li { padding: 5px 12px; border-radius: 999px; background: rgba(87, 227, 163, .18); border: 1px solid var(--line); font: 600 1.05rem var(--display); cursor: pointer; }
.chips.practise li { background: rgba(255, 107, 107, .18); }
.chips li:hover { border-color: var(--gold); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

@media (max-width: 560px) {
  .brand .site { display: none; }
  .brand h1 { font-size: 21px; }
  .topbar { gap: 6px; padding-inline: 8px; }
  .iconbtn { width: 33px; height: 33px; }
  .pill-stat { min-width: 50px; padding: 4px 10px; font-size: 1rem; }
  .lives svg { width: 18px; height: 18px; }
  .wordbar .label { display: none; }
  .target { gap: 4px; }
  .target span { width: min(36px, calc((100vw - 96px) / 8)); height: 42px; font-size: 1.35rem; border-radius: 8px; }
  .listen { width: 40px; height: 40px; }
  .wordbar { gap: 8px; min-height: 46px; }
  .choice { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
