/* File: css/pages/simulation.css
 * Owner: Person B (Saurav)
 * AI-assisted (update): Claude, 2026-11-15 - responsive pass: grid blow-out fix, canvas-first builder with a sticky bottom parts tray on phones/tablets, landscape-phone side rail, dvh heights. Reviewed by a human: YES, Person C (Yochan).
 * AI-assisted (update): Claude, 2026-11-15 - 44px zoom/undo buttons on touch screens wider than 960px. Reviewed by a human: YES, Person C (Yochan).
 * AI-assisted (update): Claude, 2026-11-15 - landscape phones: compact burn panel strip, flight window full width while a burn is open. Reviewed by a human: YES, Person C (Yochan).
 * AI-assisted (update): Claude, 2026-11-15 - pause overlay for the flight view. Reviewed by a human: YES, Person C (Yochan).
 * AI-assisted (update): Claude, 2026-11-15 - zoom -/+ buttons keep a 44px minimum width on every screen size. Reviewed by a human: YES, Person C (Yochan).
 * AI-assisted: YES — Gemini, 2026-11-14; Gemini, 2026-11-15; Claude, 2026-11-14 (flight view and burn panel styles); Claude, 2026-11-15 (burn panel buttons). Reviewed by a human: YES, Person C (Yochan).
 * AI-assisted (update): Gemini, 2026-11-15 - CAD crosshair snap indicators, 60fps GPU-composited drag performance, and prominent Science HUD meter. Reviewed by a human: YES, Person C (Yochan).
 * Sources used: none
 */
#b3 {
  display: grid;
  grid-template-columns: clamp(220px, 19vw, 270px) minmax(320px, 1fr) clamp(300px, 25vw, 380px);
  gap: 14px;
  align-items: start;
}

/* Grid children may shrink below their content width; wide content (the canvas) scrolls inside its own box. */
#b3 > *,
.fl3 > * {
  min-width: 0;
}

#pal,
#mt {
  padding: 12px 14px;
  background: #102a46f2;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  box-shadow: 0 8px 28px #040d1866;
  contain: layout style;
}

#pal h3 {
  margin: 12px 0 6px;
}

#mute.sound-on {
  border-color: var(--ok);
  color: var(--ok);
  background: #12304f;
}

.lock-toggle {
  border-color: #4c8fd1;
}

.lock-toggle.locked-on {
  border-color: var(--accent);
  background: #ffc85726;
  color: var(--accent);
  font-weight: 700;
}

.tile {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  margin: 5px 0;
  padding: 7px 9px;
  text-align: left;
  background: #0b2038cc;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
  transition: transform 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}

.tile:hover {
  border-color: var(--accent);
  background: #163a61ee;
  transform: translate3d(3px, 0, 0);
}

.tile img {
  width: 46px;
  height: 40px;
  object-fit: contain;
  flex: none;
  pointer-events: none;
}

.tile small {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Prominent Science Return HUD Pill & Progress Bar in Builder */
.science-hud-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  background: linear-gradient(135deg, #0b223d, #133559);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 2px 10px #040d1866;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.science-hud-wrap.goal-met {
  border-color: var(--ok);
  box-shadow: 0 0 14px #7fe3b833;
}

.science-hud-wrap.min-met {
  border-color: var(--accent);
}

.science-hud-wrap.low {
  border-color: var(--bad);
}

.science-hud-bar {
  width: 74px;
  height: 8px;
  background: #061322;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #295c8f88;
}

.science-hud-bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.22s ease, background-color 0.22s ease;
}

/* Full-bleed blueprint grid across the entire canvas viewport */
#cv {
  position: relative;
  width: 100%;
  height: calc(100vh - 208px);
  height: calc(100dvh - 208px);
  min-height: 480px;
  margin: 0;
  overflow: auto;
  background-color: #08182be0;
  background-image:
    linear-gradient(#5da9ff1e 1px, transparent 1px),
    linear-gradient(90deg, #5da9ff1e 1px, transparent 1px),
    linear-gradient(#5da9ff0c 1px, transparent 1px),
    linear-gradient(90deg, #5da9ff0c 1px, transparent 1px),
    radial-gradient(circle at 50% 48%, #1d4b7a66, #08182be8 78%);
  background-size:
    80px 80px,
    80px 80px,
    20px 20px,
    20px 20px,
    100% 100%;
  background-attachment: local, local, local, local, scroll;
  border: 1.5px solid #4484c4;
  box-shadow: inset 0 0 42px #040d18dd, 0 8px 28px #00000066;
  border-radius: 12px;
  touch-action: none;
  cursor: grab;
  contain: strict;
}

#cv.design-locked {
  border-color: var(--accent);
  box-shadow: inset 0 0 42px #040d18dd, 0 0 0 1px #ffc85766;
}

#cv.design-locked #world .pt {
  cursor: pointer;
}

#cv:active {
  cursor: grabbing;
}

#wr {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  margin: 0 auto;
}

/* Keep transform-origin: 0 0 so controls.js clientToWorldCoords() stays exact */
#world {
  position: relative;
  width: 960px;
  height: 1100px;
  transform-origin: 0 0;
  will-change: transform;
  background-image:
    radial-gradient(2px 2px at 140px 180px, #ffffff55, transparent),
    radial-gradient(1.5px 1.5px at 780px 240px, #7fe3b866, transparent),
    radial-gradient(2px 2px at 260px 620px, #ffc85755, transparent),
    radial-gradient(1.5px 1.5px at 720px 760px, #ffffff44, transparent),
    radial-gradient(1.5px 1.5px at 480px 120px, #ffffff44, transparent),
    linear-gradient(90deg, transparent 479px, #ffc8572e 479px, #ffc8572e 481px, transparent 481px);
  background-size: 960px 1100px;
}

/* Zero expensive SVG filter passes during idle or drag for 60fps smoothness */
.pt {
  position: absolute;
  user-select: none;
  touch-action: none;
  -webkit-user-drag: none;
  backface-visibility: hidden;
}

#world .pt {
  cursor: grab;
}

#world .pt:hover {
  outline: 1.5px dashed #7fe3b888;
  outline-offset: 2px;
  border-radius: 6px;
}

.pt.dragging {
  cursor: grabbing !important;
  opacity: 0.92;
  will-change: left, top;
}

.pt.sel {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
  background: #ffc85712;
}

.pt.float {
  opacity: 0.72;
  outline: 2px dashed var(--bad);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Sleek CAD Precision Crosshair Port Indicators (Only shown while dragging or part selected) */
.nd {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px;
  border-radius: 50%;
  border: 1.5px solid #7fe3b8cc;
  background: #08182bcc;
  z-index: 50;
  pointer-events: none;
  transition: transform 0.1s ease, border-color 0.1s ease, background-color 0.1s ease;
}

.nd::before,
.nd::after {
  content: '';
  position: absolute;
  background: currentColor;
  color: #7fe3b8;
}

.nd::before {
  left: 50%;
  top: 2px;
  bottom: 2px;
  width: 1.5px;
  margin-left: -0.75px;
}

.nd::after {
  top: 50%;
  left: 2px;
  right: 2px;
  height: 1.5px;
  margin-top: -0.75px;
}

.nd.own {
  border-color: #60a5fa;
  opacity: 0.75;
}

.nd.own::before,
.nd.own::after {
  color: #60a5fa;
}

.nd.hot {
  border-color: var(--accent);
  background: #ffc85733;
  transform: scale(1.55);
  box-shadow: 0 0 12px #ffc857aa;
}

.nd.hot::before,
.nd.hot::after {
  color: var(--accent);
}

.com {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: radial-gradient(#ffc857 42%, #10243b 48%);
  z-index: 49;
  pointer-events: none;
}

.thr {
  position: absolute;
  width: 0;
  border-left: 2px dashed var(--ok);
  opacity: 0.75;
  z-index: 48;
  pointer-events: none;
}

#insp {
  min-height: 46px;
  padding: 8px 10px;
  margin-top: 6px;
  background: #102a46f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Unified Section & Metric Boxes */
.panel-section-label {
  margin: 4px 0 6px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}

.resource-system,
.resource-card,
.panel-card {
  margin-top: 8px;
  background: #0b2038a8;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.resource-card,
.panel-card {
  padding: 8px 10px;
}

.resource-card .m:first-child {
  margin-top: 0;
}

.resource-system.bad,
.resource-card.bad {
  border-color: #ff856d88;
}

.resource-system.w,
.resource-card.w {
  border-color: #ffc85788;
}

.panel-card-title {
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
}

.forecast-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
}

.forecast-grid > div {
  padding: 5px 8px;
  background: #12304f99;
  border: 1px solid #295c8f66;
  border-radius: 6px;
}

.forecast-grid small {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
}

.forecast-grid b {
  font-size: 0.88rem;
  color: var(--text);
}

.resource-system > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.resource-system > summary::-webkit-details-marker {
  display: none;
}

.resource-system > summary::before {
  content: '▸';
  font-size: 0.85rem;
  color: var(--accent);
  transition: transform 0.15s ease;
}

.resource-system[open] > summary::before {
  transform: rotate(90deg);
}

.resource-system > summary:hover {
  background: #163a61aa;
}

.topic-title {
  flex: 1;
  font-size: 0.94rem;
}

.topic-sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.topic-badge {
  font-size: 0.8rem;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.resource-system-content {
  padding: 4px 10px 10px;
  border-top: 1px solid #295c8f66;
}

.resource-system-content .m:first-child {
  margin-top: 4px;
}

.sub-branch {
  color: var(--accent);
  font-weight: 700;
}

/* Compact Engineering Alerts Reminder Dropdown */
.alerts-box {
  margin-bottom: 10px;
  background: #0b2038cc;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.alerts-box.bad {
  border-color: var(--bad);
}

.alerts-box.w {
  border-color: var(--accent);
}

.alerts-box.ok {
  border-color: var(--ok);
}

.alerts-box > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 0.92rem;
}

.alerts-box > summary::-webkit-details-marker {
  display: none;
}

.alerts-box > summary::before {
  content: '▸';
  font-size: 0.85rem;
  color: var(--accent);
  transition: transform 0.15s ease;
}

.alerts-box[open] > summary::before {
  transform: rotate(90deg);
}

.alerts-list {
  padding: 6px 10px 10px;
  border-top: 1px solid #295c8f66;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alert-item {
  font-size: 0.84rem;
  line-height: 1.4;
  padding: 5px 8px;
  border-radius: 6px;
  background: #12304fbb;
  border-left: 3px solid var(--line);
}

.alert-item.bad {
  border-left-color: var(--bad);
}

.alert-item.w {
  border-left-color: var(--accent);
}

.alert-pill {
  display: inline-block;
  margin-right: 5px;
  padding: 1px 5px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid currentColor;
}

.alert-pill.bad {
  color: var(--bad);
}

.alert-pill.w {
  color: var(--accent);
}

.alert-clear {
  margin: 0;
  font-size: 0.84rem;
  color: var(--ok);
}

.m {
  display: grid;
  grid-template-columns: 118px 1fr 56px;
  align-items: center;
  gap: 3px 8px;
  margin-top: 8px;
}

.m.sub {
  margin-top: 6px;
  padding-left: 10px;
  border-left: 2px solid #3c78b566;
  opacity: 0.95;
}

.m i {
  height: 10px;
  overflow: hidden;
  background: #0b2038;
  border-radius: 5px;
}

.m u {
  display: block;
  height: 100%;
  transition: width 0.25s ease, background-color 0.25s ease;
}

.ok u { background: var(--ok); }
.w u { background: var(--accent); }
.bad u { background: var(--bad); }

.m b {
  font-size: 0.85rem;
  text-align: right;
}

b.ok { color: var(--ok); }
b.w { color: var(--accent); }
b.bad { color: var(--bad); }

.m em {
  grid-column: 2 / 4;
  font-style: normal;
  font-size: 0.82rem;
  color: var(--muted);
}

.why {
  grid-column: 1 / 4;
  margin: 3px 0 2px;
  padding: 5px 8px;
  font-size: 0.84rem;
  line-height: 1.4;
  color: #dbe8f5;
  background: #12304f88;
  border-radius: 5px;
}

.m span b,
.resource-number {
  color: var(--accent);
  font-weight: 700;
}

.chk {
  margin: 5px 0;
  font-size: 0.88rem;
}

.chk.ok { color: var(--ok); }
.chk.w { color: var(--accent); }
.chk.bad { color: var(--bad); }

.fl3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 24vw, 340px);
  gap: 16px;
}

#flv {
  position: relative;
  display: flex;
  justify-content: center;
  height: calc(100vh - 140px);
  height: calc(100dvh - 140px);
  min-height: 520px;
  overflow: hidden;
  background: linear-gradient(#0a1b3099, #14375a99);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.flc {
  position: relative;
  width: 520px;
  height: 540px;
}

.flc .pt {
  pointer-events: none;
}

.flc .plume {
  opacity: 0;
}

.flc.fly .plume {
  opacity: 1;
}

.flc.orbit {
  animation: orbitBob 3s ease-in-out infinite;
}

.flc.orbit .plume {
  opacity: 0;
}

@keyframes orbitBob {
  50% { transform: translateY(-8px); }
}

.flc.boom {
  animation: boom 0.8s forwards;
}

@keyframes boom {
  50% { transform: scale(1.2) rotate(6deg); filter: brightness(3); }
  to { transform: scale(0.2); opacity: 0; }
}

#log p {
  margin: 8px 0;
}

#log .bad { color: var(--bad); }
#log .ok { color: var(--ok); }

#ch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

/* ---- Flight screen: stack the log under the flight window on tablets and phones ---- */
@media (max-width: 1024px) {
  .fl3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .fl3 .box {
    max-height: 40vh;
    max-height: 40dvh;
  }

  #flv {
    height: min(66vh, 560px);
    height: min(66dvh, 560px);
    min-height: 380px;
  }
}

/* ---- Builder on tablets (portrait) and phones: canvas first, parts tray pinned to the bottom ----
   The three-column workspace needs about 960px. Below that the ship is the main thing on screen,
   the parts live in a horizontal tray under it, and the resource meters follow underneath. */
@media (max-width: 960px) {
  #b3 {
    /* minmax(0, 1fr) lets the column shrink below its content's width.
       Plain 1fr stretched the whole builder to ~1730px (the canvas world size) on phones. */
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  #b3 > .b-main {
    order: 1;
  }

  #mt {
    order: 3;
    max-height: none;
  }

  #cv {
    height: clamp(300px, calc(100vh - 330px), 640px);
    height: clamp(300px, calc(100dvh - 330px), 640px);
    min-height: 280px;
  }

  /* Tool row: one scrolling line (Undo and zoom first) instead of five wrapped rows eating the screen */
  .builder-tools {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .builder-tools::-webkit-scrollbar {
    display: none;
  }

  .builder-tools > * {
    flex: none;
  }

  .builder-tools [data-a="undo"],
  .builder-tools [data-a="zo"],
  .builder-tools [data-a="zi"] {
    order: -1;
  }

  .builder-tools [data-a="zo"],
  .builder-tools [data-a="zi"] {
    min-width: 44px;
  }

  /* The parts tray */
  #pal {
    order: 2;
    position: sticky;
    bottom: 0;
    z-index: 6;
    display: flex;
    align-items: stretch;
    gap: 8px;
    max-height: none;
    margin: 0 -4px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    background: #0a1c32f8;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 28px #040d18bb;
  }

  #pal > div {
    display: flex;
    flex: none;
    align-items: stretch;
    gap: 6px;
    padding-right: 8px;
    border-right: 1px solid #295c8f66;
  }

  #pal > div:last-child {
    border-right: 0;
  }

  /* Group label (Structure, Power, ...) becomes a small tag at the start of each group */
  #pal h3 {
    flex: none;
    align-self: center;
    width: 88px;
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
  }

  .tile {
    flex: none;
    width: 170px;
    min-height: 64px;
    margin: 0;
    padding: 6px 8px;
    gap: 8px;
    /* swipe sideways = scroll the tray; drag up = lift the part onto the canvas; tap = place it */
    touch-action: pan-x;
  }

  .tile:hover {
    transform: none;
  }

  .tile img {
    width: 38px;
    height: 34px;
  }

  .tile b {
    display: block;
    font-size: 0.85rem;
    line-height: 1.2;
  }

  .tile small {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.72rem;
    line-height: 1.25;
  }
}

@media (max-width: 480px) {
  #cv {
    min-height: 260px;
  }

  .m {
    grid-template-columns: 102px 1fr 48px;
  }

  .tile {
    width: 156px;
  }
}

/* ---- Landscape phones (short and wide): ship on the left, parts as a side rail on the right ---- */
@media (max-width: 960px) and (max-height: 520px) and (orientation: landscape) {
  #b3 {
    grid-template-columns: minmax(0, 1fr) 232px;
    align-items: start;
  }

  #b3 > .b-main {
    grid-column: 1;
    grid-row: 1;
  }

  #pal {
    grid-column: 2;
    grid-row: 1;
    top: 8px;
    bottom: auto;
    display: block;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    margin: 0;
    padding: 8px 10px;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 8px 28px #040d1866;
  }

  #pal > div {
    display: block;
    padding-right: 0;
    border-right: 0;
  }

  #pal h3 {
    width: auto;
    margin: 8px 0 4px;
    text-align: left;
    font-size: 0.85rem;
  }

  .tile {
    width: 100%;
    margin: 4px 0;
    touch-action: pan-y;
  }

  #mt {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  #cv {
    height: calc(100vh - 140px);
    height: calc(100dvh - 140px);
    min-height: 220px;
  }

  /* flight: window on the left, log on the right */
  .fl3 {
    grid-template-columns: minmax(0, 1fr) minmax(200px, 34%);
  }

  #flv {
    height: calc(100vh - 90px);
    height: calc(100dvh - 90px);
    min-height: 300px;
  }

  .fl3 .box {
    max-height: calc(100vh - 90px);
    max-height: calc(100dvh - 90px);
  }

  /* While a manual burn is open the flight window takes the full width (the log drops below)
     and the burn panel becomes a compact strip, so the map stays visible above it. */
  #flv.burning {
    grid-column: 1 / -1;
    height: calc(100vh - 80px);
    height: calc(100dvh - 80px);
    min-height: 290px;
  }

  #flv #burn {
    left: 10px;
    right: 10px;
    bottom: 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 34%);
    column-gap: 12px;
    align-items: center;
    width: auto;
    padding: 8px 12px;
    transform: none;
  }

  #flv #burntxt {
    grid-column: 1;
    margin: 0 0 4px;
    font-size: 0.8rem;
    line-height: 1.25;
  }

  #flv #burngauge {
    grid-column: 1;
    height: 22px;
    border-radius: 11px;
  }

  #flv #burnstate {
    grid-column: 1;
    min-height: 1.2em;
    margin: 4px 0 0;
    font-size: 0.85rem;
  }

  #flv #burn .row {
    grid-column: 2;
    grid-row: 1 / span 3;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 6px;
  }

  #flv #burn .row button {
    width: 100%;
    min-width: 0;
  }
}

#flv.sunhit {
  background: radial-gradient(circle at 50% -10%, #fff3b0, #ffb347 25%, #ff5a1f 55%, #3a0d05) !important;
  transition: background 3s;
}

.flc.burn {
  filter: sepia(1) saturate(8) brightness(1.5);
  transition: filter 1.5s;
}

/* ---- Stage 3 flight view: canvas, HUD and the manual burn panel ---- */
#flcv {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#flcw {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 520px;
  height: 540px;
  pointer-events: none;
  will-change: transform, opacity;
}

.fl3 .box {
  max-height: calc(100vh - 140px);
  max-height: calc(100dvh - 140px);
  min-height: 0;
  overflow-y: auto;
}

.fl3 .box h2 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#fnext {
  position: absolute;
  bottom: 14px;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
}

.flc.gone {
  opacity: 0;
  pointer-events: none;
  transition: transform 4.5s ease-in, opacity 0.6s;
}

#flhud {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  max-width: calc(100% - 170px);
  pointer-events: none;
  background: rgba(8, 22, 40, 0.82);
  border: 1px solid #295c8f88;
  border-radius: 8px;
}

#flhud .flph {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

#flhud .flday {
  font-size: 0.95rem;
  color: var(--muted);
}

#flhud .flsci {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ok);
  margin-top: 2px;
}

#fskip {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
}

#burn {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 3;
  width: min(560px, calc(100% - 24px));
  transform: translateX(-50%);
  padding: 12px 14px;
  background: rgba(8, 22, 40, 0.93);
  border: 1px solid var(--line);
  border-radius: 12px;
}

#burntxt {
  margin: 0 0 8px;
}

#burngauge {
  position: relative;
  height: 30px;
  overflow: hidden;
  background: #0a1b30;
  border: 2px solid var(--line);
  border-radius: 15px;
}

#burnzone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  background: rgba(127, 227, 184, 0.28);
  border-right: 2px solid var(--ok);
  border-left: 2px solid var(--ok);
}

#burnmark {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 2px;
  margin-left: -1px;
  background: var(--ok);
}

#burnfill {
  position: relative;
  z-index: 1;
  width: 0;
  height: 100%;
  background: var(--accent);
}

#burnfill.in {
  background: var(--ok);
}

#burnstate {
  min-height: 1.5em;
  margin: 8px 0;
  font-weight: 700;
}

#burn .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#burn .row button {
  margin-top: 0;
}

#burnbtn {
  min-width: 160px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Small screens: give the map room above the burn panel while the panel is open */
@media (max-width: 1024px) and (min-height: 521px) {
  #flv.burning {
    height: max(600px, 78vh);
    height: max(600px, 78dvh);
  }
}

#flpause {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 12, 24, 0.6);
}

#flv.paused #flpause {
  display: flex;
}

.flpause-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 26px;
  text-align: center;
  background: rgba(8, 22, 40, 0.95);
  border: 2px solid var(--accent);
  border-radius: 12px;
}

.flpause-box strong {
  font-size: 1.4rem;
  letter-spacing: 1px;
  color: var(--accent);
}

#flv.paused .flc,
#flv.paused .flc * {
  animation-play-state: paused;
}

/* ---- Pre-launch terminal countdown (T-10 to lift-off), drawn over the flight window ---- */
#flcountdown {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  text-align: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(6, 18, 34, 0.72), rgba(4, 12, 24, 0.35));
}

#flcountdown[hidden] {
  display: none;
}

#flcd-num {
  font-size: clamp(3rem, 9vw, 5.2rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 0 0 28px rgba(255, 200, 87, 0.65), 0 4px 12px #000;
}

#flcd-num.pop {
  animation: cdPop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cdPop {
  0% { transform: scale(1.45); opacity: 0.2; }
  100% { transform: scale(1); opacity: 1; }
}

#flcd-sub {
  max-width: 90%;
  font-size: clamp(0.85rem, 2.4vw, 1.05rem);
  color: var(--text);
}

/* Touch screens wider than the phone breakpoint (iPad landscape): keep the zoom and undo buttons finger-sized */
@media (pointer: coarse) {
  .builder-tools [data-a="undo"],
  .builder-tools [data-a="zo"],
  .builder-tools [data-a="zi"] {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Zoom -/+ buttons: 44px minimum touch target on every screen size (not only phones) */
.builder-tools [data-a="zo"],
.builder-tools [data-a="zi"] {
  min-width: 44px;
}
