/* Startup page only. */
/* --------------------------------------------------------------------------
   Cave Rush V5 POC theme integration: startup + select mode
   -------------------------------------------------------------------------- */

/* ── Secondary overlay foundation ────────────────────────────────────────────
   styles.css / game-ui.css define .overlay base styles for engine.html.
   index.html doesn't load those files, so we define position:fixed + hide/show
   here for the overlays that live on the startup page. */

#enterCavePromptOverlay,
#installOverlay {
  position: fixed;
  inset: 0;
  z-index: 10000;   /* above nav.startup-quick-actions which is z-index:9999 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: rgba(1, 5, 16, 0.78);
  backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

#enterCavePromptOverlay.active,
#installOverlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Enter the Cave prompt panel ─────────────────────────────────────────── */

.enter-cave-panel {
  width: min(430px, 100%);
  max-height: min(720px, calc(100vh - 28px));
  overflow: auto;
  background:
    radial-gradient(circle at 16% 8%, rgba(83, 216, 255, 0.18), transparent 34%),
    radial-gradient(circle at 88% 92%, rgba(255, 57, 231, 0.13), transparent 34%),
    rgba(7, 13, 30, 0.96);
  border: 1px solid rgba(99, 219, 255, 0.34);
  border-radius: 26px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.enter-cave-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.enter-cave-panel h2 {
  margin: 0;
  color: var(--cr-white, #fff);
  font-size: clamp(1.3rem, 5vw, 1.8rem);
}

.enter-cave-panel .subtitle {
  margin: 0;
  color: rgba(239, 249, 255, 0.72);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ── Identity summary on start screen ────────────────────────────────────── */

.identity-summary {
  color: rgba(239, 249, 255, 0.62);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  min-height: 20px;
}

.identity-summary strong {
  color: var(--cr-cyan, #2af6ff);
  font-weight: 700;
}

/* ── Onboarding form ─────────────────────────────────────────────────────── */

.identity-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.identity-form__label {
  color: rgba(239, 249, 255, 0.8);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.identity-form__optional {
  color: rgba(239, 249, 255, 0.38);
  font-weight: 400;
}

.form-error {
  margin: 0;
  color: #ff5a4f;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* ── Button row variants ─────────────────────────────────────────────────── */

.button-row--stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.button-row--stack .neon-button {
  width: 100%;
}

.enter-cave-panel .neon-button {
  min-height: clamp(52px, 8vh, 72px);
}

.enter-cave-divider {
  text-align: center;
  color: rgba(239, 249, 255, 0.32);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 4px 0;
}

/* Reuse .auth-provider-grid layout from auth.css inside the prompt panel */
.enter-cave-panel .auth-provider-grid {
  margin-top: 0;
}

.enter-cave-panel .auth-button {
  min-height: 46px;
  font-size: 0.85rem;
}

#lbIconBtn,
.music-control {
  filter: drop-shadow(0 0 12px rgba(255, 71, 222, 0.72)) drop-shadow(0 0 16px rgba(42, 246, 255, 0.48));
}

#lbIconBtn {
  width: clamp(54px, 13vw, 74px);
  height: clamp(54px, 13vw, 74px);
  border: 0;
  border-radius: 0;
  color: #ffe982;
  background: transparent;
  display: grid;
  place-items: center;
  font-size: clamp(1.45rem, 4vw, 2.05rem);
  clip-path: polygon(27% 4%, 73% 4%, 96% 27%, 96% 73%, 73% 96%, 27% 96%, 4% 73%, 4% 27%);
  box-shadow:
    inset 0 0 0 2px rgba(105, 243, 255, 0.88),
    inset 0 0 0 5px rgba(255,255,255,0.08),
    inset 0 0 26px rgba(131, 78, 255, 0.35),
    0 0 0 2px rgba(255, 71, 222, 0.52),
    0 0 24px rgba(42, 246, 255, 0.35);
  backdrop-filter: blur(4px);
}

#lbIconBtn:hover,
#lbIconBtn:focus-visible {
  transform: scale(1.06);
  background: linear-gradient(135deg, rgba(255, 93, 211, 0.4), rgba(18, 5, 49, 0.9) 44%, rgba(44, 237, 255, 0.26));
  outline: none;
}

.music-control {
  border: 0;
  background: transparent;
  backdrop-filter: none;
  padding: 0;
  gap: 8px;
}

.music-toggle {
  width: clamp(54px, 13vw, 74px);
  height: clamp(54px, 13vw, 74px);
  border: 0;
  border-radius: 0;
  font-size: clamp(1.25rem, 3.5vw, 1.8rem);
  clip-path: polygon(27% 4%, 73% 4%, 96% 27%, 96% 73%, 73% 96%, 27% 96%, 4% 73%, 4% 27%);
  background: linear-gradient(135deg, rgba(255, 93, 211, 0.4), rgba(18, 5, 49, 0.9) 44%, rgba(44, 237, 255, 0.26));
  box-shadow:
    inset 0 0 0 2px rgba(105, 243, 255, 0.88),
    inset 0 0 0 5px rgba(255,255,255,0.08),
    inset 0 0 26px rgba(131, 78, 255, 0.35),
    0 0 0 2px rgba(255, 71, 222, 0.52),
    0 0 24px rgba(42, 246, 255, 0.35);
}

.music-volume {
  width: 92px;
  max-width: 24vw;
  accent-color: var(--cr-pink);
  filter: drop-shadow(0 0 8px rgba(42, 246, 255, 0.46));
}

#startOverlay {
  padding: 0;
  isolation: isolate;
  background: #04000d;
  overflow: hidden;
}

#startOverlay::before,
#startOverlay::after {
  display: none;
}

.start-background-layer,
.start-ambient-layer,
.start-vignette-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.start-background-layer {
  z-index: -4;
  background:
    linear-gradient(to bottom, rgba(12, 0, 40, 0.18), rgba(4, 0, 18, 0.5)),
    url("../assets/bg-portrait.png") center center / cover no-repeat;
  filter: saturate(1.06) contrast(1.03) brightness(0.84);
  transform: scale(1.02);
}

.start-ambient-layer {
  z-index: -3;
  opacity: 0.86;
  background:
    radial-gradient(circle at 26% 18%, rgba(42, 246, 255, 0.22), transparent 16%),
    radial-gradient(circle at 77% 24%, rgba(255, 71, 222, 0.22), transparent 17%),
    radial-gradient(circle at 50% 74%, rgba(139, 83, 255, 0.16), transparent 24%),
    repeating-radial-gradient(circle at 50% 50%, rgba(105, 243, 255, 0.10) 0 1px, transparent 1px 46px);
  mix-blend-mode: screen;
  animation: crAmbientDrift 9s ease-in-out infinite alternate;
}

.start-vignette-layer {
  z-index: -2;
  background:
    radial-gradient(circle at 50% 38%, rgba(20, 7, 54, 0.06), rgba(5, 0, 18, 0.15) 52%, rgba(0, 0, 0, 0.62) 100%),
    linear-gradient(to bottom, rgba(0,0,0,.22), rgba(0,0,0,0.04) 20%, rgba(0,0,0,0.08) 48%, rgba(0,0,0,0.26) 74%, rgba(0,0,0,0.5));
}

#startOverlay .start-overlay-stack {
  width: 100vw;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: calc(74px + env(safe-area-inset-top, 0px)) clamp(18px, 4vw, 40px) calc(34px + env(safe-area-inset-bottom, 0px));
}

.start-hero-content {
  width: min(96vw, 760px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.8vh, 18px);
  text-align: center;
}

.logo-title {
  position: relative;
  z-index: 2;
  margin: 0;
  width: 100%;
  text-align: center;
  line-height: 0.86;
  letter-spacing: clamp(0.01em, 0.5vw, 0.04em);
  font-family: var(--font-display);
  text-transform: uppercase;
  transform: rotateX(8deg) skewX(-5deg);
  transform-origin: center 60%;
  filter:
    drop-shadow(0 0 6px rgba(255,255,255,0.72))
    drop-shadow(0 0 22px rgba(0, 230, 255, 0.55))
    drop-shadow(0 0 40px rgba(255, 40, 220, 0.38))
    drop-shadow(0 18px 0 rgba(20, 6, 80, 0.90));
}

.logo-line {
  --stroke: clamp(3.5px, 1.1vw, 9px);
  --extrude-x: clamp(6px, 1.1vw, 14px);
  --extrude-y: clamp(10px, 1.6vw, 22px);
  position: relative;
  display: block;
  font-size: clamp(6.4rem, 27vw, 15.5rem);
  font-weight: 900;
  color: transparent;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  -webkit-background-clip: text;
  text-shadow: none;
}

/* White stroke layer — painted behind the gradient fill so no paint-order needed (Android compat) */
.logo-line::before {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  z-index: -1;
  color: rgba(255, 255, 255, 0.97);
  -webkit-text-fill-color: rgba(255, 255, 255, 0.97);
  -webkit-text-stroke: var(--stroke) rgba(255, 255, 255, 0.97);
  background: none;
}

/* Extrude / 3-D shadow layer */
.logo-line::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  z-index: -2;
  color: var(--extrude-color, #060a60);
  -webkit-text-fill-color: var(--extrude-color, #060a60);
  -webkit-text-stroke: var(--stroke) var(--extrude-stroke, #03054a);
  background: none;
  transform: translate(var(--extrude-x), var(--extrude-y));
  opacity: 1;
  filter: blur(0.5px);
  pointer-events: none;
}

#startOverlay .logo-line {
  color: transparent;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  -webkit-background-clip: text;
  text-shadow: none;
}

.logo-cave {
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.45) 0%, rgba(255,255,255,0.165) 14%, rgba(255,255,255,0) 34%),
    linear-gradient(180deg, #d4ffff 0%, #5bf8ff 15%, #00d8ff 35%, #0ea0ff 55%, #1e5cff 75%, #1a30d0 100%);
  --extrude-color: #05137a;
  --extrude-stroke: #020950;
}

.logo-rush {
  margin-top: clamp(-0.04em, -0.3vw, 0em);
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.45) 0%, rgba(255,255,255,0.165) 14%, rgba(255,255,255,0) 34%),
    linear-gradient(180deg, #c9a0ff 0%, #a030ff 20%, #d820ff 42%, #ff28c0 62%, #ff3080 80%, #ff5a70 100%);
  --extrude-color: #4a0868;
  --extrude-stroke: #300248;
}

.tagline {
  margin: 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-family: var(--font-ui-heavy);
  font-size: clamp(0.88rem, 2.9vw, 1.58rem);
  color: #eefcff;
  text-shadow:
    0 2px 0 rgba(5, 0, 19, 0.95),
    0 0 12px rgba(255,255,255,0.75),
    0 0 20px rgba(120, 226, 255, 0.35);
}

.menu-actions {
  width: min(88vw, 560px);
  display: grid;
  gap: clamp(12px, 2vh, 18px);
  justify-items: center;
  margin-top: clamp(8px, 1.8vh, 18px);
}

#startOverlay .install-note {
  color: #eefcff;
  text-shadow: 0 0 12px rgba(42, 246, 255, 0.32);
  font-size: 0.82rem;
  line-height: 1.35;
  max-width: 420px;
}

#modeOverlay h2,
#modeOverlay .select-logo-title {
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  color: #fff;
  -webkit-text-stroke: 1px rgba(213, 255, 255, 0.58);
  text-shadow: 0 0 10px rgba(255,255,255,0.68), 0 0 26px rgba(42, 246, 255, 0.52), 0 0 42px rgba(255, 71, 222, 0.34);
}

@media (orientation: landscape) {
  .start-background-layer {
    background:
      linear-gradient(to bottom, rgba(12, 0, 40, 0.12), rgba(4, 0, 18, 0.38)),
      url("../assets/bg-landscape.png") center center / cover no-repeat;
  }

  #startOverlay .start-overlay-stack {
    padding-top: calc(0px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .start-hero-content {
    gap: clamp(4px, 1.2vh, 10px);
  }

  .title-wrap {
    width: min(52vw, 540px);
    min-height: 100px;
    max-height: 172px;
    height: min(34vh, 172px);
  }

  .logo-title {
    transform: rotateX(6deg) skewX(-4deg);
    filter:
      drop-shadow(0 0 5px rgba(0, 0, 0, 0.68))
      drop-shadow(0 0 16px rgba(0, 0, 0, 0.52))
      drop-shadow(0 0 28px rgba(255, 40, 220, 0.34))
      drop-shadow(0 10px 0 rgba(20, 6, 80, 0.85));
  }

  .logo-line {
    --stroke: clamp(2px, 0.58vw, 5px);
    --extrude-x: clamp(4px, 0.7vw, 8px);
    --extrude-y: clamp(6px, 1vw, 12px);
    font-size: clamp(2.9rem, 7.8vw, 5.8rem);
    letter-spacing: clamp(0em, 0.22vw, 0.025em);
  }

  .logo-rush { margin-top: 0.04em; }
  .menu-actions { width: min(52vw, 490px); gap: 10px; }
  .neon-button { min-height: clamp(52px, 9vh, 82px); }
  .neon-button.secondary { min-height: clamp(42px, 6.5vh, 62px); }
  .neon-button span { font-size: clamp(1rem, 3.2vw, 1.8rem); }
  .neon-button.secondary span { font-size: clamp(0.72rem, .9vw, 1rem); }
}

@media (max-width: 430px) and (orientation: portrait) {
  .logo-line {
    font-size: clamp(5.8rem, 28.5vw, 8.6rem);
    --stroke: clamp(3px, 1vw, 7px);
  }
}

@media (max-width: 380px) and (orientation: portrait) {
  .title-wrap { min-height: 200px; }
  .logo-line { font-size: clamp(5.2rem, 28vw, 7.5rem); }
  .music-volume { display: none; }
}

@media (max-height: 680px) and (orientation: portrait) {
  .title-wrap {
    height: min(36vh, 290px);
    min-height: 200px;
  }
  .logo-line { font-size: clamp(5.4rem, 24vw, 10rem); }
  .menu-actions { gap: 10px; }
  .neon-button { min-height: 58px; }
  .neon-button.secondary { min-height: 46px; }
}

/* --------------------------------------------------------------------------
   Cave Rush V6 refinements: install CTA, control icons, select/game-over layout
   -------------------------------------------------------------------------- */
#startOverlay .neon-button {
  appearance: none !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
  color: #ffffff !important;
  font-family: var(--font-ui-heavy) !important;
  text-shadow: 0 2px 0 rgba(0,0,0,.72), 0 0 14px rgba(42,246,255,.45);
}

#startOverlay .neon-button::before,
#startOverlay .neon-button::after { pointer-events: none; }

#startOverlay .neon-button:not([hidden]) { display: inline-grid; place-items: center; }

#startOverlay .neon-button span,
#startOverlay #installAppButton {
  position: relative;
  z-index: 1;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #ffffff !important;
}

#startOverlay #installAppButton:not([hidden]) {
  font-size: clamp(.84rem, 2.6vw, 1.1rem);
  line-height: 1.1;
  padding-inline: 24px;
}

#startOverlay #installAppButton:not([hidden])::before,
#startOverlay #installAppButton:not([hidden])::after { z-index: -1; }

#startOverlay #installAppButton:not([hidden]) + #installAppNote,
#startOverlay #installAppNote:not([hidden]) {
  display: block !important;
  margin-top: -4px;
  font-family: var(--font-ui-heavy);
  letter-spacing: .04em;
  color: rgba(238,252,255,.9);
}

/* Modernised floating controls */
#lbIconBtn,
.music-toggle {
  color: transparent !important;
  text-indent: -9999px;
  overflow: hidden;
}

#lbIconBtn::before,
.music-toggle::before,
.music-toggle::after {
  content: '';
  position: absolute;
  display: block;
  text-indent: 0;
}

#lbIconBtn::before {
  width: 44%;
  height: 44%;
  left: 28%;
  top: 22%;
  border: 3px solid #ffe982;
  border-top-width: 5px;
  border-radius: 3px 3px 10px 10px;
  box-shadow: 0 0 10px rgba(255,233,130,.72), inset 0 0 8px rgba(255,255,255,.28);
}

#lbIconBtn::after {
  content: '';
  position: absolute;
  left: 34%;
  bottom: 22%;
  width: 32%;
  height: 17%;
  border-bottom: 4px solid #ffe982;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  filter: drop-shadow(0 0 8px rgba(255,233,130,.72));
}

.music-toggle { position: relative; }

.music-toggle::before {
  left: 29%;
  top: 24%;
  width: 21%;
  height: 42%;
  border-radius: 5px 0 0 5px;
  background: #eaffff;
  box-shadow: 0 0 12px rgba(105,243,255,.86);
  clip-path: polygon(0 32%, 42% 32%, 100% 0, 100% 100%, 42% 68%, 0 68%);
}

.music-toggle::after {
  right: 24%;
  top: 27%;
  width: 23%;
  height: 38%;
  border: 3px solid #eaffff;
  border-left: 0;
  border-radius: 0 999px 999px 0;
  box-shadow: 0 0 12px rgba(105,243,255,.74);
}

.music-toggle[aria-pressed="false"]::after {
  right: 26%;
  top: 22%;
  width: 4px;
  height: 54%;
  border: 0;
  border-radius: 999px;
  background: #ff5bd7;
  transform: rotate(42deg);
  box-shadow: 0 0 12px rgba(255,91,215,.9);
}

/* Select Mode: keep controls and content clear in short landscape. */
@media (orientation: landscape) {
  body:has(#modeOverlay.active) .music-control {
    left: calc(50% - min(42vw, 260px));
    top: max(100px, calc(env(safe-area-inset-top) + 76px));
    transform: translateX(-100%);
    z-index: 26;
  }
  body:has(#modeOverlay.active) #lbIconBtn {
    right: calc(50% - min(42vw, 260px));
    top: max(100px, calc(env(safe-area-inset-top) + 76px));
    transform: translateX(100%);
    z-index: 26;
  }
  body:has(#modeOverlay.active) .music-control .music-volume { display: none; }
}

@media (orientation: landscape) and (max-height: 620px) {
  #modeOverlay {
    padding: max(6px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    overflow: hidden;
  }

  #modeOverlay .panel {
    width: min(1060px, calc(100vw - 20px));
    max-height: calc(100dvh - 12px);
    padding: clamp(10px, 2vh, 16px) clamp(14px, 2.2vw, 22px);
    display: grid !important;
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    gap: clamp(5px, 1.2vh, 10px);
    align-content: start;
    overflow: hidden;
  }

  #modeOverlay .select-logo-title {
    font-size: clamp(1.6rem, 6.2vh, 2.35rem);
    margin: 0;
  }

  #modeOverlay .subtitle {
    max-width: min(720px, 78vw);
    margin: 0 auto;
    padding: 7px 14px;
    font-size: clamp(.72rem, 2.35vh, .94rem);
    line-height: 1.16;
    border-radius: 999px;
  }

  #modeOverlay .run-variant-section {
    margin: 0;
    gap: 5px;
  }

  #modeOverlay .run-variant-label,
  #modeOverlay .mode-theme-label {
    font-size: clamp(.56rem, 1.65vh, .68rem);
    margin-bottom: 0;
  }

  #modeOverlay .run-variant-picker { gap: 8px; }
  #modeOverlay .run-variant-chip {
    min-width: clamp(126px, 18vw, 150px);
    padding: 8px 18px;
    font-size: clamp(.82rem, 2.35vh, .96rem);
  }

  #modeOverlay .mode-theme-section {
    margin: 0;
    display: grid;
    gap: 4px;
  }

  #modeOverlay .theme-picker {
    justify-content: center;
    gap: 7px;
    padding: 0 4px 2px;
    mask-image: none;
  }

  #modeOverlay .theme-chip {
    min-width: clamp(112px, 14vw, 142px);
    max-width: clamp(112px, 14vw, 142px);
    padding: 7px 9px;
  }

  #modeOverlay .theme-chip strong { font-size: clamp(.68rem, 1.8vh, .82rem); }

  #modeOverlay .mode-grid {
    margin-top: 0;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(7px, 1.1vw, 12px);
    align-items: stretch;
    min-height: 0;
  }

  #modeOverlay .mode-card {
    height: auto;
    min-height: 0;
    max-height: 100%;
    padding: clamp(8px, 1.6vh, 12px) clamp(9px, 1.4vw, 13px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  #modeOverlay .mode-card .tag {
    align-self: center;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: clamp(.54rem, 1.55vh, .66rem);
  }

  #modeOverlay .mode-card strong { font-size: clamp(1rem, 3.2vh, 1.2rem); }
  #modeOverlay .mode-card em,
  #modeOverlay .mode-card span {
    -webkit-line-clamp: 3;
    line-clamp: 3;
    font-size: clamp(.68rem, 2.05vh, .84rem);
  }
}

@media (orientation: landscape) and (max-height: 430px) {
  body:has(#modeOverlay.active) .music-control,
  body:has(#modeOverlay.active) #lbIconBtn { top: max(82px, calc(env(safe-area-inset-top) + 58px)); }
  #modeOverlay .subtitle { display: none; }
  #modeOverlay .panel { grid-template-rows: auto auto auto minmax(0, 1fr); gap: 5px; }
  #modeOverlay .theme-chip { padding-block: 5px; }
  #modeOverlay .mode-card em,
  #modeOverlay .mode-card span { -webkit-line-clamp: 2; line-clamp: 2; }
}

/* --------------------------------------------------------------------------
   Cave Rush V7 refinements: smaller icons, compact portrait, polished select
   and consistent game-over styling in index.html and engine.html.
   -------------------------------------------------------------------------- */

/* Smaller, cleaner corner controls. */
#lbIconBtn,
.music-toggle,
.icon-corner-button {
  width: clamp(42px, 8.5vw, 54px) !important;
  height: clamp(42px, 8.5vw, 54px) !important;
  min-width: 0 !important;
  min-height: 0 !important;
  border-radius: 14px !important;
  clip-path: polygon(24% 0, 76% 0, 100% 24%, 100% 76%, 76% 100%, 24% 100%, 0 76%, 0 24%) !important;
  background: linear-gradient(135deg, rgba(255, 76, 218, .34), rgba(13, 8, 42, .92) 48%, rgba(39, 231, 255, .24)) !important;
  box-shadow:
    inset 0 0 0 1px rgba(105,243,255,.58),
    inset 0 0 18px rgba(139,83,255,.24),
    0 0 12px rgba(42,246,255,.20),
    0 0 18px rgba(255,71,222,.22) !important;
  filter: drop-shadow(0 0 9px rgba(255, 71, 222, .38)) !important;
}

#lbIconBtn { font-size: 0 !important; color: transparent !important; }

#lbIconBtn::before,
#lbIconBtn::after,
.music-toggle::before,
.music-toggle::after {
  content: '' !important;
  position: absolute !important;
  display: block !important;
  pointer-events: none !important;
}

#lbIconBtn::before {
  left: 31% !important;
  top: 22% !important;
  width: 38% !important;
  height: 34% !important;
  border: 3px solid #ffe772 !important;
  border-top-width: 5px !important;
  border-radius: 5px 5px 10px 10px !important;
  box-shadow: 0 0 9px rgba(255,231,114,.78), inset 0 0 7px rgba(255,255,255,.23) !important;
}

#lbIconBtn::after {
  left: 34% !important;
  bottom: 22% !important;
  width: 32% !important;
  height: 15% !important;
  border-bottom: 4px solid #ffe772 !important;
  border-left: 4px solid transparent !important;
  border-right: 4px solid transparent !important;
  filter: drop-shadow(0 0 7px rgba(255,231,114,.86)) !important;
}

.music-toggle { font-size: 0 !important; position: relative !important; color: transparent !important; }

.music-toggle::before {
  left: 28% !important;
  top: 27% !important;
  width: 22% !important;
  height: 38% !important;
  border-radius: 4px 0 0 4px !important;
  background: #f7ffff !important;
  clip-path: polygon(0 32%, 42% 32%, 100% 0, 100% 100%, 42% 68%, 0 68%) !important;
  box-shadow: 0 0 10px rgba(105,243,255,.78) !important;
}

.music-toggle::after {
  right: 25% !important;
  top: 29% !important;
  width: 22% !important;
  height: 34% !important;
  border: 3px solid #f7ffff !important;
  border-left: 0 !important;
  border-radius: 0 999px 999px 0 !important;
  box-shadow: 0 0 9px rgba(105,243,255,.72) !important;
}

.music-toggle[aria-pressed="false"]::after {
  right: 27% !important;
  top: 22% !important;
  width: 4px !important;
  height: 56% !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: #ff5bd7 !important;
  transform: rotate(42deg) !important;
  box-shadow: 0 0 12px rgba(255,91,215,.9) !important;
}

.music-control { padding: 0 !important; background: transparent !important; border: 0 !important; }

/* Portrait: keep Select Mode inside the mobile viewport. */
@media (orientation: portrait) {
  #modeOverlay {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)) !important;
    align-items: stretch !important;
    overflow: hidden !important;
  }
  #modeOverlay .panel {
    width: min(94vw, 560px) !important;
    max-height: calc(100dvh - 18px) !important;
    height: auto !important;
    overflow: auto !important;
    scrollbar-width: none;
    padding: clamp(12px, 2.1vh, 20px) clamp(12px, 4vw, 22px) !important;
    gap: clamp(7px, 1.4vh, 12px) !important;
  }
  #modeOverlay .panel::-webkit-scrollbar { display: none; }
  #modeOverlay .select-logo-title,
  #modeOverlay h2 { font-size: clamp(2.1rem, 7.4vh, 4.8rem) !important; }
  #modeOverlay .subtitle { font-size: clamp(.78rem, 1.7vh, .95rem) !important; padding: 7px 12px !important; line-height: 1.2 !important; }
  #modeOverlay .run-variant-section,
  #modeOverlay .mode-theme-section { margin: 0 !important; gap: 6px !important; }
  #modeOverlay .run-variant-picker { gap: 8px !important; }
  #modeOverlay .run-variant-chip { flex: 1 1 0 !important; min-width: 0 !important; padding: 10px 8px !important; font-size: clamp(.72rem, 2.1vh, .9rem) !important; }
  #modeOverlay .theme-picker { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; overflow: visible !important; mask-image: none !important; padding: 0 !important; }
  #modeOverlay .theme-chip { min-width: 0 !important; max-width: none !important; width: 100% !important; padding: 8px 8px !important; font-size: clamp(.66rem, 1.8vh, .82rem) !important; }
  #modeOverlay .mode-grid { display: grid !important; grid-template-columns: 1fr !important; gap: 8px !important; margin-top: 0 !important; }
  #modeOverlay .mode-card { min-height: clamp(76px, 11.6vh, 108px) !important; padding: 10px 12px !important; }
  #modeOverlay .mode-card strong { font-size: clamp(1.15rem, 3.2vh, 1.55rem) !important; }
  #modeOverlay .mode-card .tag { padding: 3px 10px !important; font-size: clamp(.52rem, 1.45vh, .68rem) !important; }
}

@media (orientation: portrait) and (max-height: 760px) {
  #modeOverlay .select-mode-copy { display: none !important; }
  #modeOverlay .panel { gap: 6px !important; padding-top: 10px !important; padding-bottom: 10px !important; }
  #modeOverlay .select-logo-title,
  #modeOverlay h2 { font-size: clamp(1.9rem, 6.4vh, 3.7rem) !important; }
  #modeOverlay .mode-card { min-height: clamp(62px, 10vh, 82px) !important; }
  #modeOverlay .theme-chip { padding-block: 6px !important; }
  #modeOverlay .run-variant-chip { padding-block: 8px !important; }
}

/* Landscape: give the panel real height, bigger mode buttons, and no collisions. */
@media (orientation: landscape) {
  #modeOverlay {
    padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)) !important;
    align-items: center !important;
    overflow: hidden !important;
  }
  #modeOverlay .panel {
    width: min(1180px, calc(100vw - 46px)) !important;
    min-height: min(86dvh, 620px) !important;
    max-height: calc(100dvh - 28px) !important;
    padding: clamp(18px, 3vh, 30px) clamp(20px, 3.2vw, 44px) !important;
    display: grid !important;
    grid-template-rows: auto auto auto auto 1fr !important;
    gap: clamp(9px, 1.8vh, 16px) !important;
    overflow: hidden !important;
  }
  #modeOverlay .select-logo-title,
  #modeOverlay h2 { font-size: clamp(2.5rem, 9vh, 5rem) !important; line-height: .86 !important; }
  #modeOverlay .subtitle { display: none !important; }
  #modeOverlay .run-variant-picker { gap: clamp(16px, 2.4vw, 28px) !important; }
  #modeOverlay .run-variant-chip { min-width: clamp(180px, 24vw, 300px) !important; padding: clamp(14px, 2.6vh, 22px) clamp(24px, 4vw, 46px) !important; font-size: clamp(1rem, 3.1vh, 1.35rem) !important; }
  #modeOverlay .theme-picker { display: grid !important; grid-template-columns: repeat(5, minmax(0, 1fr)) !important; gap: clamp(8px, 1.4vw, 16px) !important; width: 100% !important; padding: 0 !important; overflow: visible !important; mask-image: none !important; }
  #modeOverlay .theme-chip { min-width: 0 !important; max-width: none !important; width: 100% !important; padding: clamp(8px, 1.8vh, 13px) 10px !important; font-size: clamp(.72rem, 2.2vh, .95rem) !important; }
  #modeOverlay .mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: clamp(12px, 1.8vw, 22px) !important; align-items: stretch !important; min-height: 0 !important; }
  #modeOverlay .mode-card { min-height: clamp(128px, 27vh, 190px) !important; padding: clamp(16px, 3vh, 24px) clamp(14px, 2.2vw, 22px) !important; justify-content: center !important; }
  #modeOverlay .mode-card strong { font-size: clamp(1.45rem, 5vh, 2.35rem) !important; }
  body:has(#modeOverlay.active) .music-control {
    left: max(18px, env(safe-area-inset-left)) !important;
    top: max(18px, env(safe-area-inset-top)) !important;
    transform: none !important;
    z-index: 26 !important;
  }
  body:has(#modeOverlay.active) #lbIconBtn {
    right: max(18px, env(safe-area-inset-right)) !important;
    top: max(18px, env(safe-area-inset-top)) !important;
    transform: none !important;
    z-index: 26 !important;
  }
  body:has(#modeOverlay.active) .music-control .music-volume { display: none !important; }
}

@media (orientation: landscape) and (max-height: 430px) {
  #modeOverlay .panel { min-height: calc(100dvh - 18px) !important; max-height: calc(100dvh - 18px) !important; gap: 6px !important; padding: 10px 18px !important; }
  #modeOverlay .select-logo-title,
  #modeOverlay h2 { font-size: clamp(1.9rem, 7.4vh, 3.2rem) !important; }
  #modeOverlay .run-variant-chip { padding-block: 10px !important; font-size: clamp(.88rem, 2.9vh, 1.1rem) !important; }
  #modeOverlay .theme-chip { padding-block: 6px !important; }
  #modeOverlay .mode-card { min-height: clamp(88px, 22vh, 118px) !important; padding: 10px 12px !important; }
  #modeOverlay .mode-card strong { font-size: clamp(1.1rem, 4.2vh, 1.55rem) !important; }
}

/* Tone down the over-bright white halo across modal headings/buttons. */
#modeOverlay h2,
#modeOverlay .select-logo-title,
#gameOverOverlay h2,
#statsOverlay h2 {
  -webkit-text-stroke: .5px rgba(225, 255, 255, .38) !important;
  text-shadow:
    0 0 6px rgba(255,255,255,.34),
    0 0 16px rgba(42,246,255,.36),
    0 0 28px rgba(255,71,222,.22) !important;
}

/* Smaller, cleaner corner controls. Remove the old large backing panel. */
body:has(#modeOverlay.active) .music-control {
  width: 48px !important;
  height: 48px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: visible !important;
}

body:has(#modeOverlay.active) .music-toggle,
body:has(#modeOverlay.active) #lbIconBtn {
  width: 48px !important;
  height: 48px !important;
  min-width: 48px !important;
  min-height: 48px !important;
  padding: 0 !important;
  border: 1px solid rgba(105,243,255,.48) !important;
  border-radius: 0 !important;
  clip-path: polygon(24% 0, 76% 0, 100% 24%, 100% 76%, 76% 100%, 24% 100%, 0 76%, 0 24%) !important;
  background:
    linear-gradient(135deg, rgba(255,71,222,.28), rgba(18,5,49,.82) 52%, rgba(42,246,255,.18)) !important;
  box-shadow:
    0 0 0 1px rgba(255,71,222,.16),
    0 0 12px rgba(42,246,255,.14) !important;
  color: transparent !important;
  text-indent: -9999px !important;
  overflow: hidden !important;
}

body:has(#modeOverlay.active) #lbIconBtn::before,
body:has(#modeOverlay.active) .music-toggle::before {
  content: '' !important;
  position: absolute !important;
  inset: 11px !important;
  width: auto !important;
  height: auto !important;
  left: 11px !important;
  top: 11px !important;
  right: 11px !important;
  bottom: 11px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: center / contain no-repeat !important;
  box-shadow: none !important;
  filter: drop-shadow(0 0 5px rgba(105,243,255,.50)) !important;
  clip-path: none !important;
  transform: none !important;
}

body:has(#modeOverlay.active) #lbIconBtn::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none'%3E%3Cpath d='M20 12h24v8h9c0 12-6 20-17 22v6h9v6H19v-6h9v-6C17 40 11 32 11 20h9v-8Z' stroke='%23ffe982' stroke-width='5' stroke-linejoin='round'/%3E%3Cpath d='M20 20v-2m24 2v-2M28 42h8' stroke='%23ffe982' stroke-width='5' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  filter: drop-shadow(0 0 5px rgba(255,233,130,.55)) !important;
}

body:has(#modeOverlay.active) #lbIconBtn::after { display: none !important; }

body:has(#modeOverlay.active) .music-control .music-volume { display: none !important; }

/* Landscape spacing: remove the large dead zone and keep the layout balanced. */
@media (orientation: landscape) {
  #modeOverlay .panel {
    width: min(1200px, calc(100vw - 50px)) !important;
    min-height: min(84dvh, 600px) !important;
    max-height: calc(100dvh - 30px) !important;
    padding: clamp(18px, 3.2vh, 32px) clamp(22px, 3.5vw, 46px) !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    gap: clamp(8px, 1.45vh, 14px) !important;
  }

  #modeOverlay .select-logo-title,
  #modeOverlay h2 {
    font-size: clamp(2.25rem, 7.6vh, 4.25rem) !important;
    line-height: .9 !important;
    margin: 0 0 2px !important;
  }

  #modeOverlay .run-variant-section,
  #modeOverlay .mode-theme-section {
    margin: 0 !important;
    gap: clamp(6px, 1.15vh, 10px) !important;
  }

  #modeOverlay .run-variant-picker { gap: clamp(18px, 3vw, 36px) !important; }
  #modeOverlay .run-variant-chip {
    min-width: clamp(210px, 24vw, 330px) !important;
    min-height: clamp(54px, 9vh, 72px) !important;
    padding: 12px clamp(24px, 3.8vw, 46px) !important;
    font-size: clamp(1.05rem, 3.2vh, 1.42rem) !important;
  }

  #modeOverlay .theme-picker {
    gap: clamp(10px, 1.8vw, 20px) !important;
    margin-bottom: clamp(14px, 3.2vh, 28px) !important;
  }

  #modeOverlay .theme-chip {
    min-height: clamp(44px, 7vh, 58px) !important;
    padding: 8px 14px !important;
    font-size: clamp(.78rem, 2.35vh, 1rem) !important;
  }

  #modeOverlay .mode-grid {
    margin-top: 0 !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: clamp(16px, 2.4vw, 28px) !important;
    align-items: stretch !important;
  }

  #modeOverlay .mode-card {
    min-height: clamp(112px, 21vh, 150px) !important;
    padding: clamp(14px, 2.5vh, 20px) clamp(14px, 2vw, 24px) !important;
    display: grid !important;
    grid-template-rows: auto 1fr !important;
    align-content: center !important;
    justify-content: stretch !important;
  }

  #modeOverlay .mode-card strong {
    justify-content: center !important;
    font-size: clamp(1.35rem, 4.1vh, 2.05rem) !important;
    line-height: 1 !important;
  }

  #modeOverlay .mode-card .tag {
    max-width: min(92%, 330px) !important;
    margin-inline: auto !important;
    padding-inline: 16px !important;
  }

  body:has(#modeOverlay.active) .music-control {
    left: max(22px, env(safe-area-inset-left)) !important;
    top: max(22px, env(safe-area-inset-top)) !important;
  }
  body:has(#modeOverlay.active) #lbIconBtn {
    right: max(22px, env(safe-area-inset-right)) !important;
    top: max(22px, env(safe-area-inset-top)) !important;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  #modeOverlay .panel {
    min-height: calc(100dvh - 24px) !important;
    max-height: calc(100dvh - 24px) !important;
    padding: 12px 26px !important;
    gap: 6px !important;
  }
  #modeOverlay .select-logo-title,
  #modeOverlay h2 { font-size: clamp(1.9rem, 7vh, 3rem) !important; }
  #modeOverlay .run-variant-chip { min-height: 46px !important; padding-block: 8px !important; }
  #modeOverlay .theme-chip { min-height: 38px !important; padding-block: 6px !important; }
  #modeOverlay .theme-picker { margin-bottom: 8px !important; }
  #modeOverlay .mode-card { min-height: clamp(78px, 20vh, 105px) !important; padding: 9px 12px !important; }
  #modeOverlay .mode-card strong { font-size: clamp(1.05rem, 4vh, 1.48rem) !important; }
  .mode-card-icon { width: 42px !important; height: 42px !important; flex-basis: 42px !important; font-size: 1.3rem !important; margin-right: 8px !important; }
}

/* Portrait: keep the whole selector within a mobile viewport without scrolling past the bottom. */
@media (orientation: portrait) {
  body:has(#modeOverlay.active) .music-control,
  body:has(#modeOverlay.active) #lbIconBtn,
  body:has(#modeOverlay.active) .music-toggle {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
  }

  body:has(#modeOverlay.active) #lbIconBtn::before,
  body:has(#modeOverlay.active) .music-toggle::before { inset: 10px !important; }
  body:has(#modeOverlay.active) .music-toggle::after { height: 26px !important; left: 27px !important; top: 8px !important; }

  #modeOverlay .panel {
    max-height: calc(100dvh - 14px) !important;
    padding: clamp(10px, 1.8vh, 18px) clamp(12px, 3.8vw, 20px) !important;
    gap: clamp(6px, 1.15vh, 10px) !important;
  }
  #modeOverlay .select-logo-title,
  #modeOverlay h2 { font-size: clamp(1.8rem, 6.1vh, 4.2rem) !important; }
  #modeOverlay .run-variant-chip { min-height: 42px !important; padding-block: 7px !important; }
  #modeOverlay .theme-chip { min-height: 38px !important; padding-block: 6px !important; }
  #modeOverlay .mode-card { min-height: clamp(58px, 9.2vh, 86px) !important; padding: 8px 10px !important; }
  .mode-card-icon { width: 38px !important; height: 38px !important; flex-basis: 38px !important; font-size: 1.2rem !important; margin-right: 8px !important; }
}

/* Reduce the white blow-out glow while keeping the neon identity. */
#modeOverlay h2,
#modeOverlay .select-logo-title,
#gameOverOverlay h2,
#statsOverlay h2 {
  -webkit-text-stroke: 0 !important;
  text-shadow:
    0 0 4px rgba(255,255,255,.22),
    0 0 10px rgba(42,246,255,.26),
    0 0 18px rgba(255,71,222,.16) !important;
}

/* Corner controls: use the supplied SVG assets, centered inside compact neon housings. */
body:has(#modeOverlay.active) .music-control {
  left: max(18px, env(safe-area-inset-left)) !important;
  top: max(18px, env(safe-area-inset-top)) !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  z-index: 80 !important;
}

body:has(#modeOverlay.active) .music-control .music-volume { display: none !important; }

body:has(#modeOverlay.active) .music-toggle,
body:has(#modeOverlay.active) #lbIconBtn {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  box-sizing: border-box !important;
  padding: 0 !important;
  margin: 0 !important;
  display: grid !important;
  place-items: center !important;
  border: 1px solid rgba(76, 222, 255, .40) !important;
  border-radius: 0 !important;
  clip-path: polygon(24% 0, 76% 0, 100% 24%, 100% 76%, 76% 100%, 24% 100%, 0 76%, 0 24%) !important;
  background:
    linear-gradient(135deg, rgba(255,71,222,.26), rgba(17,5,46,.88) 54%, rgba(42,246,255,.14)) !important;
  box-shadow:
    inset 0 0 12px rgba(139,83,255,.18),
    0 0 8px rgba(42,246,255,.12) !important;
  font-size: 0 !important;
  line-height: 0 !important;
  color: transparent !important;
  text-indent: 0 !important;
  overflow: hidden !important;
}

body:has(#modeOverlay.active) #lbIconBtn {
  right: max(18px, env(safe-area-inset-right)) !important;
  top: max(18px, env(safe-area-inset-top)) !important;
  z-index: 80 !important;
}

body:has(#modeOverlay.active) .music-toggle::before,
body:has(#modeOverlay.active) #lbIconBtn::before {
  content: '' !important;
  position: absolute !important;
  inset: 8px !important;
  width: auto !important;
  height: auto !important;
  left: 8px !important;
  top: 8px !important;
  right: 8px !important;
  bottom: 8px !important;
  display: block !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-size: contain !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  clip-path: none !important;
  transform: none !important;
  opacity: 1 !important;
}

body:has(#modeOverlay.active) .music-toggle::after,
body:has(#modeOverlay.active) #lbIconBtn::after {
  content: none !important;
  display: none !important;
}

body:has(#modeOverlay.active) #lbIconBtn::before {
  background-image: var(--cr-icon-trophy) !important;
  filter: drop-shadow(0 0 5px rgba(255,226,89,.44)) !important;
}

/* Select Mode landscape: use the modal height more evenly and stop content bunching. */
@media (orientation: landscape) {
  #modeOverlay {
    align-items: center !important;
    justify-content: center !important;
  }
  #modeOverlay .panel {
    width: min(1220px, calc(100vw - 42px)) !important;
    min-height: min(88dvh, 650px) !important;
    max-height: calc(100dvh - 24px) !important;
    padding: clamp(18px, 3.2vh, 34px) clamp(24px, 4vw, 54px) !important;
    gap: clamp(9px, 1.85vh, 18px) !important;
    justify-content: flex-start !important;
  }
  #modeOverlay .select-logo-title,
  #modeOverlay h2 {
    font-size: clamp(2rem, 6.6vh, 3.7rem) !important;
    line-height: .9 !important;
    margin-bottom: 0 !important;
  }
  #modeOverlay .run-variant-section,
  #modeOverlay .mode-theme-section {
    gap: clamp(6px, 1vh, 10px) !important;
  }
  #modeOverlay .run-variant-picker {
    width: min(560px, 58vw) !important;
    gap: clamp(16px, 3vw, 34px) !important;
  }
  #modeOverlay .run-variant-chip {
    min-height: clamp(48px, 8.5vh, 66px) !important;
    padding-inline: clamp(24px, 4vw, 44px) !important;
    font-size: clamp(1rem, 2.8vh, 1.42rem) !important;
  }
  #modeOverlay .theme-picker {
    width: 100% !important;
    justify-content: space-between !important;
    gap: clamp(10px, 1.8vw, 22px) !important;
    margin: 0 0 clamp(12px, 2.7vh, 28px) !important;
  }
  #modeOverlay .theme-chip {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: 220px !important;
    min-height: clamp(40px, 7vh, 56px) !important;
    font-size: clamp(.72rem, 2.1vh, 1.02rem) !important;
  }
  #modeOverlay .mode-grid {
    margin-top: clamp(8px, 2.6vh, 24px) !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: clamp(18px, 3.2vw, 46px) !important;
    align-items: stretch !important;
  }
  #modeOverlay .mode-card {
    min-height: clamp(108px, 21vh, 160px) !important;
    padding: clamp(14px, 2.8vh, 24px) clamp(16px, 2.6vw, 28px) !important;
    justify-content: center !important;
  }
  #modeOverlay .mode-card .tag {
    max-width: 86% !important;
    padding-inline: 14px !important;
    font-size: clamp(.6rem, 1.65vh, .82rem) !important;
  }
  #modeOverlay .mode-card strong {
    gap: clamp(10px, 1.6vw, 18px) !important;
    font-size: clamp(1.15rem, 3.8vh, 1.9rem) !important;
  }
  .mode-card-icon {
    width: clamp(42px, 8.2vh, 58px) !important;
    height: clamp(42px, 8.2vh, 58px) !important;
    flex-basis: clamp(42px, 8.2vh, 58px) !important;
    margin-right: 0 !important;
  }
}

@media (orientation: landscape) and (max-height: 460px) {
  body:has(#modeOverlay.active) .music-control,
  body:has(#modeOverlay.active) .music-toggle,
  body:has(#modeOverlay.active) #lbIconBtn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
  }
  body:has(#modeOverlay.active) .music-toggle::before,
  body:has(#modeOverlay.active) #lbIconBtn::before { inset: 7px !important; }
  #modeOverlay .panel {
    min-height: calc(100dvh - 20px) !important;
    padding: 10px 24px !important;
    gap: 5px !important;
  }
  #modeOverlay .select-logo-title,
  #modeOverlay h2 { font-size: clamp(1.7rem, 6.2vh, 2.45rem) !important; }
  #modeOverlay .run-variant-chip { min-height: 40px !important; }
  #modeOverlay .theme-chip { min-height: 32px !important; }
  #modeOverlay .theme-picker { margin-bottom: 5px !important; }
  #modeOverlay .mode-grid { margin-top: 4px !important; gap: 18px !important; }
  #modeOverlay .mode-card { min-height: clamp(70px, 19vh, 96px) !important; padding: 8px 10px !important; }
  #modeOverlay .mode-card strong { font-size: clamp(1rem, 3.6vh, 1.38rem) !important; }
  .mode-card-icon { width: 38px !important; height: 38px !important; flex-basis: 38px !important; }
}

@media (orientation: portrait) {
  body:has(#modeOverlay.active) .music-control,
  body:has(#modeOverlay.active) .music-toggle,
  body:has(#modeOverlay.active) #lbIconBtn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
  }
  body:has(#modeOverlay.active) .music-toggle::before,
  body:has(#modeOverlay.active) #lbIconBtn::before { inset: 8px !important; }
}

/* Cleaner, larger corner SVG buttons, centered precisely in their housings. */
body:has(#modeOverlay.active) .music-control {
  left: max(16px, env(safe-area-inset-left)) !important;
  top: max(16px, env(safe-area-inset-top)) !important;
  width: 60px !important;
  height: 60px !important;
  min-width: 60px !important;
  min-height: 60px !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
  z-index: 110 !important;
}

body:has(#modeOverlay.active) .music-control .music-volume { display: none !important; }

body:has(#modeOverlay.active) .music-toggle,
body:has(#modeOverlay.active) #lbIconBtn {
  width: 60px !important;
  height: 60px !important;
  min-width: 60px !important;
  min-height: 60px !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  border: 1.5px solid rgba(88, 228, 255, .62) !important;
  border-radius: 0 !important;
  clip-path: polygon(25% 0, 75% 0, 100% 25%, 100% 75%, 75% 100%, 25% 100%, 0 75%, 0 25%) !important;
  background:
    linear-gradient(135deg, rgba(255,71,222,.34), rgba(20,5,55,.92) 52%, rgba(42,246,255,.22)) !important;
  box-shadow:
    inset 0 0 16px rgba(139,83,255,.26),
    0 0 10px rgba(42,246,255,.20),
    0 0 16px rgba(255,71,222,.12) !important;
  font-size: 0 !important;
  line-height: 0 !important;
  color: transparent !important;
  text-indent: -9999px !important;
  overflow: hidden !important;
}

body:has(#modeOverlay.active) #lbIconBtn {
  right: max(16px, env(safe-area-inset-right)) !important;
  top: max(16px, env(safe-area-inset-top)) !important;
  z-index: 110 !important;
}

body:has(#modeOverlay.active) .music-toggle::before,
body:has(#modeOverlay.active) #lbIconBtn::before {
  content: '' !important;
  position: absolute !important;
  inset: 12px !important;
  display: block !important;
  width: auto !important;
  height: auto !important;
  left: 12px !important;
  right: 12px !important;
  top: 12px !important;
  bottom: 12px !important;
  transform: none !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: contain !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  clip-path: none !important;
  opacity: 1 !important;
}

body:has(#modeOverlay.active) #lbIconBtn::before {
  background-image: var(--cr-icon-trophy) !important;
  filter: drop-shadow(0 0 5px rgba(255,232,106,.46)) !important;
}

body:has(#modeOverlay.active) .music-toggle::after,
body:has(#modeOverlay.active) #lbIconBtn::after { display: none !important; content: none !important; }

/* Soften over-bright text glows across this theme. */
#modeOverlay .select-logo-title,
#modeOverlay h2,
#gameOverOverlay h2,
#statsOverlay h2 {
  text-shadow:
    0 0 3px rgba(255,255,255,.20),
    0 0 8px rgba(42,246,255,.24),
    0 0 14px rgba(255,71,222,.16) !important;
}

/* Focus the landscape Select Mode layout: less empty space, cleaner button sizing. */
@media (orientation: landscape) {
  #modeOverlay .panel {
    width: min(1180px, calc(100vw - 44px)) !important;
    min-height: min(88dvh, 650px) !important;
    max-height: calc(100dvh - 22px) !important;
    padding: clamp(18px, 3vh, 28px) clamp(26px, 4vw, 54px) clamp(24px, 4vh, 38px) !important;
    gap: clamp(8px, 1.25vh, 14px) !important;
  }
  #modeOverlay .select-logo-title,
  #modeOverlay h2 {
    font-size: clamp(2.15rem, 7.0vh, 3.7rem) !important;
    margin-bottom: 0 !important;
  }
  #modeOverlay .run-variant-picker {
    gap: clamp(20px, 3.2vw, 44px) !important;
  }
  #modeOverlay .run-variant-chip {
    min-width: clamp(220px, 25vw, 350px) !important;
    min-height: clamp(58px, 9.4vh, 78px) !important;
    padding: clamp(12px, 2vh, 18px) clamp(26px, 4vw, 52px) !important;
    font-size: clamp(1.05rem, 3vh, 1.42rem) !important;
  }
  #modeOverlay .theme-picker {
    gap: clamp(12px, 2vw, 24px) !important;
    margin-bottom: clamp(14px, 3vh, 26px) !important;
  }
  #modeOverlay .theme-chip {
    min-height: clamp(42px, 6.8vh, 56px) !important;
    font-size: clamp(.74rem, 2.2vh, .98rem) !important;
  }
  #modeOverlay .mode-grid {
    gap: clamp(20px, 3.1vw, 38px) !important;
  }
  #modeOverlay .mode-card {
    min-height: clamp(120px, 23vh, 165px) !important;
    padding: clamp(12px, 2.3vh, 20px) clamp(14px, 2vw, 22px) !important;
    border-radius: 18px !important;
  }
  #modeOverlay .mode-card strong {
    font-size: clamp(1.25rem, 3.9vh, 1.95rem) !important;
  }
  #modeOverlay .mode-card .tag {
    max-width: calc(100% - 42px) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

/* Very shallow landscape screens: stay inside the viewport. */
@media (orientation: landscape) and (max-height: 460px) {
  body:has(#modeOverlay.active) .music-control,
  body:has(#modeOverlay.active) .music-toggle,
  body:has(#modeOverlay.active) #lbIconBtn {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
  }
  body:has(#modeOverlay.active) .music-toggle::before,
  body:has(#modeOverlay.active) #lbIconBtn::before { inset: 10px !important; }
  #modeOverlay .panel {
    min-height: calc(100dvh - 18px) !important;
    max-height: calc(100dvh - 18px) !important;
    padding: 10px 26px 14px !important;
    gap: 4px !important;
  }
  #modeOverlay .run-variant-chip { min-height: 42px !important; padding-block: 7px !important; }
  #modeOverlay .theme-chip { min-height: 34px !important; padding-block: 4px !important; }
  #modeOverlay .theme-picker { margin-bottom: 6px !important; }
  #modeOverlay .mode-card { min-height: clamp(74px, 19vh, 96px) !important; padding: 8px 10px !important; }
  #modeOverlay .mode-card .mode-card-icon { width: 38px !important; height: 38px !important; min-width: 38px !important; font-size: 1.2rem !important; }
}

/* Portrait Select Mode should still fit a phone viewport. */
@media (orientation: portrait) {
  body:has(#modeOverlay.active) .music-control,
  body:has(#modeOverlay.active) .music-toggle,
  body:has(#modeOverlay.active) #lbIconBtn {
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    min-height: 50px !important;
  }
  body:has(#modeOverlay.active) .music-toggle::before,
  body:has(#modeOverlay.active) #lbIconBtn::before { inset: 10px !important; }
  #modeOverlay .panel {
    max-height: calc(100dvh - 14px) !important;
    padding: clamp(10px, 1.7vh, 17px) clamp(12px, 3.8vw, 20px) !important;
  }
  #modeOverlay .run-variant-chip,
  #modeOverlay .theme-chip { clip-path: polygon(7% 0, 93% 0, 100% 50%, 93% 100%, 7% 100%, 0 50%) !important; }
  #modeOverlay .mode-card .mode-card-icon {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    font-size: 1.22rem !important;
  }
}

/* Top corner icons: use supplied SVGs with solid rounded housings and lower transparency. */
#lbIconBtn,
.music-toggle {
  position: relative !important;
  width: 64px !important;
  height: 64px !important;
  min-width: 64px !important;
  min-height: 64px !important;
  border-radius: 20px !important;
  border: 2px solid rgba(109, 238, 255, 0.65) !important;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01)) padding-box,
    linear-gradient(145deg, rgba(42,246,255,0.55), rgba(255,71,222,0.45)) border-box !important;
  box-shadow:
    0 0 18px rgba(42,246,255,0.18),
    0 0 18px rgba(255,71,222,0.14),
    inset 0 0 24px rgba(121, 67, 255, 0.18) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 0 !important;
  text-indent: -9999px !important;
  overflow: hidden !important;
}

#lbIconBtn::before,
.music-toggle::before {
  content: '' !important;
  position: absolute !important;
  inset: 15px !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: contain !important;
  z-index: 1 !important;
}

#lbIconBtn::before {
  background-image: var(--cr-icon-trophy) !important;
  filter: drop-shadow(0 0 4px rgba(255, 234, 125, 0.45)) !important;
}

.music-toggle::before {
  background-image: var(--cr-icon-sound-on) !important;
  filter: drop-shadow(0 0 4px rgba(42,246,255,0.42)) !important;
}

.music-toggle[aria-pressed="false"]::before {
  background-image: var(--cr-icon-sound-off) !important;
}

#lbIconBtn::after,
.music-toggle::after { display: none !important; content: none !important; }

.music-control {
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.music-volume { display: none !important; }

@media (max-width: 640px) {
  #lbIconBtn,
  .music-toggle { width: 56px !important; height: 56px !important; min-width: 56px !important; min-height: 56px !important; border-radius: 18px !important; }
  #lbIconBtn::before,
  .music-toggle::before { inset: 13px !important; }
}

#modeOverlay .select-logo-title,
#modeOverlay h2 {
  margin: 0 0 4px !important;
  font-size: clamp(2.4rem, 5.8vw, 4rem) !important;
  line-height: .9 !important;
  text-shadow: 0 0 3px rgba(255,255,255,0.18), 0 0 8px rgba(42,246,255,0.18), 0 0 12px rgba(255,71,222,0.10) !important;
  -webkit-text-stroke: 1px rgba(225, 247, 255, 0.32) !important;
}

/* ============================================================================
   Cave Rush V12: position fix, icon layout, neon angled theme chips,
   emoji mode icons, tight landscape layout, proper icon separation.
   ============================================================================ */

/* --- Critical fix: #lbIconBtn lost position:fixed in V11 ---
   V11 added position:relative!important globally which broke the fixed
   corner position of the standalone trophy anchor. This restores it.  */
#lbIconBtn {
  position: fixed !important;
  top: max(16px, env(safe-area-inset-top)) !important;
  right: max(16px, env(safe-area-inset-right)) !important;
  left: auto !important;
}

/* Ensure music-control is fixed on the LEFT at all times */
.music-control {
  position: fixed !important;
  top: max(16px, env(safe-area-inset-top)) !important;
  left: max(16px, env(safe-area-inset-left)) !important;
  right: auto !important;
}

/* Select Mode: confirm opposite corners (sound ← left, trophy → right) */
body:has(#modeOverlay.active) .music-control {
  left: max(16px, env(safe-area-inset-left)) !important;
  right: auto !important;
  top: max(16px, env(safe-area-inset-top)) !important;
}

body:has(#modeOverlay.active) #lbIconBtn {
  right: max(16px, env(safe-area-inset-right)) !important;
  left: auto !important;
  top: max(16px, env(safe-area-inset-top)) !important;
}

/* V12 addendum: ensure lbIconBtn z-index is above all overlays on start screen */
#lbIconBtn {
  z-index: 90 !important;
}

/* Start screen: give the icon buttons a bit more margin from edge */
body:not(:has(#modeOverlay.active)) #lbIconBtn {
  top: max(16px, env(safe-area-inset-top)) !important;
  right: max(16px, env(safe-area-inset-right)) !important;
}

body:not(:has(#modeOverlay.active)) .music-control {
  top: max(16px, env(safe-area-inset-top)) !important;
  left: max(16px, env(safe-area-inset-left)) !important;
}

/* Corner controls: cut-corner housing with a real neon edge. */
#lbIconBtn,
.music-toggle {
  border: 0 !important;
  border-radius: 0 !important;
  clip-path: polygon(18% 0, 82% 0, 100% 18%, 100% 82%, 82% 100%, 18% 100%, 0 82%, 0 18%) !important;
  background:
    linear-gradient(135deg, rgba(42,246,255,.78), rgba(142,86,255,.68), rgba(255,71,222,.72)) border-box !important;
  box-shadow:
    0 0 10px rgba(42,246,255,.18),
    0 0 12px rgba(255,71,222,.14) !important;
  isolation: isolate !important;
}

#lbIconBtn::after,
.music-toggle::after {
  content: '' !important;
  display: block !important;
  position: absolute !important;
  inset: 2px !important;
  clip-path: polygon(18% 0, 82% 0, 100% 18%, 100% 82%, 82% 100%, 18% 100%, 0 82%, 0 18%) !important;
  background:
    radial-gradient(circle at 32% 22%, rgba(42,246,255,.22), transparent 45%),
    linear-gradient(145deg, rgba(17,7,48,.96), rgba(8,2,28,.98)) !important;
  z-index: -1 !important;
}

#lbIconBtn::before {
  inset: 11px !important;
  filter: none !important;
  z-index: 1 !important;
}

.music-toggle::before {
  inset: 12px !important;
  filter: drop-shadow(0 0 2px rgba(42,246,255,.28)) !important;
  z-index: 1 !important;
}

@media (max-width: 640px) {
  #lbIconBtn::before { inset: 9px !important; }
  .music-toggle::before { inset: 10px !important; }
}

/* Hide the leaderboard trophy while Detailed Stats is open. */
body:has(#statsOverlay.active) #lbIconBtn {
  display: none !important;
}

/* Use the same cut-corner, neon-edged housing across Startup, Select Mode and Game Over. */
#lbIconBtn,
.music-toggle,
body:has(#modeOverlay.active) #lbIconBtn,
body:has(#modeOverlay.active) .music-toggle {
  width: var(--cr-v14-corner-size) !important;
  height: var(--cr-v14-corner-size) !important;
  min-width: var(--cr-v14-corner-size) !important;
  min-height: var(--cr-v14-corner-size) !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  clip-path: var(--cr-v14-corner-border) !important;
  background: linear-gradient(135deg, rgba(42,246,255,.95), rgba(132,86,255,.84) 48%, rgba(255,71,222,.92)) !important;
  box-shadow:
    0 0 0 1px rgba(42,246,255,.22),
    0 0 12px rgba(42,246,255,.16),
    0 0 14px rgba(255,71,222,.12) !important;
  display: grid !important;
  place-items: center !important;
  overflow: hidden !important;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 0 !important;
  text-indent: -9999px !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  isolation: isolate !important;
}

#lbIconBtn::after,
.music-toggle::after,
body:has(#modeOverlay.active) #lbIconBtn::after,
body:has(#modeOverlay.active) .music-toggle::after {
  content: '' !important;
  display: block !important;
  position: absolute !important;
  inset: 3px !important;
  clip-path: var(--cr-v14-corner-border) !important;
  background:
    radial-gradient(circle at 28% 18%, rgba(42,246,255,.30), transparent 42%),
    radial-gradient(circle at 78% 82%, rgba(255,71,222,.22), transparent 48%),
    linear-gradient(145deg, rgba(19,8,58,.98), rgba(5,1,24,.99)) !important;
  z-index: -1 !important;
}

#lbIconBtn::before,
.music-toggle::before,
body:has(#modeOverlay.active) #lbIconBtn::before,
body:has(#modeOverlay.active) .music-toggle::before {
  content: '' !important;
  position: absolute !important;
  display: block !important;
  inset: 11px !important;
  left: 11px !important;
  right: 11px !important;
  top: 11px !important;
  bottom: 11px !important;
  width: auto !important;
  height: auto !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: contain !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  clip-path: none !important;
  opacity: 1 !important;
  transform: none !important;
  z-index: 1 !important;
}

#lbIconBtn::before,
body:has(#modeOverlay.active) #lbIconBtn::before {
  background-image: var(--cr-icon-trophy) !important;
  filter: drop-shadow(0 0 1px rgba(255,255,255,.20)) !important;
}

.music-control,
body:has(#modeOverlay.active) .music-control {
  position: fixed !important;
  top: max(20px, env(safe-area-inset-top)) !important;
  left: max(20px, env(safe-area-inset-left)) !important;
  width: var(--cr-v14-corner-size) !important;
  height: var(--cr-v14-corner-size) !important;
  min-width: var(--cr-v14-corner-size) !important;
  min-height: var(--cr-v14-corner-size) !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  filter: none !important;
  overflow: visible !important;
  z-index: 120 !important;
}

#lbIconBtn,
body:has(#modeOverlay.active) #lbIconBtn {
  position: fixed !important;
  top: max(20px, env(safe-area-inset-top)) !important;
  right: max(20px, env(safe-area-inset-right)) !important;
  z-index: 120 !important;
}

.music-control .music-volume { display: none !important; }

@media (max-width: 640px) {
  :root { --cr-v14-corner-size: 52px; }
  .music-control,
  body:has(#modeOverlay.active) .music-control {
    top: max(18px, env(safe-area-inset-top)) !important;
    left: max(18px, env(safe-area-inset-left)) !important;
  }
  #lbIconBtn,
  body:has(#modeOverlay.active) #lbIconBtn {
    top: max(18px, env(safe-area-inset-top)) !important;
    right: max(18px, env(safe-area-inset-right)) !important;
  }
  #lbIconBtn::before,
  .music-toggle::before,
  body:has(#modeOverlay.active) #lbIconBtn::before,
  body:has(#modeOverlay.active) .music-toggle::before {
    inset: 10px !important;
    left: 10px !important;
    right: 10px !important;
    top: 10px !important;
    bottom: 10px !important;
  }
}

/* Game Over gets the exact same trophy treatment as the first two screens. */
body:has(#gameOverOverlay.active) #lbIconBtn {
  --cr-v14-corner-size: 56px;
  top: max(18px, env(safe-area-inset-top)) !important;
  right: max(18px, env(safe-area-inset-right)) !important;
}

body:has(#gameOverOverlay.active) #lbIconBtn::before {
  inset: 11px !important;
  filter: drop-shadow(0 0 1px rgba(255,255,255,.20)) !important;
}

/* Left/right wrappers only position the shared controls. */
.music-control,
body:has(#modeOverlay.active) .music-control,
body:has(#gameOverOverlay.active) .music-control {
  position: fixed !important;
  top: max(22px, env(safe-area-inset-top)) !important;
  left: max(22px, env(safe-area-inset-left)) !important;
  width: var(--cr-corner-size) !important;
  height: var(--cr-corner-size) !important;
  min-width: var(--cr-corner-size) !important;
  min-height: var(--cr-corner-size) !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  filter: none !important;
  overflow: visible !important;
  z-index: 130 !important;
}

.music-control::before,
.music-control::after,
.music-control .music-volume {
  display: none !important;
  content: none !important;
}

#lbIconBtn,
.music-toggle,
body:has(#modeOverlay.active) #lbIconBtn,
body:has(#modeOverlay.active) .music-toggle,
body:has(#gameOverOverlay.active) #lbIconBtn,
body:has(#gameOverOverlay.active) .music-toggle {
  --cr-corner-icon: var(--cr-icon-trophy);
  position: relative !important;
  display: grid !important;
  place-items: center !important;
  width: var(--cr-corner-size) !important;
  height: var(--cr-corner-size) !important;
  min-width: var(--cr-corner-size) !important;
  min-height: var(--cr-corner-size) !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  outline: 0 !important;
  clip-path: var(--cr-corner-shape) !important;
  background: linear-gradient(135deg, #41efff 0%, #815cff 52%, #f044d9 100%) !important;
  box-shadow:
    0 0 0 1px rgba(42, 246, 255, .20),
    0 0 12px rgba(42, 246, 255, .16),
    0 0 12px rgba(255, 71, 222, .14) !important;
  color: transparent !important;
  font-size: 0 !important;
  line-height: 0 !important;
  text-indent: 0 !important;
  text-shadow: none !important;
  text-decoration: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: hidden !important;
  isolation: isolate !important;
  -webkit-tap-highlight-color: transparent !important;
}

#lbIconBtn,
body:has(#modeOverlay.active) #lbIconBtn,
body:has(#gameOverOverlay.active) #lbIconBtn {
  position: fixed !important;
  top: max(22px, env(safe-area-inset-top)) !important;
  right: max(22px, env(safe-area-inset-right)) !important;
  z-index: 130 !important;
}

/* Inner face of the octagon. This replaces all previous corner artwork. */
#lbIconBtn::before,
.music-toggle::before,
body:has(#modeOverlay.active) #lbIconBtn::before,
body:has(#modeOverlay.active) .music-toggle::before,
body:has(#gameOverOverlay.active) #lbIconBtn::before,
body:has(#gameOverOverlay.active) .music-toggle::before {
  content: '' !important;
  position: absolute !important;
  display: block !important;
  inset: 3px !important;
  width: auto !important;
  height: auto !important;
  left: 3px !important;
  right: 3px !important;
  top: 3px !important;
  bottom: 3px !important;
  border: 0 !important;
  border-radius: 0 !important;
  clip-path: var(--cr-corner-shape) !important;
  background:
    radial-gradient(circle at 28% 18%, rgba(97, 246, 255, .35), transparent 42%),
    radial-gradient(circle at 80% 86%, rgba(255, 71, 222, .32), transparent 46%),
    linear-gradient(145deg, rgba(22, 9, 68, .98), rgba(8, 2, 30, .99)) !important;
  box-shadow: inset 0 0 18px rgba(42, 246, 255, .10) !important;
  filter: none !important;
  opacity: 1 !important;
  transform: none !important;
  z-index: 0 !important;
}

/* Actual icon: one centered SVG layer, no old square/hand-drawn remnants. */
#lbIconBtn::after,
.music-toggle::after,
body:has(#modeOverlay.active) #lbIconBtn::after,
body:has(#modeOverlay.active) .music-toggle::after,
body:has(#gameOverOverlay.active) #lbIconBtn::after,
body:has(#gameOverOverlay.active) .music-toggle::after {
  content: '' !important;
  position: absolute !important;
  display: block !important;
  inset: 13px !important;
  width: auto !important;
  height: auto !important;
  left: 13px !important;
  right: 13px !important;
  top: 13px !important;
  bottom: 13px !important;
  border: 0 !important;
  border-radius: 0 !important;
  clip-path: none !important;
  background: var(--cr-corner-icon) center / contain no-repeat !important;
  box-shadow: none !important;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, .20)) !important;
  opacity: 1 !important;
  transform: none !important;
  z-index: 1 !important;
}

#lbIconBtn:hover,
#lbIconBtn:focus-visible,
.music-toggle:hover,
.music-toggle:focus-visible {
  transform: translateY(-1px) scale(1.03) !important;
  box-shadow:
    0 0 0 1px rgba(42, 246, 255, .28),
    0 0 16px rgba(42, 246, 255, .22),
    0 0 18px rgba(255, 71, 222, .18) !important;
}

@media (max-width: 640px) {
  :root { --cr-corner-size: 54px; }
  .music-control,
  body:has(#modeOverlay.active) .music-control,
  body:has(#gameOverOverlay.active) .music-control {
    top: max(18px, env(safe-area-inset-top)) !important;
    left: max(18px, env(safe-area-inset-left)) !important;
  }
  #lbIconBtn,
  body:has(#modeOverlay.active) #lbIconBtn,
  body:has(#gameOverOverlay.active) #lbIconBtn {
    top: max(18px, env(safe-area-inset-top)) !important;
    right: max(18px, env(safe-area-inset-right)) !important;
  }
  #lbIconBtn::after,
  .music-toggle::after,
  body:has(#modeOverlay.active) #lbIconBtn::after,
  body:has(#modeOverlay.active) .music-toggle::after,
  body:has(#gameOverOverlay.active) #lbIconBtn::after,
  body:has(#gameOverOverlay.active) .music-toggle::after {
    inset: 12px !important;
    left: 12px !important;
    right: 12px !important;
    top: 12px !important;
    bottom: 12px !important;
  }
}

/* Keep Detailed Stats clear of the top-right trophy. */
body:has(#statsOverlay.active) #lbIconBtn {
  display: none !important;
}

html.route-select-mode #startOverlay { display: none !important; }

html.installed-web-app #installAppButton,
    html.installed-web-app #installAppNote {
      display: none !important;
    }

#lbIconBtn {
      position: fixed;
      top: max(14px, env(safe-area-inset-top));
      right: max(14px, env(safe-area-inset-right));
      z-index: 20;
      width: 42px;
      height: 42px;
      border-radius: 12px;
      border: 1px solid transparent;
      background: transparent;
      backdrop-filter: blur(10px);
      font-size: 1.3rem;
      display: grid;
      place-items: center;
      cursor: pointer;
      transition: background 140ms, border-color 140ms, transform 140ms;
      text-decoration: none;
    }

#lbIconBtn:hover { transform: scale(1.08); }

body.playing #lbIconBtn { opacity: 0; pointer-events: none; }

.music-control {
      position: fixed;
      top: max(14px, env(safe-area-inset-top));
      left: max(14px, env(safe-area-inset-left));
      z-index: 21;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 10px;
      border: 1px solid rgba(99, 219, 255, 0.26);
      border-radius: 14px;
      background: rgba(3, 8, 18, 0.62);
      backdrop-filter: blur(10px);
    }

.music-toggle {
      width: 36px;
      height: 36px;
      padding: 0;
      min-height: 0;
      border-radius: 11px;
      display: grid;
      place-items: center;
      font-size: 1rem;
      border: 1px solid rgba(120, 225, 255, 0.34);
      background: rgba(42, 197, 255, 0.12);
    }

.music-volume {
      width: 110px;
      accent-color: #53d8ff;
      cursor: pointer;
    }

@media (max-width: 640px) {
      .music-control {
        top: max(10px, env(safe-area-inset-top));
        left: max(10px, env(safe-area-inset-left));
        padding: 7px 8px;
        gap: 8px;
      }

      .music-toggle {
        width: 34px;
        height: 34px;
      }

      .music-volume {
        width: 92px;
      }
    }

body.startup-page:not(.playing) #startOverlay { opacity: 1; pointer-events: auto; }
.startup-quick-actions {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  z-index: 132;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.startup-quick-actions .corner-action { pointer-events: auto; }
.startup-quick-actions .music-control { position: static !important; display: flex; align-items: center; gap: 0; padding: 0; background: transparent; border: 0; box-shadow: none; pointer-events: auto; }
.startup-quick-actions .music-volume { display: none; }
.startup-quick-actions #profileIconBtn { margin-inline: auto; }
@media (orientation: landscape) {
  body.startup-page::before {  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 28px; text-align: center; color: #fff; background: radial-gradient(circle at 50% 40%, rgba(42,246,255,.14), transparent 32%), rgba(2,3,10,.94); font-family: var(--font-ui-heavy); font-size: clamp(1.2rem, 4vw, 2.4rem); letter-spacing: .04em; text-transform: uppercase; }
}


/* --------------------------------------------------------------------------
   Startup follow-up fixes: top controls, centering, spacing, and full-height
   background coverage for mobile browser + home-screen launches.
   -------------------------------------------------------------------------- */

.startup-quick-actions {
  left: auto;
  right: max(14px, env(safe-area-inset-right));
  width: auto;
  justify-content: flex-end;
  gap: clamp(10px, 2.8vw, 14px);
}

.startup-quick-actions #profileIconBtn {
  margin-inline: 0;
}

.startup-quick-actions .music-control {
  flex: 0 0 auto;
}

.startup-quick-actions #musicToggleButton.corner-action--sound::after {
  background: url('../assets/sound-on.svg') center / contain no-repeat !important;
}

.startup-quick-actions #musicToggleButton.corner-action--sound.is-muted::after {
  background: url('../assets/sound-off.svg') center / contain no-repeat !important;
}

#startOverlay,
#startOverlay .start-background-layer,
#startOverlay .start-ambient-layer,
#startOverlay .start-vignette-layer,
#startOverlay .start-overlay-stack {
  min-height: max(var(--stage-height), 100lvh);
}

#startOverlay .start-background-layer,
#startOverlay .start-ambient-layer,
#startOverlay .start-vignette-layer,
#startOverlay .start-overlay-stack {
  height: max(var(--stage-height), 100lvh);
}

#startOverlay .start-background-layer {
  background-position: center bottom;
  transform: scale(1.035);
}

#startOverlay .start-overlay-stack {
  width: 100%;
  justify-items: center;
  padding-top: calc(118px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
}

.start-hero-content,
.title-wrap,
.logo-title,
.menu-actions {
  margin-inline: auto;
}

.start-hero-content {
  width: min(88vw, 600px);
  gap: clamp(8px, 1.2vh, 14px);
  transform: translateY(clamp(-36px, -4vh, -18px));
}

.title-wrap {
  width: min(86vw, 560px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tagline {
  margin-top: clamp(-6px, -0.9vh, -2px);
}

.menu-actions {
  margin-top: clamp(2px, 0.8vh, 8px);
  gap: clamp(10px, 1.5vh, 14px);
}

@media (max-width: 430px) and (orientation: portrait) {
  #startOverlay .start-overlay-stack {
    padding-top: calc(110px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .start-hero-content {
    width: min(90vw, 560px);
    transform: translateY(clamp(-28px, -3.6vh, -14px));
  }
}

@media (max-height: 760px) and (orientation: portrait) {
  #startOverlay .start-overlay-stack {
    padding-top: calc(108px + env(safe-area-inset-top, 0px));
  }

  .start-hero-content {
    gap: 8px;
    transform: translateY(clamp(-22px, -3vh, -10px));
  }

  .menu-actions {
    gap: 10px;
  }
}

/* --------------------------------------------------------------------------
   Startup layout correction v3: use the visible viewport, keep controls in a
   single right-aligned row, and prevent portrait content from being clipped.
   -------------------------------------------------------------------------- */

html[data-cave-page="startup"],
html[data-cave-page="startup"] body.startup-page {
  width: 100vw !important;
  height: var(--app-height, 100dvh) !important;
  min-height: var(--app-height, 100dvh) !important;
  max-height: var(--app-height, 100dvh) !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  position: fixed !important;
  inset: 0 !important;
}

body.startup-page .startup-quick-actions {
  position: fixed !important;
  top: max(14px, env(safe-area-inset-top, 0px)) !important;
  right: max(12px, env(safe-area-inset-right, 0px)) !important;
  left: auto !important;
  width: auto !important;
  max-width: calc(100vw - max(12px, env(safe-area-inset-left, 0px)) - max(12px, env(safe-area-inset-right, 0px))) !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: clamp(8px, 2.2vw, 12px) !important;
  z-index: 132 !important;
  pointer-events: none !important;
}

body.startup-page .startup-quick-actions > * {
  position: relative !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  pointer-events: auto !important;
}

body.startup-page .startup-quick-actions .music-control {
  display: contents !important;
}

body.startup-page .startup-quick-actions .music-volume {
  display: none !important;
}

body.startup-page .startup-quick-actions #profileIconBtn {
  margin: 0 !important;
}

body.startup-page .startup-quick-actions .corner-action {
  --cr-corner-size: clamp(50px, 12vw, 62px);
}

body.startup-page .startup-quick-actions #musicToggleButton.corner-action--sound::after {
  background: url('../assets/sound-on.svg') center / contain no-repeat !important;
}

body.startup-page .startup-quick-actions #musicToggleButton.corner-action--sound.is-muted::after {
  background: url('../assets/sound-off.svg') center / contain no-repeat !important;
}

body.startup-page #startOverlay {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: var(--app-height, 100dvh) !important;
  min-height: var(--app-height, 100dvh) !important;
  max-height: var(--app-height, 100dvh) !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}

body.startup-page #game,
body.startup-page #game canvas,
body.startup-page #startOverlay .start-background-layer,
body.startup-page #startOverlay .start-ambient-layer,
body.startup-page #startOverlay .start-vignette-layer {
  width: 100vw !important;
  height: var(--app-height, 100dvh) !important;
  min-height: 0 !important;
  max-height: none !important;
}

body.startup-page #startOverlay .start-background-layer,
body.startup-page #startOverlay .start-ambient-layer,
body.startup-page #startOverlay .start-vignette-layer {
  position: absolute !important;
  inset: 0 !important;
}

body.startup-page #startOverlay .start-background-layer {
  background-position: center bottom !important;
  background-size: cover !important;
  transform: none !important;
}

body.startup-page #startOverlay .start-overlay-stack {
  position: relative !important;
  width: 100vw !important;
  height: var(--app-height, 100dvh) !important;
  min-height: 0 !important;
  max-height: var(--app-height, 100dvh) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  padding: calc(86px + env(safe-area-inset-top, 0px)) 0 calc(10px + env(safe-area-inset-bottom, 0px)) 0 !important;
  margin: 0 !important;
  left: 0 !important;
  right: 0 !important;
  overflow: hidden !important;
}

body.startup-page .start-hero-content,
body.startup-page .title-wrap,
body.startup-page .logo-title,
body.startup-page .tagline,
body.startup-page .menu-actions {
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  text-align: center !important;
}

body.startup-page .start-hero-content {
  width: min(92vw, 560px) !important;
  max-width: 92vw !important;
  align-items: center !important;
  justify-content: center !important;
  gap: clamp(8px, 1.2vh, 14px) !important;
  transform: translateY(clamp(-64px, -7.4vh, -38px)) !important;
}

body.startup-page .title-wrap {
  width: min(86vw, 540px) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

body.startup-page .logo-title {
  transform: translateX(0) rotateX(8deg) skewX(-5deg) !important;
  transform-origin: center 60% !important;
}

body.startup-page .tagline {
  margin-top: clamp(-8px, -1vh, -3px) !important;
}

body.startup-page .menu-actions {
  width: min(90vw, 560px) !important;
  margin-top: clamp(0px, .6vh, 6px) !important;
  gap: clamp(8px, 1.3vh, 12px) !important;
  justify-items: center !important;
}

@media (max-width: 430px) and (orientation: portrait) {
  body.startup-page .startup-quick-actions {
    top: max(13px, env(safe-area-inset-top, 0px)) !important;
    right: max(10px, env(safe-area-inset-right, 0px)) !important;
    gap: 8px !important;
  }

  body.startup-page .startup-quick-actions .corner-action {
    --cr-corner-size: clamp(48px, 12.5vw, 56px);
  }

  body.startup-page #startOverlay .start-overlay-stack {
    margin-left: 0px !important;
    padding-left: 0px !important;
    padding-right: 0px !important;
    padding-top: calc(84px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.startup-page .start-hero-content {
    width: min(92vw, 430px) !important;
    max-width: 92vw !important;
    transform: translateY(clamp(-70px, -8.3vh, -44px)) !important;
  }

  body.startup-page .title-wrap {
    width: min(86vw, 380px) !important;
  }

  body.startup-page .menu-actions {
    width: min(90vw, 380px) !important;
  }
}

@media (max-height: 760px) and (orientation: portrait) {
  body.startup-page #startOverlay .start-overlay-stack {
    padding-top: calc(76px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.startup-page .start-hero-content {
    gap: 7px !important;
    transform: translateY(clamp(-74px, -9vh, -48px)) !important;
  }

  body.startup-page .menu-actions {
    gap: 8px !important;
  }
}

/* ── Store actions (Remove Ads / Restore Purchases) ────────────────────────── */
.menu-actions--store {
  margin-top: clamp(4px, 0.8vh, 10px);
  display: flex;
  flex-direction: row;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.neon-button--store {
  min-height: 34px !important;
  padding: 0 14px !important;
  font-size: 0.72rem !important;
  opacity: 0.62;
  letter-spacing: 0.02em;
}

.neon-button--store:hover,
.neon-button--store:focus-visible {
  opacity: 0.9;
}

.neon-button--store.purchased {
  opacity: 0.35;
  cursor: default;
}

.neon-button--store span {
  font-size: inherit !important;
}
