:root {
  color-scheme: dark;
  --bg: #121318;
  --panel: #20232c;
  --ink: #f7f4e8;
  --muted: #aeb4c5;
  --line: #393e4c;
  --accent: #34d399;
  --danger: #ff5d73;
  --gold: #ffd166;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 16%, rgba(52, 211, 153, 0.18), transparent 25rem),
    linear-gradient(135deg, #121318 0%, #181922 52%, #231b27 100%);
  color: var(--ink);
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
}

body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.app {
  display: grid;
  grid-template-columns: minmax(132px, 170px) minmax(300px, 420px) minmax(132px, 170px);
  gap: 18px;
  align-items: start;
  width: min(100%, 820px);
}

.hud,
.controls {
  display: grid;
  gap: 12px;
}

.hud > div,
.controls button,
.current-panel,
.roster-panel,
.overlay-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(32, 35, 44, 0.88);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

.hud > div {
  padding: 14px;
}

.current-panel,
.roster-panel {
  padding: 12px;
}

.current-panel strong {
  display: block;
  margin-bottom: 4px;
  font-size: 22px;
  line-height: 1.05;
}

.current-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

strong {
  font-size: 30px;
  line-height: 1;
}

.next-panel {
  display: grid;
  place-items: center;
}

.next-panel .label {
  justify-self: start;
}

#nextCanvas {
  width: 88px;
  height: 88px;
}

.stage-wrap {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 3 / 5;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid #4a5060;
  border-radius: 8px;
  background: #181b22;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 19, 24, 0.58);
  backdrop-filter: blur(6px);
}

.overlay.hidden {
  display: none;
}

.overlay-box {
  width: min(100%, 280px);
  padding: 20px;
  text-align: center;
}

.overlay h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.overlay p {
  margin: 0 0 18px;
  color: var(--muted);
}

button {
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.controls button,
#restartButton {
  background: linear-gradient(180deg, #2b303a, #20242d);
}

#dropButton,
#restartButton {
  border-color: rgba(52, 211, 153, 0.7);
  background: linear-gradient(180deg, #19b981, #0b7f68);
}

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

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

.roster-panel {
  max-height: none;
  overflow: auto;
}

#rosterList {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#rosterList .roster-item {
  display: grid;
  grid-template-columns: 18px 24px 1fr;
  gap: 6px;
  align-items: center;
  min-height: 24px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

#rosterList .rank {
  color: #7d8496;
  font-variant-numeric: tabular-nums;
}

#rosterList canvas {
  width: 24px;
  height: 24px;
}

#rosterList .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  body {
    padding: 12px;
  }

  .app {
    grid-template-columns: 1fr;
    gap: 10px;
    width: min(100%, 430px);
  }

  .hud {
    grid-template-columns: 1fr 1fr 92px;
    align-items: stretch;
  }

  .hud > div {
    min-height: 76px;
    padding: 10px;
  }

  strong {
    font-size: 24px;
  }

  .next-panel {
    padding: 6px;
  }

  #nextCanvas {
    width: 54px;
    height: 54px;
  }

  .stage-wrap {
    justify-self: center;
    max-height: 70vh;
  }

  .controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .current-panel,
  .roster-panel {
    grid-column: 1 / -1;
  }

  .roster-panel {
    max-height: none;
  }

  #rosterList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
