:root {
  color-scheme: light;
  --ink: #12161f;
  --muted: #5d6472;
  --paper: #fffdf8;
  --line: rgba(18, 22, 31, 0.14);
  --coral: #f76666;
  --mint: #16c7a6;
  --sun: #f6e65d;
  --blue: #3b75ff;
  --shadow: 0 18px 54px rgba(18, 22, 31, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: #f5f7fb;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 48px;
  padding: 0 18px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover:enabled {
  box-shadow: 0 8px 0 var(--ink);
  transform: translateY(-4px);
}

button:active:enabled {
  box-shadow: 0 2px 0 var(--ink);
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.shell {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 320px;
  margin: 0 auto;
  max-width: 1240px;
  min-height: 100vh;
  padding: 16px;
}

.stage,
.side-panel {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  align-items: center;
  border-bottom: 2px solid var(--ink);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 18px;
}

.kicker {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 5.8vw, 4.8rem);
  line-height: 0.9;
  margin: 0;
}

.score-strip,
.stat-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
}

.score-strip span,
.stat-grid span {
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  font-size: 0.78rem;
  font-weight: 800;
  min-height: 58px;
  padding: 8px 10px;
}

.score-strip strong,
.stat-grid strong {
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.playfield {
  min-height: 0;
  position: relative;
}

canvas {
  display: block;
  height: 100%;
  min-height: 420px;
  width: 100%;
}

.hud {
  align-items: center;
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid var(--ink);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  left: 18px;
  padding: 10px 12px;
  position: absolute;
  top: 18px;
}

.hud span,
.hud strong {
  white-space: nowrap;
}

.hud strong {
  color: var(--coral);
  font-size: 1.1rem;
}

.controls {
  border-top: 2px solid var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1.4fr 1fr;
  padding: 14px;
}

.primary {
  background: var(--sun);
}

.hold {
  background: var(--mint);
}

.hold.is-pressed {
  background: var(--coral);
  color: #ffffff;
}

.side-panel {
  align-content: start;
  display: grid;
  gap: 14px;
  padding: 14px;
}

.stat-grid {
  grid-template-columns: 1fr 1fr;
}

.gate-list {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr 1fr;
  list-style: none;
  margin: 0;
  padding: 0;
}

.gate-list li {
  align-items: center;
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  min-height: 42px;
  padding: 8px 10px;
}

.gate-list span {
  background: var(--ink);
  border-radius: 999px;
  color: #ffffff;
  display: inline-grid;
  font-size: 0.78rem;
  font-weight: 900;
  height: 24px;
  place-items: center;
  width: 24px;
}

.gate-list strong {
  font-size: 0.84rem;
}

.gate-list .active {
  border-color: var(--blue);
  box-shadow: inset 0 -4px 0 rgba(59, 117, 255, 0.24);
}

.gate-list .perfect,
.gate-list .clear {
  border-color: var(--mint);
}

.gate-list .graze {
  border-color: var(--sun);
}

.gate-list .miss {
  border-color: var(--coral);
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .topbar {
    align-items: stretch;
    display: grid;
  }

  h1 {
    font-size: clamp(2.7rem, 16vw, 4.2rem);
  }

  .score-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .stage {
    grid-template-rows: auto minmax(330px, 52vh) auto;
  }

  canvas {
    min-height: 330px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .side-panel {
    box-shadow: none;
  }
}

@media (max-width: 430px) {
  .shell {
    gap: 10px;
  }

  .topbar {
    padding: 14px;
  }

  .score-strip span,
  .stat-grid span {
    min-height: 54px;
    padding: 7px;
  }

  .score-strip strong,
  .stat-grid strong {
    font-size: 1rem;
  }

  .hud {
    bottom: 12px;
    left: 10px;
    right: 10px;
    top: auto;
    justify-content: space-between;
  }

  .hud span,
  .hud strong {
    font-size: 0.86rem;
  }

  .gate-list {
    grid-template-columns: repeat(4, 1fr);
  }

  .gate-list li {
    display: grid;
    justify-items: center;
    min-height: 48px;
    padding: 5px;
  }
}
