:root {
  color-scheme: dark;
  --bg: #12130f;
  --panel: #1d2118;
  --ink: #f4efd8;
  --muted: #bbb694;
  --accent: #f8c14a;
  --accent-2: #6ad7b4;
  --danger: #ff7058;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(106, 215, 180, 0.13), transparent 24%),
    linear-gradient(135deg, #10120f 0%, #171a13 52%, #24200f 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.game-shell {
  width: min(100%, 1040px);
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 3rem);
  line-height: 1;
}

.scoreboard {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 700;
}

.scoreboard span {
  min-width: 112px;
  padding: 10px 12px;
  border: 1px solid rgba(244, 239, 216, 0.16);
  background: rgba(29, 33, 24, 0.78);
  border-radius: 8px;
  box-shadow: 0 12px 40px var(--shadow);
}

.scoreboard strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.word-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.word-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.letters {
  display: grid;
  grid-template-columns: repeat(9, minmax(28px, 1fr));
  gap: 7px;
  width: min(100%, 520px);
}

.letter-slot {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid rgba(244, 239, 216, 0.18);
  border-radius: 8px;
  background: rgba(29, 33, 24, 0.78);
  color: rgba(244, 239, 216, 0.34);
  font-weight: 950;
  box-shadow: 0 10px 28px var(--shadow);
}

.letter-slot.active {
  border-color: rgba(248, 193, 74, 0.7);
  color: var(--accent);
}

.letter-slot.collected {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #10251e;
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(244, 239, 216, 0.2);
  border-radius: 8px;
  background: #dbeee9;
  box-shadow: 0 26px 80px var(--shadow);
  aspect-ratio: 8 / 3;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  cursor: pointer;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
  color: #1b241d;
  background: rgba(244, 239, 216, 0.62);
  backdrop-filter: blur(2px);
  transition: opacity 160ms ease;
}

.overlay.hidden {
  pointer-events: none;
  opacity: 0;
}

.overlay p {
  margin: 0;
  font-size: clamp(1.7rem, 6vw, 4.2rem);
  font-weight: 900;
}

.overlay span {
  color: #3a4437;
  font-weight: 700;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

button {
  min-width: 112px;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--accent);
  color: #201800;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(248, 193, 74, 0.16);
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
}

#pauseButton,
#muteButton {
  background: #2a2f23;
  color: var(--ink);
  border: 1px solid rgba(244, 239, 216, 0.14);
  box-shadow: none;
}

@media (max-width: 720px) {
  body {
    padding: 14px;
  }

  .hud {
    align-items: stretch;
    flex-direction: column;
  }

  .scoreboard {
    justify-content: stretch;
  }

  .scoreboard span {
    flex: 1;
    min-width: 0;
  }

  .word-strip {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .letters {
    width: 100%;
    gap: 5px;
  }

  .letter-slot {
    min-height: 30px;
    font-size: 0.9rem;
  }

  .stage-wrap {
    aspect-ratio: 16 / 9;
  }

  .controls button {
    flex: 1;
    min-width: 0;
  }
}
