:root {
  color-scheme: dark;
  --ink: #f7f3ea;
  --muted: #e4d8c4;
  --amber: #f0b45a;
  --panel: rgba(24, 18, 28, 0.92);
  --edge: rgba(240, 180, 90, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #1a1422; color: var(--ink); font-family: var(--font); }
body { overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
#hud {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 4; pointer-events: none;
}
#hud[hidden] { display: none; }
#hud div {
  min-width: 78px; padding: 6px 10px; border-radius: 12px; text-align: center;
  background: rgba(18, 12, 22, 0.78); border: 1px solid var(--edge);
}
#hud span { display: block; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#hud b { font-size: 18px; }
#topbar { position: fixed; top: 12px; left: 12px; display: flex; gap: 8px; z-index: 6; }
.icon {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--edge);
  background: rgba(18, 12, 22, 0.78); color: var(--ink); display: grid; place-items: center; padding: 0;
}
.icon svg { width: 20px; height: 20px; }
#muteBtn.muted .on, #muteBtn:not(.muted) .off { display: none; }
body:not(.playing) #pauseBtn { display: none; }
#prompt {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%);
  z-index: 4; text-align: center; width: min(640px, 92vw); pointer-events: none;
}
#prompt[hidden] { display: none; }
#nextWord { color: var(--muted); letter-spacing: 0.12em; min-height: 1.2em; font-size: 14px; text-transform: uppercase; }
#word { font-size: clamp(32px, 7vw, 64px); font-weight: 800; letter-spacing: 0.04em; margin-top: 6px; }
#word .done { color: #f0b45a; }
#word .rest { color: #f7f3ea; }
#word.bad { animation: shake 0.18s linear; }
#keys {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: min(760px, 96vw); display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; z-index: 4;
}
#keys[hidden] { display: none; }
#keys button {
  width: 34px; height: 36px; border-radius: 8px; border: 1px solid var(--edge);
  background: rgba(18, 12, 22, 0.8); color: var(--ink); font-weight: 800;
}
.overlay {
  position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(10, 6, 14, 0.38); overflow: auto;
}
.overlay[hidden] { display: none !important; }
.panel {
  width: min(480px, 100%); background: var(--panel); border: 1px solid var(--edge);
  border-radius: 22px; padding: 22px 22px 16px; text-align: center;
}
h1 {
  margin: 0; font-size: clamp(36px, 8vw, 58px); line-height: 0.95;
  background: linear-gradient(100deg, #f7f3ea, #f0b45a 50%, #f2d48a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
h2 { margin: 0 0 6px; font-size: 28px; }
.tag, .sub { color: var(--muted); margin: 8px 0 14px; font-size: 15px; }
.btn { border: 0; border-radius: 999px; padding: 12px 18px; margin: 4px; font-weight: 800; font-size: 16px; }
.btn.primary { background: linear-gradient(100deg, #f6e2b0, #f0b45a); color: #2a1c10; min-width: 150px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--edge); }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.card { background: rgba(247, 243, 234, 0.05); border: 1px solid var(--edge); border-radius: 12px; padding: 8px; }
.card .k { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.card .v { font-size: 18px; font-weight: 800; margin-top: 2px; }
.howto { list-style: none; padding: 0; margin: 12px 0 0; text-align: left; color: var(--muted); font-size: 13px; line-height: 1.55; }
.howto b { color: var(--ink); }
kbd { border: 1px solid var(--edge); border-radius: 5px; padding: 0 5px; font-size: 12px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
@media (max-width: 420px) {
  .panel { padding: 16px 14px; }
  .btn.primary { width: calc(100% - 8px); }
  #keys button { width: 28px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
