* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --ink: #17212b;
  --panel: rgba(255, 255, 246, 0.95);
  --mint: #4ec4a6;
  --blue: #3387d8;
  --coral: #f26f63;
  --sun: #ffd76b;
  --plum: #6650a6;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 14px;
  color: var(--ink);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 2px, transparent 2px 54px),
    linear-gradient(180deg, #7bd7e4 0%, #f7e7a4 48%, #f8b6a0 100%);
}

button {
  font: inherit;
}

.game-shell {
  width: min(100%, 980px);
  display: grid;
  gap: 12px;
}

.game-top,
.score-row,
.touch-controls {
  border: 2px solid rgba(23, 33, 43, 0.1);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(27, 53, 72, 0.18);
}

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #9b3f34;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.08;
}

.sound-toggle,
.overlay-card button,
.touch-controls button {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: #17212b;
  background: linear-gradient(180deg, #fff08f, #ffaf43);
  box-shadow: 0 5px 0 #b75d1b;
  font-weight: 900;
}

.sound-toggle {
  min-width: 128px;
  padding: 0 14px;
}

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

.score-card {
  display: grid;
  min-width: 0;
  min-height: 62px;
  align-content: center;
  gap: 3px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.score-card span {
  color: #52606d;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score-card strong {
  font-size: 1.55rem;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 3px solid #ffffff;
  border-radius: 8px;
  background: #fff8df;
  box-shadow: 0 18px 35px rgba(27, 53, 72, 0.2);
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 66vh;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(255, 248, 223, 0.82);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(100%, 440px);
  padding: 22px;
  border: 3px solid #fff;
  border-radius: 8px;
  background: #fffdf4;
  box-shadow: 0 16px 30px rgba(27, 53, 72, 0.22);
  text-align: center;
}

.overlay-card h2 {
  margin: 0 0 8px;
  font-size: 1.75rem;
}

.overlay-card p {
  margin: 0 0 16px;
  line-height: 1.45;
}

.overlay-card button {
  min-width: 170px;
  padding: 0 18px;
}

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

.touch-controls button {
  width: 100%;
  padding: 0 8px;
}

.status-text {
  min-height: 28px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 246, 0.82);
  font-weight: 800;
  text-align: center;
}

button:focus-visible {
  outline: 4px solid var(--plum);
  outline-offset: 3px;
}

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

  .game-top {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 1.45rem;
  }

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

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

  .touch-controls button {
    min-height: 62px;
  }
}

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