@import url("https://fonts.googleapis.com/css2?family=Changa+One:ital@0;1&family=Nunito:wght@600;800&display=swap");

:root {
  color-scheme: dark;
  font-family: "Nunito", system-ui, sans-serif;
  --cream: #fff4d1;
  --orange: #ff9b38;
  --green: #64cc65;
  --panel: #101d1a;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--cream);
  background:
    radial-gradient(circle at 20% 5%, #32553a 0, transparent 28%),
    radial-gradient(circle at 80% 80%, #172f39 0, transparent 30%),
    #09120f;
}

button {
  font: inherit;
}

.game-shell {
  width: min(96vw, 840px);
  margin: auto;
  padding: 22px 20px 28px;
}

.game-header,
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.game-header {
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-family: "Changa One", sans-serif;
  font-weight: 400;
  letter-spacing: 0.02em;
}

h1 {
  color: #ffcb65;
  font-size: clamp(2rem, 6vw, 3.6rem);
  line-height: 0.9;
  text-shadow: 0 4px #703d1e, 0 8px 25px #000;
}

.eyebrow,
.panel-kicker {
  color: #92c895;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow {
  margin-bottom: 7px;
}

.small-button {
  padding: 9px 14px;
  border: 1px solid #ffffff24;
  border-radius: 999px;
  color: #dbe7d9;
  background: #ffffff0b;
  cursor: pointer;
}

.hud {
  gap: 8px;
  margin-bottom: 9px;
}

.hud div {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid #ffffff18;
  border-radius: 11px;
  background: #17241fe6;
  box-shadow: inset 0 1px #ffffff0d;
}

.hud span {
  display: block;
  overflow: hidden;
  color: #8baa8d;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.hud strong {
  color: #fff2bf;
  font-size: 1.1rem;
}

#lives {
  color: #d78b4a;
  letter-spacing: 0.08em;
}

.game-frame {
  position: relative;
  overflow: hidden;
  border: 4px solid #76502d;
  border-radius: 18px;
  background: #162c20;
  box-shadow: 0 24px 70px #000b, inset 0 0 0 3px #26170d;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0.09;
  background: repeating-linear-gradient(transparent 0 3px, #08100e 3px 4px);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #07100dc4;
  backdrop-filter: blur(5px);
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(100%, 470px);
  padding: 30px;
  border: 2px solid #a56a35;
  border-radius: 18px;
  text-align: center;
  background:
    linear-gradient(#1b3028ee, #102019f2),
    #14251f;
  box-shadow: 0 18px 60px #000c, inset 0 0 35px #31543b33;
}

.panel h2 {
  margin: 8px 0 10px;
  color: #ffc65d;
  font-size: clamp(2rem, 6vw, 3rem);
}

.panel > p:not(.panel-kicker, .key-hint) {
  color: #d2d9c4;
  line-height: 1.55;
}

.legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 18px;
  color: #aebda9;
  font-size: 0.82rem;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend b {
  display: inline-block;
  border-radius: 50%;
}

.berry-dot {
  width: 11px;
  height: 11px;
  background: #ed4752;
  box-shadow: 0 0 7px #f14c57;
}

.power-dot {
  width: 17px;
  height: 17px;
  background: #c099ff;
  box-shadow: 0 0 10px #b17bff;
}

.start-button {
  margin-top: 24px;
  padding: 13px 24px;
  border: 0;
  border-radius: 9px;
  color: #2a1809;
  font-family: "Changa One", sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  background: linear-gradient(#ffc862, #ed8d32);
  box-shadow: 0 5px #81451f, 0 10px 25px #0008;
  cursor: pointer;
}

.start-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px #81451f;
}

.key-hint {
  margin-top: 16px;
  color: #78927c;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.touch-controls {
  display: none;
  grid-template-columns: repeat(3, 58px);
  grid-template-areas:
    ". up ."
    "left down right";
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
}

.touch-controls button {
  height: 48px;
  border: 1px solid #ffffff1f;
  border-radius: 11px;
  color: #e7e5cd;
  background: #ffffff10;
}

[data-direction="up"] { grid-area: up; }
[data-direction="left"] { grid-area: left; }
[data-direction="down"] { grid-area: down; }
[data-direction="right"] { grid-area: right; }

.footer-note {
  margin-top: 12px;
  color: #6f8874;
  font-size: 0.73rem;
  text-align: center;
}

@media (pointer: coarse), (max-width: 700px) {
  .touch-controls {
    display: grid;
  }

  .game-shell {
    padding: 12px 9px 22px;
  }

  .small-button {
    padding: 7px 9px;
    font-size: 0.72rem;
  }

  .hud div {
    padding: 6px 8px;
  }

  .panel {
    padding: 22px 18px;
  }
}


/* Keep the welcome and replay buttons reachable on narrow screens. */
@media (max-width: 700px) {
  .game-frame:has(.overlay:not(.hidden)) { min-height: 430px; }
  .overlay { padding: 10px; overflow-y: auto; align-items: start; }
  .panel { padding: 16px 12px; margin: auto; }
  .panel h2 { font-size: clamp(1.5rem, 7vw, 2rem); }
  .panel > p:not(.panel-kicker, .key-hint) { font-size: 0.9rem; line-height: 1.4; }
  .legend { margin-top: 12px; gap: 16px; }
  .start-button { margin-top: 16px; min-height: 48px; }
  .key-hint { margin-top: 12px; }
  .touch-controls button { touch-action: none; user-select: none; -webkit-user-select: none; }
}