html {
  font-size: 1px;
}

/* Fonts copied from the Unity project (Hex.Text/Fonts):
   Eurostile Extended Black drives the board digits, Orbitron the UI. */
@font-face {
  font-family: "EurostileExt";
  src: url("../fonts/EurostileExtendedBlack.woff2") format("woff2"),
    url("../fonts/EurostileExtendedBlack.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Orbitron";
  src: url("../fonts/Orbitron-Black.woff2") format("woff2"),
    url("../fonts/Orbitron-Black.ttf") format("truetype");
  font-weight: 900;
  font-display: swap;
}

@font-face {
  font-family: "Orbitron";
  src: url("../fonts/Orbitron-Bold.woff2") format("woff2"),
    url("../fonts/orbitron-bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}

/* Palette ported from Unity HexUIStyle.cs */
:root {
  --panel-bg: rgba(6, 14, 29, 0.82);
  --panel-border: rgba(41, 120, 219, 0.30);
  --text-primary: #b8d6f5;
  --text-secondary: rgba(102, 143, 184, 0.85);
  --accent: #00b8ff;
  --danger: #ff472e;
  --success: #26eb85;
  --backdrop: rgba(2, 4, 9, 0.72);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #020409;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14rem;
  color: var(--text-primary);
  -webkit-user-select: none;
  user-select: none;
  /* Lock the layout viewport on iOS so % / absolute children don't collapse. */
  position: fixed;
  inset: 0;
}

#board {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
  cursor: grab;
  display: block;
  z-index: 0;
  background: #020409;
}

/* Ad strip nudges #board top; shrink height so the planet isn’t centered
   into the clipped region below the fold (shared CSS only sets top). */
body.fg-ads-offset > #board {
  top: var(--fg-ad-h) !important;
  height: calc(100% - var(--fg-ad-h)) !important;
  height: calc(100dvh - var(--fg-ad-h)) !important;
  bottom: auto !important;
  max-height: calc(100dvh - var(--fg-ad-h));
}

/* Keep full-screen menus below the ad strip (shared rule only covers .overlay). */
body.fg-ads-offset > .screen,
body.fg-ads-offset > .modal {
  padding-top: var(--fg-ad-h);
  box-sizing: border-box;
}

#board.dragging {
  cursor: grabbing;
}

/* ---- HUD top bar ---- */

#hud {
  position: absolute;
  top: 14rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(720rem, calc(100% - 28rem));
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

#hud .hud-btn,
#hud .hud-progress {
  pointer-events: auto;
}

.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12rem;
  width: 100%;
  height: 52rem;
  padding: 0 14rem;
  border-radius: 12rem;
  background: linear-gradient(
    to bottom,
    rgba(6, 14, 29, 0.15),
    rgba(6, 14, 29, 0.88)
  );
  border: 1rem solid var(--panel-border);
  backdrop-filter: blur(8rem);
  box-shadow: 0 4rem 24rem rgba(0, 0, 0, 0.5);
}

.hud-progress {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(2rem, 0.8vw, 5rem);
  min-width: 0;
  height: 100%;
}

/* Flat-top hex cells — empty = charcoal + accent pinstripe; filled = marker glow */
.hud-hex {
  position: relative;
  flex: 0 1 auto;
  width: min(30rem, 5.2vw);
  aspect-ratio: 1 / 0.866;
  max-height: 34rem;
}

.hud-hex svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.hud-hex .hex-face {
  fill: #0b0c10;
  transition: fill 0.18s ease;
}

.hud-hex .hex-stripe {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linejoin: round;
  opacity: 0.85;
  transition: stroke 0.18s ease, opacity 0.18s ease;
}

.hud-hex.filled .hex-face {
  fill: var(--accent);
}

.hud-hex.filled .hex-stripe {
  stroke: rgba(255, 255, 255, 0.35);
  opacity: 0.9;
}

.hud-hex.filled {
  filter: drop-shadow(0 0 5rem var(--accent-glow, rgba(0, 184, 255, 0.55)))
    drop-shadow(0 0 12rem var(--accent));
}

.hud-hex.burst {
  animation: hud-hex-burst 0.65s ease-out;
}

@keyframes hud-hex-burst {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
  35% {
    transform: scale(1.22);
    filter: drop-shadow(0 0 10rem var(--accent))
      drop-shadow(0 0 18rem rgba(255, 255, 255, 0.55));
  }
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 5rem var(--accent-glow, rgba(0, 184, 255, 0.55)))
      drop-shadow(0 0 12rem var(--accent));
  }
}

.hud-hex.over {
  filter: drop-shadow(0 0 6rem rgba(255, 71, 46, 0.7));
}

.hud-hex.over .hex-face {
  fill: var(--danger);
}

.hud-hex.over .hex-stripe {
  stroke: rgba(255, 255, 255, 0.45);
}

.hud-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 18rem;
  text-align: center;
  pointer-events: none;
}

.hud-level-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 38rem;
  height: 34rem;
  padding: 0 12rem;
  border-radius: 8rem;
  border: 1rem solid var(--panel-border);
  background: rgba(41, 120, 219, 0.12);
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 14rem;
  font-weight: 700;
  letter-spacing: 1rem;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  user-select: none;
  pointer-events: none;
}

.hud-timer {
  font-family: "Orbitron", "Consolas", monospace;
  font-size: 16rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-shadow: 0 0 18rem rgba(0, 0, 0, 0.65);
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 10rem;
  min-width: 120rem;
}

.hud-center {
  justify-content: center;
}

.hud-right {
  justify-content: flex-end;
}

.hud-label {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: 10rem;
  letter-spacing: 2rem;
  color: var(--text-secondary);
}

.hud-value {
  font-family: "Orbitron", "Consolas", monospace;
  font-size: 18rem;
  font-weight: 700;
  letter-spacing: 1rem;
  font-variant-numeric: tabular-nums;
}

.hud-value.danger {
  color: var(--danger);
}

.hud-btn {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 12rem;
  font-weight: 700;
  letter-spacing: 2rem;
  color: var(--text-primary);
  background: rgba(41, 120, 219, 0.12);
  border: 1rem solid var(--panel-border);
  border-radius: 8rem;
  padding: 8rem 18rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.hud-btn:hover {
  background: rgba(41, 120, 219, 0.28);
  border-color: var(--accent);
}

.hud-btn.active {
  background: rgba(41, 120, 219, 0.3);
  border-color: var(--accent);
}

.menu-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 18rem var(--accent-glow, rgba(0, 184, 255, 0.35));
}

.hud-btn.accent {
  color: var(--accent-text, #04121d);
  background: var(--accent);
  border-color: var(--accent);
}

.hud-btn.accent:hover {
  filter: brightness(1.18);
}

.hud-btn.icon {
  padding: 8rem 12rem;
  font-size: 14rem;
  line-height: 1;
}

.hidden {
  display: none !important;
}

/* ---- Full-page screens (title, level select) ---- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--backdrop);
  z-index: 20;
  overflow-y: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Title screen — art-driven layout matching the menu concept.
   Use #id so overflow wins over .screen { overflow-y: auto }.
   Size with vw/vh/px (not rem) so the 1px-root rem scale can't blow up mobile. */
#titleScreen.title-screen {
  background: #020409;
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.title-starfield {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  user-select: none;
}

.title-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  height: 100%;
  max-height: 100%;
  padding: clamp(12px, 3vh, 28px) 16px clamp(16px, 4vh, 36px);
  box-sizing: border-box;
  overflow: hidden;
}

/* Sphere + wordmark share the same 1254² artboard — stack 1:1 */
.title-hero {
  position: relative;
  width: min(72vw, 48vh, 560px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  flex: 0 0 auto;
}

.title-sphere,
.title-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.title-logo {
  z-index: 2;
}

.game-subtitle {
  position: absolute;
  left: 0;
  right: 0;
  top: 57.5%;
  z-index: 3;
  margin: 0;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: clamp(10px, 1.8vmin, 15px);
  letter-spacing: 0.55em;
  padding-left: 0.55em; /* recenters letter-spaced text */
  color: #5ec8ff;
  text-shadow: 0 0 18px rgba(0, 200, 255, 0.55),
    0 0 40px rgba(0, 160, 255, 0.28);
  pointer-events: none;
}

.title-buttons,
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14rem;
  align-items: center;
}

.title-actions {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  width: min(360px, 78vw);
}

.title-buttons {
  position: relative;
  z-index: 4;
  width: 100%;
  margin-top: clamp(-36px, -5vh, -12px);
  gap: clamp(8px, 1.4vh, 14px);
  flex: 0 0 auto;
}

/* Image buttons — label is baked into the PNG */
.title-btn {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  border-radius: 0;
  transition: filter 0.15s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.title-btn img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
}

.title-btn:hover,
.title-btn:focus-visible {
  filter: brightness(1.16) saturate(1.08);
  outline: none;
}

.title-btn:active {
  filter: brightness(0.92);
  transform: scale(0.985);
}

.menu-btn {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 15rem;
  font-weight: 700;
  letter-spacing: 3rem;
  width: min(300rem, 90%);
  padding: 14rem 0;
  color: var(--text-primary);
  background: rgba(41, 120, 219, 0.12);
  border: 1rem solid var(--panel-border);
  border-radius: 10rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, filter 0.15s;
}

.menu-btn:hover {
  background: rgba(41, 120, 219, 0.28);
  border-color: var(--accent);
}

.menu-btn.accent {
  color: var(--accent-text, #04121d);
  background: var(--accent);
  border-color: var(--accent);
}

.menu-btn.accent:hover {
  filter: brightness(1.18);
}

.link-btn {
  margin-top: 20rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 10rem;
  letter-spacing: 2rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.link-btn:hover {
  color: var(--text-primary);
}

.title-back {
  display: inline-block;
  margin-top: clamp(18px, 3.5vh, 32px);
  text-decoration: none;
  color: rgba(150, 180, 210, 0.72);
  letter-spacing: 0.28em;
  padding-left: 0.28em;
  flex: 0 0 auto;
}

.title-back:hover {
  color: #b8d6f5;
}

/* Compact title layout on short viewports */
@media (max-height: 720px) {
  .title-hero {
    width: min(62vw, 42vh, 420px);
  }

  .title-actions {
    width: min(300px, 70vw);
  }

  .title-buttons {
    margin-top: clamp(-28px, -4vh, -8px);
  }
}

@media (max-height: 560px) {
  .title-hero {
    width: min(48vw, 34vh, 300px);
  }

  .game-subtitle {
    font-size: clamp(8px, 1.5vmin, 12px);
  }

  .title-actions {
    width: min(260px, 62vw);
  }

  .title-buttons {
    gap: 6px;
  }

  .title-back {
    margin-top: 12px;
  }
}

/* iPhone / short landscape: sphere beside actions so nothing clips */
@media (orientation: landscape) and (max-height: 520px) {
  #titleScreen.title-screen .title-inner {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 3vw, 40px);
    padding: clamp(6px, 2vh, 14px) clamp(12px, 3vw, 28px);
  }

  .title-hero {
    /* Stay inside the padded content box (viewport minus ad strip). */
    width: min(calc(100dvh - var(--fg-ad-h, 0px) - 16px), 38vw, 280px);
    flex: 0 0 auto;
  }

  .title-actions {
    width: min(280px, 42vw);
    align-items: stretch;
  }

  .title-buttons {
    margin-top: 0;
    gap: clamp(4px, 1.4vh, 10px);
  }

  .title-back {
    margin-top: clamp(6px, 2vh, 14px);
  }

  .game-subtitle {
    font-size: clamp(7px, 2.2vh, 12px);
    letter-spacing: 0.4em;
    padding-left: 0.4em;
  }
}

/* ---- Level select ---- */

.level-inner {
  width: min(720rem, calc(100% - 28rem));
  max-height: calc(100% - 48rem);
  padding: 22rem 24rem 26rem;
  border-radius: 16rem;
  background: var(--panel-bg);
  border: 1rem solid var(--panel-border);
  backdrop-filter: blur(10rem);
  box-shadow: 0 8rem 48rem rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 14rem;
  margin-bottom: 18rem;
}

.screen-title {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-weight: 900;
  font-size: 18rem;
  letter-spacing: 5rem;
  color: var(--text-primary);
}

.screen-title.center {
  text-align: center;
  margin-bottom: 22rem;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120rem, 1fr));
  gap: 10rem;
  overflow-y: auto;
  padding-right: 4rem;
}

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5rem;
  padding: 12rem 8rem 10rem;
  border-radius: 10rem;
  background: rgba(41, 120, 219, 0.08);
  border: 1rem solid var(--panel-border);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.level-card:hover:not(:disabled) {
  background: rgba(41, 120, 219, 0.22);
  border-color: var(--accent);
}

.level-card:disabled {
  opacity: 0.35;
  cursor: default;
}

.level-card.current {
  border-color: var(--accent);
  background: rgba(41, 120, 219, 0.14);
}

.level-card .lc-num {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-weight: 900;
  font-size: 20rem;
  color: var(--text-primary);
}

.level-card .lc-dot {
  width: 12rem;
  height: 12rem;
  border-radius: 50%;
  border: 1rem solid rgba(255, 255, 255, 0.25);
}

.level-card .lc-dot.inv {
  border-radius: 3rem; /* square dot marks inverted levels */
}

.level-card .lc-info {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 8rem;
  letter-spacing: 0.5rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.level-card .lc-best {
  font-family: "Orbitron", "Consolas", monospace;
  font-size: 9rem;
  letter-spacing: 0.5rem;
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

.level-card .lc-lock {
  font-size: 14rem;
  color: var(--text-secondary);
}

.level-card .lc-progress {
  position: relative;
  width: calc(100% - 8rem);
  height: 13rem;
  border-radius: 7rem;
  background: rgba(184, 214, 245, 0.12);
  border: 1rem solid rgba(184, 214, 245, 0.18);
  overflow: hidden;
}

.level-card .lc-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  opacity: 0.75;
}

.level-card .lc-progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 8rem;
  font-weight: 700;
  letter-spacing: 0.5rem;
  color: var(--text-primary);
  text-shadow: 0 0 3rem rgba(0, 0, 0, 0.8);
}

/* ---- Modals (help, pause, win/lose) ---- */

.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--backdrop);
  /* Above .screen (20) so help opens over the title screen. */
  z-index: 30;
}

.modal-panel {
  width: min(560rem, calc(100% - 28rem));
  max-height: calc(100% - 48rem);
  overflow-y: auto;
  padding: 26rem 32rem 30rem;
  border-radius: 16rem;
  background: var(--panel-bg);
  border: 1rem solid var(--panel-border);
  backdrop-filter: blur(10rem);
  box-shadow: 0 8rem 48rem rgba(0, 0, 0, 0.7);
}

.modal-panel.narrow {
  width: auto;
  min-width: min(380rem, calc(100% - 28rem));
  text-align: center;
  padding: 40rem 56rem;
}

.help-body {
  font-size: 13rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.help-body p {
  margin-bottom: 14rem;
}

.help-list {
  list-style: none;
  margin-bottom: 14rem;
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

.help-body b {
  color: var(--accent);
  font-weight: 600;
}

.help-sum {
  color: var(--text-secondary);
  font-size: 12rem;
}

.help-columns {
  display: flex;
  gap: 24rem;
  margin-bottom: 14rem;
}

.help-col {
  flex: 1;
  min-width: 0;
}

.help-col-title {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: 11rem;
  letter-spacing: 3rem;
  color: var(--text-secondary);
  margin-bottom: 8rem;
}

/* The device's own column is listed first and highlighted. */
.help-col.primary .help-col-title {
  color: var(--accent);
}

.help-chord {
  color: var(--text-secondary);
  font-size: 12rem;
}

/* ---- Sum clue diagrams (grid of all totals 1-21) ---- */

.bomb-word {
  font-weight: 600;
}

.bomb-word.red {
  color: var(--danger);
}

.bomb-word.gray {
  color: #8b95a6;
}

.sum-rows {
  display: flex;
  flex-direction: column;
  gap: 4rem;
  margin-top: 12rem;
}

.sum-row {
  display: flex;
  align-items: center;
  gap: 16rem;
}

.sum-row-hexes {
  display: flex;
  gap: 4rem;
  flex-shrink: 0;
}

.sum-row-hexes svg {
  display: block;
  width: 110rem;
  height: 110rem;
}

.sum-row .sum-row-text {
  font-size: 13rem;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0;
}

.sum-rows .sg-center {
  font-family: "EurostileExt", "Orbitron", sans-serif;
  font-size: 24rem;
  font-weight: 900;
  fill: #ffffff;
  text-anchor: middle;
  dominant-baseline: middle;
}

.sum-rows .sg-side {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 9rem;
  font-weight: 700;
  fill: var(--accent);
  opacity: 0.85;
  text-anchor: middle;
  dominant-baseline: middle;
}

@media (max-width: 480px) {
  .help-columns {
    flex-direction: column;
    gap: 14rem;
  }

  .sum-row-hexes svg {
    width: 88rem;
    height: 88rem;
  }
}

/* ---- Level debug panel ---- */

.debug-panel {
  position: absolute;
  left: 14rem;
  bottom: 14rem;
  width: 200rem;
  padding: 10rem 12rem;
  border-radius: 10rem;
  background: var(--panel-bg);
  border: 1rem solid var(--panel-border);
  backdrop-filter: blur(8rem);
  box-shadow: 0 4rem 24rem rgba(0, 0, 0, 0.5);
  z-index: 5;
}

.debug-header {
  cursor: pointer;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 10rem;
  font-weight: 700;
  letter-spacing: 2rem;
  color: var(--text-secondary);
}

.debug-body {
  margin-top: 8rem;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

.debug-level {
  display: flex;
  align-items: center;
  gap: 8rem;
  padding: 4rem 8rem;
  background: none;
  border: 1rem solid transparent;
  border-radius: 6rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.debug-level:hover {
  background: rgba(41, 120, 219, 0.15);
}

.debug-level.selected {
  border-color: var(--accent);
  background: rgba(41, 120, 219, 0.1);
}

.debug-level .lv-num {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-weight: 900;
  font-size: 12rem;
  color: var(--text-primary);
  width: 18rem;
  text-align: right;
  flex-shrink: 0;
}

.debug-level .lv-dot {
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  border: 1rem solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.debug-level .lv-info {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 8rem;
  letter-spacing: 0.5rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.debug-sliders {
  margin-top: 8rem;
  padding-top: 8rem;
  border-top: 1rem solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 6rem;
}

.debug-slider {
  display: flex;
  align-items: center;
  gap: 6rem;
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 8rem;
  letter-spacing: 0.5rem;
  color: var(--text-secondary);
}

.debug-slider span:first-child {
  width: 58rem;
  flex-shrink: 0;
}

.debug-slider input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

.debug-slider-val {
  width: 26rem;
  text-align: right;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* ---- Win / lose overlay ---- */

#overlay .modal-panel h1 {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: clamp(26rem, 6vh, 40rem);
  font-weight: 900;
  letter-spacing: 8rem;
  margin-bottom: 12rem;
}

#overlay .modal-panel h1.danger {
  color: var(--danger);
  text-shadow: 0 0 24rem rgba(255, 71, 46, 0.5);
}

#overlay .modal-panel h1.success {
  color: var(--success);
  text-shadow: 0 0 24rem rgba(38, 235, 133, 0.5);
}

#overlayTime {
  font-family: "Orbitron", "Consolas", monospace;
  font-weight: 700;
  font-size: 18rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.overlay-best {
  font-family: "Orbitron", "Segoe UI", sans-serif;
  font-size: 11rem;
  letter-spacing: 2rem;
  color: var(--success);
  margin-top: 8rem;
}

.overlay-buttons {
  display: flex;
  gap: 14rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 26rem;
}

/* ---- Small screens ---- */

@media (max-width: 560px) {
  #hud {
    height: 46rem;
    padding: 0 10rem;
  }

  .hud-group {
    min-width: 0;
    gap: 6rem;
  }

  .hud-value {
    font-size: 14rem;
  }

  #timer {
    font-size: 12rem;
  }

  .hud-btn {
    padding: 7rem 10rem;
    font-size: 10rem;
    letter-spacing: 1rem;
  }

  .modal-panel.narrow {
    padding: 30rem 24rem;
  }
}

/* Short landscape gameplay: compact HUD so the planet keeps vertical room */
@media (orientation: landscape) and (max-height: 520px) {
  #hud {
    top: 6rem;
    width: min(720rem, calc(100% - 20rem));
  }

  .hud-bar {
    height: 40rem;
    padding: 0 10rem;
    gap: 8rem;
  }

  .hud-meta {
    margin-top: 8rem;
  }

  .hud-timer {
    font-size: 13rem;
  }

  .hud-hex {
    width: min(24rem, 4.2vw);
    max-height: 26rem;
  }

  .hud-level-badge {
    min-width: 32rem;
    height: 28rem;
    font-size: 12rem;
    padding: 0 8rem;
  }

  .modal-panel.narrow {
    padding: 22rem 28rem;
  }

  .menu-btn {
    font-size: 12rem;
    padding: 10rem 0;
    width: min(260rem, 90%);
  }
}
