/* ======================================================================
   Hamster Maze Dash — styling
   Cosy arcade: warm paper, cheddar accents, chunky rounded panels.
   ====================================================================== */
:root {
  --bg-0: #2a1d16;
  --bg-1: #3b2820;
  --paper: #fff6e6;
  --ink: #3a2417;
  --ink-soft: #7a5a44;
  --cheddar: #f6b64c;
  --cheddar-dk: #a6601c;
  --cheddar-lt: #ffd884;
  --berry: #e0567a;
  --leaf: #7fae5a;
  --gold: #ffcf5c;
  --shadow: 0 18px 40px rgba(0, 0, 0, .38);
  --radius: 18px;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background:
    radial-gradient(1200px 700px at 50% -10%, #52382a 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  color: var(--paper);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 12px 8px;
  gap: 8px;
}

/* ------------------------------- top bar ------------------------------ */
#topbar {
  width: 100%; max-width: 1200px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background:
    radial-gradient(circle at 30% 30%, var(--cheddar-lt), var(--cheddar) 60%, var(--cheddar-dk));
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.35);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 70% 65%, rgba(120,60,10,.55) 0 3px, transparent 3px),
    radial-gradient(circle at 35% 70%, rgba(120,60,10,.45) 0 2px, transparent 2px);
  border-radius: 8px;
}
.brand-name { font-size: 18px; letter-spacing: .4px; font-weight: 700; color: #ffe9c6; }
.brand-name em { color: var(--cheddar); font-style: normal; }

.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,246,230,.08); color: #ffe9c6; font-size: 16px; cursor: pointer;
  display: grid; place-items: center; transition: transform .08s ease, background .15s ease;
}
.icon-btn:hover { background: rgba(255,246,230,.18); }
.icon-btn:active { transform: scale(.92); }
body.muted .snd-on { display: none; }
body:not(.muted) .snd-off { display: none; }

/* -------------------------------- stage ------------------------------- */
#stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 3px rgba(246,182,76,.18);
  background: #ffe2bb;
}
#game { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }

/* --------------------------------- HUD -------------------------------- */
.hud {
  position: absolute; inset: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 16px; pointer-events: none;
  opacity: 0; transition: opacity .25s ease;
}
body[data-state="play"] .hud,
body[data-state="ready"] .hud,
body[data-state="dead"] .hud { opacity: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(58, 36, 23, .55);
  border: 1px solid rgba(255, 233, 198, .22);
  backdrop-filter: blur(3px);
  color: #ffe9c6; border-radius: 999px; padding: 5px 12px;
  font-size: 13px; letter-spacing: .3px; line-height: 1.4;
  margin: 0 4px 6px 0;
}
.pill .k { opacity: .62; text-transform: uppercase; font-size: 10px; letter-spacing: 1px; }
.pill .v { font-weight: 700; }
.seed-ico {
  width: 12px; height: 15px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: linear-gradient(160deg, #a0764a, #4b3524);
  display: inline-block; box-shadow: inset -1px -1px 0 rgba(255,255,255,.25);
}
.hud-score { text-align: center; }
.score-num {
  font-size: 64px; font-weight: 800; line-height: 1;
  color: #fff8ec;
  text-shadow: 0 4px 0 rgba(120, 62, 16, .55), 0 10px 22px rgba(0, 0, 0, .35);
  letter-spacing: -1px;
  transition: transform .08s ease;
}
.score-num.bump { transform: scale(1.14); }
.combo {
  height: 22px; font-size: 15px; font-weight: 700; color: var(--gold);
  text-shadow: 0 2px 0 rgba(120, 62, 16, .5);
}

/* -------------------------------- toast ------------------------------- */
.toast {
  position: absolute; left: 50%; top: 34%;
  transform: translate(-50%, -50%) scale(.9);
  padding: 10px 22px; border-radius: 999px;
  background: rgba(58, 36, 23, .82); color: #ffe9c6;
  border: 1px solid rgba(255, 216, 132, .4);
  font-size: 17px; font-weight: 700; letter-spacing: .4px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .25s cubic-bezier(.2, 1.6, .4, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast.gold { background: rgba(166, 96, 28, .92); color: #fff6df; border-color: #ffd884; }

/* ------------------------------ overlays ------------------------------ */
.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(700px 460px at 50% 45%, rgba(42, 29, 22, .35), rgba(42, 29, 22, .78));
  opacity: 0; visibility: hidden;
  transition: opacity .22s ease, visibility .22s;
  padding: 16px;
  overflow: auto;            /* tall panels stay reachable on short screens */
}
.overlay.show { opacity: 1; visibility: visible; }

.panel {
  background: linear-gradient(180deg, #fffaf0, #ffeccc);
  color: var(--ink);
  border-radius: 22px;
  border: 3px solid var(--cheddar-dk);
  box-shadow: 0 22px 50px rgba(0, 0, 0, .5), inset 0 2px 0 rgba(255, 255, 255, .8);
  padding: 26px 30px;
  max-width: 520px; width: 100%;
  text-align: center;
  transform: translateY(10px) scale(.98);
  transition: transform .25s cubic-bezier(.2, 1.5, .4, 1);
}
.overlay.show .panel { transform: translateY(0) scale(1); }

.title {
  margin: 0 0 6px; font-size: 44px; line-height: .95; font-weight: 800;
  letter-spacing: -1px; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.title span { display: block; }
.title-maze {
  color: var(--cheddar-dk);
  font-size: 62px;
  text-shadow: 0 3px 0 var(--cheddar-lt), 0 6px 0 rgba(166, 96, 28, .25);
}
.tagline { margin: 8px 0 20px; color: var(--ink-soft); font-size: 15px; }

.btn {
  font-family: inherit; font-size: 17px; font-weight: 700; cursor: pointer;
  border-radius: 14px; padding: 12px 22px; border: 2px solid transparent;
  transition: transform .08s ease, box-shadow .12s ease, background .15s ease;
}
.btn:active { transform: translateY(2px) scale(.99); }
.btn-primary {
  background: linear-gradient(180deg, #ffcf6d, var(--cheddar) 60%, #e09a2f);
  color: #4a2a10; border-color: var(--cheddar-dk);
  box-shadow: 0 6px 0 #93561a, 0 12px 22px rgba(0, 0, 0, .32);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { box-shadow: 0 2px 0 #93561a; }
.btn-ghost {
  background: rgba(58, 36, 23, .07); color: var(--ink);
  border-color: rgba(58, 36, 23, .25);
}
.btn-ghost:hover { background: rgba(58, 36, 23, .14); }
.btn-emoji { margin-right: 4px; }

kbd {
  font-family: inherit; font-size: .78em; font-weight: 700;
  background: rgba(58, 36, 23, .12); border: 1px solid rgba(58, 36, 23, .25);
  border-bottom-width: 3px; border-radius: 6px; padding: 1px 6px; margin: 0 2px;
}

.menu-grid {
  display: grid; grid-template-columns: 1.7fr 1fr 1fr 1fr; gap: 8px; margin: 18px 0 14px;
}
.menu-cell {
  background: rgba(58, 36, 23, .06); border-radius: 12px; padding: 9px 6px;
  font-size: 12px; color: var(--ink-soft); display: flex; flex-direction: column;
  gap: 3px; align-items: center; justify-content: center; line-height: 1.35;
}
.menu-cell b { color: var(--ink); font-size: 12px; white-space: nowrap; }
.menu-stats {
  display: flex; justify-content: center; gap: 26px; font-size: 13px; color: var(--ink-soft);
}
.menu-stats b { color: var(--cheddar-dk); font-size: 18px; margin-left: 6px; }
.menu-stats .k { text-transform: uppercase; letter-spacing: 1px; font-size: 10px; opacity: .8; }

/* ready */
.ready-hint { text-align: center; color: #fff3dd; text-shadow: 0 3px 8px rgba(0, 0, 0, .5); }
.ready-hint p { margin: 6px 0; font-size: 20px; font-weight: 700; }
.ready-hint .sub { font-size: 14px; font-weight: 500; opacity: .85; }
.tap-ring {
  width: 74px; height: 74px; margin: 0 auto 14px; border-radius: 50%;
  border: 3px dashed rgba(255, 240, 215, .8);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: .55; }
  50% { transform: scale(1.18); opacity: 1; }
}

/* dead */
.dead-emoji { font-size: 46px; line-height: 1; }
.dead-title { margin: 4px 0 14px; font-size: 30px; color: var(--cheddar-dk); }
.score-row { display: flex; gap: 12px; justify-content: center; margin-bottom: 12px; }
.score-box {
  flex: 1; max-width: 160px; background: rgba(246, 182, 76, .18);
  border: 2px solid rgba(166, 96, 28, .35); border-radius: 14px; padding: 10px;
}
.score-box .k { display: block; font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--ink-soft); }
.score-box b { font-size: 34px; color: var(--ink); }
.breakdown {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px 14px; text-align: left; font-size: 13px; color: var(--ink-soft);
  background: rgba(58, 36, 23, .05); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px;
}
.breakdown div { display: flex; justify-content: space-between; }
.breakdown b { color: var(--ink); }
.medal-wrap { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; }
.medal {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  font-size: 28px; background: radial-gradient(circle at 35% 30%, #fff2cf, #f0c96a 60%, #c9902f);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .18), inset 0 0 0 3px rgba(255, 255, 255, .45);
}
#medal-label { font-weight: 700; color: var(--cheddar-dk); font-size: 16px; }
.medal-wrap.is-new .medal {
  box-shadow: 0 0 0 5px rgba(255, 207, 92, .45), 0 4px 0 rgba(0, 0, 0, .18),
    inset 0 0 0 3px rgba(255, 255, 255, .5);
  animation: medal-pop .55s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes medal-pop {
  0% { transform: scale(.5) rotate(-14deg); }
  60% { transform: scale(1.18) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
/* ---- difficulty picker ------------------------------------------------ */
.diff-block {
  margin: 14px 0 2px;
  padding: 11px 13px 12px;
  background: rgba(255, 246, 230, .6);
  border: 1px solid rgba(166, 96, 28, .22);
  border-radius: 14px;
  text-align: left;
}
.diff-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 9px;
}
.diff-title {
  font-size: 11px; font-weight: 800; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--cheddar-dk);
}
.diff-hint { font-size: 11px; color: var(--ink-soft); }
.diff-picker { display: flex; gap: 7px; flex-wrap: wrap; }
.diff-btn {
  flex: 1 1 0; min-width: 72px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 6px 7px;
  background: #fffaf0;
  border: 2px solid rgba(166, 96, 28, .26);
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(166, 96, 28, .2);
  color: var(--ink); font-family: var(--font);
  cursor: pointer;
  transition: transform .08s ease, border-color .12s ease, background .12s ease;
}
.diff-btn:hover { transform: translateY(-1px); border-color: rgba(166, 96, 28, .5); }
.diff-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(166, 96, 28, .2); }
.diff-btn:focus-visible { outline: 3px solid var(--berry); outline-offset: 2px; }
.diff-emoji { font-size: 20px; line-height: 1.1; filter: grayscale(.6) opacity(.7); }
.diff-label { font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.diff-btn[aria-checked="true"] {
  background: linear-gradient(180deg, var(--cheddar-lt), var(--cheddar));
  border-color: var(--cheddar-dk);
  box-shadow: 0 3px 0 #93561a, inset 0 1px 0 rgba(255, 255, 255, .55);
}
.diff-btn[aria-checked="true"] .diff-emoji { filter: none; }
.diff-blurb {
  margin: 9px 2px 0; min-height: 16px;
  font-size: 11.5px; line-height: 1.45; color: var(--ink-soft);
}
/* ---- standalone pages (404) ------------------------------------------ */
/* The 404 is served without the app shell, so give the body a frame for the
   panel. No inline styles anywhere -- CSP is style-src 'self'. */
body.static-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.notfound { width: 100%; max-width: 460px; }
.notfound .btn { text-decoration: none; display: inline-block; }

/* ---- character picker -------------------------------------------------- */
.char-picker { display: flex; gap: 7px; flex-wrap: wrap; }
.char-btn {
  flex: 1 1 0; min-width: 130px;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px;
  background: #fffaf0;
  border: 2px solid rgba(166, 96, 28, .26);
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(166, 96, 28, .2);
  color: var(--ink); font-family: var(--font);
  cursor: pointer;
  transition: transform .08s ease, border-color .12s ease, background .12s ease;
}
.char-btn:hover { transform: translateY(-1px); border-color: rgba(166, 96, 28, .5); }
.char-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(166, 96, 28, .2); }
.char-btn:focus-visible { outline: 3px solid var(--berry); outline-offset: 2px; }
.char-swatch {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid rgba(58, 36, 23, .55);
  box-shadow: inset -2px -2px 0 rgba(90, 60, 30, .18), inset 2px 2px 0 rgba(255, 255, 255, .6);
}
.char-name { font-size: 13px; font-weight: 700; letter-spacing: .2px; }
.char-btn[aria-checked="true"] {
  background: linear-gradient(180deg, var(--cheddar-lt), var(--cheddar));
  border-color: var(--cheddar-dk);
  box-shadow: 0 3px 0 #93561a, inset 0 1px 0 rgba(255, 255, 255, .55);
}

/* accent the HUD pill with the current difficulty */
.pill-diff { border-color: rgba(246, 182, 76, .5); }
body[data-diff="chill"]  .pill-diff { border-color: rgba(127, 174, 90, .65); }
body[data-diff="spicy"]  .pill-diff { border-color: rgba(224, 86, 122, .6); }
body[data-diff="brutal"] .pill-diff { border-color: rgba(222, 78, 45, .7); }

.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* help */
.panel-help { text-align: left; max-width: 560px; }
.panel-help h2 { text-align: center; margin-top: 0; color: var(--cheddar-dk); }
.panel-help ul { padding-left: 20px; margin: 0 0 16px; line-height: 1.65; font-size: 14px; color: var(--ink-soft); }
.panel-help li b { color: var(--ink); }
.panel-help .btn-row { justify-content: center; }
.panel-pause h2 { margin: 0 0 6px; color: var(--cheddar-dk); }
.panel-pause p { margin: 0 0 16px; color: var(--ink-soft); }

/* -------------------------------- foot -------------------------------- */
#foot { flex: 0 0 auto; font-size: 11px; color: rgba(255, 233, 198, .45); }
#fps { font-variant-numeric: tabular-nums; }

/* ------------------------------ responsive ---------------------------- */
@media (max-width: 720px) {
  .title { font-size: 30px; }
  .title-maze { font-size: 42px; }
  .score-num { font-size: 46px; }
  .menu-grid { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: 18px 18px; }
  #topbar { padding: 0 2px; }
  .brand-name { font-size: 15px; }
}
@media (max-height: 560px) {
  #foot { display: none; }
  .tagline { margin: 6px 0 12px; }
  .menu-grid { margin: 10px 0 8px; }
}
