:root {
  --bg: #181018;
  --panel: rgba(24, 17, 28, 0.92);
  --panel-2: rgba(38, 29, 44, 0.94);
  --text: #fde68a;
  --muted: #fbbf24;
  --accent: #f59e0b;
  --good: #5eead4;
  --bad: #f87171;
  --border: #fbbf24;
  --gold: #fcd34d;
  --gold-dark: #b45309;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Press Start 2P", "Courier New", monospace;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, #30223c 0%, #100c1a 28%, #05030a 100%);
  overflow: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 8% 14%, rgba(255,255,255,0.9), transparent 40%),
    radial-gradient(1px 1px at 25% 32%, rgba(255,255,255,0.7), transparent 40%),
    radial-gradient(1px 1px at 45% 60%, rgba(255,255,255,0.65), transparent 40%),
    radial-gradient(1px 1px at 76% 20%, rgba(255,255,255,0.85), transparent 40%),
    radial-gradient(1px 1px at 80% 78%, rgba(255,255,255,0.6), transparent 40%);
  background-repeat: no-repeat;
  mix-blend-mode: screen;
  opacity: 0.75;
}

#map { z-index: 0; }
#map > gmp-map-3d { z-index: 0; }

.start-banner { z-index: 15; }
.hud { z-index: 16; }

.entry-gate {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.entry-loading {
  opacity: 1;
  transform: translateY(0);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #f4e4ab;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.entry-loading-dots::after {
  content: "";
  display: inline-block;
  width: 1.8em;
  text-align: left;
  animation: loadingDots 1.2s steps(4, end) infinite;
}

@keyframes loadingDots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
  100% { content: ""; }
}

.entry-start-btn {
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  margin-top: -20px;
  border: 2px solid var(--gold);
  background: linear-gradient(145deg, rgba(252, 211, 77, 0.62), rgba(245, 158, 11, 0.62));
  color: #3f2a00;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  width: auto;
  min-width: 120px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 4px 0 #b45309, 0 10px 18px rgba(0, 0, 0, 0.4);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.entry-gate.ready {
  pointer-events: auto;
}

.entry-gate.ready .entry-loading {
  opacity: 0;
  transform: translateY(-4px);
}

.entry-gate.ready .entry-start-btn {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
}

.entry-gate.hide {
  opacity: 0;
  transition: opacity 0.35s ease;
}

#map {
  position: fixed;
  inset: 0;
}

#map > gmp-map-3d {
  width: 100%;
  height: 100%;
  display: block;
}

.start-banner {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.08);
  backdrop-filter: none;
  border: none;
  box-shadow: none;
}

.start-banner.show {
  display: flex;
  animation: bannerFadeIn 0.7s ease;
}

.start-banner.show .start-home-logo {
  animation: logoPulse 4.8s ease-in-out infinite, menuLogoFadeIn 0.75s ease forwards;
}

.start-banner.show .start-home-subtitle {
  opacity: 0;
  animation: menuItemFadeIn 0.7s ease 0.12s forwards;
}

.start-banner.show .start-home-buttons {
  opacity: 0;
  animation: menuItemFadeIn 0.7s ease 0.22s forwards;
}

.start-banner.hide {
  animation: bannerFadeOut 0.45s ease forwards;
}

.start-banner-inner {
  text-align: center;
  padding: 20px 16px;
  max-width: min(860px, calc(100vw - 40px));
  border: none;
  background: rgba(0, 0, 0, 0.00);
  box-shadow: none;
}

.start-home-title {
  font-size: clamp(48px, 8vw, 92px);
  font-weight: 900;
  color: #ffeb6d;
  letter-spacing: 0.14em;
  text-shadow: 0 0 10px rgba(252, 211, 77, 0.95), 0 0 24px rgba(239, 115, 28, 0.7);
  margin-bottom: 12px;
}

.start-home-logo {
  display: block;
  width: min(92vw, 1180px);
  max-height: 46vh;
  object-fit: contain;
  margin: 0 auto 12px;
  transform: translateX(calc(clamp(-140px, -12vw, -90px) - 34px));
  filter: drop-shadow(0 0 10px rgba(252, 211, 77, 0.7)) drop-shadow(0 0 26px rgba(239, 115, 28, 0.4));
  animation: logoPulse 4.8s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% {
    transform: translateX(calc(clamp(-140px, -12vw, -90px) - 34px)) scale(1);
    filter: drop-shadow(0 0 10px rgba(252, 211, 77, 0.68)) drop-shadow(0 0 26px rgba(239, 115, 28, 0.38));
  }
  50% {
    transform: translateX(calc(clamp(-140px, -12vw, -90px) - 34px)) scale(1.025);
    filter: drop-shadow(0 0 14px rgba(252, 211, 77, 0.82)) drop-shadow(0 0 32px rgba(239, 115, 28, 0.55));
  }
}

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

@keyframes menuLogoFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.start-home-subtitle {
  font-size: clamp(15px, 2vw, 18px);
  color: #f4e4ab;
  margin-bottom: 20px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.based-on-tag {
  position: fixed;
  left: -42px;
  bottom: 40px;
  width: 220px;
  text-align: center;
  z-index: 2;
  pointer-events: none;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #f4e4ab;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.55);
  opacity: 0;
}

.start-home-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 280px;
  margin: 0 auto;
}

.start-home-buttons button {
  flex: 1;
  min-width: 80px;
  min-height: 40px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  border-radius: 6px;
  border: 2px solid rgba(255, 222, 122, 0.8);
  box-shadow: 0 3px 0 #b45309, 0 6px 10px rgba(0,0,0,0.3);
  background: linear-gradient(145deg, rgba(255, 217, 97, 0.88), rgba(240, 155, 24, 0.92));
  padding: 6px 12px;
}

.start-kicker,
.start-title,
.start-subtitle {
  display: none;
}

.start-subtitle {
  max-width: 760px;
  margin: 0 auto;
  font-size: clamp(14px, 2vw, 18px);
  line-height: 1.55;
  color: #dbeafe;
  text-shadow: 0 0 16px rgba(15, 23, 42, 0.45);
}

.hud {
  position: fixed;
  z-index: 10;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  backdrop-filter: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  transition: box-shadow 1s ease;
}

.hud.flash-good {
  box-shadow:
    inset 0 0 0 4px rgba(34, 197, 94, 0.95),
    inset 0 0 28px rgba(34, 197, 94, 0.28),
    inset 0 0 60px rgba(34, 197, 94, 0.14),
    0 0 18px rgba(34, 197, 94, 0.55),
    0 0 42px rgba(34, 197, 94, 0.42),
    0 0 82px rgba(74, 222, 128, 0.25);
}

.hud.flash-bad {
  box-shadow:
    inset 0 0 0 4px rgba(239, 68, 68, 0.95),
    inset 0 0 28px rgba(239, 68, 68, 0.28),
    inset 0 0 60px rgba(239, 68, 68, 0.14),
    0 0 18px rgba(239, 68, 68, 0.55),
    0 0 42px rgba(239, 68, 68, 0.42),
    0 0 82px rgba(251, 113, 133, 0.25);
}

.hud.flash-good.flash-good-out {
  box-shadow:
    inset 0 0 0 4px rgba(34, 197, 94, 0),
    inset 0 0 28px rgba(34, 197, 94, 0),
    inset 0 0 60px rgba(34, 197, 94, 0),
    0 0 18px rgba(34, 197, 94, 0),
    0 0 42px rgba(34, 197, 94, 0),
    0 0 82px rgba(74, 222, 128, 0);
}

.hud.flash-bad.flash-bad-out {
  box-shadow:
    inset 0 0 0 4px rgba(239, 68, 68, 0),
    inset 0 0 28px rgba(239, 68, 68, 0),
    inset 0 0 60px rgba(239, 68, 68, 0),
    0 0 18px rgba(239, 68, 68, 0),
    0 0 42px rgba(239, 68, 68, 0),
    0 0 82px rgba(251, 113, 133, 0);
}

.hud > * {
  pointer-events: auto;
}

.hud-top {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-bottom {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(460px, calc(100vw - 28px));
}

.hud-bottom .field {
  width: 100%;
}

.hud-bottom .row {
  width: 100%;
  display: flex;
  gap: 8px;
}

.hud-bottom button {
  flex: 1;
}

.chip.study-reveal-panel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(145deg, rgba(16, 10, 25, 0.9), rgba(32, 18, 48, 0.9));
  border: 2px solid #f59e0b;
  border-radius: 999px;
  box-shadow: 0 4px 0 #8b4513, 0 8px 14px rgba(0, 0, 0, 0.4);
}

.study-reveal-panel button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 148px;
  width: auto;
  padding: 8px 12px;
  font-size: 10px;
  line-height: 1.15;
  text-align: center;
  border: 3px solid #f59e0b;
  background: linear-gradient(145deg, rgba(20, 13, 35, 0.98), rgba(42, 30, 70, 0.98));
  color: #fffbde;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
  box-shadow: 0 4px 0 #8b4513, 0 10px 18px rgba(0, 0, 0, 0.55);
}

.study-reveal-panel button:hover {
  opacity: 1;
}

.study-reveal-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  color: #fff6d6;
  text-transform: uppercase;
  text-shadow: 0 0 3px rgba(255, 228, 160, 0.28), 0 0 1px rgba(0, 0, 0, 0.7);
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(252, 211, 77, 0.22);
  border-radius: 999px;
  padding: 3px 12px;
}

.study-reveal-text-inner {
  display: inline-block;
  transform: translateY(2px);
}

.study-options {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.study-option-btn {
  width: 100%;
  min-height: 46px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.study-option-btn:disabled {
  opacity: 1;
}

.study-option-btn.study-option-correct {
  background: linear-gradient(145deg, #22c55e, #15803d);
  border-color: #166534;
  color: #f0fdf4;
  box-shadow: 0 4px 0 #14532d, 0 10px 16px rgba(0, 0, 0, 0.45);
}

.study-option-btn.study-option-wrong {
  background: linear-gradient(145deg, #fb7185, #dc2626);
  border-color: #b91c1c;
  color: #fff1f2;
  box-shadow: 0 4px 0 #991b1b, 0 10px 16px rgba(0, 0, 0, 0.45);
}

.study-next-btn,
.study-next-btn.secondary {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 220;
  width: min(320px, calc(100vw - 36px));
  min-height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 3px solid #facc15;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(252, 211, 77, 0.9), rgba(245, 158, 11, 0.9));
  color: #2f1f00;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.45);
  box-shadow: 0 6px 0 #b45309, 0 18px 30px rgba(0, 0, 0, 0.55);
}

.study-next-btn:active {
  transform: translate(-50%, calc(-50% + 2px));
}

.level-next-btn,
.level-next-btn.secondary {
  position: static;
  z-index: auto;
  width: min(320px, calc(100vw - 36px));
  min-height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 3px solid #facc15;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(252, 211, 77, 0.9), rgba(245, 158, 11, 0.9));
  color: #2f1f00;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.45);
  box-shadow: 0 6px 0 #b45309, 0 18px 30px rgba(0, 0, 0, 0.55);
  margin: 16px auto 0;
}

.level-next-btn:active {
  transform: translateY(2px);
}

.menu-button {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 11;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: linear-gradient(145deg, rgba(255, 217, 97, 0.88), rgba(240, 155, 24, 0.92));
  box-shadow: 0 4px 0 #b45309, 0 8px 12px rgba(0,0,0,0.35);
  color: #3f2a00;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
  padding: 0;
}

.menu-button:hover {
  opacity: 0.98;
}

.menu-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #b45309, 0 6px 8px rgba(0,0,0,0.4);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#volumeSlider {
  width: 100%;
  accent-color: var(--gold);
  height: 8px;
  cursor: pointer;
  background: linear-gradient(90deg, #facc15 0%, #f59e0b 100%);
}

select,
input,
button {
  width: 100%;
  border: 2px solid var(--gold);
  background: linear-gradient(145deg, rgba(69, 49, 84, 0.92), rgba(84, 58, 102, 0.96));
  color: #ffe8a8;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: inset 0 0 0 1px rgba(252, 211, 77, 0.2), 0 2px 0 rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hud.flash-good input {
  border-color: #22c55e !important;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.2), 0 2px 0 rgba(0, 0, 0, 0.25);
}

.hud.flash-bad input {
  border-color: #ef4444 !important;
  box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.2), 0 2px 0 rgba(0, 0, 0, 0.25);
}

button {
  cursor: pointer;
  font-weight: 700;
  background: linear-gradient(145deg, #fcd34d, #f59e0b);
  color: #2f1f00;
  border: 2px solid #f59e0b;
  box-shadow: 0 4px 0 #b45309, 0 8px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}

button:hover { opacity: 0.98; }
button:active { transform: translateY(2px); box-shadow: 0 2px 0 #b45309, 0 6px 8px rgba(0, 0, 0, 0.4); }

.primary { background: linear-gradient(145deg, #fcd34d, #f59e0b); color: #3f2a00; }
.secondary { background: linear-gradient(145deg, rgba(183, 138, 65, 0.48), rgba(255, 199, 44, 0.22)); color: #3f2a00; }
.danger { background: linear-gradient(145deg, rgba(251, 113, 133, 0.85), rgba(220, 38, 38, 0.9)); color: #fff1f2; }

#resetViewBtn {
  background: linear-gradient(145deg, rgba(252, 211, 77, 0.96), rgba(245, 158, 11, 0.96));
  border-color: #d97706;
  color: #2f1f00;
}

button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
}

.level-chip {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 58px;
  padding: 12px 22px;
  border-radius: 999px;
  overflow: hidden;
  font-weight: 900;
  letter-spacing: 0.12em;
  border: 3px solid #f59e0b;
  background: linear-gradient(145deg, rgba(16, 10, 25, 0.98), rgba(32, 18, 48, 0.98));
  box-shadow: 0 5px 0 #8b4513, 0 12px 22px rgba(0, 0, 0, 0.55);
  text-transform: uppercase;
  color: #fffef2;
  text-shadow: 0 0 8px rgba(255, 245, 160, 1), 0 0 12px rgba(255, 255, 255, 0.55);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.level-chip span {
  font-size: 20px;
  color: #fef2c7;
  text-shadow: 0 0 5px rgba(254, 226, 132, 0.8);
}

.level-chip span {
  display: inline-block;
  margin: 0 4px;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  transition: transform 0.2s ease, text-shadow 0.2s ease, filter 0.2s ease;
}

.level-chip.level-up {
  animation: levelBurst 0.55s ease;
}

.level-style-1 {
  color: #fefcf0;
  background: linear-gradient(145deg, rgba(30, 20, 40, 0.92), rgba(56, 38, 73, 0.94));
  border-color: #f59e0b;
  box-shadow: 0 4px 0 #8b4513, 0 10px 18px rgba(0,0,0,0.45);
}

.level-style-1 span { color: #fffbde; text-shadow: 0 0 4px rgba(255,255,255,0.8); }

.level-style-2 {
  color: #fff9ce;
  background: linear-gradient(145deg, rgba(20, 25, 50, 0.92), rgba(34, 50, 86, 0.94));
  border-color: #3b82f6;
  box-shadow: 0 4px 0 #1d4ed8, 0 10px 18px rgba(0,0,0,0.45);
}

.level-style-2 span { color: #dbdfff; text-shadow: 0 0 4px rgba(107, 114, 128,0.8); }

.level-style-3 {
  color: #cffafe;
  background: linear-gradient(145deg, rgba(10, 35, 45, 0.92), rgba(28, 95, 120, 0.94));
  border-color: #22d3ee;
  box-shadow: 0 4px 0 #0ea5e9, 0 10px 18px rgba(0,0,0,0.45);
}

.level-style-3 span { color: #b5f3ff; text-shadow: 0 0 4px rgba(66, 194, 255,0.8); }

.level-style-4 {
  color: #ddd6fe;
  background: linear-gradient(145deg, rgba(35, 25, 60, 0.92), rgba(80, 60, 115, 0.94));
  border-color: #a78bfa;
  box-shadow: 0 4px 0 #7c3aed, 0 10px 18px rgba(0,0,0,0.45);
}

.level-style-4 span { color: #c4b5fd; text-shadow: 0 0 4px rgba(167, 139, 250,0.8); }

.level-style-5 {
  color: #f5d0fe;
  background: linear-gradient(145deg, rgba(50, 20, 70, 0.92), rgba(110, 45, 130, 0.94));
  border-color: #f472b6;
  box-shadow: 0 4px 0 #be185d, 0 10px 18px rgba(0,0,0,0.45);
}

.level-style-1 { color: #fffef2 !important; background: linear-gradient(145deg, rgba(20, 13, 35, 0.96), rgba(42, 30, 70, 0.96)) !important; border-color: #f59e0b !important; box-shadow: 0 4px 0 #8b4513, 0 10px 18px rgba(0,0,0,0.55) !important; }
.level-style-1 span { color: #fffbde !important; text-shadow: 0 0 5px rgba(255,255,255,0.85) !important; }

.level-style-2 { color: #fff9ce !important; background: linear-gradient(145deg, rgba(16, 15, 42, 0.96), rgba(36, 48, 86, 0.96)) !important; border-color: #3b82f6 !important; box-shadow: 0 4px 0 #1d4ed8, 0 10px 18px rgba(0,0,0,0.55) !important; }
.level-style-2 span { color: #dbe8ff !important; text-shadow: 0 0 5px rgba(155, 180, 255,0.85) !important; }

.level-style-3 { color: #cffafe !important; background: linear-gradient(145deg, rgba(15, 28, 45, 0.96), rgba(22, 86, 120, 0.96)) !important; border-color: #22d3ee !important; box-shadow: 0 4px 0 #0ea5e9, 0 10px 18px rgba(0,0,0,0.55) !important; }
.level-style-3 span { color: #b5f3ff !important; text-shadow: 0 0 5px rgba(66, 194, 255,0.85) !important; }

.level-style-4 { color: #ddd6fe !important; background: linear-gradient(145deg, rgba(25, 20, 60, 0.96), rgba(68, 60, 115, 0.96)) !important; border-color: #a78bfa !important; box-shadow: 0 4px 0 #7c3aed, 0 10px 18px rgba(0,0,0,0.55) !important; }
.level-style-4 span { color: #c4b5fd !important; text-shadow: 0 0 5px rgba(167, 139, 250,0.85) !important; }

.level-style-5 { color: #f5d0fe !important; background: linear-gradient(145deg, rgba(35, 20, 80, 0.96), rgba(95, 45, 130, 0.96)) !important; border-color: #f472b6 !important; box-shadow: 0 4px 0 #be185d, 0 10px 18px rgba(0,0,0,0.55) !important; }
.level-style-5 span { color: #f9a8d4 !important; text-shadow: 0 0 5px rgba(236, 72, 153,0.8) !important; }

.level-style-2 span { color: #bfdbfe; text-shadow: 0 0 10px rgba(96, 165, 250, 0.35); }

.level-style-3 {
  color: #cffafe;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(56, 189, 248, 0.14));
  border-color: rgba(34, 211, 238, 0.42);
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.22);
}

.level-style-3 span { color: #67e8f9; text-shadow: 0 0 12px rgba(34, 211, 238, 0.45); }

.level-style-4 {
  color: #ddd6fe;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(168, 85, 247, 0.18));
  border-color: rgba(167, 139, 250, 0.44);
  box-shadow: 0 0 22px rgba(139, 92, 246, 0.24);
}

.level-style-4 span { color: #c4b5fd; text-shadow: 0 0 14px rgba(168, 85, 247, 0.48); }

.level-style-5 {
  color: #f5d0fe;
  background: linear-gradient(135deg, rgba(217, 70, 239, 0.24), rgba(236, 72, 153, 0.2));
  border-color: rgba(244, 114, 182, 0.46);
  box-shadow: 0 0 24px rgba(236, 72, 153, 0.26);
}

.level-style-5 span {
  color: #f9a8d4;
  text-shadow: 0 0 16px rgba(244, 114, 182, 0.5);
  transform: scale(1.03);
}

.level-style-6 {
  color: #fde68a;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.82), rgba(251, 191, 36, 0.75));
  border-color: rgba(251, 191, 36, 0.9);
  box-shadow: 0 0 26px rgba(245, 158, 11, 0.75);
}

.level-style-6 span {
  color: #fcd34d;
  text-shadow: 0 0 18px rgba(251, 191, 36, 0.6);
  transform: scale(1.06);
}

.level-style-7 {
  color: #fed7aa;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.85), rgba(239, 68, 68, 0.8));
  border-color: rgba(251, 146, 60, 0.95);
  box-shadow: 0 0 28px rgba(249, 115, 22, 0.8);
}

.level-style-7 span {
  color: #fdba74;
  text-shadow: 0 0 20px rgba(249, 115, 22, 0.68);
  transform: scale(1.09);
  animation: emberFlicker 1.8s ease-in-out infinite;
}

.level-style-8 {
  color: #e9d5ff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(168, 85, 247, 0.92), rgba(236, 72, 153, 0.9));
  border-color: rgba(192, 132, 252, 0.95);
  box-shadow: 0 0 30px rgba(168, 85, 247, 0.85);
}

.level-style-8 span {
  color: #f0abfc;
  text-shadow: 0 0 22px rgba(192, 132, 252, 0.72);
  transform: scale(1.12);
  animation: plasmaPulse 1.5s ease-in-out infinite;
}

.level-style-9 {
  color: #fff7ed;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(251, 191, 36, 0.75));
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 34px rgba(255, 255, 255, 0.7), 0 0 22px rgba(251, 191, 36, 0.75);
}

.level-style-9 span {
  color: #ffffff;
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.85), 0 0 18px rgba(251, 191, 36, 0.5);
  transform: scale(1.16);
  animation: divinePulse 1.35s ease-in-out infinite;
}

.level-style-10 {
  color: #fff7ed;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(251, 191, 36, 0.8), rgba(249, 115, 22, 0.85), rgba(239, 68, 68, 0.8));
  border-color: rgba(251, 191, 36, 1);
  box-shadow: 0 0 42px rgba(249, 115, 22, 0.72), 0 0 28px rgba(251, 191, 36, 0.72);
}

.level-style-10 span {
  color: #ffffff;
  text-shadow: 0 0 28px rgba(255, 255, 255, 0.85), 0 0 22px rgba(251, 146, 60, 0.72), 0 0 16px rgba(239, 68, 68, 0.56);
  transform: scale(1.2);
  animation: infernoPulse 1.05s ease-in-out infinite;
}

.message {
  margin-top: 10px;
  min-height: 20px;
  font-size: 12px;
  font-weight: 700;
  color: #fee4a3;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.7);
}

.message.center-feedback {
  position: fixed;
  inset: 0;
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.9), 0 0 40px rgba(255, 235, 108, 0.7), 0 0 60px rgba(252, 211, 77, 0.5);
  z-index: 200;
  background: transparent;
  animation: centerFeedbackShow 0.4s ease-out;
  pointer-events: none;
}

.message.center-feedback.good {
  color: var(--gold);
}

.message.center-feedback.bad {
  color: var(--bad);
}

@keyframes centerFeedbackShow {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.good { color: #22c55e; }
.bad { color: #fb7185; }

.result-card {
  margin-top: 10px;
  border-radius: 10px;
  padding: 10px;
  border: 2px solid #f59e0b;
  background: linear-gradient(145deg, rgba(33, 20, 38, 0.85), rgba(52, 38, 58, 0.95));
  box-shadow: 0 0 0 1px rgba(252, 211, 77, 0.28), 0 8px 18px rgba(0, 0, 0, 0.35);
  display: none;
  transform: scale(0.98);
  opacity: 0;
}

.result-card.show {
  display: block;
  animation: popIn 0.32s ease forwards;
}

.result-card.level-center.show {
  animation: popInCenter 0.32s ease forwards;
}

.result-card.level-center {
  position: fixed;
  left: 50%;
  top: 50vh;
  transform: translate(-50%, -50%);
  margin-top: 0;
  width: min(760px, calc(100vw - 36px));
  padding: 18px 20px;
  z-index: 210;
  border-width: 3px;
  box-shadow: 0 0 0 1px rgba(252, 211, 77, 0.35), 0 18px 34px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.result-card.level-center .result-title {
  font-size: 20px;
  margin-bottom: 8px;
}

.result-card.level-center .result-meta {
  font-size: 16px;
  line-height: 1.5;
}

.result-card.level-center .level-next-btn,
.result-card.level-center .level-next-btn.secondary {
  width: min(320px, 92%);
  margin-top: 18px;
}

.result-card.success { border-color: #22c55e !important; }
.result-card.fail { border-color: #ef4444 !important; }

.result-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
  color: #ffecb3;
  text-shadow: 0 0 6px rgba(255, 210, 85, 0.6);
}

.result-meta {
  font-size: 11px;
  color: #f8f0c5;
  line-height: 1.45;
}

.level-change-splash {
  background: rgba(10, 6, 24, 0.58);
  border: 3px solid #f59e0b;
  box-shadow: 0 0 0 1px rgba(252, 211, 77, 0.4), 0 0 24px rgba(249, 115, 22, 0.35);
}

.level-change-text {
  font-family: "Press Start 2P", "Courier New", monospace;
  color: #fde68a;
  text-shadow: 0 0 8px rgba(252, 211, 77, 0.8), 0 0 18px rgba(148, 163, 184, 0.7);
}

.level-run-intro .intro-title {
  font-family: "Press Start 2P", monospace;
  color: #ffeb00;
  text-shadow: 0 0 12px rgba(252, 211, 77, 0.95), 0 0 20px rgba(255, 153, 0, 0.8);
}

.level-run-intro {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
  background: radial-gradient(circle at 30% 70%, rgba(255, 69, 0, 0.3) 0%, rgba(255, 140, 0, 0.2) 25%, rgba(255, 215, 0, 0.1) 50%, transparent 70%),
              radial-gradient(circle at 70% 30%, rgba(255, 0, 150, 0.25) 0%, rgba(255, 100, 200, 0.15) 30%, transparent 60%),
              linear-gradient(180deg, rgba(20, 10, 30, 0.9) 0%, rgba(40, 20, 50, 0.8) 50%, rgba(10, 5, 20, 0.95) 100%);
  overflow: hidden;
  font-family: "Press Start 2P", "Courier New", Courier, monospace;
}

.level-run-intro.show {
  display: flex;
  animation: introArcade 2s ease-in-out forwards;
}

.level-run-guide {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  pointer-events: all;
  padding: 12px;
}

.level-run-guide.show {
  display: flex;
}

/* ── Free-mode setup overlay ── */
.free-mode-setup {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  pointer-events: all;
  padding: 12px;
}

.free-mode-setup.show {
  display: flex;
}

.free-mode-setup .guide-box label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fcd34d;
  margin-bottom: 4px;
}

.free-mode-setup .guide-box select {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(252, 211, 77, 0.5);
  border-radius: 6px;
  color: #fffef2;
  padding: 6px 8px;
  font-size: 11px;
  font-family: 'Press Start 2P', monospace;
  cursor: pointer;
}

.free-mode-setup .guide-box select option {
  background: #1a1028;
}

.free-mode-setup .guide-box button {
  width: 100%;
  border: 2px solid var(--gold);
  background: linear-gradient(145deg, #fcd34d, #f59e0b);
  color: #3f2a00;
  padding: 10px 12px;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: 8px;
}

.free-mode-setup .guide-box button:hover { opacity: 0.95; }
.free-mode-setup .guide-box button:active { transform: translateY(1px); }

@media (max-width: 740px) {
  .hud-top {
    flex-direction: column;
    width: calc(100vw - 24px);
    align-items: stretch;
  }

  .study-reveal-panel {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
  }

  .study-reveal-panel button {
    min-width: 132px;
  }

}

/* ── City reveal overlay ── */
.city-reveal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
}

.city-reveal-box {
  background: linear-gradient(145deg, rgba(39, 24, 56, 0.97), rgba(68, 43, 92, 0.97));
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 22px 34px;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(252, 211, 77, 0.45), 0 12px 28px rgba(0,0,0,0.65);
  animation: cityRevealFade 5s ease forwards;
}

.city-reveal-box span {
  font-size: 16px;
  font-weight: 900;
  color: #fffef2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(252, 211, 77, 0.6);
}

@keyframes cityRevealFade {
  0%   { opacity: 0; transform: scale(0.88); }
  12%  { opacity: 1; transform: scale(1); }
  80%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.92); }
}

/* ── Free play chip (top bar) ── */
.free-play-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 22px;
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(16,10,25,0.98), rgba(32,18,48,0.98));
  border: 2px solid #f59e0b;
  box-shadow: 0 4px 0 #8b4513, 0 10px 18px rgba(0,0,0,0.5);
  color: #fffef2;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 900;
  text-shadow: 0 0 6px rgba(255,245,160,0.9);
  cursor: pointer;
  user-select: none;
}

.free-play-chip:hover {
  border-color: #fcd34d;
}

.free-chip-sep {
  opacity: 0.5;
  font-size: 14px;
}

.free-chip-edit {
  opacity: 0.65;
  font-size: 11px;
  margin-left: 2px;
}

/* ── Filter popup anchored below the chip ── */
.free-filter-popup {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 130;
  background: linear-gradient(145deg, rgba(28,17,42,0.98), rgba(52,32,72,0.98));
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.65);
  cursor: default;
  text-align: left;
}

.free-filter-popup.open {
  display: block;
  animation: ffpFadeIn 0.18s ease;
}

@keyframes ffpFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.ffp-title {
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #fcd34d;
  margin-bottom: 12px;
  text-align: center;
}

.free-filter-popup label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #fcd34d;
  margin-bottom: 4px;
  margin-top: 10px;
}

.free-filter-popup label:first-of-type {
  margin-top: 0;
}

.free-filter-popup select {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(252,211,77,0.45);
  border-radius: 6px;
  color: #fffef2;
  padding: 7px 10px;
  font-size: 12px;
  font-family: 'Press Start 2P', monospace;
  cursor: pointer;
}

.free-filter-popup select option {
  background: #1a1028;
}

.free-filter-popup button {
  margin-top: 14px;
  width: 100%;
  border: 2px solid var(--gold);
  background: linear-gradient(145deg, #fcd34d, #f59e0b);
  color: #3f2a00;
  padding: 10px 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  letter-spacing: 0.07em;
  cursor: pointer;
  border-radius: 7px;
}

.free-filter-popup button:hover { opacity: 0.92; }
.free-filter-popup button:active { transform: translateY(1px); }

.guide-box {
  width: min(60vw, 340px);
  background: linear-gradient(145deg, rgba(39, 24, 56, 0.95), rgba(68, 43, 92, 0.95));
  border: 2px solid var(--gold);
  padding: 18px 16px;
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(252, 211, 77, 0.45), 0 10px 22px rgba(0,0,0,0.55);
  color: #fef3c7;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
}

.guide-title {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: #fff;
}

.guide-box p {
  margin: 7px 0;
}

#gotItBtn {
  margin-top: 12px;
  width: 100%;
  border: 2px solid var(--gold);
  background: linear-gradient(145deg, #fcd34d, #f59e0b);
  color: #3f2a00;
  padding: 10px 12px;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: 8px;
}

#gotItBtn:hover {
  opacity: 0.95;
}

#gotItBtn:active {
  transform: translateY(1px);
}

.level-run-guide .guide-title {
  font-size: 14px;
  margin-bottom: 8px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid rgba(252, 211, 77, 0.5);
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.level-run-guide p {
  margin: 4px 0;
}

.level-run-intro::before,
.level-run-intro::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  background: #ff4f8b;
  box-shadow: 0 0 8px #ff4f8b, 0 0 18px rgba(255, 79, 139, 0.5);
  border: 2px solid #ff74b1;
  transform: scale(0.7);
  animation: pixelPulse 1.2s ease-in-out infinite alternate;
}

.level-run-intro::before {
  left: 16%;
  top: 40%;
  background: #ff964b;
  box-shadow: 0 0 6px #ff964b, 0 0 20px rgba(255, 150, 75, 0.55);
}

.level-run-intro::after {
  right: 18%;
  top: 38%;
  background: #36e7ff;
  box-shadow: 0 0 6px #36e7ff, 0 0 20px rgba(54, 231, 255, 0.55);
  animation-delay: 0.18s;
}

.level-run-intro::before,
.level-run-intro::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 999px;
  filter: blur(32px);
  opacity: 0.7;
  animation: orbPulse 1.5s ease-in-out infinite;
}

.level-run-intro::before {
  background: radial-gradient(circle, rgba(255, 69, 0, 0.4) 0%, rgba(255, 140, 0, 0.3) 50%, transparent 100%);
  left: calc(50% - 300px);
  top: calc(50% - 100px);
}

.level-run-intro::after {
  background: radial-gradient(circle, rgba(255, 0, 150, 0.35) 0%, rgba(255, 100, 200, 0.25) 50%, transparent 100%);
  left: calc(50% + 60px);
  top: calc(50% - 80px);
  animation-delay: 0.3s;
}

.intro-title {
  position: relative;
  z-index: 2;
  font-size: clamp(40px, 7vw, 84px);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  text-shadow:
    0 0 14px rgba(248, 140, 80, 0.9),
    0 0 20px rgba(255, 255, 255, 0.6),
    0 0 30px rgba(93, 167, 255, 0.55),
    0 0 46px rgba(240, 80, 180, 0.5),
    2px 2px 0 #ff4500,
    4px 4px 0 #ff8c00,
    6px 6px 0 #ffd700;
  filter: contrast(1.15);
  animation: burnTitle 3.2s ease-in-out forwards;
}

.intro-title::before {
  content: "LEVEL RUN";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, #ff4500, #ff8c00, #ffd700, #ff4500);
  background-size: 400% 400%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: burnShift 2s ease-in-out infinite;
  opacity: 0.8;
  z-index: -1;
}

.intro-title span {
  background: linear-gradient(45deg, #ffe36f 0%, #fd5d97 38%, #6fd4ff 70%, #82ff88 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.intro-flare {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 10px;
  height: 10px;
  border-radius: 0;
  background: #fff;
  opacity: 0;
  box-shadow: 0 0 14px rgba(255,255,255,0.9);
  animation: sparkBurst 1.2s ease forwards;
}

.intro-title span {
  background: linear-gradient(135deg, #ffffff 0%, #67e8f9 30%, #f0abfc 62%, #fdba74 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.intro-flare {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: white;
  opacity: 0;
  box-shadow: 0 0 14px rgba(255,255,255,0.7);
  animation: sparkBurst 1.2s cubic-bezier(0.12, 0.48, 0.28, 1.02) forwards;
}

.intro-flare.f1 { --dx: -260px; --dy: -120px; --c: #67e8f9; animation-delay: 0.03s; }
.intro-flare.f2 { --dx: -180px; --dy: -170px; --c: #f0abfc; animation-delay: 0.08s; }
.intro-flare.f3 { --dx: -90px; --dy: -140px; --c: #fdba74; animation-delay: 0.14s; }
.intro-flare.f4 { --dx: 90px; --dy: -150px; --c: #facc15; animation-delay: 0.05s; }
.intro-flare.f5 { --dx: 180px; --dy: -120px; --c: #fb7185; animation-delay: 0.11s; }
.intro-flare.f6 { --dx: 240px; --dy: -40px; --c: #67e8f9; animation-delay: 0.18s; }
.intro-flare.f7 { --dx: -240px; --dy: 20px; --c: #f59e0b; animation-delay: 0.16s; }
.intro-flare.f8 { --dx: -120px; --dy: 90px; --c: #c084fc; animation-delay: 0.07s; }
.intro-flare.f9 { --dx: 120px; --dy: 95px; --c: #34d399; animation-delay: 0.12s; }
.intro-flare.f10 { --dx: 230px; --dy: 45px; --c: #fb7185; animation-delay: 0.2s; }
.intro-flare.f11 { --dx: 0px; --dy: -200px; --c: #ff4500; animation-delay: 0.25s; }
.intro-flare.f12 { --dx: -320px; --dy: -80px; --c: #ffd700; animation-delay: 0.3s; }
.intro-flare.f13 { --dx: 320px; --dy: -60px; --c: #ff1493; animation-delay: 0.35s; }
.intro-flare.f14 { --dx: -160px; --dy: 120px; --c: #00ffff; animation-delay: 0.4s; }
.intro-flare.f15 { --dx: 160px; --dy: 140px; --c: #ff6347; animation-delay: 0.45s; }

.intro-flame {
  position: absolute;
  bottom: 18%;
  width: 120px;
  height: 160px;
  background: 
    linear-gradient(180deg, #ff4500 0%, #ff6b35 20%, #ff8c42 40%, #ffa336 60%, #ff5f6a 80%, #8e42ff 100%),
    repeating-linear-gradient(90deg, transparent 0px, transparent 8px, rgba(255, 255, 255, 0.1) 8px, rgba(255, 255, 255, 0.1) 16px),
    repeating-linear-gradient(0deg, transparent 0px, transparent 8px, rgba(255, 255, 255, 0.05) 8px, rgba(255, 255, 255, 0.05) 16px);
  background-size: 100% 100%, 16px 16px, 16px 16px;
  box-shadow: 
    0 0 30px rgba(255, 69, 0, 0.8), 
    0 0 60px rgba(255, 140, 0, 0.6), 
    0 0 90px rgba(142, 66, 255, 0.4),
    inset 0 0 20px rgba(255, 255, 255, 0.2);
  opacity: 0;
  animation: flameRise 3.2s ease-in-out forwards, pixelFlameFlicker 0.15s ease-in-out infinite alternate;
  filter: contrast(1.2) brightness(1.1);
  border-radius: 8px;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.intro-flame.left,
.intro-flame.right {
  animation: spriteFlame 1.9s ease-in-out infinite;
}

.intro-flame.center {
  left: calc(50% - 60px);
  transform: rotate(0deg);
  animation: spriteFlame 2.1s ease-in-out infinite;
  animation-delay: 0.2s;
}

.intro-flame.left {
  left: calc(50% - 300px);
  transform: rotate(-12deg);
}

.intro-flame.right {
  left: calc(50% + 160px);
  transform: rotate(12deg);
  animation-delay: 0.1s;
}

.level-change-splash {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.08), rgba(2, 6, 23, 0.38));
}

.level-change-splash.show {
  display: flex;
  animation: levelSplashFade 2.1s ease forwards;
}

.level-change-text {
  font-size: clamp(46px, 9vw, 116px);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
  text-align: center;
  padding: 0 24px;
  text-shadow:
    0 0 18px rgba(255, 255, 255, 0.65),
    0 0 34px rgba(252, 211, 77, 0.45),
    0 0 54px rgba(249, 115, 22, 0.35);
  transform: scale(0.72) translateY(18px);
  opacity: 0;
  font-family: "Press Start 2P", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
}

.level-change-splash.show .level-change-text {
  animation: levelSplashText 2.1s ease forwards;
}

.level-change-splash.up .level-change-text {
  color: var(--gold);
}

.level-change-splash.down .level-change-text {
  color: var(--bad);
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.94) translateY(6px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes popInCenter {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.94); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes levelBurst {
  0% { transform: scale(1); }
  35% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes emberFlicker {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.16); }
}

@keyframes plasmaPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

@keyframes divinePulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

@keyframes infernoPulse {
  0%, 100% { filter: brightness(1) saturate(1); }
  50% { filter: brightness(1.24) saturate(1.22); }
}

@keyframes introArcade {
  0% {
    opacity: 0;
    transform: scale(0.7) rotate(0deg);
    filter: saturate(0.6) brightness(0.6);
  }
  15% {
    opacity: 1;
    transform: scale(1.25) rotate(-3deg);
    filter: saturate(1.2) brightness(1.2);
  }
  35% {
    transform: scale(1.1) rotate(4deg);
    filter: saturate(1.3) brightness(1.3);
  }
  55% {
    transform: scale(1.05) rotate(-2deg);
    filter: saturate(1.4) brightness(1.4);
  }
  75% {
    transform: scale(1.15) rotate(6deg);
    filter: saturate(1.2) brightness(1.2);
  }
  100% {
    opacity: 0;
    transform: scale(1.3) rotate(10deg);
    filter: saturate(0.8) brightness(0.8);
  }
}

@keyframes pixelPulse {
  0% {
    transform: translateY(0) scale(0.72);
    opacity: 0.46;
  }
  50% {
    transform: translateY(-21px) scale(1.14);
    opacity: 1;
  }
  100% {
    transform: translateY(-40px) scale(0.86);
    opacity: 0.54;
  }
}

@keyframes spriteFlame {
  0%, 100% {
    box-shadow: 5px 2px 0 #ff3f6b, 10px -8px 0 #ffd76e, 16px 4px 0 #7f63ff, -10px 14px 0 #36d8ff;
    transform: translateY(0) scale(1);
  }
  50% {
    box-shadow: 5px -8px 0 #ff9c6b, 10px 1px 0 #f2ff5f, -14px -8px 0 #57f1ff, -6px 8px 0 #f279ff;
    transform: translateY(-12px) scale(1.08);
  }
}

@keyframes sparkBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }
  20% {
    opacity: 1;
  }
  70% {
    opacity: 1;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.6) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.9) rotate(260deg);
  }
}

@keyframes introTitlePop {
  0% { opacity: 0; transform: scale(0.75) translateY(22px); }
  55% { opacity: 1; transform: scale(1.06) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes orbPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.42; }
  50% { transform: scale(1.08); opacity: 0.72; }
}

@keyframes sparkBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.25);
    box-shadow: 0 0 0 rgba(255,255,255,0);
  }
  20% {
    opacity: 1;
    background: var(--c);
  }
  100% {
    opacity: 0;
    background: var(--c);
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.9);
    box-shadow: 0 0 24px var(--c);
  }
}

@keyframes flameRise {
  0% { opacity: 0; transform: translateY(40px) scale(0.6); }
  15% { opacity: 0.9; transform: translateY(20px) scale(0.8); }
  40% { opacity: 1; transform: translateY(-10px) scale(1); }
  70% { opacity: 0.8; transform: translateY(-30px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1.2); }
}

@keyframes burnTitle {
  0% { 
    opacity: 0; 
    transform: scale(0.8) translateY(30px) rotate(-5deg); 
    filter: brightness(0.5) contrast(1); 
    text-shadow: 0 0 10px rgba(248, 140, 80, 0.5);
  }
  20% { 
    opacity: 1; 
    transform: scale(1.1) translateY(-10px) rotate(2deg); 
    filter: brightness(1.2) contrast(1.2); 
    text-shadow: 0 0 20px rgba(248, 140, 80, 0.8), 2px 2px 0 #ff4500;
  }
  50% { 
    transform: scale(1.05) translateY(0) rotate(0deg); 
    filter: brightness(1.3) contrast(1.3); 
    text-shadow: 0 0 30px rgba(248, 140, 80, 1), 4px 4px 0 #ff8c00, 2px 2px 0 #ff4500;
  }
  80% { 
    transform: scale(1.02) translateY(5px) rotate(1deg); 
    filter: brightness(1.1) contrast(1.2); 
    text-shadow: 0 0 25px rgba(248, 140, 80, 0.9), 6px 6px 0 #ffd700, 4px 4px 0 #ff8c00, 2px 2px 0 #ff4500;
  }
  100% { 
    opacity: 0; 
    transform: scale(1.15) translateY(-20px) rotate(3deg); 
    filter: brightness(0.8) contrast(1.1); 
    text-shadow: 0 0 15px rgba(248, 140, 80, 0.6), 6px 6px 0 #ffd700, 4px 4px 0 #ff8c00, 2px 2px 0 #ff4500;
  }
}

@keyframes burnShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes bannerFadeOut {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.02); }
}

@keyframes bannerGlow {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.18)); }
  50% { filter: drop-shadow(0 0 26px rgba(192, 132, 252, 0.24)); }
}

@keyframes bannerFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes levelSplashFade {
  0% { opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes levelSplashText {
  0% {
    opacity: 0;
    transform: scale(0.72) translateY(18px);
    filter: blur(8px);
  }
  20% {
    opacity: 1;
    transform: scale(1.04) translateY(0);
    filter: blur(0);
  }
  75% {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
  100% {
    opacity: 0;
    transform: scale(1) translateY(-8px);
    filter: blur(1px);
  }
}

.menu-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  pointer-events: auto;
}

.menu-modal.show {
  display: flex;
}

.back-to-menu-btn {
  width: 100%;
  margin-bottom: 18px;
  padding: 12px;
  background: linear-gradient(145deg, #fcd34d, #f59e0b);
  color: #3f2a00;
  border: 2px solid var(--gold);
  border-radius: 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: 0 3px 0 #b45309;
}
.back-to-menu-btn:hover { opacity: 0.92; }
.back-to-menu-btn:active { transform: translateY(1px); box-shadow: none; }

.menu-content {
  background: linear-gradient(135deg, rgba(25, 15, 23, 0.95), rgba(45, 36, 53, 0.97));
  border: 3px solid var(--gold);
  border-radius: 12px;
  box-shadow: 0 0 0 2px rgba(252, 211, 77, 0.5), 0 20px 48px rgba(0, 0, 0, 0.55);
  padding: 20px;
  max-width: min(420px, calc(100vw - 40px));
  max-height: 80vh;
  overflow-y: auto;
  animation: menuSlideIn 0.3s ease forwards;
}

@keyframes menuSlideIn {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(252, 211, 77, 0.25);
}

.menu-header h2 {
  font-size: 18px;
  color: #ffeb6d;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.close-btn {
  background: transparent;
  border: none;
  color: #ffeb6d;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.close-btn:hover {
  color: #fde68a;
}

.menu-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-body h3 {
  font-size: 12px;
  color: #f4e4ab;
  margin: 8px 0 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .row { flex-direction: column; }

  .start-banner-inner {
    padding: 24px 20px;
  }

  .start-kicker {
    font-size: 13px;
  }

  .hud {
    top: 10px;
    left: 10px;
    width: min(340px, calc(100vw - 20px));
    padding: 11px;
  }

  .level-change-text {
    font-size: clamp(34px, 10vw, 68px);
    letter-spacing: 0.05em;
  }
}

/* Level run intro using transparent PNG letter assets */
.level-run-intro {
  background:
    radial-gradient(circle at 28% 56%, rgba(56, 189, 248, 0.28) 0%, rgba(56, 189, 248, 0) 48%),
    radial-gradient(circle at 72% 44%, rgba(236, 72, 153, 0.26) 0%, rgba(236, 72, 153, 0) 46%),
    linear-gradient(180deg, rgba(9, 6, 17, 0.62) 0%, rgba(5, 4, 12, 0.72) 100%);
  backdrop-filter: blur(2px);
}

.level-run-intro::before,
.level-run-intro::after {
  content: "";
  position: absolute;
  inset: auto;
  width: min(56vw, 620px);
  height: min(56vw, 620px);
  border-radius: 999px;
  pointer-events: none;
  filter: blur(34px);
  opacity: 0;
}

.level-run-intro::before {
  left: calc(50% - min(38vw, 410px));
  top: calc(50% - min(26vw, 220px));
  background: radial-gradient(circle, rgba(56, 189, 248, 0.42) 0%, rgba(56, 189, 248, 0) 66%);
}

.level-run-intro::after {
  left: calc(50% - min(20vw, 160px));
  top: calc(50% - min(22vw, 200px));
  background: radial-gradient(circle, rgba(244, 114, 182, 0.38) 0%, rgba(244, 114, 182, 0) 68%);
}

.level-run-intro.show {
  display: flex;
  animation: lrIntroFade 2.05s ease forwards;
}

.level-run-intro.show::before,
.level-run-intro.show::after {
  animation: lrIntroOrb 1.55s ease-out forwards;
}

.intro-word {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  transform: translateY(8px) scale(0.97);
  opacity: 0;
}

.intro-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(1px, 0.35vw, 5px);
}

.intro-row-top {
  transform: rotate(-2deg);
}

.intro-row-bottom {
  margin-top: clamp(-18px, -1.8vw, -10px);
  transform: rotate(1.4deg);
}

.intro-letter {
  --curve-y: 0px;
  --curve-r: 0deg;
  width: clamp(56px, 8vw, 116px);
  height: auto;
  opacity: 0;
  transform: translateY(28px) scale(0.72) rotate(-5deg);
  filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0));
  will-change: transform, opacity, filter;
}

.level-run-intro.show .intro-word {
  animation: lrWordInOut 1.95s cubic-bezier(0.2, 0.7, 0.25, 1) forwards;
}

.level-run-intro.show .intro-letter {
  animation: lrLetterIn 0.58s cubic-bezier(0.2, 0.7, 0.25, 1) forwards,
             lrLetterFloat 0.8s ease-in-out infinite;
  animation-delay: var(--letter-delay), calc(var(--letter-delay) + 0.62s);
}

.level-run-intro.show .intro-letter.d1 { --letter-delay: 0.00s; --curve-y: 8px; --curve-r: -4deg; }
.level-run-intro.show .intro-letter.d2 { --letter-delay: 0.07s; --curve-y: 2px; --curve-r: -2deg; }
.level-run-intro.show .intro-letter.d3 { --letter-delay: 0.14s; --curve-y: -3px; --curve-r: 0deg; }
.level-run-intro.show .intro-letter.d4 { --letter-delay: 0.21s; --curve-y: 2px; --curve-r: 2deg; }
.level-run-intro.show .intro-letter.d5 { --letter-delay: 0.28s; --curve-y: 9px; --curve-r: 4deg; }
.level-run-intro.show .intro-letter.d6 { --letter-delay: 0.38s; --curve-y: 6px; --curve-r: -3deg; }
.level-run-intro.show .intro-letter.d7 { --letter-delay: 0.45s; --curve-y: 0px; --curve-r: 0deg; }
.level-run-intro.show .intro-letter.d8 { --letter-delay: 0.52s; --curve-y: 7px; --curve-r: 3deg; }

@keyframes lrIntroFade {
  0% { opacity: 0; }
  14% { opacity: 1; }
  82% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes lrIntroOrb {
  0% { opacity: 0; transform: scale(0.7); }
  28% { opacity: 0.78; transform: scale(1.02); }
  100% { opacity: 0; transform: scale(1.18); }
}

@keyframes lrWordInOut {
  0% { opacity: 0; transform: translateY(8px) scale(0.97); }
  24% { opacity: 1; transform: translateY(0) scale(1); }
  74% { opacity: 1; transform: translateY(0) scale(1.015); }
  100% { opacity: 0; transform: translateY(-18px) scale(1.08); }
}

@keyframes lrLetterIn {
  0% {
    opacity: 0;
    transform: translateY(28px) scale(0.72) rotate(-5deg);
    filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0));
  }
  70% {
    opacity: 1;
    transform: translateY(calc(var(--curve-y) - 4px)) scale(1.08) rotate(calc(var(--curve-r) + 1deg));
    filter: drop-shadow(0 0 16px rgba(255, 255, 255, 0.62));
  }
  100% {
    opacity: 1;
    transform: translateY(var(--curve-y)) scale(1) rotate(var(--curve-r));
    filter: drop-shadow(0 0 9px rgba(255, 255, 255, 0.38));
  }
}

@keyframes lrLetterFloat {
  0%, 100% { transform: translateY(var(--curve-y)) scale(1) rotate(var(--curve-r)); }
  50% { transform: translateY(calc(var(--curve-y) - 3px)) scale(1.01) rotate(var(--curve-r)); }
}

@media (max-width: 720px) {
  .intro-row {
    gap: clamp(0px, 0.2vw, 2px);
  }

  .intro-letter {
    width: clamp(34px, 9.5vw, 72px);
  }

  .intro-row-bottom {
    margin-top: clamp(-11px, -2.1vw, -6px);
  }
}