* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sky-top: #6bbdf2;
  --sky-bottom: #bce6ff;
  --panel: #fdf3d9;
  --panel-dark: #f3e2ba;
  --panel-light: #fffae8;
  --border: #7a4f21;
  --border-light: #b98c52;
  --text: #5a3a16;
  --dim: #a08556;
  --heart-empty: #d9c49a;
  --panel-shadow: rgba(90, 58, 22, 0.35);
  --orange: #ff8a00;
  --blue: #3f7fd6;
  --green: #3cb54a;
  --red: #e8442e;
}

body.dark {
  --panel: #46381f;
  --panel-dark: #3a2e18;
  --panel-light: #55452a;
  --border: #241b0c;
  --border-light: #6b5836;
  --text: #f3e5c4;
  --dim: #b39c74;
  --heart-empty: #5f4e2e;
  --panel-shadow: rgba(0, 0, 0, 0.5);
  --blue: #6ea3ef;
}

html, body { height: 100%; }

body {
  background:
    radial-gradient(220px 90px at 18% 18%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0) 70%),
    radial-gradient(160px 70px at 26% 14%, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 70%),
    radial-gradient(260px 100px at 78% 26%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0) 70%),
    radial-gradient(180px 80px at 86% 20%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 70%),
    radial-gradient(200px 85px at 55% 82%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 70%, #d9f2c4 100%);
  color: var(--text);
  transition: background 0.3s ease;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
  user-select: none;
  -webkit-user-select: none;
}

/* Night sky: stars, moon, dim clouds */
body.dark {
  background:
    radial-gradient(26px 26px at 84% 12%, rgba(255, 244, 200, 0.95) 30%, rgba(255, 244, 200, 0) 70%),
    radial-gradient(2.5px 2.5px at 12% 18%, #fff 60%, rgba(255,255,255,0) 100%),
    radial-gradient(2px 2px at 24% 9%, #fff 60%, rgba(255,255,255,0) 100%),
    radial-gradient(2px 2px at 38% 22%, #fff 60%, rgba(255,255,255,0) 100%),
    radial-gradient(2.5px 2.5px at 55% 8%, #fff 60%, rgba(255,255,255,0) 100%),
    radial-gradient(2px 2px at 68% 18%, #fff 60%, rgba(255,255,255,0) 100%),
    radial-gradient(2px 2px at 91% 30%, #fff 60%, rgba(255,255,255,0) 100%),
    radial-gradient(2px 2px at 8% 55%, rgba(255,255,255,0.7) 60%, rgba(255,255,255,0) 100%),
    radial-gradient(2px 2px at 94% 62%, rgba(255,255,255,0.7) 60%, rgba(255,255,255,0) 100%),
    radial-gradient(220px 90px at 18% 20%, rgba(180, 195, 230, 0.14) 0%, rgba(180, 195, 230, 0) 70%),
    radial-gradient(260px 100px at 78% 28%, rgba(180, 195, 230, 0.12) 0%, rgba(180, 195, 230, 0) 70%),
    linear-gradient(180deg, #131c36 0%, #23335c 65%, #1d3226 100%);
}

.wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- HUD ---------- */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--panel-light), var(--panel));
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 8px 18px;
  box-shadow: 0 5px 0 var(--panel-shadow), inset 0 2px 0 rgba(255, 255, 255, 0.15);
}

.hud-lives { display: inline-flex; gap: 6px; margin-right: 8px; }

.icon-btn {
  width: 32px;
  height: 32px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  background: linear-gradient(180deg, var(--panel-light), var(--panel-dark));
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn:active { transform: translateY(2px); border-bottom-width: 2px; }

.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.hud-label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
  font-weight: 700;
}

.hud-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.hud-value.score { color: var(--orange); min-width: 90px; }

.hud-best {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
  font-weight: 700;
}

.hud-best span { color: var(--blue); }

.hud-right { gap: 6px; }

.heart {
  width: 18px;
  height: 18px;
  display: inline-block;
  background: var(--red);
  clip-path: path("M9 17 C 2 11, 0 7, 0 4.5 C 0 2, 2 0, 4.5 0 C 6.5 0, 8 1.2, 9 3 C 10 1.2, 11.5 0, 13.5 0 C 16 0, 18 2, 18 4.5 C 18 7, 16 11, 9 17 Z");
  filter: drop-shadow(0 1.5px 0 rgba(90, 58, 22, 0.4));
}

.heart.empty {
  background: var(--heart-empty);
  filter: none;
}

/* ---------- Stage ---------- */

.stage {
  position: relative;
  border-radius: 18px;
  padding: 8px;
  background: linear-gradient(180deg, var(--panel-light), var(--panel-dark));
  border: 3px solid var(--border);
  box-shadow: 0 8px 0 var(--panel-shadow), inset 0 2px 0 rgba(255, 255, 255, 0.15);
}

canvas {
  display: block;
  border-radius: 10px;
  background: #85cb55;
}

/* ---------- Overlay ---------- */

.overlay {
  position: absolute;
  inset: 8px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(70, 46, 14, 0.35);
  backdrop-filter: blur(2px);
  transition: opacity 0.25s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-inner {
  text-align: center;
  background: linear-gradient(180deg, var(--panel-light), var(--panel));
  border: 3px solid var(--border);
  border-radius: 18px;
  padding: 28px 40px;
  box-shadow: 0 6px 0 rgba(20, 12, 2, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.15);
  max-width: 90%;
}

.title {
  font-size: 50px;
  letter-spacing: 2px;
  font-weight: 900;
  color: var(--orange);
  text-shadow:
    -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff, 2px 2px 0 #fff,
    0 -3px 0 #fff, 0 3px 0 #fff, -3px 0 0 #fff, 3px 0 0 #fff,
    0 5px 0 rgba(122, 79, 33, 0.55);
}

.title span { color: var(--blue); }

.title.small { font-size: 38px; }

.title.danger, .title.danger span { color: var(--red); }

.title.win, .title.win span { color: var(--green); }

.subtitle {
  margin-top: 10px;
  color: var(--dim);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
}

.final-score {
  margin-top: 14px;
  font-size: 17px;
  color: var(--text);
}

.final-score b { color: var(--orange); font-size: 25px; }

.controls {
  margin: 22px auto 0;
  display: inline-flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  font-size: 14px;
  color: var(--text);
  font-weight: 700;
}

.control-row { display: flex; align-items: center; gap: 12px; }

.keys { display: inline-flex; gap: 4px; min-width: 118px; justify-content: flex-end; }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  background: linear-gradient(180deg, var(--panel-light), var(--panel-dark));
  border: 2px solid var(--border);
  border-bottom-width: 4px;
  border-radius: 8px;
}

kbd.wide { padding: 0 14px; }

.prompt {
  margin-top: 26px;
  font-size: 15px;
  letter-spacing: 3px;
  font-weight: 800;
  color: var(--orange);
  text-shadow: 0 2px 0 rgba(122, 79, 33, 0.25);
}

.blink { animation: blink 1.1s steps(2, start) infinite; }

@keyframes blink {
  50% { opacity: 0.2; }
}

/* ---------- Power-up icons (drawn by game.js) ---------- */

canvas.pu-icon {
  display: inline-block; /* the base canvas rule sets block for the game board */
  width: 30px;
  height: 30px;
  background: transparent;
  border-radius: 0;
  vertical-align: middle;
}

canvas.pu-icon.inline {
  width: 24px;
  height: 24px;
  margin-left: 2px;
}

canvas.pu-icon.mini {
  width: 22px;
  height: 22px;
  margin-left: 14px;
}

.foot canvas.pu-icon.mini:first-child { margin-left: 0; }

.pu-legend {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  gap: 18px;
}

.pu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--dim);
  text-transform: uppercase;
  font-weight: 700;
}

/* ---------- Footer ---------- */

.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text);
  text-transform: uppercase;
  font-weight: 700;
  background: linear-gradient(180deg, var(--panel-light), var(--panel));
  border: 3px solid var(--border);
  border-radius: 14px;
  padding: 7px 16px;
  box-shadow: 0 4px 0 var(--panel-shadow), inset 0 2px 0 rgba(255, 255, 255, 0.15);
}
