:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: #071916;
  color: #fff8db;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  display: flex;
  justify-content: center;
  padding: 18px;
  background:
    radial-gradient(circle at 20% 12%, rgba(255, 207, 90, 0.22), transparent 13rem),
    radial-gradient(circle at 88% 8%, rgba(112, 232, 163, 0.2), transparent 12rem),
    linear-gradient(180deg, #071916 0%, #0e2f32 58%, #163b2c 100%);
}

button {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  color: #071916;
  font: 900 1rem/1.08 "Trebuchet MS", "Segoe UI", sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 4px solid #fff8db;
  outline-offset: 3px;
}

.game-shell {
  position: relative;
  width: min(100%, 980px);
  min-height: 100vh;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #8df1bc;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 720px;
  color: #fff8db;
  font-size: 2.55rem;
  line-height: 1;
}

.sound-toggle {
  flex: 0 0 auto;
  min-width: 130px;
  padding: 0 18px;
  background: #ffcf5a;
  color: #071916;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.26);
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.score-tile {
  min-height: 66px;
  padding: 10px;
  border: 3px solid rgba(255, 248, 219, 0.14);
  border-radius: 8px;
  background: rgba(7, 25, 22, 0.78);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.18);
}

.score-tile span {
  display: block;
  color: #8df1bc;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.score-tile strong {
  display: block;
  margin-top: 2px;
  color: #fff8db;
  font-size: 1.8rem;
  line-height: 1;
  white-space: nowrap;
}

.canvas-wrap {
  width: 100%;
  border: 4px solid #fff8db;
  border-radius: 8px;
  background: #071916;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 64vh;
  background: #071916;
  touch-action: none;
}

.target-panel {
  margin-top: 12px;
  padding: 12px 14px;
  border: 3px solid rgba(255, 248, 219, 0.14);
  border-radius: 8px;
  background: rgba(255, 248, 219, 0.08);
}

.prompt-text {
  min-height: 22px;
  margin: 0 0 10px;
  color: #fff8db;
  font-weight: 900;
}

.meter {
  height: 18px;
  border: 2px solid rgba(255, 248, 219, 0.28);
  border-radius: 999px;
  background: rgba(7, 25, 22, 0.74);
  overflow: hidden;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff7063 0%, #ffcf5a 52%, #8df1bc 100%);
  transition: width 160ms ease;
}

.lane-controls,
.touch-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.lane-button {
  min-height: 64px;
  padding: 7px 8px;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.22);
}

.lane-button span {
  display: inline-block;
  margin-top: 3px;
  font-size: 0.78rem;
  font-weight: 900;
}

.lane-button[aria-pressed="true"] {
  transform: translateY(2px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.26);
}

.lane-left {
  background: #ff8b7f;
}

.lane-center {
  background: #ffcf5a;
}

.lane-right {
  background: #8df1bc;
}

.control-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.start-button,
.restart-button,
.result-card button {
  padding: 0 16px;
  background: #fff8db;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.22);
}

.status {
  min-height: 48px;
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255, 248, 219, 0.12);
  color: #fff8db;
  font-weight: 900;
}

.result-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 25, 22, 0.76);
  z-index: 10;
}

.result-card {
  width: min(100%, 430px);
  padding: 24px;
  border: 4px solid #fff8db;
  border-radius: 8px;
  background: #12372f;
  color: #fff8db;
  box-shadow: 0 18px 0 rgba(0, 0, 0, 0.28);
}

.result-card p {
  font-weight: 800;
}

@media (max-width: 720px) {
  body {
    padding: 10px;
  }

  .game-header {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 1.72rem;
    line-height: 1.06;
  }

  .sound-toggle {
    width: 100%;
  }

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

  .score-tile strong {
    font-size: 1.45rem;
  }

  #gameCanvas {
    max-height: 56vh;
  }

  .lane-button {
    padding-inline: 4px;
  }
}

@media (max-width: 360px) {
  h1 {
    font-size: 1.46rem;
  }

  .score-tile {
    padding: 8px;
  }

  .score-tile strong {
    font-size: 1.22rem;
  }

  .control-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
