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

* {
  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:
    linear-gradient(135deg, rgba(255, 211, 112, 0.3) 0%, transparent 26%),
    linear-gradient(180deg, #dff7ff 0%, #f7f4ff 45%, #fff2d8 100%);
}

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

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

.sound-toggle {
  flex: 0 0 auto;
  min-width: 130px;
  padding: 0 18px;
  background: #1b3442;
  color: #fff7df;
  box-shadow: 0 8px 0 rgba(27, 52, 66, 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(27, 52, 66, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 7px 0 rgba(27, 52, 66, 0.08);
}

.score-tile span {
  display: block;
  color: #5b6f79;
  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 #1b3442;
  border-radius: 8px;
  background: #eefbff;
  box-shadow: 0 12px 0 rgba(27, 52, 66, 0.12);
  overflow: hidden;
}

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

.checkpoint-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 56px;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #4ed1bd;
  color: #0f3e43;
  box-shadow: 0 7px 0 rgba(27, 52, 66, 0.14);
}

.checkpoint-panel span {
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.checkpoint-panel strong {
  font-size: 1.18rem;
  line-height: 1;
}

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

.touch-controls button,
.result-card button {
  padding: 0 14px;
  background: #ffd56f;
  box-shadow: 0 7px 0 rgba(27, 52, 66, 0.16);
}

#rightButton {
  background: #7edfe5;
}

#jumpButton {
  background: #ff9a76;
}

#crouchButton {
  background: #c9b8ff;
}

.touch-controls button[aria-pressed="true"] {
  background: #4ed1bd;
}

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

.result-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(27, 52, 66, 0.48);
  z-index: 10;
}

.result-card {
  width: min(100%, 430px);
  padding: 24px;
  border: 4px solid #1b3442;
  border-radius: 8px;
  background: #fff7df;
  box-shadow: 0 14px 0 rgba(27, 52, 66, 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.48rem;
    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.28rem;
  }

  #gameCanvas {
    max-height: 210px;
  }

  .checkpoint-panel {
    min-height: 48px;
    margin-top: 8px;
    padding: 8px 10px;
  }

  .checkpoint-panel strong {
    font-size: 1rem;
  }

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

  .touch-controls button,
  .result-card button {
    min-height: 58px;
    padding: 0 8px;
    font-size: 0.9rem;
  }

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

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

  h1 {
    font-size: 1.34rem;
  }

  #gameCanvas {
    max-height: 176px;
  }

  .touch-controls button,
  .result-card button {
    font-size: 0.82rem;
  }

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

@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;
  }
}
