:root {
  --surface-backdrop: #0a1628;
  --accent-primary: #0d9488;
  --accent-primary-deep: #0f766e;
  --accent-secondary: #d97706;
  --text-bright: #fff7ed;
  --text-strong: #1c1917;
  --text-soft: #a8a29e;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --menu-bg-image: none;
}

html.has-menu-bg #startPanel {
  background-image: var(--menu-bg-image);
  background-size: cover;
  background-position: center;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--surface-backdrop);
  color: var(--text-bright);
  font-family: var(--font-body);
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  background: #7dd3fc;
  touch-action: none;
  -webkit-touch-callout: none;
}

#uiOverlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#uiOverlay .panel {
  pointer-events: auto;
}

.intro-root {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  background:
    radial-gradient(ellipse 70% 55% at 50% 40%, rgba(88, 48, 36, 0.35), transparent 70%),
    linear-gradient(180deg, #050308 0%, #0c0812 55%, #120a10 100%);
  cursor: pointer;
}

.intro-root::before {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  z-index: -1;
}

.intro-root.hidden {
  display: none;
}

.intro-gate {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.intro-gate.hidden {
  display: none;
}

.intro-gate-msg {
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 3.5vw, 1.45rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--text-bright) 88%, transparent);
  animation: introPulse 1.6s ease-in-out infinite;
}

@keyframes introPulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.intro-beat {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.45s ease, transform 0.45s ease;
  pointer-events: none;
}

.intro-beat.hidden {
  display: none;
}

.intro-beat.intro-visible {
  opacity: 1;
  transform: scale(1);
}

.intro-beat.intro-exit {
  opacity: 0;
  transform: scale(1.03);
}

.intro-logo {
  max-width: min(720px, 86vw);
  max-height: min(48vh, 420px);
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 12px 36px rgba(0, 0, 0, 0.45));
}

.intro-logo-studio {
  max-width: min(640px, 82vw);
}

.intro-logo-partner {
  max-width: min(680px, 88vw);
  max-height: min(36vh, 280px);
  padding: 1.1rem 1.4rem;
  border-radius: 16px;
  background: #f4efe6;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.intro-logo-title {
  max-width: min(820px, 92vw);
  max-height: min(42vh, 360px);
}

.intro-partnership {
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 3.8vw, 1.65rem);
  font-weight: 700;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  text-transform: lowercase;
  color: color-mix(in srgb, var(--text-bright) 78%, transparent);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}

.intro-presents {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  text-transform: uppercase;
  color: #f3e7d3;
  text-shadow: 0 2px 24px rgba(220, 110, 63, 0.35);
}

.intro-skip {
  position: absolute;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--text-bright) 45%, transparent);
  pointer-events: none;
}

.intro-skip.hidden {
  display: none;
}

#startPanel,
#pausePanel,
#gameOverPanel,
#optionsPanel,
#scoresModal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: min(10vh, 88px);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.35) 0%, rgba(15, 23, 42, 0.08) 45%, rgba(15, 23, 42, 0.45) 100%);
  gap: 0.85rem;
  overflow: hidden;
}

/*
 * Start menu — strict non-overlapping zones:
 *  hero (top) → scores → actions (waterline) → hint → legal
 */
#startPanel.start-panel {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr);
  /* hero + scores at top; equal slack pins actions near the waterline */
  grid-template-rows:
    auto
    minmax(0, 26vh)
    minmax(0.75rem, 1fr)
    auto
    minmax(0.75rem, 1fr)
    auto
    auto;
  grid-template-areas:
    "hero"
    "scores"
    "."
    "actions"
    "."
    "hint"
    "legal";
  justify-items: center;
  align-items: stretch;
  gap: 0.4rem;
  padding:
    max(0.5rem, env(safe-area-inset-top))
    0.85rem
    0;
  overflow: hidden;
  box-sizing: border-box;
}

#startPanel.start-panel > .start-glow {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  grid-area: unset;
  z-index: 0;
  pointer-events: none;
}

#startPanel.start-panel > .start-hero {
  grid-area: hero;
  z-index: 1;
}

#startPanel.start-panel > .start-scores {
  grid-area: scores;
  z-index: 1;
  min-height: 0;
}

#startPanel.start-panel > .start-waterline {
  grid-area: actions;
  z-index: 2;
}

#startPanel.start-panel > .start-hint {
  grid-area: hint;
  z-index: 1;
}

#startPanel.start-panel > .legal-footer {
  grid-area: legal;
  z-index: 1;
}

.start-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: min(720px, 94vw);
  margin: 0;
  padding: 0;
}

.start-hero .brand,
.start-hero #gameTitle.brand {
  margin: 0;
  font-size: clamp(2.1rem, 6.5vw, 3.4rem);
  line-height: 1.05;
  animation: none;
}

.start-hero .tagline {
  margin: 0;
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  animation: none;
}

.start-hero .high-score {
  margin: 0.15rem 0 0;
  padding: 0.35rem 0.9rem;
  animation: none;
}

.start-hero .diff-label {
  margin: 0;
  animation: none;
}

.start-scores {
  width: min(400px, 94vw);
  display: flex;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.scores-card {
  width: 100%;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(10, 22, 40, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 0.65rem 0.75rem 0.55rem;
  backdrop-filter: blur(6px);
  animation: none;
}

.scores-card .leaderboard-top10 {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.scores-card-head,
.scores-modal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}

.scores-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: #fde68a;
  letter-spacing: 0.02em;
}

.scores-link {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 800;
  color: #7dd3fc;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  pointer-events: auto;
}

.scores-link:hover {
  color: #bae6fd;
}

.start-waterline {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  transform: none;
  width: min(420px, 92vw);
  display: flex;
  justify-content: center;
  margin: 0.35rem 0 0;
  pointer-events: auto;
}

.btn-row-waterline {
  flex-direction: row;
  width: 100%;
  gap: 0.75rem;
  animation: none;
}

.btn-row-waterline .btn {
  flex: 1;
  min-width: 0;
}

.start-hint {
  position: relative;
  left: auto;
  bottom: auto;
  transform: none;
  width: min(420px, 92vw);
  margin: 0;
  pointer-events: none;
  animation: none;
}

#startPanel.start-panel > .legal-footer {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  width: 100%;
  margin: 0;
  padding: 0.35rem 0.75rem max(0.65rem, env(safe-area-inset-bottom));
}

.scores-modal {
  z-index: 25;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  background: rgba(8, 14, 24, 0.72);
  backdrop-filter: blur(8px);
}

.scores-modal-card {
  width: min(420px, 94vw);
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1rem 1.1rem;
  background:
    linear-gradient(165deg, rgba(12, 74, 110, 0.95) 0%, rgba(19, 78, 74, 0.96) 50%, rgba(28, 25, 23, 0.97) 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
}

.leaderboard-top100 {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  width: 100%;
  margin: 0;
}

#pausePanel,
#gameOverPanel,
#optionsPanel {
  justify-content: center;
  padding-top: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(253, 186, 116, 0.35), transparent 55%),
    linear-gradient(165deg, rgba(12, 74, 110, 0.92) 0%, rgba(19, 78, 74, 0.94) 45%, rgba(28, 25, 23, 0.96) 100%);
}

.start-glow {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 247, 237, 0.18), transparent 65%);
  top: 12%;
  pointer-events: none;
  animation: pulseGlow 4s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.08); opacity: 1; }
}

#startPanel.hidden,
#pausePanel.hidden,
#gameOverPanel.hidden,
#optionsPanel.hidden,
#scoresModal.hidden,
#hud.hidden {
  display: none !important;
}

.brand {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 11vw, 6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-bright);
  text-shadow:
    0 2px 0 color-mix(in srgb, var(--accent-secondary) 55%, transparent),
    0 12px 40px rgba(0, 0, 0, 0.45);
  line-height: 0.95;
  animation: brandIn 0.7s ease-out both;
}

.brand-sm {
  font-size: clamp(2.2rem, 7vw, 3.6rem);
}

.legal-footer {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
}

.studio-credit {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--text-bright) 65%, transparent);
}

.copyright {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--text-bright) 48%, transparent);
}

.partner-credit {
  margin: 0.15rem 0 0;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.45;
  color: color-mix(in srgb, var(--text-bright) 52%, transparent);
}

.partner-credit-link {
  display: inline;
  margin-left: 0.35em;
  color: color-mix(in srgb, #e8c9a8 75%, var(--text-bright));
  text-decoration: none;
}

.partner-credit-link:hover,
.partner-credit-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

@keyframes brandIn {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tagline {
  position: relative;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.35rem;
  color: color-mix(in srgb, var(--text-bright) 88%, transparent);
  margin-bottom: 0.35rem;
  animation: brandIn 0.7s 0.1s ease-out both;
}

.high-score {
  position: relative;
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 247, 237, 0.95);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.55rem 1.35rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
  animation: brandIn 0.7s 0.18s ease-out both;
}

.btn-row {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: center;
  width: min(280px, 90vw);
  animation: brandIn 0.7s 0.26s ease-out both;
}

.debug-toggle {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.15rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(255, 247, 237, 0.88);
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  animation: brandIn 0.7s 0.3s ease-out both;
}

.debug-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: #f59e0b;
  cursor: pointer;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.95rem 1.5rem;
  border-radius: 14px;
  width: 100%;
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
  pointer-events: auto;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25);
}

.btn:hover {
  transform: translateY(-3px);
  filter: brightness(1.06);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-primary), var(--accent-primary-deep));
  color: var(--text-bright);
}

.btn-secondary {
  background: linear-gradient(
    180deg,
    var(--accent-secondary),
    color-mix(in srgb, var(--accent-secondary) 55%, #000)
  );
  color: var(--text-bright);
}

.btn-ghost {
  background: color-mix(in srgb, var(--text-bright) 14%, transparent);
  color: var(--text-bright);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  border: 1px solid color-mix(in srgb, var(--text-bright) 22%, transparent);
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  pointer-events: none;
  z-index: 5;
  font-family: var(--font-body);
}

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-left: auto;
}

.hud-jump {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-bright);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  cursor: default;
  user-select: none;
}

.hud-jump-label {
  letter-spacing: 0.02em;
}

.hud-jump-val {
  min-width: 3.1rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #fde68a;
}

.hud-jump input[type="range"] {
  width: min(140px, 28vw);
  height: 6px;
  appearance: none;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

.hud-jump input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fbbf24, #d97706);
  border: 2px solid #fff7ed;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.hud-jump input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fbbf24, #d97706);
  border: 2px solid #fff7ed;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.hud-stat {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-bright);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.hud-stat-hot {
  border-color: rgba(251, 191, 36, 0.55);
  color: #fde68a;
  box-shadow: 0 4px 16px rgba(217, 119, 6, 0.35);
}

.hud-banner {
  position: absolute;
  top: 4.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: linear-gradient(180deg, #f59e0b, #b45309);
  color: #fffbeb;
  padding: 0.45rem 1.35rem;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(180, 83, 9, 0.4);
}

.hud-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hint {
  position: relative;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255, 247, 237, 0.7);
  max-width: 340px;
  text-align: center;
  line-height: 1.45;
  margin-top: 0.35rem;
  animation: brandIn 0.7s 0.34s ease-out both;
}

.diff-label {
  position: relative;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fde68a;
  margin-top: -0.25rem;
  animation: brandIn 0.7s 0.2s ease-out both;
}

.mod-badge {
  position: relative;
  font-size: 0.85rem;
  font-weight: 800;
  color: #a7f3d0;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(52, 211, 153, 0.45);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  animation: brandIn 0.7s 0.16s ease-out both;
}

.mod-badge.hidden {
  display: none !important;
}

.mod-error {
  position: relative;
  min-height: 1.1em;
  max-width: min(340px, 92vw);
  font-size: 0.82rem;
  font-weight: 700;
  color: #fda4af;
  text-align: center;
}

.mod-logo {
  display: block;
  max-width: min(220px, 50vw);
  max-height: 96px;
  object-fit: contain;
  margin: 0 auto 0.35rem;
  animation: brandIn 0.7s ease-out both;
}

.mod-logo.hidden {
  display: none !important;
}

#startPanel.mod-drop-hover {
  outline: 3px dashed rgba(251, 191, 36, 0.75);
  outline-offset: -10px;
}

.leaderboard {
  position: relative;
  list-style: none;
  width: min(360px, 94vw);
  margin: 0.15rem 0 0.35rem;
  padding: 0.55rem 0.85rem;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  font-family: var(--font-body);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  color: rgba(255, 247, 237, 0.9);
  animation: brandIn 0.7s 0.22s ease-out both;
}

.leaderboard-top10 {
  width: 100%;
  margin: 0;
  padding: 0.15rem 0.15rem 0.05rem;
  background: transparent;
  border: none;
  border-radius: 0;
  max-height: min(28vh, 260px);
  overflow: auto;
  animation: none;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr) 2.6rem 2.2rem 2.6rem;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.15rem;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.leaderboard li:last-child {
  border-bottom: none;
}

.leaderboard .lb-rank {
  color: rgb(253, 230, 138, 0.85);
  font-size: 0.82rem;
}

.leaderboard .lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.leaderboard .lb-score {
  text-align: right;
  color: #fff7ed;
}

.leaderboard .lb-poles,
.leaderboard .lb-time {
  text-align: right;
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(255, 247, 237, 0.68);
}

.leaderboard .lb-empty {
  display: block;
  text-align: center;
  color: rgba(255, 247, 237, 0.55);
  font-weight: 600;
  border-bottom: none;
  padding: 0.65rem 0.25rem;
}

.opt-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.opt-select {
  appearance: none;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-bright);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.opt-divider {
  margin-top: 0.25rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(253, 230, 138, 0.75);
}

.highscore-entry {
  width: min(280px, 90vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.85rem 1rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 16px;
}

.highscore-entry.hidden {
  display: none !important;
}

.hs-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fde68a;
}

.hs-hint {
  font-size: 0.85rem;
  color: rgba(255, 247, 237, 0.7);
}

.hs-input {
  width: 5.5rem;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  padding: 0.45rem 0.35rem;
  border-radius: 10px;
  border: 2px solid rgba(251, 191, 36, 0.65);
  background: rgba(255, 247, 237, 0.95);
  color: #1c1917;
  text-transform: uppercase;
  pointer-events: auto;
}

.hs-input-name {
  width: min(240px, 80vw);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-indent: 0;
  text-transform: none;
}

.hs-error {
  min-height: 1.1em;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fda4af;
}

#endBtnRow.hidden {
  display: none !important;
}

.options-card {
  width: min(340px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.1rem 1.2rem;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  pointer-events: auto;
}

.opt-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-bright);
  cursor: pointer;
  user-select: none;
}

.opt-toggle input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: #14b8a6;
  cursor: pointer;
}

.opt-slider {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  pointer-events: auto;
}

.opt-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  font-weight: 700;
  color: rgba(255, 247, 237, 0.9);
}

.opt-label em {
  font-style: normal;
  color: #fde68a;
  font-variant-numeric: tabular-nums;
}

.opt-slider input[type="range"] {
  width: 100%;
  accent-color: #f59e0b;
  cursor: pointer;
  touch-action: none;
}

/* Portrait / landscape layout */
@media (orientation: portrait) {
  #startPanel,
  #pausePanel,
  #gameOverPanel {
    padding-top: max(env(safe-area-inset-top), min(8vh, 64px));
    padding-bottom: env(safe-area-inset-bottom);
  }

  #startPanel.start-panel {
    padding-top: max(0.5rem, env(safe-area-inset-top));
  }

  #pausePanel .brand,
  #gameOverPanel .brand,
  #optionsPanel .brand {
    font-size: clamp(2.8rem, 14vw, 5rem);
  }

  #hud {
    flex-wrap: wrap;
    padding: max(0.65rem, env(safe-area-inset-top)) 0.75rem 0.65rem;
  }

  .hud-stats {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

  .hud-jump {
    max-width: 100%;
  }

  .hint {
    max-width: min(340px, 92vw);
    font-size: 0.82rem;
  }
}

@media (orientation: landscape) and (max-height: 480px) {
  #startPanel.start-panel {
    padding-top: max(0.35rem, env(safe-area-inset-top));
    grid-template-rows:
      auto
      minmax(0, 22vh)
      minmax(0.35rem, 0.7fr)
      auto
      minmax(0.35rem, 0.7fr)
      auto
      auto;
    gap: 0.25rem;
  }

  .start-hero .brand {
    font-size: clamp(1.8rem, 7vw, 2.8rem);
  }

  .start-hero .tagline,
  .debug-toggle {
    display: none;
  }

  .start-scores {
    width: min(300px, 48vw);
  }

  .btn-row-waterline {
    width: min(360px, 70vw);
  }

  .start-hint {
    font-size: 0.78rem;
  }

  #hud {
    padding: max(0.4rem, env(safe-area-inset-top)) 1rem 0.4rem;
  }
}

/* Courseware ModKit embed (?preview=1) */
html.preview-embed .mod-badge,
html.preview-embed #modError {
  display: none !important;
}

html.preview-embed #startPanel {
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--surface-backdrop) 72%, transparent) 0%,
      color-mix(in srgb, var(--accent-primary) 22%, transparent) 42%,
      color-mix(in srgb, var(--surface-backdrop) 55%, transparent) 100%
    );
}

html.preview-embed .start-glow {
  background: radial-gradient(circle, color-mix(in srgb, var(--text-bright) 28%, transparent), transparent 65%);
}

