/* ==========================================================================
   BE THE HAMSTER â€” styles
   Mobile-first, portrait-locked, single-thumb. No external libraries.
   Palette: warm browns, cream, golden yellows, soft greens â€” cosy & playful.
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #f3e7cd;
}

body {
  font-family: "Lemon Days", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
  color: #7a5227;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

/* Portrait game column: 9:16, centered, letterboxed on any screen.
   On portrait screens (phones and tablets) the game fills the whole
   display edge to edge instead. */
#game-root {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(100vw, 100vh * 0.5625, 520px);
  width: min(100vw, calc(100dvh * 0.5625), 520px);
  aspect-ratio: 9 / 16;
  background: #eed9ae;
  overflow: hidden;
  touch-action: none;
  box-shadow: 0 8px 40px rgba(90, 60, 25, 0.35);
  border-radius: 6px;
}

@media (orientation: portrait) {
  #game-root {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Subtle static vignette (cheap: pure CSS, GPU-composited). */
#vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(90, 60, 25, 0) 58%, rgba(90, 60, 25, 0.22) 100%);
}

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

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 18px 0;
  pointer-events: none;
  z-index: 2;
  opacity: 1;
  transition: opacity 0.25s ease;
}

#hud.inactive {
  opacity: 0;
}

.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 6px;
}

.hud-block {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ffd93d;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.5);
}

.hud-value {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 2px 0 #7a5227, 0 3px 0 rgba(40, 25, 10, 0.3);
}

.hud-value-sm {
  font-size: 22px;
}

#hud-timer {
  border: 16px solid transparent;
  border-image: url('Assets/UI/button_brown.png?v=68') 16 fill / 16px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  padding: 4px 24px;
  color: #ffd93d;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.6);
}

#hud-timer.low {
  border-image: url('Assets/UI/button_brown_close.png?v=68') 16 fill / 16px stretch;
  color: #ff6b57;
}

/* Pause button */
#pause-btn {
  pointer-events: auto;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: url('Assets/UI/round_brown.png?v=68') no-repeat center / 100% 100%;
  image-rendering: pixelated;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: filter 0.1s ease, transform 0.1s ease;
}

#pause-btn span {
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 2px 0 rgba(40, 25, 10, 0.5);
}

#pause-btn:active {
  filter: brightness(0.85);
  transform: scale(0.94);
}

#pause-btn.hidden {
  visibility: hidden;
  pointer-events: none;
}

/* Multiplier chip */
.chip {
  align-self: flex-end;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  background: url('Assets/UI/round_brown.png?v=68') no-repeat center / 100% 100%;
  image-rendering: pixelated;
  border: none;
  padding: 8px 14px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.6);
  transition: color 0.2s ease;
}

.chip.active {
  color: #ffd93d;
}

/* Active powerup pills â€” centered under the timer, clear of the score. */
#powerup-bar {
  position: absolute;
  top: calc(134px + env(safe-area-inset-top));
  left: 18px;
  right: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
  z-index: 2;
}

.powerup-pill {
  --pill-color: #ffd93d;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 9px;
  border: 2px solid var(--pill-color);
  border-radius: 10px;
  background: rgba(40, 25, 10, 0.78);
  color: var(--pill-color);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  animation: pillIn 0.3s ease-out both;
}

@keyframes pillIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ----------------------------- achievement toast ------------------------ */

/* Floating score feedback (+10, +5s, x2!) */
.float-text {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: "Lemon Days", "Comic Sans MS", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.7);
  pointer-events: none;
  z-index: 7;
}

/* Score numbers pop when they change. */
#hud-score.pop {
  animation: scorePop 0.22s ease-out;
}

/* Combo announcements grow and glow with each tier. */
.combo-text {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.8), 0 0 18px rgba(255, 217, 61, 0.7);
  animation: comboIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.combo-text.c2 { font-size: 32px; }
.combo-text.c3 { font-size: 40px; text-shadow: 0 2px 0 rgba(40, 25, 10, 0.8), 0 0 24px rgba(255, 107, 87, 0.8); }
.combo-text.c4 { font-size: 48px; text-shadow: 0 2px 0 rgba(40, 25, 10, 0.8), 0 0 30px rgba(255, 107, 87, 1); }

/* Storm announcements (Sandstorm! / Blizzard!) — locked dead-centre,
   independent of the player or any camera movement. */
#storm-banner {
  position: fixed;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  font-family: "Lemon Days", "Comic Sans MS", system-ui, sans-serif;
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.9), 0 0 26px rgba(255, 220, 140, 0.9);
  pointer-events: none;
  z-index: 9;
}

#storm-banner.hidden {
  display: none;
}

#storm-banner.pop {
  animation: stormPop 1.6s ease-out both;
}

@keyframes stormPop {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.05); opacity: 0; }
}

@keyframes comboIn {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1.12); opacity: 1; }
}

@keyframes scorePop {
  40% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

/* New best bounces in. */
#new-best {
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

#toast {
  position: absolute;
  top: calc(120px + env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -12px);
  padding: 8px 24px;
  border: 16px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 16 fill / 16px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 2px 0 #7a5227;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
  white-space: nowrap;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Active-for-this-run consumables, shown during the countdown. */
#countdown-consumables {
  position: absolute;
  top: calc(150px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(40, 25, 10, 0.82);
  border: 2px solid rgba(255, 217, 61, 0.6);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

#countdown-consumables.hidden {
  display: none;
}

.countdown-cons-icon {
  width: 42px;
  height: 42px;
  image-rendering: pixelated;
}

/* One-time control tutorial: a thumb zone box + one-liner shown while
   the 3-2-1 countdown plays, hidden with it once the run starts. */
#tutorial {
  position: absolute;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(76%, 300px);
  pointer-events: none;
  animation: tutorialIn 0.4s ease-out 0.15s both;
}

@keyframes tutorialIn {
  from {
    opacity: 0;
    transform: translate(-50%, 14px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.thumb-zone {
  width: 150px;
  height: 104px;
  border: 3px dashed rgba(255, 217, 61, 0.9);
  border-radius: 16px;
  background: rgba(122, 82, 39, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 18px rgba(255, 217, 61, 0.15);
}

.thumb-dot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 0 rgba(122, 82, 39, 0.5);
  animation: thumbPulse 1.2s ease-in-out infinite;
}

@keyframes thumbPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.14);
    opacity: 1;
  }
}

.tutorial-text {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.7);
  background: rgba(90, 60, 25, 0.55);
  padding: 6px 12px;
  border-radius: 10px;
  max-width: 280px;
}

/* ------------------------------- countdown ------------------------------ */

#countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
}

#countdown.hidden {
  display: none;
}

#countdown-num {
  font-size: 110px;
  font-weight: 800;
  color: #ffd93d;
  -webkit-text-stroke: 3px #7a5227;
  text-shadow: 0 4px 0 #7a5227, 0 7px 0 rgba(40, 25, 10, 0.35);
  opacity: 0;
  font-variant-numeric: tabular-nums;
}

#countdown-num.pop {
  animation: countPop 0.62s ease-out both;
}

#countdown-num.go {
  animation: countGo 0.5s ease-out both;
  color: #9edb7a;
  -webkit-text-stroke: 3px #3a5a28;
  text-shadow: 0 4px 0 #3a5a28, 0 7px 0 rgba(30, 45, 20, 0.35);
}

@keyframes countPop {
  0% {
    opacity: 0;
    transform: scale(2.2);
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes countGo {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  30% {
    opacity: 1;
    transform: scale(1.15);
  }
  100% {
    opacity: 0;
    transform: scale(1.4);
  }
}

/* ------------------------------ overlays -------------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 244, 224, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 24px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0s linear 0.28s;
}

.overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.28s ease, visibility 0s;
}

/* Keep content centered, but allow scrolling when it overflows. */
.overlay > *:first-child {
  margin-top: auto;
}

.overlay > *:last-child {
  margin-bottom: auto;
}

/* Staggered panel entry when an overlay appears. */
.overlay.visible > * {
  animation: fadeUp 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.overlay.visible > *:nth-child(1) { animation-delay: 0s; }
.overlay.visible > *:nth-child(2) { animation-delay: 0.06s; }
.overlay.visible > *:nth-child(3) { animation-delay: 0.12s; }
.overlay.visible > *:nth-child(4) { animation-delay: 0.18s; }
.overlay.visible > *:nth-child(5) { animation-delay: 0.24s; }
.overlay.visible > *:nth-child(6) { animation-delay: 0.3s; }
.overlay.visible > *:nth-child(7) { animation-delay: 0.36s; }

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overlay h1:not(.title) {
  font-size: 40px;
  letter-spacing: 1px;
  margin-bottom: 14px;
  color: #fff;
  -webkit-text-stroke: 2px #7a5227;
  text-shadow: 0 3px 0 #7a5227;
}

/* Big, celebratory heading on the winning screen. */
#go-title {
  font-size: 38px;
  letter-spacing: 1px;
  white-space: nowrap;
  color: #ffd93d;
  -webkit-text-stroke: 2px #7a5227;
  text-shadow: 0 3px 0 #7a5227, 0 6px 0 #b07b45, 0 10px 18px rgba(90, 60, 25, 0.35);
}

#new-best.hidden,
#rotate-overlay.hidden {
  display: none;
}

/* The game-over content sits up high; the hit hamster peeks over the
   bottom edge and floats free. */
#game-over {
  overflow: visible;
  justify-content: flex-start;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: 0;
}

#game-over > *:first-child {
  margin-top: 0;
}

/* Retry and Menu sit side by side, clear of the hamster below. */
#game-over-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

#game-over-buttons .btn {
  margin-top: 0;
  padding: 5px 18px;
  font-size: 15px;
}

/* The hamster: hit when you lose, celebrating when you win — only one
   shows at a time. */
.gameover-hamster {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
  bottom: -10px;
  width: 240px;
  height: 240px;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 6;
  animation: none;
  filter: drop-shadow(0 10px 10px rgba(90, 60, 25, 0.4));
}

.gameover-hamster.hidden {
  display: none;
}

#new-best {
  margin-top: 2px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ffd93d;
  -webkit-text-stroke: 1px #7a5227;
  text-shadow: 0 2px 0 #7a5227;
}

/* --------------------------- session summary ---------------------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 380px;
  margin: 6px 0;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  border: 16px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 16 fill / 16px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 245, 220, 0.8);
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
}

.stat-value {
  font-size: 19px;
  font-weight: 800;
  color: #ffd93d;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.6);
}

/* ---------------------------- statistics list --------------------------- */

.stats-list {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 15px;
  border: 16px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 16 fill / 16px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
}

.stat-row span:first-child {
  color: rgba(255, 245, 220, 0.85);
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
}

.stat-row span:last-child {
  font-weight: 700;
  color: #ffd93d;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.6);
}

/* ---------------------------- consumables -------------------------------- */

/* Readied-for-next-run items: a small row of icons under the power-up
   pills; tapping an icon removes it from the loadout. */
#consumable-bar {
  position: absolute;
  top: calc(150px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 5px 9px;
  background: rgba(90, 60, 25, 0.55);
  border-radius: 10px;
  pointer-events: auto;
  z-index: 3;
}

#consumable-bar.hidden {
  display: none;
}

.cons-bar-icon {
  width: 34px;
  height: 34px;
  image-rendering: pixelated;
  cursor: pointer;
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(40, 25, 10, 0.4);
}

.cons-bar-icon:active {
  transform: scale(0.9);
  opacity: 0.7;
}

/* Catalogue grid: large icon with count pill, name, description, Use. */
.cons-hint {
  font-size: 12px;
  color: #7a5227;
  text-align: center;
  max-width: 320px;
  margin-bottom: 10px;
}

#cons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 360px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px;
}

.cons-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  text-align: center;
  border: 12px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 12 fill / 12px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
}

.cons-card.equipped {
  border-image: url('Assets/UI/panel_brown.png?v=68') 12 fill / 12px stretch;
  box-shadow: 0 0 10px rgba(255, 217, 61, 0.5);
}

/* Equipped cards sit on a light panel — dark text reads clearly there. */
.cons-card.equipped .cons-name {
  color: #5b3516;
  text-shadow: none;
}

.cons-card.equipped .cons-desc {
  color: #8a5a2b;
}

.cons-icon-wrap {
  position: relative;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The source art is small — force it up to ~4x its native display size. */
.cons-icon {
  width: 150px;
  height: 150px;
  object-fit: contain;
  image-rendering: pixelated;
  flex: none;
}

.cons-count {
  position: absolute;
  top: -4px;
  right: -6px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: #e0523d;
  border: 2px solid #7a2f1e;
  border-radius: 10px;
  padding: 1px 7px;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.7);
}

.cons-count.zero {
  background: #7a6a52;
  border-color: #4a3f2e;
}

.cons-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
  line-height: 1.15;
}

.cons-desc {
  font-size: 10px;
  line-height: 1.3;
  color: rgba(255, 245, 220, 0.75);
}

.cons-use {
  margin-top: 6px;
  padding: 4px 14px;
  font-size: 13px;
  font-family: "Lemon Days", "Comic Sans MS", system-ui, sans-serif;
  font-weight: 400;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 1px 0 rgba(60, 35, 15, 0.7);
  cursor: pointer;
  border: 10px solid transparent;
  border-image: url('Assets/UI/button_brown.png?v=68') 10 fill / 10px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
}

.cons-use.equipped {
  border-image: url('Assets/UI/button_grey.png?v=68') 10 fill / 10px stretch;
}

.cons-use:disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* End-screen row of consumables found during the run. */
#final-consumables {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

#final-consumables.hidden {
  display: none;
}

.final-cons-label {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffe9b0;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
}

.final-cons-row {
  display: flex;
  gap: 10px;
}

.final-cons-icon {
  width: 54px;
  height: 54px;
  image-rendering: pixelated;
}

/* Chest found on a win: a touch bigger, purely decorative. */
.final-chest-icon {
  width: 62px;
  height: 62px;
}

/* Newly unlocked unlockables / adventures shown after a run. */
#final-unlocks {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
}

#final-unlocks.hidden {
  display: none;
}

.final-unlock-row {
  font-size: 13px;
  font-weight: 700;
  color: #ffd93d;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
  text-align: center;
}

/* Records beaten this run (overall / per-map score / distance). */
#final-records {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
}

#final-records.hidden {
  display: none;
}

.final-record-row {
  font-size: 14px;
  font-weight: 800;
  color: #9edb7a;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
  text-align: center;
}

/* ---------------------------- treasure chests ---------------------------- */

/* Floating chest shortcut on the menu (top-left, count badge). */
#chest-menu-btn {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  width: 74px;
  height: 74px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  z-index: 8;
}

#chest-menu-btn.hidden {
  display: none;
}

#chest-menu-btn img {
  width: 74px;
  height: 74px;
  image-rendering: pixelated;
  filter: drop-shadow(0 3px 4px rgba(20, 12, 4, 0.5));
}

#chest-menu-btn:active img {
  transform: scale(0.92);
}

#chest-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 26px;
  height: 26px;
  border-radius: 13px;
  background: #e0523d;
  border: 2px solid #7a2f1e;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  padding: 0 6px;
}

/* Full-screen chest opening sequence. */
#chest-overlay {
  background: rgba(30, 20, 8, 0.9);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Kill the overlay's auto-margin rules that fight the centering. */
#chest-overlay > * {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

#chest-stage {
  position: relative;
  width: 84vw;
  max-width: 380px;
  height: 84vw;
  max-height: 380px;
  cursor: pointer;
  transform: translateY(0);
  transition: transform 0.55s ease-in-out;
}

#chest-stage.sink {
  transform: translateY(60px);
}

/* Closed and open chests occupy the exact same spot — the open image
   replaces the closed one. */
#chest-closed-img {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
  max-width: 88%;
  max-height: 88%;
  width: auto;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.5));
}

#chest-closed-img.chest-bounce {
  animation: chestBounce 0.6s ease-in-out;
}

@keyframes chestBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-24px) scale(1.06, 0.96); }
  60% { transform: translateY(0) scale(0.96, 1.04); }
}

#chest-open-img {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
  max-width: 92%;
  max-height: 92%;
  width: auto;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 24px rgba(255, 200, 80, 0.8));
  animation: chestReveal 0.35s ease-out both;
}

@keyframes chestReveal {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#chest-closed-img.hidden,
#chest-open-img.hidden,
#chest-flash.hidden,
#chest-glow.hidden,
#chest-sparkles.hidden,
#chest-reward.hidden,
#chest-reward-img.hidden,
#chest-reward-emoji.hidden,
#chest-continue-btn.hidden,
#chest-hint.hidden {
  display: none;
}

/* Quick golden flash bridging closed -> open. */
#chest-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 230, 140, 0.95), rgba(255, 200, 60, 0.4) 55%, transparent 75%);
  animation: chestFlash 0.26s ease-out both;
  z-index: 3;
}

@keyframes chestFlash {
  from { opacity: 1; }
  to { opacity: 0; }
}

#chest-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 200, 80, 0.45), transparent 65%);
  animation: chestGlowPulse 1.4s ease-in-out infinite;
}

@keyframes chestGlowPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

#chest-sparkles {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  font-size: 30px;
  z-index: 2;
  pointer-events: none;
}

#chest-sparkles span {
  animation: chestTwinkle 1s ease-in-out infinite;
  text-shadow: 0 0 10px rgba(255, 220, 120, 0.9);
}

#chest-sparkles span:nth-child(2n) { animation-delay: 0.3s; font-size: 40px; }
#chest-sparkles span:nth-child(3n) { animation-delay: 0.6s; }

@keyframes chestTwinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.25); }
}

/* The prize floats above the open chest; it sinks with the chest. */
#chest-reward {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 10px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  z-index: 4;
  animation: rewardPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#chest-reward.float {
  animation: rewardBob 1.6s ease-in-out infinite;
}

@keyframes rewardPop {
  from { transform: translateX(-50%) scale(0.3); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes rewardBob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-10px); }
}

#chest-reward-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.chest-reward-item-img {
  width: 50px;
  height: 50px;
  flex: none;
  image-rendering: pixelated;
  animation: rewardGlow 1.6s ease-in-out infinite;
}

.chest-reward-item-emoji {
  font-size: 40px;
  line-height: 1;
  flex: none;
  animation: rewardGlow 1.6s ease-in-out infinite;
}

@keyframes rewardGlow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(255, 220, 120, 0.5)); }
  50% { filter: drop-shadow(0 0 24px rgba(255, 220, 120, 1)); }
}

/* Prize name sits beside the icons; small, at most two lines. */
.chest-reward-name {
  font-size: 13px;
  font-weight: 800;
  color: #ffd93d;
  max-width: 150px;
  line-height: 1.15;
  text-align: left;
  animation: textGlow 1.6s ease-in-out infinite;
}

@keyframes textGlow {
  0%, 100% { text-shadow: 0 1px 0 rgba(40, 25, 10, 0.8), 0 0 8px rgba(255, 217, 61, 0.4); }
  50% { text-shadow: 0 1px 0 rgba(40, 25, 10, 0.8), 0 0 20px rgba(255, 217, 61, 0.95); }
}

#chest-reward-desc {
  font-size: 11px;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 245, 220, 0.9);
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
}

#chest-hint {
  position: fixed;
  bottom: calc(5% + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  margin: 0 auto;
  width: fit-content;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffe9b0;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
  animation: hintPulse 1.2s ease-in-out infinite;
}

#chest-continue-btn {
  position: fixed;
  bottom: calc(12% + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  margin: 0 auto;
  width: fit-content;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* --------------------- unlock celebration cards ------------------------- */

#celebrate-overlay {
  background: rgba(30, 20, 8, 0.88);
}

#celebrate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(84%, 340px);
  padding: 26px 20px;
  text-align: center;
  border: 24px solid transparent;
  border-image: url('Assets/UI/panel_brown.png?v=68') 24 fill / 24px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  box-shadow: 0 0 40px rgba(255, 200, 80, 0.35);
}

#celebrate-card.pop {
  animation: celebratePop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes celebratePop {
  from { transform: scale(0.4) rotate(-3deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

#celebrate-category {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ffd93d;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
}

#celebrate-img {
  width: 130px;
  height: 130px;
  image-rendering: pixelated;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(40, 25, 10, 0.4));
  animation: celebrateFloat 2s ease-in-out infinite;
}

#celebrate-emoji {
  font-size: 90px;
  line-height: 1;
  animation: celebrateFloat 2s ease-in-out infinite;
}

#celebrate-img.hidden,
#celebrate-emoji.hidden {
  display: none;
}

@keyframes celebrateFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

#celebrate-title {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  -webkit-text-stroke: 1.5px #7a5227;
  text-shadow: 0 2px 0 #7a5227;
}

#celebrate-desc {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255, 245, 220, 0.9);
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
  max-width: 280px;
}

/* ------------------------------ burrow ----------------------------------- */

/* Full-screen home for the hamsters; fade handled by .overlay.visible. */
#burrow-overlay {
  background: #2e2417;
  overflow: hidden;
}

#burrow-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  user-select: none;
  -webkit-user-drag: none;
}

#burrow-hamsters {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.burrow-hamster {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 88px;
  height: 88px;
  image-rendering: pixelated;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(20, 12, 4, 0.5));
}

#burrow-back-btn {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  margin: 0;
  z-index: 2;
}

/* ------------------------------- toggles -------------------------------- */

.toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 320px;
  padding: 8px 16px;
  border: 16px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 16 fill / 16px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  cursor: pointer;
  color: #fff;
  font-family: inherit;
}

.toggle-track {
  position: relative;
  width: 36px;
  height: 36px;
  flex: none;
  background: url('Assets/UI/checkbox_brown_empty.png?v=68') no-repeat center / contain;
  image-rendering: pixelated;
}

.toggle.on .toggle-track {
  background-image: url('Assets/UI/checkbox_brown_checked.png?v=68');
}

.toggle-label {
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.6);
}

/* Notched volume sliders (10 steps each). */
.vol-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 320px;
  padding: 10px 16px;
  border: 16px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 16 fill / 16px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
}

.vol-label {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.6);
}

.vol-slider {
  width: 100%;
  accent-color: #ffd93d;
  height: 28px;
  cursor: pointer;
  /* The game root blocks touch gestures; sliders must opt back in. */
  touch-action: auto;
  -webkit-user-select: auto;
  user-select: auto;
}

/* Kawaii Stitch â€” the playful title font (bundled locally). */
@font-face {
  font-family: "Kawaii Stitch";
  src: url('Assets/Fonts/Kawaii Stitch.ttf?v=68') format('truetype');
  font-display: swap;
}

/* Lemon Days â€” the friendly UI font used everywhere except the title. */
@font-face {
  font-family: "Lemon Days";
  src: url('Assets/Fonts/Lemon Days.ttf?v=68') format('truetype');
  font-display: swap;
}

/* ------------------------------ start menu ------------------------------ */

/* The title screen: menu card centered in the middle, with the hero
   scene (front-facing hamster peeking over the bottom edge +
   decorations) visible at the top and bottom. */
#menu {
  background: linear-gradient(
    180deg,
    rgba(255, 244, 224, 0) 0%,
    rgba(255, 244, 224, 0.4) 14%,
    rgba(255, 244, 224, 0.95) 34%,
    rgba(255, 244, 224, 0.92) 66%,
    rgba(255, 244, 224, 0.4) 86%,
    rgba(255, 244, 224, 0) 100%
  );
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: visible; /* let the best-score crown and hamster float free */
}

.menu-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  position: relative;
  border: 32px solid transparent;
  border-image: url('Assets/UI/panel_brown_corners_b.png?v=68') 32 fill / 32px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  padding: 14px 22px 58px;
  box-shadow: 0 12px 0 rgba(90, 60, 25, 0.3), 0 18px 30px rgba(90, 60, 25, 0.25);
}

/* The title sits on a hanging wooden banner from the UI pack. It is
   pushed down so the best-score crown can sit above the card edge. */
.title-banner {
  border: 24px 96px;
  border-image: url('Assets/UI/banner_hanging.png?v=68') 24 96 fill / 24px 96px stretch;
  image-rendering: pixelated;
  background: none;
  padding: 10px 16px 12px;
  margin-top: 46px;
  margin-bottom: 2px;
}

/* Stagger the menu card's contents too. */
.overlay.visible .menu-panel > * {
  animation: fadeUp 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

.overlay.visible .menu-panel > *:nth-child(1) { animation-delay: 0.05s; }
.overlay.visible .menu-panel > *:nth-child(2) { animation-delay: 0.12s; }
.overlay.visible .menu-panel > *:nth-child(3) { animation-delay: 0.19s; }
.overlay.visible .menu-panel > *:nth-child(4) { animation-delay: 0.26s; }
.overlay.visible .menu-panel > *:nth-child(5) { animation-delay: 0.33s; }
.overlay.visible .menu-panel > *:nth-child(6) { animation-delay: 0.4s; }
.overlay.visible .menu-panel > *:nth-child(7) { animation-delay: 0.47s; }

.title {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.05;
  font-family: "Kawaii Stitch", "Comic Sans MS", "Chalkboard SE", cursive;
}

.title-kicker {
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 4px;
  padding-left: 4px; /* balances the letter-spacing */
  color: #4a2f12;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.35), 0 4px 0 rgba(255, 255, 255, 0.2);
}

.title-main {
  font-size: 72px;
  font-weight: 400;
  letter-spacing: 1px;
  padding-left: 1px;
  color: #ffd93d;
  -webkit-text-stroke: 2px #7a5227;
  text-shadow: 0 3px 0 #b07b45, 0 6px 0 #7a5227, 0 10px 18px rgba(90, 60, 25, 0.3);
}

.tagline {
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #6b4a2b;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  white-space: nowrap;
}

/* The best-score hexagon crowns the menu card: half above, half on. */
.menu-best {
  position: absolute;
  top: -86px;
  left: 0;
  right: 0;
  margin: 0 auto;
  z-index: 5;
  animation: none; /* the stagger animation would fight the centering */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 128px; /* matches the hexagon's 3:4 aspect â€” no squashing */
  background: url('Assets/UI/hexagon_damaged_brown.png?v=68') no-repeat center / 100% 100%;
  image-rendering: pixelated;
  color: #fff;
}

.menu-best-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #5b3516;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

.menu-best-value {
  font-size: 26px;
  font-weight: 900;
  line-height: 1.15;
  color: #e0523d;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(40, 25, 10, 0.45);
}

/* The hero hamster peeks up over the bottom-right corner of the menu
   card, breathing gently while waiting. */
.menu-hamster {
  position: absolute;
  left: auto;
  right: -22px;
  margin: 0;
  bottom: -108px;
  width: 175px;
  height: 175px;
  image-rendering: pixelated;
  object-fit: contain;
  pointer-events: none;
  z-index: 6;
  filter: drop-shadow(0 10px 10px rgba(90, 60, 25, 0.4));
}

/* Breathing beats the menu stagger animation on the floating hamster. */
.overlay.visible .menu-panel > .menu-hamster {
  animation: hamsterBreath 3.2s ease-in-out infinite;
}

@keyframes hamsterBreath {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.02);
  }
}

.menu-hint {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(107, 74, 43, 0.8);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* The selected-adventure indicator pill. */
.menu-adv-pill {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  border: 12px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 12 fill / 12px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  padding: 5px 14px;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
}

.menu-adv-pill b {
  color: #ffd93d;
}

/* ------------------------------- buttons -------------------------------- */

/* Pixel-art buttons: 9-slice stretched from the UI sprite sheet. */
.btn {
  margin-top: 20px;
  padding: 11px 38px;
  font-family: "Lemon Days", "Comic Sans MS", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 1px;
  border: 16px solid transparent;
  border-image: url('Assets/UI/button_brown.png?v=68') 16 fill / 16px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  color: #fff;
  text-shadow: 0 2px 0 rgba(60, 35, 15, 0.7);
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.1s ease;
}

.btn:active {
  border-image: url('Assets/UI/button_brown_close.png?v=68') 16 fill / 16px stretch;
  transform: translateY(2px);
  filter: brightness(0.95);
}

.btn-primary {
  color: #fff;
}

.btn-ghost {
  border-image: url('Assets/UI/button_grey.png?v=68') 16 fill / 16px stretch;
  text-shadow: 0 2px 0 rgba(40, 30, 20, 0.6);
}

.btn-ghost:active {
  border-image: url('Assets/UI/button_grey_close.png?v=68') 16 fill / 16px stretch;
}

/* Gentle hover lift on devices that can hover. */
@media (hover: hover) {
  .btn:hover {
    transform: translateY(-2px) scale(1.03);
  }
}

/* Start spans exactly the width of a row of square buttons so the card
   lines up. Sizes live in CSS vars so they can't drift apart. */
.menu-panel {
  --btn-cols: 3;
  --btn-size: 110px;
  --btn-gap: 10px;
}

#start-btn {
  width: calc(var(--btn-cols) * var(--btn-size) + (var(--btn-cols) - 1) * var(--btn-gap));
  font-size: 20px;
  padding: 12px 0;
  color: #4a2f12;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

.menu-btns {
  display: grid;
  grid-template-columns: repeat(var(--btn-cols), var(--btn-size));
  justify-content: center;
  gap: var(--btn-gap);
  margin-top: 2px;
}

.btn-square {
  width: 110px;
  height: 110px;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  padding: 8px 4px;
  font-size: 13px;
  line-height: 1.1;
  border-image: url('Assets/UI/button_grey.png?v=68') 16 fill / 16px stretch;
}

.btn-square .btn-icon {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  flex: none;
}

.btn-square:active {
  border-image: url('Assets/UI/button_grey_close.png?v=68') 16 fill / 16px stretch;
}

/* Adventures gets the red button; the rest stay grey. */
#adv-btn {
  border-image: url('Assets/UI/button_red.png?v=68') 16 fill / 16px stretch;
  color: #ffe6e6;
}

#adv-btn:active {
  border-image: url('Assets/UI/button_red_close.png?v=68') 16 fill / 16px stretch;
}

/* The burrow is locked for now — greyed out until it opens. */
#burrow-btn {
  opacity: 0.45;
  filter: grayscale(0.85);
}

/* Wipe Game Data: smaller red button (Back stays full-size grey). */
.btn-sm {
  padding: 7px 20px;
  font-size: 14px;
  margin-top: 18px;
}

.btn-danger {
  border-image: url('Assets/UI/button_red.png?v=68') 16 fill / 16px stretch;
  color: #ffe6e6;
}

.btn-danger:active {
  border-image: url('Assets/UI/button_red_close.png?v=68') 16 fill / 16px stretch;
}

/* Disabled buttons (e.g. the hamster Select button) fade out. */
.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Select + Back sit side by side under the Unlockables panes. */
.col-footer {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.col-footer .btn {
  margin-top: 0;
}

#wipe-data-btn {
  border-image: url('Assets/UI/button_red.png?v=68') 16 fill / 16px stretch;
  color: #ffe6e6;
}

#wipe-data-btn:active {
  border-image: url('Assets/UI/button_red_close.png?v=68') 16 fill / 16px stretch;
}

.overlay .btn + .btn {
  margin-top: 0;
}

/* ---------------------------- speedometer ------------------------------- */

#speedometer {
  position: absolute;
  top: calc(116px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  height: 12px;
  border: 2px solid rgba(122, 82, 39, 0.8);
  background: rgba(40, 25, 10, 0.45);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#speed-fill {
  height: 100%;
  width: 0%;
  max-width: 100%;
  background: linear-gradient(90deg, #9edb7a, #ffd93d 60%, #ff6b57);
  border-radius: 2px;
  transition: width 0.12s linear;
}

/* Max speed: the gauge glows gold and shows the x1.5 bonus badge. */
#speedometer.max {
  border-color: #ffd93d;
  box-shadow: 0 0 8px rgba(255, 217, 61, 0.8);
}

#speed-max {
  position: absolute;
  top: -16px;
  right: 0;
  display: none;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffd93d;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.9);
  white-space: nowrap;
  animation: maxPulse 0.5s ease-in-out infinite;
}

#speedometer.max #speed-max {
  display: block;
}

@keyframes maxPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

/* --------------------------- rotate overlay ----------------------------- */

#rotate-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: #f6ecd8;
}

#rotate-overlay p {
  font-size: 16px;
  letter-spacing: 1px;
  color: #7a5227;
  font-weight: 700;
}

.rotate-icon {
  width: 64px;
  height: 108px;
  border: 4px solid #e08f2e;
  border-radius: 14px;
  position: relative;
  animation: rotateDevice 2.4s ease-in-out infinite;
}

.rotate-icon::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #e08f2e;
}

@keyframes rotateDevice {
  0%,
  100% {
    transform: rotate(90deg);
  }
  50% {
    transform: rotate(0deg);
  }
}

/* --------------------------- accessibility ------------------------------ */

/* --------------------------- achievements ------------------------------- */

/* Tabs for the collectibles window. */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

/* Second row of tabs (Hamsters / Swag). */
.tab-bar-2 {
  margin-top: -4px;
  margin-bottom: 12px;
}

.tab-btn.locked-tab {
  opacity: 0.35;
  cursor: default;
}

.tab-btn {
  font-family: "Lemon Days", "Comic Sans MS", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: rgba(255, 245, 220, 0.85);
  border: 10px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 10 fill / 10px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  padding: 4px 16px;
  cursor: pointer;
  opacity: 0.6;
}

/* Three tabs fit on phones with smaller buttons. */
@media (max-width: 440px) {
  .tab-bar {
    gap: 5px;
  }

  .tab-btn {
    font-size: 12px;
    padding: 3px 9px;
    border: 8px solid transparent;
    border-image: url('Assets/UI/panel_brown_dark.png?v=68') 8 fill / 8px stretch;
  }

  .tab-btn.active {
    opacity: 1;
  }
}

.tab-btn.active {
  opacity: 1;
  color: #fff;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
}

.tab-pane {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tab-pane.hidden {
  display: none;
}

/* Hammie Farts: selectable dust-trail cards. */
.farts-list {
  width: 100%;
  max-width: 340px;
  max-height: 46vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.fart-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  text-align: left;
  border: 16px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 16 fill / 16px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  cursor: pointer;
  opacity: 0.55;
}

.fart-card.selected {
  opacity: 1;
  border-image: url('Assets/UI/panel_brown.png?v=68') 16 fill / 16px stretch;
  box-shadow: 0 0 10px rgba(255, 217, 61, 0.5);
}

.fart-card.locked {
  cursor: default;
}

.fart-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
}

.fart-card.selected .fart-name {
  color: #ffd93d;
}

/* Companion aura cards show a preview image of the companion. */
.unlock-icon {
  width: 46px;
  height: 46px;
  align-self: center;
  image-rendering: pixelated;
}

.fart-desc {
  font-size: 12px;
  color: rgba(255, 245, 220, 0.75);
}

/* Selected unlockables sit on the light panel — dark brown text. */
.fart-card.selected .fart-desc {
  color: #5b3516;
}

.fart-lock,
.adv-lock {
  font-size: 11px;
  font-weight: 700;
  color: #ffb3a0;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
}

/* Power-up cards: big icon on the left, name + description on the right. */
.power-card {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

/* Unlocked power-ups are full-brightness; only locked ones are dimmed. */
.fart-card.power-card {
  opacity: 1;
}

.fart-card.power-card.locked {
  opacity: 0.55;
}

.power-icon {
  width: 56px;
  height: 56px;
  flex: none;
  image-rendering: pixelated;
}

.power-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.power-info .fart-name {
  font-size: 17px;
}

/* Locked power-ups are dimmed; the card still reads clearly. */
.fart-card.locked .power-icon {
  filter: grayscale(0.9) brightness(0.55);
}

/* The hamster carousel scrolls INSIDE its own pane like the other
   tabs, so the overlay itself never shifts when you touch it. */
#pane-hamster {
  width: 100%;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* The id rule above outranks .tab-pane.hidden — restore hiding. */
#pane-hamster.hidden {
  display: none;
}

/* Hamster carousel: swipe (or arrows) through the roster. */
.hamster-carousel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-bottom: 6px;
}

.hamster-view {
  position: relative;
  flex: none;
  width: min(56vw, 210px);
  height: min(30vh, 210px);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-y;
  cursor: pointer;
}

#hamster-img {
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(90, 60, 25, 0.35));
  user-select: none;
  -webkit-user-drag: none;
}

#hamster-img.dimmed {
  filter: grayscale(0.9) brightness(0.5);
}

#hamster-lock {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  color: #ffb3a0;
  background: rgba(40, 25, 10, 0.85);
  border: 2px solid rgba(255, 107, 107, 0.6);
  border-radius: 8px;
  padding: 4px 10px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

#hamster-lock.hidden {
  display: none;
}

.ham-arrow {
  flex: none;
  width: 40px;
  height: 40px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 50%;
  background: rgba(90, 60, 25, 0.6);
  cursor: pointer;
  line-height: 1;
}

.ham-arrow:active {
  background: rgba(90, 60, 25, 0.85);
}

#hamster-name {
  font-size: 30px;
  font-weight: 700;
  color: #ffd93d;
  -webkit-text-stroke: 1.5px #7a5227;
  text-shadow: 0 2px 0 #7a5227;
  text-align: center;
}

#hamster-stars {
  font-size: 26px;
  letter-spacing: 4px;
  line-height: 1.2;
  filter: drop-shadow(0 2px 2px rgba(40, 25, 10, 0.4));
}

#hamster-xp-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  max-width: 220px;
}

#hamster-xp-wrap.hidden {
  display: none;
}

#hamster-xp-bar {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background: rgba(40, 25, 10, 0.35);
  border: 1px solid rgba(40, 25, 10, 0.4);
  overflow: hidden;
}

#hamster-xp-fill {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, #ffb545, #ffd93d);
  transition: width 0.5s ease-out;
}

#hamster-xp-text {
  font-size: 11px;
  font-weight: 700;
  color: #5b3516;
  font-variant-numeric: tabular-nums;
}

.hamster-section-label {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #7a5227;
}

#hamster-bonuses {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.hamster-bonus {
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.hamster-bonus.unlocked {
  color: #5b3516;
  animation: bonusGlow 1.2s ease-out;
}

.hamster-bonus.locked {
  color: rgba(122, 82, 39, 0.45);
}

@keyframes bonusGlow {
  0% { text-shadow: 0 0 14px rgba(255, 217, 61, 1); }
  100% { text-shadow: 0 0 0 rgba(255, 217, 61, 0); }
}

#hamster-stats {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #5b3516;
  text-shadow: none;
  text-align: center;
}

#hamster-desc {
  margin-top: 4px;
  font-size: 12px;
  max-width: 300px;
  color: #7a5227;
  text-align: center;
}

#hamster-dots {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.ham-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
}

.ham-dot.active {
  background: #ffd93d;
}

/* Adventures: selectable map thumbnails, easy -> hard. */
.adv-grid {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 10px;
}

.adv-card {
  position: relative;
  display: block;
  border: 16px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 16 fill / 16px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.adv-card.selected {
  opacity: 1;
  border-image: url('Assets/UI/panel_brown.png?v=68') 16 fill / 16px stretch;
  box-shadow: 0 0 12px rgba(255, 217, 61, 0.5);
}

.adv-thumb {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
  image-rendering: pixelated;
  border-radius: 2px;
}

.adv-name {
  position: absolute;
  left: 10px;
  top: 8px;
  bottom: auto;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  background: rgba(40, 25, 10, 0.75);
  border: 2px solid rgba(255, 217, 61, 0.6);
  border-radius: 6px;
  padding: 3px 10px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

.adv-card.selected .adv-name {
  border-color: #ffd93d;
  color: #ffd93d;
}

/* Best-score + distance pills, centered at the bottom of the card. */
.adv-best-row {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.adv-best {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  background: rgba(40, 25, 10, 0.75);
  border: 2px solid rgba(255, 217, 61, 0.6);
  border-radius: 6px;
  padding: 3px 10px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

.adv-best b {
  color: #ffd93d;
  font-variant-numeric: tabular-nums;
}

.adv-card.locked {
  opacity: 0.6;
  cursor: default;
}

.adv-card.locked .adv-lock {
  position: absolute;
  left: 10px;
  bottom: 32px;
  font-size: 11px;
  font-weight: 700;
  color: #ffb3a0;
  background: rgba(40, 25, 10, 0.8);
  border: 2px solid rgba(255, 107, 107, 0.6);
  border-radius: 6px;
  padding: 3px 8px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

.adv-hint {
  font-size: 13px;
  color: rgba(122, 82, 39, 0.75);
  margin-bottom: 6px;
}

.ach-list {
  width: 100%;
  max-width: 340px;
  max-height: 46vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.ach-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 16px solid transparent;
  border-image: url('Assets/UI/panel_brown_dark.png?v=68') 16 fill / 16px stretch;
  image-rendering: pixelated;
  background: none;
  border-radius: 0;
  opacity: 0.55;
}

.ach-row.unlocked {
  opacity: 1;
  border-image: url('Assets/UI/panel_brown.png?v=68') 16 fill / 16px stretch;
}

.ach-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
  flex: none;
}

.ach-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.ach-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
}

.ach-row.unlocked .ach-title {
  color: #ffd93d;
}

.ach-desc {
  font-size: 12px;
  color: rgba(255, 245, 220, 0.75);
}

/* Completed achievements sit on a light panel — dark brown text reads
   clearly there. */
.ach-row.unlocked .ach-desc {
  color: #5b3516;
}

.ach-count {
  font-size: 13px;
  font-weight: 700;
  color: #ffd93d;
  text-shadow: 0 1px 0 rgba(40, 25, 10, 0.6);
  margin-bottom: 4px;
}

/* Narrow screens (phones): keep the menu card fully on screen, centred,
   with a clear gap of background all the way around. */
@media (max-width: 440px) {
  .menu-panel {
    border: 24px solid transparent;
    border-image: url('Assets/UI/panel_brown_corners_b.png?v=68') 24 fill / 24px stretch;
    padding: 8px 14px 34px;
    gap: 6px;
    --btn-size: 84px;
    --btn-gap: 7px;
  }

  /* The hanging banner stretches to fit instead of eating fixed borders. */
  .title-banner {
    border: none;
    background: url('Assets/UI/banner_hanging.png?v=68') no-repeat center / 100% 100%;
    padding: 8px 12px 10px;
    margin-top: 20px;
  }

  .title-kicker {
    font-size: 16px;
    letter-spacing: 3px;
    padding-left: 3px;
  }

  .title-main {
    font-size: 40px;
  }

  .tagline {
    font-size: 9px;
    letter-spacing: 2px;
  }

  .menu-adv-pill {
    font-size: 10px;
    padding: 2px 8px;
  }

  #start-btn {
    font-size: 16px;
    padding: 8px 0;
  }

  .btn-square {
    width: 84px;
    height: 84px;
    font-size: 10px;
    padding: 5px 3px;
    gap: 2px;
  }

  .btn-square .btn-icon {
    width: 26px;
    height: 26px;
  }

  .menu-best {
    width: 72px;
    height: 96px;
    top: -64px;
  }

  .menu-best-value {
    font-size: 18px;
  }

  .menu-best-label {
    font-size: 10px;
    letter-spacing: 1px;
  }

  .menu-hint {
    margin-top: 2px;
    font-size: 10px;
  }
}

:focus-visible {
  outline: 3px solid #ffd93d;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .overlay.visible > *,
  .overlay.visible .menu-panel > *,
  .overlay.visible .menu-panel > .menu-hamster,
  .powerup-pill,
  #countdown-num.pop,
  #countdown-num.go,
  #hud-score.pop,
  #new-best,
  .rotate-icon {
    animation: none;
  }

  #countdown-num.pop,
  #countdown-num.go {
    opacity: 1;
  }

  #toast {
    transition: opacity 0.1s ease;
  }
}








