:root {
  color-scheme: light;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: #dff9ff;
  color: #143743;
}

* {
  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 16% 10%, rgba(255, 255, 255, 0.86), transparent 15rem),
    linear-gradient(180deg, #c9f7ff 0%, #e7fbdf 54%, #fff3c4 100%);
}

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

button:focus-visible {
  outline: 4px solid #143743;
  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: #1e7480;
  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: #143743;
  font-size: 2.82rem;
  line-height: 0.98;
}

.sound-toggle {
  flex: 0 0 auto;
  min-width: 130px;
  padding: 0 18px;
  background: #143743;
  color: #fff8db;
  box-shadow: 0 8px 0 rgba(20, 55, 67, 0.18);
}

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

.score-tile {
  min-height: 64px;
  padding: 10px;
  border: 3px solid rgba(20, 55, 67, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 7px 0 rgba(20, 55, 67, 0.08);
}

.score-tile span {
  display: block;
  color: #577180;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score-tile strong {
  display: block;
  margin-top: 2px;
  font-size: 2rem;
  line-height: 1;
}

.canvas-wrap {
  width: 100%;
  border: 4px solid #143743;
  border-radius: 8px;
  background: #dff9ff;
  box-shadow: 0 12px 0 rgba(20, 55, 67, 0.12);
  overflow: hidden;
}

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

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-top: 12px;
}

.start-button,
.result-card button {
  padding: 0 16px;
  background: #ffcf5a;
  box-shadow: 0 7px 0 rgba(20, 55, 67, 0.16);
}

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

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

.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(20, 55, 67, 0.18);
}

.lane-red {
  background: #ff8c8a;
}

.lane-yellow {
  background: #ffe36e;
}

.lane-blue {
  background: #80d5ff;
}

.lane-green {
  background: #8be89f;
}

.status {
  min-height: 48px;
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: #143743;
  font-weight: 800;
}

.result-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 55, 67, 0.5);
  z-index: 10;
}

.result-card {
  width: min(100%, 430px);
  padding: 24px;
  border: 4px solid #143743;
  border-radius: 8px;
  background: #fff8db;
  box-shadow: 0 14px 0 rgba(20, 55, 67, 0.22);
}

.result-card p:not(.eyebrow) {
  margin: 12px 0 18px;
  font-weight: 800;
}

@media (max-width: 660px) {
  body {
    padding: 8px;
  }

  .game-header {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
  }

  .game-shell {
    min-height: auto;
  }

  .eyebrow {
    font-size: 0.7rem;
  }

  .sound-toggle {
    width: 100%;
    min-height: 58px;
  }

  h1 {
    font-size: 1.46rem;
    line-height: 1;
  }

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

  .score-tile {
    min-height: 50px;
    padding: 7px 8px;
  }

  .score-tile span {
    font-size: 0.68rem;
  }

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

  .canvas-wrap {
    max-width: 300px;
    margin: 0 auto;
  }

  #gameCanvas {
    max-height: 169px;
  }

  .action-row,
  .lane-controls {
    gap: 6px;
    margin-top: 8px;
  }

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

  .start-button,
  .lane-button,
  .result-card button {
    min-height: 58px;
    padding: 0 6px;
    font-size: 0.84rem;
  }

  .lane-button span {
    font-size: 0.7rem;
  }

  .status {
    min-height: 42px;
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 0.84rem;
  }
}

@media (max-width: 360px) {
  body {
    padding: 6px 8px;
  }

  h1 {
    font-size: 1.32rem;
  }

  .canvas-wrap {
    max-width: 254px;
  }

  #gameCanvas {
    max-height: 143px;
  }

  .start-button,
  .lane-button,
  .result-card button {
    font-size: 0.76rem;
  }

  .status {
    min-height: 38px;
    padding: 6px 8px;
    font-size: 0.77rem;
  }
}

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