:root {
  color-scheme: dark;
  --bg: #101015;
  --panel: #1b1b23;
  --panel-soft: #24242e;
  --line: #343443;
  --text: #f7f3ff;
  --muted: #aaa5b8;
  --red: #ff4f6d;
  --cyan: #31d6ff;
  --gold: #ffd166;
  --green: #7cff8a;
  --purple: #b76cff;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
  overflow-x: hidden;
  background: linear-gradient(135deg, #101015 0%, #181820 48%, #101015 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.is-hidden {
  display: none !important;
}

.screen {
  display: grid;
  place-items: center;
  width: min(100%, 920px);
  min-height: calc(100vh - 36px);
  padding: 24px;
}

.intro-screen {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(9, 9, 13, 0.38), rgba(9, 9, 13, 0.12)),
    url("together.jpg") center / cover no-repeat;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
}

.final-screen {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 79, 109, 0.28), transparent 34%),
    linear-gradient(135deg, #15151d 0%, #221825 52%, #101015 100%);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
}

.message-panel {
  width: min(100%, 620px);
  margin-right: auto;
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(16, 16, 21, 0.24);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(1.5px);
}

.final-screen .message-panel {
  margin: 0;
  text-align: center;
}

.message-panel p {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.45;
}

.message-panel p:last-of-type {
  margin-bottom: 24px;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #292936;
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.primary-button {
  width: 100%;
  border-color: rgba(124, 255, 138, 0.48);
  background: rgba(124, 255, 138, 0.16);
  font-weight: 800;
}

button:hover {
  border-color: #5c5c72;
  background: #303041;
}

button:active,
.lane-button.is-pressed {
  border-color: currentColor;
  box-shadow: 0 0 18px currentColor;
  transform: translateY(1px) scale(0.98);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 480px) minmax(280px, 360px);
  gap: 18px;
  width: min(100%, 920px);
  align-items: stretch;
}

.stage-panel,
.hud-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 27, 35, 0.9);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
}

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

#gameCanvas {
  display: block;
  width: 100%;
  height: min(76vh, 820px);
  min-height: 520px;
  background: #12121a;
  touch-action: none;
}

.touch-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  background: #15151d;
}

.lane-button {
  height: 54px;
  font-weight: 800;
  font-size: 1.1rem;
}

.lane-a {
  color: var(--red);
}

.lane-s {
  color: var(--cyan);
}

.lane-k {
  color: var(--gold);
}

.lane-l {
  color: var(--green);
}

.hud-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.brand-block {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 3rem;
  line-height: 0.96;
}

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

.stats-grid div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.stats-grid strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-size: 1.1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

#startButton {
  border-color: rgba(124, 255, 138, 0.45);
  background: rgba(124, 255, 138, 0.12);
}

#stopButton {
  border-color: rgba(255, 79, 109, 0.45);
  background: rgba(255, 79, 109, 0.12);
}

#finalButton {
  margin-top: auto;
}

@media (max-width: 780px) {
  body {
    display: block;
    padding: 0;
  }

  .screen {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
  }

  .intro-screen,
  .final-screen {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .message-panel {
    padding: 20px;
  }

  .message-panel p {
    font-size: 1.05rem;
  }

  .app-shell {
    grid-template-columns: 1fr;
    width: 100%;
    gap: 0;
  }

  .stage-panel,
  .hud-panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  #gameCanvas {
    height: 68vh;
    min-height: 430px;
  }

  .hud-panel {
    min-height: 44vh;
  }

  h1 {
    font-size: 2.25rem;
  }
}
