:root {
  color-scheme: light;
  --ink: #182026;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --line: rgba(24, 32, 38, 0.14);
  --green: #58d96c;
  --sun: #f5db5c;
  --coin: #ffc93c;
  --cat: #f19039;
  --path: #8c552d;
  --blue: #2766db;
  --red: #e8475e;
  --shadow: 0 18px 48px rgba(25, 40, 35, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 22% 12%, rgba(255, 248, 171, 0.82), transparent 28%),
    linear-gradient(155deg, #52dc72 0%, #82e77e 44%, #f4dc61 100%);
}

button,
a {
  font: inherit;
}

button {
  min-height: 44px;
}

.game-shell {
  width: min(1200px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.topbar,
.lower-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(25, 40, 35, 0.1);
  backdrop-filter: blur(12px);
}

.home-link {
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.stats > span {
  min-width: 106px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: #45515a;
  font-weight: 800;
  text-align: center;
}

.stats strong {
  color: var(--ink);
}

.life-stat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.life-pips {
  display: inline-flex;
  gap: 4px;
}

.life-pip {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(24, 32, 38, 0.18);
  border-radius: 999px;
  background: var(--red);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.38);
}

.life-pip.empty {
  background: #c9d2da;
  box-shadow: none;
}

.actions {
  display: flex;
  gap: 8px;
}

.actions button,
.outfit,
.touch-controls button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.actions button:hover,
.outfit:hover,
.touch-controls button:hover {
  border-color: rgba(39, 102, 219, 0.42);
  box-shadow: 0 10px 24px rgba(39, 102, 219, 0.14);
  transform: translateY(-1px);
}

#startButton {
  min-width: 96px;
  padding: 0 18px;
  background: var(--blue);
  color: #ffffff;
}

#pauseButton {
  display: grid;
  place-items: center;
  width: 48px;
}

.pause-icon {
  width: 18px;
  height: 20px;
  border-left: 6px solid currentColor;
  border-right: 6px solid currentColor;
}

.stage {
  position: relative;
  overflow: hidden;
  margin: 16px 0;
  border: 1px solid rgba(24, 32, 38, 0.18);
  border-radius: 8px;
  background: #60d96f;
  box-shadow: var(--shadow);
}

#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: transparent;
  image-rendering: pixelated;
}

.message-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(440px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid rgba(24, 32, 38, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 48px rgba(25, 40, 35, 0.18);
  text-align: center;
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease, visibility 180ms ease, transform 180ms ease;
}

.message-panel.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -46%);
}

.message-kicker {
  margin: 0 0 8px;
  color: var(--blue);
  font-weight: 900;
  text-transform: uppercase;
}

.message-panel h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.message-panel p {
  margin: 0;
  color: #53605d;
  font-weight: 700;
  line-height: 1.5;
}

.lower-bar {
  align-items: stretch;
}

.outfits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.outfit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.outfit.active {
  border-color: rgba(39, 102, 219, 0.58);
  box-shadow: inset 0 0 0 2px rgba(39, 102, 219, 0.18);
}

.swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(24, 32, 38, 0.18);
  border-radius: 999px;
}

.swatch.cape {
  background: var(--red);
}

.swatch.hat {
  background: var(--blue);
}

.swatch.bow {
  background: #2fac73;
}

.swatch.stars {
  background:
    linear-gradient(45deg, transparent 42%, #ffffff 42% 58%, transparent 58%),
    var(--coin);
}

.touch-controls {
  display: flex;
  gap: 8px;
}

.touch-controls button {
  display: grid;
  place-items: center;
  width: 54px;
}

.arrow {
  display: block;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
}

.arrow.left {
  border-right: 15px solid currentColor;
}

.arrow.right {
  border-left: 15px solid currentColor;
}

.arrow.up {
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 16px solid currentColor;
  border-top: 0;
}

@media (max-width: 780px) {
  .game-shell {
    width: min(100% - 18px, 1200px);
    padding-top: 9px;
  }

  .topbar,
  .lower-bar {
    flex-wrap: wrap;
  }

  .home-link,
  .actions,
  .stats,
  .outfits,
  .touch-controls {
    width: 100%;
  }

  .actions,
  .touch-controls {
    justify-content: stretch;
  }

  .actions button,
  .touch-controls button {
    flex: 1;
  }

  .stats > span {
    flex: 1 1 96px;
  }

  .outfit {
    flex: 1 1 130px;
    justify-content: center;
  }

  .message-panel {
    padding: 18px;
  }
}
