:root {
  color-scheme: dark;
  --ink: #f1fff8;
  --muted: #b4d8cf;
  --lime: #c6ff87;
  --lime-deep: #8ee053;
  --aqua: #8ff5e5;
  --danger: #ff758f;
  --edge: #eafff838;
  --edge-strong: #f2fffb66;
  --surface: linear-gradient(145deg, #ffffff24, #d2fff30d 52%, #b4e5ff1c);
  --panel: linear-gradient(155deg, #1b464be6, #0f2c36f2);
  --world-hue: 168;
  --skin-hue: 106;
  font-family: ui-rounded, 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden], .hidden {
  display: none !important;
}

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 15%, hsl(var(--skin-hue) 78% 68% / .18), transparent 38%),
    radial-gradient(circle at 86% 80%, #7ce3da24, transparent 42%),
    linear-gradient(155deg, #0b2229, #12363e 55%, #19443c);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

button, a, input, select {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .16s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

button:active:not(:disabled) {
  transform: scale(.97);
}

button:disabled {
  cursor: default;
  opacity: .48;
}

button:focus-visible, a:focus-visible, canvas:focus-visible, input:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 2px;
}

.overline {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: #cfeFD3;
}

/* ---------- Boot Screen ---------- */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 24px calc(18px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(ellipse at 50% 28%, #347064aa, transparent 60%),
    linear-gradient(160deg, #0d262d, #13393f);
  text-align: center;
  gap: 12px;
  overflow: hidden;
}

.boot-orbit {
  display: grid;
  place-items: center;
  width: clamp(132px, 24vh, 184px);
  height: clamp(132px, 24vh, 184px);
  border-radius: 50%;
  border: 1px solid #dcffd036;
  background: radial-gradient(circle, #c6ff8730, transparent 68%);
  box-shadow: 0 0 0 18px #d4ffc807, inset 0 1px #fff4;
}

.boot-orbit img {
  width: 76%;
  height: 76%;
  object-fit: contain;
  animation: menu-jelly 3s ease-in-out infinite;
  filter: drop-shadow(0 12px 18px #041d2466);
}

.boot-kicker, .boot-screen small {
  letter-spacing: 2px;
  font-size: 10px;
  font-weight: 700;
  color: #c8e8cc;
}

.boot-screen small {
  margin-top: 12px;
  opacity: .68;
}

.boot-screen h1 {
  font-size: clamp(40px, 8vw, 68px);
  letter-spacing: -3px;
  line-height: .96;
  margin: 0;
  font-weight: 900;
}

.boot-screen h1 span {
  color: var(--lime);
}

.boot-screen p {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

.boot-screen progress {
  width: min(260px, 78vw);
  height: 7px;
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  background: #ffffff1c;
}

.boot-screen progress::-webkit-progress-bar {
  background: #ffffff1c;
}

.boot-screen progress::-webkit-progress-value {
  background: linear-gradient(90deg, #7fe8b8, var(--lime));
  transition: width .2s ease;
}

#bootStatus {
  font-size: 12px;
  min-height: 20px;
}

.boot-screen .primary {
  width: min(290px, 84vw);
}

/* ---------- Buttons & Pills ---------- */
.primary {
  min-height: 52px;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #f4ffdb;
  border-radius: 18px;
  background: linear-gradient(155deg, #e5ffb5, #9be45e);
  box-shadow: inset 0 1px 1px #fff, 0 10px 26px #9dea5c47, 0 0 20px #d7ffb338;
  color: #173821;
  font-size: 16px;
  font-weight: 850;
  letter-spacing: -.2px;
}

.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(155deg, #efffc8, #acee72);
  box-shadow: inset 0 1px 1px #fff, 0 14px 30px #9dea5c60, 0 0 26px #d7ffb355;
}

.primary span:last-child {
  font-size: 20px;
  line-height: 1;
}

.secondary-btn {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--edge-strong);
  background: linear-gradient(145deg, #ffffff2b, #b9f5e614);
  box-shadow: inset 0 1px #fff6, 0 6px 16px #00182233;
  font-size: 13px;
  font-weight: 700;
}

.secondary-btn:hover:not(:disabled) {
  background: linear-gradient(145deg, #ffffff40, #c8ffef26);
}

.circle-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--edge-strong);
  background: linear-gradient(145deg, #ffffff28, #c7f8ec12);
  box-shadow: inset 0 1px #fff6, 0 4px 12px #0018222e;
  font-size: 17px;
  line-height: 1;
  flex: none;
}

.circle-btn:hover:not(:disabled) {
  background: linear-gradient(145deg, #ffffff3d, #d2fff422);
}

.audio-btn {
  width: auto;
  min-width: 54px;
  padding: 0 11px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 800;
}

.audio-btn span {
  font-size: 9px;
  letter-spacing: .6px;
}

.audio-btn[aria-pressed="false"] {
  opacity: .65;
}

.pill-btn {
  height: 42px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 99px;
  border: 1px solid var(--edge-strong);
  background: linear-gradient(145deg, #ffffff26, #c7f8ec12);
  box-shadow: inset 0 1px #fff6, 0 4px 12px #0018222a;
  font-size: 13px;
  font-weight: 700;
}

.pill-btn span {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #d7ff9e33;
  color: var(--lime);
  font-weight: 850;
  font-size: 12px;
}

/* ---------- Main Menu (Open-Canvas, Boxless, Zero-Scroll Responsive) ---------- */
#gameContent {
  height: 100%;
  height: 100dvh;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.menu-screen {
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  padding:
    calc(10px + env(safe-area-inset-top, 0px))
    calc(16px + env(safe-area-inset-right, 0px))
    calc(10px + env(safe-area-inset-bottom, 0px))
    calc(16px + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  background:
    radial-gradient(ellipse at 50% 22%, hsl(var(--skin-hue) 88% 70% / .20), transparent 56%),
    radial-gradient(ellipse at 80% 85%, #6be7d81c, transparent 50%);
}

.menu-topbar {
  width: min(100%, 960px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #dfffab, #71ca5d);
  color: #153827;
  font-weight: 900;
  font-size: 18px;
  box-shadow: inset 0 1px #fff9, 0 4px 12px #001a2244;
  transform: rotate(-6deg);
  flex: none;
}

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

.brand-text strong {
  font-size: 19px;
  font-weight: 850;
  letter-spacing: -.5px;
  line-height: 1.05;
}

.brand-text small {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.6px;
  line-height: 1.1;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-layout {
  width: min(100%, 460px);
  flex: 1;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 8px;
}

.hero-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 5px;
  min-height: 0;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 11px;
  border-radius: 99px;
  background: #ffffff12;
  color: #e2ffd0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime);
}

.hero-stage {
  position: relative;
  width: 100%;
  height: clamp(72px, 13.5dvh, 148px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-stage::before {
  content: '';
  position: absolute;
  width: 200px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, hsl(var(--skin-hue) 92% 72% / .38), #9bf8e81a 54%, transparent 74%);
  filter: blur(10px);
}

.hero-pedestal {
  position: absolute;
  bottom: 2px;
  width: 112px;
  height: 15px;
  border-radius: 50%;
  background: radial-gradient(ellipse, #e8ffff66, #8fd8e212 72%, transparent);
}

.menu-mascot {
  position: relative;
  z-index: 1;
  width: clamp(70px, 13dvh, 142px);
  height: clamp(70px, 13dvh, 142px);
  object-fit: contain;
  transform-origin: 50% 85%;
  animation: menu-jelly 3s ease-in-out infinite;
  filter: drop-shadow(0 12px 16px #051e2788) drop-shadow(0 0 20px hsl(var(--skin-hue) 85% 74% / .35));
}

.hero-bubble {
  position: absolute;
  border: 1px solid #edfff575;
  border-radius: 50%;
  background: radial-gradient(circle at 28% 23%, #fff9, transparent 28%), linear-gradient(150deg, #e1fff52e, #b7fff508);
  animation: bubble-float 5s ease-in-out infinite;
}

.hero-bubble.a { width: 22px; height: 22px; left: 20%; top: 12%; }
.hero-bubble.b { width: 14px; height: 14px; right: 20%; top: 54%; animation-delay: -2s; }
.hero-bubble.c { width: 9px; height: 9px; right: 29%; top: 12%; animation-delay: -3.2s; }

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

.menu-heading h2 {
  font-size: clamp(28px, 4.6dvh, 50px);
  line-height: 1.08;
  padding-bottom: 2px;
  letter-spacing: -2px;
  margin: 0;
  font-weight: 900;
  background: linear-gradient(165deg, #fff 20%, #d8ffdf 65%, #9eedde);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 14px #001c2644);
}

.menu-heading p {
  margin: 0;
  font-size: clamp(11px, 1.55dvh, 12.5px);
  line-height: 1.35;
  color: #c8e5db;
}

.menu-stats {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 1px;
  padding: 5px 18px;
  border-radius: 99px;
  background: #ffffff0f;
}

.stat-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.stat-item small {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--muted);
}

.stat-item strong {
  font-size: 14px;
  font-weight: 850;
  color: #fff;
}

.stat-divider {
  width: 1px;
  height: 14px;
  background: #ffffff2e;
}

/* Control Pane (Fluid, no outer box) */
.control-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.mode-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}

.link-pill {
  padding: 3px 10px;
  border-radius: 99px;
  border: 0;
  background: #ffffff14;
  font-size: 11px;
  font-weight: 750;
  color: #dfffb8;
}

.link-pill:hover {
  background: #ffffff24;
}

/* Segmented pill bar instead of 5 separate boxes */
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  padding: 4px;
  border-radius: 18px;
  background: #0820266e;
  border: 1px solid #ffffff1f;
}

.mode-tab {
  min-height: clamp(38px, 5.4dvh, 46px);
  padding: 4px 4px;
  border-radius: 14px;
  border: 0;
  background: transparent;
  color: #c7e3d9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}

.mode-tab:hover:not([aria-pressed="true"]) {
  background: #ffffff0f;
  color: #fff;
}

.mode-tab span {
  font-size: 15px;
  line-height: 1;
}

.mode-tab b {
  font-size: 10px;
  font-weight: 750;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-tab small {
  display: none;
}

.mode-tab[aria-pressed="true"] {
  background: linear-gradient(155deg, #dcfba7, #96e467);
  color: #153620;
  box-shadow: 0 4px 12px #00182044;
}

.mode-tab[aria-pressed="true"] b {
  font-weight: 850;
}

.level-picker {
  width: 100%;
  min-height: 34px;
  padding: 5px 13px;
  border-radius: 99px;
  border: 1px solid #d8ffab59;
  background: #d4ff9c1a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
}

.level-picker span {
  font-size: 9.5px;
  font-weight: 850;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--lime);
}

.level-picker strong {
  margin-right: auto;
  font-weight: 800;
}

.level-picker em {
  font-style: normal;
  font-weight: 750;
  color: #dcffb6;
}

.mode-description {
  margin: 0;
  padding: 0 4px;
  color: #c8e5da;
  font-size: 11.5px;
  line-height: 1.32;
  text-align: center;
}

.play-cta {
  min-height: clamp(44px, 6.2dvh, 54px);
  font-size: 16.5px;
  border-radius: 99px;
  padding: 10px 22px;
}

.market-strip {
  width: 100%;
  padding: 8px 14px;
  border-radius: 18px;
  border: 1px solid #ffffff26;
  background: #ffffff10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.market-strip:hover {
  background: #ffffff1c;
  border-color: #dfffb566;
}

.market-card-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.market-card-copy .overline {
  font-size: 8.5px;
  line-height: 1.15;
}

.market-card-copy strong {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.18;
}

.market-card-copy small {
  font-size: 10.5px;
  line-height: 1.25;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallet-badge {
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid #dfffab66;
  background: #c8ff871f;
  color: #e6ffbe;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  flex: none;
}

.save-notice:empty {
  display: none;
}

.save-notice {
  margin: 0;
  font-size: 10.5px;
  color: #ffd7a8;
  text-align: center;
}

.guide-strip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 1px;
}

.guide-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  font-size: 10.5px;
  color: #d4ece2;
}

.guide-steps b {
  color: var(--lime);
  margin-right: 3px;
}

.guide-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid transparent;
  background: #ffffff10;
  font-size: 9.5px;
  font-weight: 700;
  color: #daf3e8;
  white-space: nowrap;
}

.chip.active {
  border-color: var(--lime);
  background: #c8ff8728;
  color: #fff;
  box-shadow: 0 0 12px #c8ff8730;
}

.chip b {
  font-weight: 900;
}

.chip.bounce b { color: #c8ff87; }
.chip.rest b { color: #9de8ff; }
.chip.fragile b { color: #ffe08a; }
.chip.ice b { color: #a7f4ff; }
.chip.reverse b { color: #dfb8ff; }
.chip.hazard b { color: #ff8098; }

/* Compact portrait smartphones (browser address bar visible, e.g. 640px-740px tall) */
@media (max-width: 819px) and (max-height: 750px) {
  .menu-screen {
    padding:
      calc(8px + env(safe-area-inset-top, 0px))
      calc(14px + env(safe-area-inset-right, 0px))
      calc(8px + env(safe-area-inset-bottom, 0px))
      calc(14px + env(safe-area-inset-left, 0px));
    gap: 4px;
  }
  .menu-layout {
    gap: 6px;
  }
  .hero-pane {
    gap: 4px;
  }
  .hero-stage {
    height: clamp(60px, 10.5dvh, 88px);
  }
  .menu-mascot {
    width: clamp(58px, 10dvh, 84px);
    height: clamp(58px, 10dvh, 84px);
  }
  .menu-heading h2 {
    font-size: clamp(25px, 4dvh, 32px);
  }
  .menu-heading p {
    font-size: 11px;
    line-height: 1.25;
  }
  .control-pane {
    gap: 6px;
  }
  .mode-block {
    gap: 4px;
  }
  .mode-tab {
    min-height: 36px;
  }
  .play-cta {
    min-height: 42px;
    padding: 8px 18px;
    font-size: 15px;
  }
  .market-strip {
    padding: 6px 12px;
  }
  .guide-strip {
    gap: 4px;
  }
}

/* Very short portrait screens (e.g. iPhone SE 375x667 with browser bars or split view) */
@media (max-width: 819px) and (max-height: 675px) {
  .hero-badge, .menu-heading p, .guide-steps {
    display: none;
  }
  .hero-stage {
    height: 56px;
  }
  .menu-mascot {
    width: 54px;
    height: 54px;
  }
}

/* Desktop & tablet wide layout: clean side-by-side without heavy boxes */
@media (min-width: 820px) {
  .menu-screen {
    padding: 24px 36px;
  }
  .menu-layout {
    width: min(100%, 920px);
    display: grid;
    grid-template-columns: 1fr 1.08fr;
    gap: 48px;
    align-items: center;
  }
  .hero-pane {
    gap: 12px;
  }
  .hero-stage {
    height: 185px;
  }
  .menu-mascot {
    width: 168px;
    height: 168px;
  }
  .control-pane {
    gap: 14px;
  }
  .mode-tab {
    min-height: 54px;
  }
  .mode-tab b {
    font-size: 11px;
  }
  .mode-description {
    text-align: left;
    font-size: 13px;
  }
  .guide-steps, .guide-chips {
    justify-content: flex-start;
  }
}

/* Short landscape phones */
@media (max-height: 540px) and (orientation: landscape) {
  .menu-screen {
    padding: 8px 18px;
  }
  .menu-layout {
    width: min(100%, 820px);
    display: grid;
    grid-template-columns: .88fr 1.12fr;
    gap: 22px;
    align-items: center;
  }
  .hero-stage {
    height: 84px;
  }
  .menu-mascot {
    width: 82px;
    height: 82px;
  }
  .menu-heading h2 {
    font-size: 28px;
  }
  .menu-heading p, .guide-strip {
    display: none;
  }
  .control-pane {
    gap: 8px;
  }
  .mode-tab {
    min-height: 40px;
  }
  .play-cta {
    min-height: 44px;
    padding: 9px 18px;
  }
}

@media (max-width: 400px) {
  .mode-tab b {
    font-size: 9.5px;
  }
  .pill-btn b {
    display: none;
  }
  .pill-btn {
    padding: 0 11px;
  }
}

/* ---------- Gameplay Stage ---------- */
#gameContent.in-menu .play-stage {
  display: none;
}

.play-stage {
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(10px + env(safe-area-inset-top, 0px))
    calc(10px + env(safe-area-inset-right, 0px))
    calc(10px + env(safe-area-inset-bottom, 0px))
    calc(10px + env(safe-area-inset-left, 0px));
}

.game-shell {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) 72px;
  grid-template-columns: minmax(0, 1fr);
  width: min(100%, 520px);
  min-width: 0;
  height: min(100%, 960px);
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid #f0fffa66;
  background: linear-gradient(155deg, #275350, #133339);
  box-shadow: 0 28px 90px #00131ca8;
}

#game {
  grid-row: 2;
  grid-column: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: block;
  touch-action: none;
}

.game-top, .status-dock {
  position: relative;
  z-index: 2;
  min-width: 0;
  overflow: hidden;
  background: linear-gradient(130deg, hsl(var(--world-hue) 46% 25% / .92), hsl(calc(var(--world-hue) + 26) 42% 16% / .92));
  border-color: hsl(var(--world-hue) 70% 85% / .36);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}

.game-top {
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--edge);
}

.run-score {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.05;
  flex: none;
}

#score {
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

#score span {
  font-size: 11px;
  margin-left: 2px;
  font-weight: 700;
  color: var(--muted);
}

#modeLabel {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .5px;
  line-height: 1.2;
  color: #d6f7e7;
  max-width: 96px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.objective-hud {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 11px;
  background: #08222959;
  border: 1px solid #e8fff626;
}

#runObjective {
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .4px;
  color: #e4fff0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.objective-bar {
  height: 4px;
  border-radius: 99px;
  overflow: hidden;
  background: #ffffff21;
}

#objectiveFill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #7fe9c3, var(--lime));
  transition: width .2s ease;
}

.objective-hud[data-urgent="true"] #objectiveFill {
  background: linear-gradient(90deg, #ffae70, #ff6c8b);
}

.run-record {
  display: flex;
  flex-direction: column;
  text-align: right;
  white-space: nowrap;
  flex: none;
}

.run-record small {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
}

.run-record strong {
  font-size: 12px;
  font-weight: 800;
}

.run-controls {
  display: flex;
  gap: 6px;
  flex: none;
}

.game-top .circle-btn {
  width: 38px;
  height: 38px;
  font-size: 15px;
}

/* Status Dock */
.status-dock {
  grid-row: 3;
  padding: 9px 14px 6px;
  border-top: 1px solid var(--edge);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.growth-hud {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hud-meter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .3px;
}

.meter-track {
  height: 5px;
  border-radius: 99px;
  overflow: hidden;
  background: #041d2666;
  box-shadow: inset 0 1px 2px #0006;
}

.meter-track i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6be2b4, var(--lime));
  transition: width .22s ease;
}

.meter-track[data-low="true"] i {
  background: linear-gradient(90deg, #ff9b73, #ffd27d);
}

.meter-track[data-active="true"] i {
  background: linear-gradient(90deg, #7cf7e4, #d2fff6);
}

.game-bottom {
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .4px;
  color: #daf5ea;
  pointer-events: none;
}

#hint, #toast {
  transition: opacity .15s ease;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

#toast {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 850;
  color: var(--lime);
  opacity: 0;
}

#charge {
  position: absolute;
  bottom: 2px;
  left: 14px;
  right: 14px;
  height: 5px;
  border-radius: 99px;
  background: #e7ffff26;
  border: 1px solid #efffff45;
  overflow: hidden;
  opacity: 0;
}

#charge::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 2px #fff3;
}

#charge div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #62e3c6, #e2ffa4);
}

#charge[data-aim="perfect"] div {
  background: #d4ff93;
}

#charge[data-aim="danger"] div {
  background: var(--danger);
}

/* Mobile & narrow desktop window: full-bleed gameplay */
@media (max-width: 760px) {
  .play-stage {
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  }
  .game-shell {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
}

@media (max-width: 410px) {
  .run-record {
    display: none;
  }
}

/* ---------- Pause / Result Overlay ---------- */
.overlay {
  position: absolute;
  inset: 58px 0 72px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 35%, #16444bcc, #0a2028e6);
  backdrop-filter: blur(18px) saturate(155%);
  -webkit-backdrop-filter: blur(18px) saturate(155%);
}

.overlay-card {
  width: min(100%, 340px);
  max-height: 100%;
  overflow: hidden;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.overlay-card h2 {
  margin: 0;
  font-size: clamp(32px, 7vw, 42px);
  font-weight: 900;
  letter-spacing: -1.6px;
  line-height: 1;
}

.overlay-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: #cbe7dc;
}

.overlay-card .primary {
  border-radius: 99px;
}

.overlay-card .primary:focus-visible {
  outline-offset: 3px;
}

.run-reward {
  padding: 6px 14px;
  border-radius: 99px;
  background: #c8ff8722;
  border: 1px solid #dfffab55;
  color: #e4ffba !important;
  font-size: 12px !important;
  font-weight: 800;
  align-self: center;
}

.run-reward:empty, .share-status:empty {
  display: none;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.overlay-actions button {
  flex: 1 1 130px;
  border-radius: 99px;
}

.share-status {
  font-size: 11px !important;
  color: var(--lime) !important;
}

/* ---------- Modal Dialogs (Market, Modes, Levels, Help — Single-Screen Fit) ---------- */
dialog {
  color: var(--ink);
  width: min(760px, calc(100% - 16px));
  max-height: min(94dvh, 780px);
  margin: auto;
  padding: 0;
  border-radius: 24px;
  border: 1px solid var(--edge-strong);
  background:
    radial-gradient(ellipse at 12% 0%, #4b877c88, transparent 65%),
    linear-gradient(155deg, #193e45f5, #102834fa);
  box-shadow: inset 0 1px #fff8, 0 30px 90px #00131dcc;
  overflow: hidden;
}

dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog::backdrop {
  background: #051820b8;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.dialog-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--edge);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #ffffff0a;
  flex: none;
}

.dialog-header .overline {
  font-size: 9px;
}

.dialog-header h2 {
  margin: 2px 0 0;
  font-size: clamp(19px, 3.6vw, 25px);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -.8px;
}

.dialog-body {
  padding: 12px 14px 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.dialog-note {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--muted);
}

/* Jelly Market: 2x4 compact grid on mobile, 4x2 on wide screens */
.market-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.market-intro {
  margin: 0;
  font-size: 11.5px;
  color: #d3ece2;
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 7px;
}

@media (min-width: 720px) {
  .skin-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }
}

.skin-card {
  cursor: pointer;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 4px 8px;
  align-items: center;
  padding: 7px 9px;
  border-radius: 15px;
  border: 1px solid var(--edge);
  background:
    radial-gradient(ellipse at 12% 10%, #ffffff1f, transparent 60%),
    linear-gradient(135deg, #d8fff517, #c9deff0a);
  box-shadow: inset 0 1px #fff6, 0 6px 14px #00182224;
  transition: border-color .18s ease, background .18s ease, transform .15s ease;
}

.skin-card.equipped {
  border-color: #dfffabaa;
  background: linear-gradient(135deg, #d7ff9c28, #8ff5e514);
}

.skin-card.expanded {
  grid-column: 1 / -1;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 6px 12px;
  padding: 10px 12px;
  border-color: var(--lime);
  background:
    radial-gradient(ellipse at 15% 15%, #e6ffba2b, transparent 65%),
    linear-gradient(135deg, #d7ff9c30, #7cebe01c);
  box-shadow: inset 0 1px #fff8, 0 10px 24px #00182244, 0 0 18px #c8ff8722;
}

.skin-portrait {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: radial-gradient(circle at 50% 65%, hsl(var(--skin, 106) / .22), transparent 70%);
}

.skin-card.expanded .skin-portrait {
  width: 54px;
  height: 54px;
  border-radius: 15px;
}

.skin-portrait img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px #001a2444);
}

.skin-card.expanded .skin-portrait img {
  width: 48px;
  height: 48px;
}

.skin-copy {
  min-width: 0;
}

.skin-copy h3 {
  margin: 0;
  font-size: 12px;
  line-height: 1.15;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skin-card.expanded .skin-copy h3 {
  font-size: 14px;
  white-space: normal;
}

.skin-copy b {
  display: block;
  font-size: 8px;
  line-height: 1.15;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--lime);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skin-card.expanded .skin-copy b {
  font-size: 10px;
  letter-spacing: .6px;
  white-space: normal;
  overflow: visible;
}

.skin-copy p {
  margin: 2px 0 0;
  font-size: 9.5px;
  line-height: 1.22;
  color: #c2dfd4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.skin-card.expanded .skin-copy p {
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.35;
  color: #e9fff6;
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.skin-card button {
  grid-column: 1 / -1;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 9px;
  border: 1px solid #dfffab75;
  background: linear-gradient(135deg, #d8ffa633, #a8ffe614);
  font-size: 10.5px;
  font-weight: 800;
}

.skin-card.expanded button {
  grid-column: 3;
  grid-row: 1;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 11.5px;
  white-space: nowrap;
}

/* Keep the 8-skin dialog fitting on one smartphone screen when a card expands */
.skin-grid:has(.expanded) .skin-card:not(.expanded) {
  padding: 5px 8px;
}

.skin-grid:has(.expanded) .skin-card:not(.expanded) .skin-copy p {
  display: none;
}

@media (max-width: 719px) {
  .skin-grid:has(.expanded) .skin-card:last-child:not(.expanded),
  .skin-grid:has(.skin-card:last-child.expanded) .skin-card:nth-child(7) {
    grid-column: 1 / -1;
    grid-template-columns: 36px minmax(0, 1fr) auto;
  }
  .skin-grid:has(.expanded) .skin-card:last-child:not(.expanded) button,
  .skin-grid:has(.skin-card:last-child.expanded) .skin-card:nth-child(7) button {
    grid-column: 3;
    grid-row: 1;
    padding: 4px 12px;
  }
  #market .dialog-note:last-child {
    display: none;
  }
}

/* Modes Dialog */
.mode-cards {
  display: grid;
  gap: 7px;
}

.mode-card {
  width: 100%;
  padding: 10px 13px;
  border-radius: 15px;
  border: 1px solid var(--edge);
  background: linear-gradient(135deg, #ffffff1f, #c7f8ec0c);
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.mode-card:hover {
  border-color: #dfffab99;
  background: linear-gradient(135deg, #ffffff2e, #d4ffea1a);
}

.mode-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: #d6ff9e24;
  border: 1px solid #dfffab55;
  color: var(--lime);
  font-size: 17px;
  font-weight: 800;
}

.mode-card small {
  display: block;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 1.1px;
  color: var(--lime);
}

.mode-card strong {
  display: block;
  font-size: 13.5px;
  margin: 1px 0;
}

.mode-card p {
  margin: 0;
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
}

.mode-card b {
  font-size: 16px;
  color: var(--lime);
}

/* Campaign Levels Dialog: 4 worlds × 3 columns (all 12 levels on one screen) */
.campaign-summary {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--lime);
}

.level-grid {
  display: grid;
  gap: 7px;
}

.journey-world {
  padding: 8px 10px;
  border-radius: 15px;
  border: 1px solid var(--edge);
  background: #ffffff0d;
}

.world-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.world-heading span {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.1px;
  color: var(--lime);
  order: 1;
}

.world-heading h3 {
  margin: 0 auto 0 4px;
  font-size: 12.5px;
  font-weight: 850;
  order: 2;
}

.world-heading small {
  font-size: 10px;
  font-weight: 800;
  color: #ffe999;
  order: 3;
}

.journey-path {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 6px;
}

.journey-path:has(.expanded-item) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.journey-path li.expanded-item {
  grid-column: 1 / -1;
}

.level-tile {
  width: 100%;
  padding: 6px 7px;
  border-radius: 11px;
  border: 1px solid var(--edge);
  background: #ffffff12;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 3px 5px;
  text-align: left;
}

.level-tile.locked {
  opacity: .62;
}

.level-tile.selected {
  border-color: var(--lime);
  background: #c8ff8724;
}

.level-tile.expanded {
  opacity: 1;
  border-color: var(--lime);
  background: linear-gradient(135deg, #d7ff9c2c, #8ff5e518);
  padding: 8px 10px;
}

.level-orb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff1c;
  font-size: 9.5px;
  font-weight: 850;
}

.level-tile.completed .level-orb {
  background: #c8ff8733;
  color: var(--lime);
}

.level-stars {
  font-size: 10px;
  letter-spacing: .5px;
  color: #ffe685;
  justify-self: end;
}

.level-copy {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.level-copy small {
  font-size: 8px;
  letter-spacing: .4px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-copy strong {
  font-size: 10.5px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-copy span {
  font-size: 8.5px;
  line-height: 1.15;
  color: #cbe6dc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-tile.expanded .level-copy small,
.level-tile.expanded .level-copy strong,
.level-tile.expanded .level-copy span {
  white-space: normal;
  overflow: visible;
}

.level-tile.expanded .level-copy strong {
  font-size: 12.5px;
}

.level-tile.expanded .level-copy span {
  font-size: 10.5px;
  color: #ebfff7;
}

#levelsDialog:has(.level-tile.expanded) .journey-world:not(:has(.level-tile.expanded)) .level-copy span {
  display: none;
}

/* Help Dialog */
.help-steps {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 7px;
}

.help-steps li {
  font-size: 12px;
  line-height: 1.35;
}

.help-steps p {
  margin: 2px 0 0;
  color: #c7e4d9;
  font-size: 11px;
}

.help-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.help-controls span {
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: #ffffff12;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.help-controls b {
  color: var(--lime);
}

.audio-setting {
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: #ffffff12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-weight: 700;
}

.audio-setting input {
  width: 48%;
  accent-color: var(--lime);
}

@keyframes menu-jelly {
  0%, 100% { transform: translateY(0) scale(1) rotate(-2deg); }
  40% { transform: translateY(-6px) scale(.97, 1.04) rotate(2deg); }
  70% { transform: translateY(2px) scale(1.04, .96); }
}

@keyframes bubble-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Legal Footer, Privacy Notice & Privacy Policy Page ---------- */
.menu-legal {
  width: min(100%, 960px);
  margin: 0 auto;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
}

.menu-legal a,
.menu-legal .legal-link-btn {
  background: none;
  border: 0;
  padding: 2px 4px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: .88;
}

.menu-legal a:hover,
.menu-legal .legal-link-btn:hover {
  color: var(--lime);
  opacity: 1;
}

.privacy-status {
  margin: 4px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--aqua);
}

.help-legal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.help-legal-row a {
  color: var(--lime);
  text-decoration: underline;
  text-underline-offset: 2px;
}

html:has(.privacy-page),
body.privacy-page {
  height: auto;
  min-height: 100dvh;
  overflow: auto;
  user-select: text;
  -webkit-user-select: text;
}

.privacy-shell {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.privacy-card {
  padding: 24px 22px;
  border-radius: 22px;
  border: 1px solid var(--edge);
  background: var(--panel);
  box-shadow: 0 20px 50px #00182248;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.privacy-card h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.15;
}

.privacy-updated {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.privacy-card section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.privacy-card h2 {
  margin: 4px 0 0;
  font-size: 16px;
  color: var(--lime);
}

.privacy-card p,
.privacy-card li {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #e4f8f1;
}

.privacy-card ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.privacy-card a {
  color: var(--aqua);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.privacy-card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: #ffffff14;
}

.privacy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.privacy-actions .primary,
.privacy-actions .secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 99px;
}
