:root {
  color-scheme: dark;
  --bg: #101114;
  --surface: #191c22;
  --surface-2: #222832;
  --text: #f4f7fb;
  --muted: #a8b0bd;
  --line: #343b49;
  --red: #e85d63;
  --cyan: #4dd3d8;
  --green: #72d572;
  --yellow: #f2c94c;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(77, 211, 216, 0.14), transparent 32%),
    linear-gradient(315deg, rgba(232, 93, 99, 0.14), transparent 36%),
    var(--bg);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 620px) minmax(280px, 360px);
  gap: 24px;
  align-items: center;
  padding: 28px 0;
}

.game-area,
.panel {
  background: rgba(25, 28, 34, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.game-area {
  padding: 20px;
}

.board-wrap {
  position: relative;
  width: min(100%, 390px);
  aspect-ratio: 1 / 2;
  margin: 0 auto;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  border: 2px solid #4b5565;
  background: #0b0d10;
  image-rendering: pixelated;
  touch-action: none;
  user-select: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  background: rgba(11, 13, 16, 0.68);
}

.overlay.hidden {
  display: none;
}

.overlay strong {
  font-size: 2.4rem;
}

.overlay span {
  color: var(--muted);
}

.panel {
  padding: 18px;
}

.meter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.meter {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.meter span,
.section-title,
.name-box label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.meter strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  line-height: 1;
}

.next-box,
.scoreboard,
.name-box,
.keys {
  margin-top: 18px;
}

#next {
  width: 120px;
  height: 120px;
  display: block;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b0d10;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
}

button {
  min-height: 42px;
  border: 1px solid #596273;
  border-radius: 6px;
  color: var(--text);
  background: #2b3340;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

button:hover {
  border-color: var(--cyan);
}

#startBtn {
  background: #24584f;
  border-color: #3f8c7f;
}

.name-box {
  display: grid;
  gap: 8px;
}

input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #11151a;
}

.keys {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.keys span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #151920;
  font-size: 0.88rem;
}

#scoreList {
  min-height: 180px;
  margin: 10px 0 0;
  padding-left: 24px;
}

#scoreList li {
  margin: 8px 0;
  color: var(--muted);
}

#scoreList strong {
  color: var(--text);
}

.mobile-controls {
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.mobile-controls button {
  font-size: 1.35rem;
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 16px 0;
  }

  .game-area {
    padding: 14px;
  }

  .panel {
    order: 2;
  }

  .board-wrap {
    width: min(100%, 330px);
  }

  .mobile-controls {
    display: grid;
  }
}
