:root {
  color-scheme: dark;
  --bg: #07121f;
  --ink: #f8fbff;
  --muted: #9fb5c8;
  --teal: #23d4d9;
  --pink: #ff4caf;
  --gold: #ffd464;
  --panel: rgba(8, 18, 34, 0.72);
  --panel-line: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 10%, rgba(35, 212, 217, 0.22), transparent 30rem),
    radial-gradient(circle at 90% 16%, rgba(255, 76, 175, 0.18), transparent 26rem),
    linear-gradient(135deg, #07121f 0%, #11192c 50%, #081b25 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  overflow-x: hidden;
}

.app-shell {
  width: min(100vw, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(12px, 2.2vw, 28px);
  display: grid;
  align-content: center;
  gap: 14px;
}

.mode-tabs,
.game-surface,
.controls {
  width: min(100%, calc((100vh - 172px) * 4 / 3), 1120px);
  justify-self: center;
}

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

.mode-tabs button[aria-pressed="true"] {
  border-color: rgba(255, 212, 100, 0.86);
  background: rgba(77, 54, 17, 0.92);
  color: #fff6d8;
}

.game-surface {
  position: relative;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow:
    0 18px 54px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(35, 212, 217, 0.09) inset;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.start-panel,
.game-over-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 8, 20, 0.46);
}

.start-panel.is-hidden,
.game-over-panel.is-hidden {
  display: none;
}

.start-panel-content,
.game-over-content {
  width: min(360px, 100%);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(7, 19, 34, 0.9);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.34);
}

.game-over-content {
  display: grid;
  gap: 14px;
}

.start-title {
  margin-bottom: 14px;
  color: #ffd45c;
  font: 900 1rem / 1 system-ui, sans-serif;
  text-align: center;
}

.game-over-content .start-title {
  margin-bottom: 0;
}

.game-over-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.game-over-stats div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.game-over-stats span {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  font: 800 0.68rem / 1 system-ui, sans-serif;
}

.game-over-stats strong {
  display: block;
  margin-top: 6px;
  color: #ffd45c;
  font: 900 1.45rem / 1 system-ui, sans-serif;
}

.share-status {
  min-height: 1em;
  color: rgba(255, 255, 255, 0.74);
  font: 800 0.78rem / 1.2 system-ui, sans-serif;
  text-align: center;
}

.start-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.start-actions button[autofocus] {
  border-color: rgba(255, 212, 100, 0.86);
  background: rgba(77, 54, 17, 0.92);
  color: #fff6d8;
}

.controls {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
}

button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(10, 28, 47, 0.84);
  color: var(--ink);
  font: 700 clamp(0.7rem, 1.6vw, 0.88rem) / 1 system-ui, sans-serif;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

button:hover,
button:focus-visible {
  border-color: rgba(35, 212, 217, 0.72);
  background: rgba(17, 53, 78, 0.94);
  outline: none;
}

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

@media (max-width: 780px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    width: 100vw;
    max-width: 100vw;
    align-content: start;
    gap: 8px;
    padding: 8px;
    overflow-x: hidden;
  }

  .mode-tabs,
  .game-surface,
  .controls {
    width: min(calc(100vw - 16px), 390px);
    max-width: calc(100vw - 16px);
  }

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

  .start-panel,
  .game-over-panel {
    padding: 18px;
  }

  .start-panel-content,
  .game-over-content {
    padding: 18px;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding: 6px;
  }

  button {
    min-height: 40px;
  }

  .controls {
    gap: 6px;
  }
}
