/* ═══ BASE ═══ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0a0a15;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: 'Nunito', sans-serif;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
}
canvas {
  display: block;
  margin: 0 auto;
  touch-action: none;
  position: relative;
}
#loading {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #fff; font-family: 'Nunito', sans-serif; font-size: 24px;
}

/* ═══ OVERLAYS ═══ */
.overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: auto;
}

/* ═══ GLASS CARD ═══ */
.glass-card {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 24px 20px;
}

/* ═══ BUTTONS ═══ */
.btn {
  display: block;
  width: 100%;
  max-width: 240px;
  margin: 0 auto 10px;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.5px;
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  transform: scale(0.96);
}
.btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.2), rgba(255,255,255,0));
  border-radius: 14px 14px 0 0;
  pointer-events: none;
}
.btn-icon {
  margin-right: 6px;
}

/* Button variants */
.btn-primary {
  background: linear-gradient(180deg, #5CB85C 0%, #3D8B3D 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(60, 140, 60, 0.4), inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn-secondary {
  background: linear-gradient(180deg, #AB47BC 0%, #7B1FA2 100%);
  color: #FFD700;
  box-shadow: 0 4px 12px rgba(120, 30, 160, 0.4), inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn-info {
  background: linear-gradient(180deg, #42A5F5 0%, #1E88E5 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(30, 136, 229, 0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn-warning {
  background: linear-gradient(180deg, #FFA726 0%, #EF6C00 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 108, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn-ghost {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: none;
}
.btn-ghost::before { display: none; }
.btn-danger-ghost {
  border-color: rgba(229, 57, 53, 0.4);
  color: #EF5350;
}
.btn-large {
  padding: 16px 24px;
  font-size: 18px;
}
.btn-glow {
  animation: btnGlow 2s ease-in-out infinite;
}
@keyframes btnGlow {
  0%, 100% { box-shadow: 0 4px 12px rgba(60, 140, 60, 0.4), inset 0 1px 0 rgba(255,255,255,0.15); }
  50% { box-shadow: 0 4px 20px rgba(60, 140, 60, 0.6), 0 0 30px rgba(60, 140, 60, 0.2), inset 0 1px 0 rgba(255,255,255,0.15); }
}

/* ═══ MENU ═══ */
#menu-overlay {
  background: #0a0a15;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

/* Animated background scene */
.menu-bg-scene {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  z-index: 0;
  animation: kenBurns 20s ease-in-out infinite alternate;
}
@keyframes kenBurns {
  0% { transform: scale(1.0) translate(0, 0); }
  33% { transform: scale(1.03) translate(-0.5%, 0.3%); }
  66% { transform: scale(1.02) translate(0.5%, -0.2%); }
  100% { transform: scale(1.04) translate(-0.3%, 0.5%); }
}
.menu-bg-image {
  position: absolute;
  top: -3%; left: -3%; right: -3%; bottom: -3%;
  background-image: url('../img/menu-bg.png');
  background-size: cover;
  background-position: center;
  transform-origin: 50% 58%;
  animation: punchRock 4s ease-in-out infinite;
}
@keyframes punchRock {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(0.3deg) scale(1.003); }
  50% { transform: rotate(0deg) scale(1.001); }
  75% { transform: rotate(-0.25deg) scale(1.002); }
}

/* Punch breathing — hidden, using transform-origin on bg instead */
.punch-breathe { display: none; }

/* Fireflies */
.firefly {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: #ffffaa;
  box-shadow: 0 0 8px 3px rgba(255,255,150,0.6), 0 0 20px 6px rgba(255,255,100,0.2);
  animation: fireflyFloat var(--d) ease-in-out infinite alternate;
  animation-delay: var(--delay);
  z-index: 1;
  pointer-events: none;
}
@keyframes fireflyFloat {
  0% { transform: translate(0, 0); opacity: 0.3; }
  25% { opacity: 0.9; }
  50% { transform: translate(15px, -20px); opacity: 0.5; }
  75% { opacity: 1; }
  100% { transform: translate(-10px, 15px); opacity: 0.2; }
}

/* Leaf overlays (dark silhouettes for depth) */
.leaf {
  position: absolute;
  width: 120px;
  height: 120px;
  background: radial-gradient(ellipse at center, rgba(15,40,20,0.9) 0%, rgba(15,40,20,0.4) 50%, transparent 70%);
  pointer-events: none;
  z-index: 2;
}
.leaf-tl {
  top: -10px; left: -20px;
  animation: leafSway 6s ease-in-out infinite alternate;
  transform-origin: top left;
}
.leaf-tr {
  top: -10px; right: -20px;
  animation: leafSway 7s ease-in-out infinite alternate-reverse;
  transform-origin: top right;
}
.leaf-bl {
  bottom: 40px; left: -30px;
  width: 100px; height: 100px;
  animation: leafSway 5.5s ease-in-out infinite alternate;
  transform-origin: bottom left;
  animation-delay: 1s;
}
.leaf-br {
  bottom: 40px; right: -30px;
  width: 100px; height: 100px;
  animation: leafSway 6.5s ease-in-out infinite alternate-reverse;
  transform-origin: bottom right;
  animation-delay: 0.5s;
}
@keyframes leafSway {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(2deg) scale(1.02); }
  100% { transform: rotate(-1.5deg) scale(0.98); }
}
.menu-content {
  width: 100%;
  max-width: 400px;
  padding: 0 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  animation: fadeInUp 0.6s ease-out;
  position: relative;
  z-index: 5;
}
.menu-title-wrap {
  text-align: center;
  margin-top: 16px;
  margin-bottom: 0;
}
.menu-title {
  font-family: 'Fredoka One', cursive;
  font-size: 32px;
  color: #FFD700;
  text-shadow: 0 2px 0 #b8860b, 0 4px 8px rgba(0,0,0,0.7), 0 0 30px rgba(255,215,0,0.25);
  line-height: 1.05;
  margin-bottom: 4px;
  -webkit-text-stroke: 1px rgba(139,69,19,0.5);
}
.title-accent {
  color: #FF8C00;
  font-size: 44px;
  text-shadow: 0 3px 0 #8B4513, 0 5px 10px rgba(0,0,0,0.7), 0 0 40px rgba(255,140,0,0.3);
  display: block;
}
.menu-subtitle {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.menu-buttons {
  width: 100%;
  max-width: 280px;
  margin-top: auto;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.menu-buttons .btn-row {
  display: flex;
  gap: 10px;
}
.menu-buttons .btn-row .btn {
  flex: 1;
  margin: 0;
}
.best-score {
  text-align: center;
  color: #FFD700;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 20px;
  background: linear-gradient(180deg, #6B4226 0%, #4A2C17 50%, #6B4226 100%);
  border-radius: 10px;
  border: 2px solid #8B5E3C;
  box-shadow: 0 3px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* Wooden button style (Story Mode) */
.btn-wood {
  background: linear-gradient(180deg, #D4A056 0%, #B8782C 30%, #A0601A 70%, #C49040 100%);
  color: #4A2000;
  border: 2px solid #8B5A2B;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -2px 0 rgba(0,0,0,0.15);
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  font-size: 15px;
}
.btn-wood::before {
  background: linear-gradient(to bottom, rgba(255,255,255,0.25), rgba(255,255,255,0));
}

/* Metallic button style (Endless Mode) */
.btn-metal {
  background: linear-gradient(180deg, #8A8A8A 0%, #5A5A5A 30%, #404040 70%, #7A7A7A 100%);
  color: #fff;
  border: 2px solid #666;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -2px 0 rgba(0,0,0,0.2);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  font-size: 15px;
}

/* Controls button (small, round) */
.btn-controls {
  width: 44px;
  height: 44px;
  max-width: 44px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #6B4226 0%, #4A2C17 100%);
  border: 2px solid #8B5E3C;
  color: #FFD700;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 3px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
  margin: 0;
  flex: none;
}

/* Controls panel (hidden by default, toggled by ? button) */
.menu-controls {
  display: none;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 14px;
  padding: 14px 18px;
  width: 100%;
  max-width: 280px;
  margin-bottom: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  animation: fadeInScale 0.2s ease-out;
}
.menu-controls.visible { display: block; }
.control-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  justify-content: center;
}
.control-row:last-child { margin-bottom: 0; }
kbd {
  display: inline-block;
  padding: 3px 8px;
  font-family: 'Nunito', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  min-width: 28px;
  text-align: center;
}
.control-label {
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}
.menu-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 320px;
  padding-bottom: 8px;
  font-size: 10px;
  color: rgba(255,255,255,0.3);
}
.footer-landing-link {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 11px;
}
.footer-landing-link:hover {
  color: rgba(255,255,255,0.8);
}

/* ═══ GAMEPLAY HUD — Premium Mobile Game Style ═══ */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  pointer-events: none;
  z-index: 10;
  padding: 8px;
  font-family: 'Nunito', sans-serif;
}
#hud * { pointer-events: auto; }
.hud-left {
  position: absolute;
  top: 10px; left: 10px;
}
.hud-right {
  position: absolute;
  top: 8px; right: 8px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* ─── Comfort bar (premium wooden frame) ─── */
.hud-comfort-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: linear-gradient(180deg, #5C3A1E 0%, #3D2510 50%, #5C3A1E 100%);
  border: 2px solid #8B6914;
  border-radius: 14px;
  padding: 3px 4px 3px 2px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,220,130,0.15), 0 0 12px rgba(139,105,20,0.2);
  position: relative;
}
.hud-comfort-icon {
  font-size: 16px;
  margin: 0 3px 0 4px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  flex-shrink: 0;
  line-height: 1;
}
.hud-sprite-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  vertical-align: middle;
  margin: 0 2px;
}
.hud-comfort-track {
  width: 140px;
  height: 22px;
  background: rgba(0,0,0,0.55);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(139,105,20,0.3);
}
.hud-comfort-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.3s ease, background 0.3s ease;
  position: relative;
}
.hud-comfort-fill::after {
  content: '';
  position: absolute;
  top: 2px; left: 4px; right: 4px;
  height: 38%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.3), rgba(255,255,255,0));
  border-radius: 6px;
}
.hud-comfort-fill.high { background: linear-gradient(90deg, #43A047, #7BC67E); }
.hud-comfort-fill.mid { background: linear-gradient(90deg, #EF6C00, #FFB74D); }
.hud-comfort-fill.low { background: linear-gradient(90deg, #C62828, #EF5350); }
.hud-comfort-fill.low-pulse { animation: comfortPulse 0.8s ease-in-out infinite; }
@keyframes comfortPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255,50,50,0.3); }
  50% { box-shadow: 0 0 18px rgba(255,50,50,0.7); }
}
.hud-comfort-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8), 0 0 6px rgba(0,0,0,0.3);
  letter-spacing: 0.5px;
}

/* ─── Stats panel (golden warm tones) ─── */
.hud-panel {
  background: rgba(15,10,5,0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid #8B6914;
  border-radius: 12px;
  padding: 7px 14px 8px;
  min-width: 130px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,220,130,0.1), 0 0 12px rgba(139,105,20,0.15);
}
.hud-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.hud-name {
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  color: #FFD700;
  text-shadow: 0 1px 0 #8B6914, 0 2px 6px rgba(0,0,0,0.6);
  letter-spacing: 1px;
}
.hud-dist {
  font-size: 12px;
  font-weight: 800;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.hud-stats-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.hud-stat-icon {
  font-size: 13px;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4));
}
.hud-stat {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.hud-stat-sep {
  font-size: 11px;
  color: rgba(139,105,20,0.5);
  margin: 0 2px;
}
.hud-orange { color: #FFD080; }
.hud-pink { color: #FF8CB0; }
.hud-friends-row, .hud-shield-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Shield bar row */
.hud-shield-bar-row {
  margin-top: 4px;
}
.hud-shield-bar {
  width: 100%;
  height: 6px;
  background: rgba(0,0,0,0.4);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(139,105,20,0.2);
}
.hud-shield-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
  background: linear-gradient(90deg, #43A047, #66BB6A);
}

/* ─── Right-side buttons column ─── */
.hud-right-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* Pause button (circular, premium frame) */
.hud-pause-btn {
  width: 40px;
  height: 40px;
  background: linear-gradient(180deg, rgba(30,20,10,0.8) 0%, rgba(15,10,5,0.9) 100%);
  border: 2px solid #8B6914;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,220,130,0.15), 0 0 8px rgba(139,105,20,0.2);
  transition: transform 0.15s, box-shadow 0.15s;
}
.hud-pause-btn:active {
  transform: scale(0.92);
}
.hud-pause-btn .pause-bar {
  width: 4px;
  height: 16px;
  background: linear-gradient(180deg, #FFD700, #DAA520);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Speed button (gold badge) */
.hud-speed-btn {
  width: 36px;
  height: 22px;
  background: linear-gradient(180deg, rgba(30,20,10,0.75) 0%, rgba(15,10,5,0.85) 100%);
  border: 2px solid #8B6914;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,220,130,0.1);
  transition: transform 0.15s;
}
.hud-speed-btn:active {
  transform: scale(0.92);
}
.hud-speed-btn span {
  font-size: 11px;
  font-weight: 900;
  color: #DAA520;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Zone pill */
.hud-zone-pill {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,10,5,0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1.5px solid rgba(139,105,20,0.35);
  padding: 5px 16px;
  border-radius: 14px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,220,150,0.7);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ═══ PREMIUM CARD (shared glassmorphism) ═══ */
.premium-card {
  background: rgba(10, 10, 25, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 24px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
}

/* ═══ PAUSE ═══ */
#pause-overlay {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.pause-content {
  width: 85%;
  max-width: 300px;
  text-align: center;
  animation: fadeInScale 0.25s ease-out;
}
.pause-icon {
  font-size: 36px;
  margin-bottom: 4px;
  opacity: 0.7;
  filter: grayscale(1) brightness(2);
}
.pause-title {
  font-family: 'Fredoka One', cursive;
  font-size: 28px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  margin-bottom: 12px;
}
.pause-stats {
  color: rgba(255,255,255,0.65);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 16px;
  line-height: 1.8;
}
.pause-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.pause-hint {
  color: rgba(255,255,255,0.3);
  font-size: 11px;
  animation: pulse 2s ease-in-out infinite;
}

/* ═══ GAME OVER ═══ */
#gameover-overlay {
  background: rgba(0,0,0,0.85);
}
.go-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(180,0,0,0.25) 70%, rgba(100,0,0,0.5) 100%);
  pointer-events: none;
  z-index: 1;
}
.go-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}
.go-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(255,80,80,0.6);
  border-radius: 50%;
  animation: particleFall linear infinite;
}
@keyframes particleFall {
  0% { transform: translateY(-10px) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 0.6; }
  100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}
.gameover-content {
  width: 90%;
  max-width: 340px;
  text-align: center;
  animation: fadeInUp 0.5s ease-out;
  position: relative;
  z-index: 3;
}
.gameover-title {
  font-family: 'Fredoka One', cursive;
  font-size: 38px;
  color: #FF4444;
  text-shadow: 0 0 40px rgba(255,68,68,0.6), 0 0 80px rgba(255,0,0,0.3), 0 2px 4px rgba(0,0,0,0.8);
  margin-bottom: 6px;
  animation: goTitlePulse 3s ease-in-out infinite;
}
@keyframes goTitlePulse {
  0%, 100% { text-shadow: 0 0 40px rgba(255,68,68,0.6), 0 0 80px rgba(255,0,0,0.3), 0 2px 4px rgba(0,0,0,0.8); }
  50% { text-shadow: 0 0 60px rgba(255,68,68,0.8), 0 0 100px rgba(255,0,0,0.4), 0 2px 4px rgba(0,0,0,0.8); }
}
.gameover-subtitle {
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}
.gameover-encourage {
  color: rgba(255,180,130,0.65);
  font-size: 12px;
  font-style: italic;
  margin-bottom: 12px;
}
.go-story-line {
  color: rgba(255,220,180,0.55);
  font-size: 11px;
  font-style: italic;
  margin: 8px 0 4px;
  line-height: 1.3;
}

/* Score display (shared) */
.score-display {
  margin: 12px 0;
}
.score-number {
  font-family: 'Fredoka One', cursive;
  font-size: 52px;
  color: #FFD700;
  text-shadow: 0 0 20px rgba(255,215,0,0.4), 0 0 40px rgba(255,215,0,0.15), 0 2px 4px rgba(0,0,0,0.5);
  line-height: 1;
  animation: scoreGlow 2s ease-in-out infinite;
}
.score-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  letter-spacing: 3px;
  margin-top: 2px;
}
.new-best {
  color: #FF6B9D;
  font-size: 13px;
  font-weight: 800;
  margin-top: 4px;
  animation: pulse 1s ease-in-out infinite;
  text-shadow: 0 0 15px rgba(255,107,157,0.5);
}
@keyframes scoreGlow {
  0%, 100% { text-shadow: 0 0 20px rgba(255,215,0,0.4), 0 0 40px rgba(255,215,0,0.15), 0 2px 4px rgba(0,0,0,0.5); }
  50% { text-shadow: 0 0 35px rgba(255,215,0,0.7), 0 0 60px rgba(255,215,0,0.3), 0 2px 4px rgba(0,0,0,0.5); }
}

/* Stats row */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 0;
  margin: 12px 0;
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px 0;
}
.stat-item {
  flex: 1;
  text-align: center;
  position: relative;
}
.stat-item:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0; top: 4px; bottom: 4px;
  width: 1px;
  background: rgba(255,255,255,0.1);
}
.stat-value {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}
.stat-value.orange { color: #FFB347; }
.stat-value.pink { color: #FF6B9D; }
.stat-label {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  letter-spacing: 1px;
  margin-top: 2px;
}

.gameover-buttons, .victory-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

/* ═══ VICTORY ═══ */
#victory-overlay {
  background: rgba(10,5,0,0.85);
}
.vic-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(255,215,0,0.15) 0%, rgba(255,180,0,0.08) 40%, transparent 70%);
  pointer-events: none;
  z-index: 1;
  animation: vicGlowPulse 3s ease-in-out infinite;
}
@keyframes vicGlowPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
.vic-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 6px;
  height: 6px;
  opacity: 0.8;
  animation: confettiFall linear infinite;
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg) scale(1); opacity: 0; }
  10% { opacity: 0.9; }
  50% { transform: translateY(50vh) rotate(360deg) scale(0.8); }
  100% { transform: translateY(100vh) rotate(720deg) scale(0.5); opacity: 0; }
}
.victory-content {
  width: 90%;
  max-width: 340px;
  text-align: center;
  animation: fadeInUp 0.5s ease-out;
  position: relative;
  z-index: 3;
}
.victory-title {
  font-family: 'Fredoka One', cursive;
  font-size: 40px;
  color: #FFD700;
  text-shadow: 0 0 40px rgba(255,215,0,0.7), 0 0 80px rgba(255,180,0,0.3), 0 3px 0 #b8860b, 0 4px 8px rgba(0,0,0,0.7);
  margin-bottom: 4px;
  animation: vicTitleShine 3s ease-in-out infinite;
}
@keyframes vicTitleShine {
  0%, 100% { text-shadow: 0 0 40px rgba(255,215,0,0.7), 0 0 80px rgba(255,180,0,0.3), 0 3px 0 #b8860b, 0 4px 8px rgba(0,0,0,0.7); }
  50% { text-shadow: 0 0 60px rgba(255,215,0,1), 0 0 100px rgba(255,180,0,0.5), 0 3px 0 #b8860b, 0 4px 8px rgba(0,0,0,0.7); }
}
.victory-subtitle {
  color: rgba(255,255,255,0.8);
  font-size: 13px;
  font-weight: 600;
}
.victory-quote {
  color: rgba(255,220,150,0.55);
  font-size: 11px;
  font-style: italic;
  margin: 4px 0 4px;
}
.victory-story-line {
  color: rgba(255,220,180,0.5);
  font-size: 10px;
  font-style: italic;
  margin: 0 0 8px;
  line-height: 1.3;
}
.victory-rating-wrap {
  margin: 8px 0;
}
.victory-rating {
  font-family: 'Fredoka One', cursive;
  font-size: 72px;
  line-height: 1;
  text-shadow: 0 0 30px currentColor, 0 0 60px currentColor, 0 2px 4px rgba(0,0,0,0.5);
  animation: ratingPulse 2s ease-in-out infinite;
}
@keyframes ratingPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.victory-rating.S { color: #FFD700; }
.victory-rating.A { color: #4CAF50; }
.victory-rating.B { color: #42A5F5; }
.victory-rating.C { color: #FF9800; }
.rating-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  letter-spacing: 2px;
}

/* ═══ ACCENT BUTTON (clean gradient, primary action) ═══ */
.btn-accent {
  background: linear-gradient(180deg, #5CB85C 0%, #449D44 50%, #398439 100%);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.25);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  font-size: 15px;
  font-weight: 700;
}
.btn-accent::before {
  background: linear-gradient(to bottom, rgba(255,255,255,0.2), rgba(255,255,255,0));
}

/* ═══ OUTLINE BUTTON (secondary action) ═══ */
.btn-outline {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  border: 2px solid rgba(255,255,255,0.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.btn-outline::before {
  background: none;
}

/* ═══ GOLDEN BUTTON (Victory) ═══ */
.btn-gold {
  background: linear-gradient(180deg, #FFD700 0%, #DAA520 30%, #B8860B 70%, #DAA520 100%);
  color: #4A2000;
  border: 2px solid #B8860B;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5), 0 0 20px rgba(255,215,0,0.2), inset 0 1px 0 rgba(255,255,255,0.4), inset 0 -2px 0 rgba(0,0,0,0.15);
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  font-size: 15px;
  font-weight: 800;
}
.btn-gold::before {
  background: linear-gradient(to bottom, rgba(255,255,255,0.35), rgba(255,255,255,0));
}

/* ═══ REVIVE PROMPT ═══ */
#revive-overlay {
  background: rgba(0,0,0,0.85);
}
.revive-content {
  width: 90%;
  max-width: 320px;
  text-align: center;
  animation: fadeInScale 0.35s ease-out;
  position: relative;
  z-index: 3;
}
.revive-icon {
  font-size: 48px;
  margin-bottom: 8px;
  animation: reviveBounce 1.5s ease-in-out infinite;
}
@keyframes reviveBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.08); }
}
.revive-title {
  font-family: 'Fredoka One', cursive;
  font-size: 28px;
  color: #FFA726;
  text-shadow: 0 0 20px rgba(255,167,38,0.5), 0 2px 4px rgba(0,0,0,0.6);
  margin-bottom: 6px;
}
.revive-subtitle {
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.4;
}
.revive-reward {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,215,0,0.1);
  border: 1px solid rgba(255,215,0,0.2);
  border-radius: 10px;
  padding: 8px 16px;
  margin-bottom: 14px;
}
.revive-reward-icon {
  font-size: 20px;
}
.revive-reward-text {
  font-size: 13px;
  font-weight: 700;
  color: #FFD700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.revive-cooldown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 6px 14px;
  margin-bottom: 12px;
}
.revive-cooldown-icon {
  font-size: 16px;
}
.revive-cooldown-text {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
}
.revive-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

/* Orange glow for Watch Ad button */
.btn-glow-orange {
  animation: btnGlowOrange 2s ease-in-out infinite;
}
@keyframes btnGlowOrange {
  0%, 100% { box-shadow: 0 4px 12px rgba(239, 108, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.15); }
  50% { box-shadow: 0 4px 20px rgba(239, 108, 0, 0.6), 0 0 30px rgba(255, 152, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.15); }
}

/* ═══ ZONE TRANSITION OVERLAY ═══ */
#zone-transition-overlay {
  background: rgba(0, 0, 0, 0.8);
}
.zone-transition-content {
  width: 90%;
  max-width: 340px;
  text-align: center;
  animation: fadeInScale 0.4s ease-out;
  position: relative;
  z-index: 3;
}
.zt-cleared {
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  color: #FFD700;
  text-shadow: 0 0 12px rgba(255,215,0,0.4), 0 2px 4px rgba(0,0,0,0.5);
  margin-bottom: 18px;
  animation: fadeInUp 0.5s ease-out 0.2s both;
}
.zt-check {
  color: #66BB6A;
  font-size: 18px;
}
.zt-zone-number {
  font-family: 'Fredoka One', cursive;
  font-size: 36px;
  color: #fff;
  text-shadow: 0 0 20px rgba(255,255,255,0.3), 0 2px 6px rgba(0,0,0,0.6);
  margin-bottom: 4px;
  animation: fadeInUp 0.5s ease-out 0.35s both;
}
.zt-zone-name {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  text-shadow: 0 0 16px currentColor, 0 2px 4px rgba(0,0,0,0.5);
  margin-bottom: 20px;
  animation: fadeInUp 0.5s ease-out 0.5s both;
}
.zt-narrative {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  line-height: 1.6;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  margin-bottom: 24px;
  animation: fadeInUp 0.5s ease-out 0.7s both;
}
.zt-narrative .zt-line {
  display: block;
  margin-bottom: 4px;
}
.zt-narrative .zt-line.zt-quote {
  font-style: italic;
  color: rgba(255,220,150,0.9);
}
.zt-continue {
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  color: rgba(255,255,255,0.7);
  animation: pulseFade 1.5s ease-in-out infinite;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulseFade {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ═══ AD PLAYING OVERLAY (test mode) ═══ */
.ad-playing-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0,0,0,0.95) !important;
  z-index: 9999 !important;
}
.ad-playing-content {
  text-align: center;
  animation: fadeInScale 0.2s ease-out;
}
.ad-playing-icon {
  font-size: 56px;
  margin-bottom: 12px;
  animation: adPulse 1.5s ease-in-out infinite;
}
@keyframes adPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
}
.ad-playing-text {
  font-family: 'Fredoka One', cursive;
  font-size: 24px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  margin-bottom: 16px;
}
.ad-countdown {
  font-family: 'Fredoka One', cursive;
  font-size: 64px;
  color: #FFA726;
  text-shadow: 0 0 30px rgba(255,167,38,0.6), 0 2px 4px rgba(0,0,0,0.5);
  line-height: 1;
  margin-bottom: 12px;
  animation: countdownPop 1s ease-in-out infinite;
}
@keyframes countdownPop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.ad-playing-hint {
  color: rgba(255,255,255,0.3);
  font-size: 11px;
  font-weight: 600;
}

/* ═══ TUTORIAL OVERLAY ═══ */
#tutorial-overlay {
  background: rgba(0, 0, 0, 0.92);
}
.tutorial-content {
  width: 90%;
  max-width: 320px;
  text-align: center;
  animation: fadeInScale 0.4s ease-out;
  position: relative;
  z-index: 3;
  padding: 20px 18px 16px;
  max-height: 90%;
  overflow-y: auto;
  scrollbar-width: none;
}
.tutorial-content::-webkit-scrollbar { display: none; }
.tutorial-story {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  font-style: italic;
  color: #FFD080;
  line-height: 1.5;
  margin-bottom: 16px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  animation: fadeInUp 0.5s ease-out 0.1s both;
}
.tutorial-section {
  margin-bottom: 12px;
  animation: fadeInUp 0.5s ease-out both;
}
.tutorial-danger { animation-delay: 0.2s; }
.tutorial-friends { animation-delay: 0.4s; }
.tutorial-section-title {
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  letter-spacing: 2px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tutorial-section-icon {
  font-size: 16px;
}
.tutorial-danger .tutorial-section-title {
  color: #FF6B6B;
  text-shadow: 0 0 12px rgba(255,107,107,0.4), 0 1px 3px rgba(0,0,0,0.5);
}
.tutorial-friends .tutorial-section-title {
  color: #66BB6A;
  text-shadow: 0 0 12px rgba(102,187,106,0.4), 0 1px 3px rgba(0,0,0,0.5);
}
.tutorial-entity {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  margin-bottom: 4px;
  transition: background 0.2s;
}
.tutorial-entity-danger {
  background: rgba(255,60,60,0.08);
  border: 1px solid rgba(255,60,60,0.12);
}
.tutorial-entity-friend {
  background: rgba(60,200,60,0.08);
  border: 1px solid rgba(60,200,60,0.12);
}
.tutorial-entity-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
}
.tutorial-entity-icon-wrap canvas {
  width: 60px;
  height: 60px;
}
.tutorial-icon-danger {
  background: rgba(255,60,60,0.15);
  box-shadow: 0 0 8px rgba(255,60,60,0.15);
}
.tutorial-icon-friend {
  background: rgba(60,200,60,0.15);
  box-shadow: 0 0 8px rgba(60,200,60,0.15);
}
.tutorial-entity-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.tutorial-entity-name {
  font-family: 'Fredoka One', cursive;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.tutorial-entity-action {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.55);
}
.tutorial-entity-danger .tutorial-entity-action {
  color: rgba(255,180,150,0.7);
}
.tutorial-entity-friend .tutorial-entity-action {
  color: rgba(150,230,150,0.7);
}
.tutorial-hint {
  font-family: 'Fredoka One', cursive;
  font-size: 13px;
  color: #FFD700;
  text-shadow: 0 0 10px rgba(255,215,0,0.3), 0 1px 3px rgba(0,0,0,0.5);
  margin-bottom: 14px;
  animation: fadeInUp 0.5s ease-out 0.6s both;
}
#btn-tutorial-start {
  animation: fadeInUp 0.5s ease-out 0.7s both;
  margin-bottom: 10px;
}
/* Tutorial checkbox */
.tutorial-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  animation: fadeInUp 0.5s ease-out 0.8s both;
  -webkit-tap-highlight-color: transparent;
}
.tutorial-checkbox-input {
  display: none;
}
.tutorial-checkbox-mark {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.tutorial-checkbox-input:checked + .tutorial-checkbox-mark {
  background: rgba(102,187,106,0.3);
  border-color: #66BB6A;
}
.tutorial-checkbox-input:checked + .tutorial-checkbox-mark::after {
  content: '✓';
  color: #66BB6A;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}
.tutorial-checkbox-text {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
}

/* ═══ ANIMATIONS ═══ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ═══ KO-FI BUTTON ═══ */
.kofi-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: linear-gradient(180deg, #FFE066 0%, #FFD700 40%, #E8B800 100%);
  border: 2px solid #B8860B;
  border-radius: 50px;
  color: #4A2000;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 3px 10px rgba(184, 134, 11, 0.4), inset 0 1px 0 rgba(255,255,255,0.4);
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 10;
}
.kofi-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 5px 18px rgba(184, 134, 11, 0.5), 0 0 20px rgba(255, 215, 0, 0.2), inset 0 1px 0 rgba(255,255,255,0.4);
}
.kofi-btn:active {
  transform: scale(0.97);
}
.kofi-emoji {
  font-size: 16px;
  animation: kofiWiggle 2.5s ease-in-out infinite;
}
@keyframes kofiWiggle {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(-12deg); }
  30% { transform: rotate(10deg); }
  45% { transform: rotate(-6deg); }
  55% { transform: rotate(0deg); }
}

/* Menu-specific: positioned between buttons and footer */
.kofi-btn-menu {
  margin-bottom: 10px;
  font-size: 12px;
  padding: 7px 16px;
  opacity: 0.85;
}
.kofi-btn-menu:hover {
  opacity: 1;
}

/* Game over / Victory overlay: subtle at bottom */
.kofi-btn-overlay {
  margin-top: 12px;
  font-size: 11px;
  padding: 6px 14px;
  opacity: 0.7;
  background: linear-gradient(180deg, rgba(255,224,102,0.9) 0%, rgba(255,215,0,0.9) 40%, rgba(232,184,0,0.9) 100%);
}
.kofi-btn-overlay:hover {
  opacity: 1;
}

/* Real story link */
.real-story-link {
  display: inline-block;
  margin-top: 8px;
  color: rgba(255,255,255,0.45);
  font-size: 10px;
  text-decoration: none;
  transition: color 0.2s;
}
.real-story-link:hover {
  color: rgba(255,255,255,0.8);
}
