/* HD-2D DOM overlay for CreditQuest. */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --bg: #06070c;
  --panel: #0b0d14;
  --panel-2: #14182a;
  --ink: #e6eefc;
  --dim: #7b89a8;
  --cyan: #4de0ff;
  --cyan-d: #2a8fae;
  --pink: #ff5abf;
  --yellow: #ffcb4a;
  --red: #e04a4a;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  padding: 12px;
  box-sizing: border-box;
  background:
    radial-gradient(ellipse at center, #10141f 0%, #05060b 78%),
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.008) 0px,
      rgba(255,255,255,0.008) 1px,
      transparent 1px,
      transparent 4px
    );
}

#frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(100%, 992px);
  padding: 14px;
  box-sizing: border-box;
  border: 1px solid #1b2236;
  background: #080a12;
  box-shadow: 0 0 0 1px #0f1322 inset, 0 18px 48px rgba(0, 0, 0, 0.42);
}

.bar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--dim);
  text-transform: uppercase;
}
.bar .brand { color: var(--cyan); }
.bar .brand a { color: var(--dim); text-decoration: none; border-bottom: 1px dotted #334; }
.bar .brand a:hover { color: var(--cyan); }
.bar .hint b { color: var(--ink); font-weight: 600; }

#stage {
  position: relative;
  width: min(960px, 100%);
  max-width: 100%;
  max-height: calc(100vh - 170px);
  aspect-ratio: 4 / 3;
  height: auto;
  background: #000;
  border: 1px solid #223;
  overflow: hidden;
}

#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* -------- HUD overlay -------- */
.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  user-select: none;
}

.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

.hearts {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: rgba(6, 8, 14, 0.72);
  border: 1px solid rgba(77, 224, 255, 0.35);
}
.heart {
  width: 18px;
  height: 16px;
  background-size: contain;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

.credits {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(6, 8, 14, 0.72);
  border: 1px solid rgba(77, 224, 255, 0.35);
  color: var(--yellow);
  font-size: 14px;
  letter-spacing: 0.1em;
}
.vibe {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(6, 8, 14, 0.72);
  border: 1px solid rgba(77, 224, 255, 0.35);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0.1em;
}
.vibe .label { color: var(--dim); }
#vibe-num { color: var(--pink); min-width: 1ch; text-align: right; }
.credits .coin {
  width: 12px;
  height: 12px;
  background-size: contain;
  image-rendering: pixelated;
}
.credits .label {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-shadow: none;
}

/* -------- Always-on objective bar -------- */
.objective-bar {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(6,8,14,0.7);
  border: 1px solid rgba(77,224,255,0.18);
  font-size: 11px;
  letter-spacing: 0.16em;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.objective-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 10px;
  margin-bottom: 2px;
}
.objective-bar .label {
  color: var(--cyan);
  margin-right: 0;
}
.objective-bar .chapter {
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.objective-bar .text {
  color: var(--ink);
  text-transform: uppercase;
  display: block;
}
.title .slot-hint {
  font-size: 9px;
  color: var(--dim);
  letter-spacing: 0.12em;
  margin-bottom: 2px;
}
.objective-bar .subtext {
  display: block;
  margin-top: 4px;
  color: var(--cyan-d);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* Help overlay (F1) — static binding list from i18n */
.help-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 5, 10, 0.82);
  box-sizing: border-box;
  pointer-events: auto;
}
.help-overlay.hidden { display: none; }
.help-inner {
  max-width: 420px;
  width: 100%;
  padding: 16px 18px;
  background: rgba(6, 8, 14, 0.96);
  border: 1px solid rgba(77, 224, 255, 0.22);
  box-shadow: 0 0 0 1px #0f1322 inset, 0 0 32px rgba(77, 224, 255, 0.12);
  font-size: 11px;
  letter-spacing: 0.1em;
  line-height: 1.6;
}
.help-title {
  color: var(--cyan);
  font-size: 13px;
  margin: 0 0 10px 0;
  letter-spacing: 0.2em;
}
.help-list {
  list-style: none;
  margin: 0 0 12px 0;
  padding: 0;
  color: var(--ink);
}
.help-list li {
  padding: 4px 0;
  border-bottom: 1px solid rgba(77, 224, 255, 0.08);
}
.help-footer {
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.panel.shop .items .item { cursor: pointer; }

/* -------- Feature 36: first-run tutorial hint --------
   Sits near the bottom-center of the stage, just above the toast band
   and well clear of the HUD. Low-contrast cyan "TIP:" label followed
   by the ink-colored hint text. Opacity is driven each frame from
   window.Core.tutorialHintAlpha() so fades line up with the 2D build. */
.tutorial-hint {
  position: absolute;
  left: 50%;
  bottom: 28%;
  transform: translateX(-50%);
  padding: 4px 12px;
  background: rgba(6, 8, 14, 0.55);
  border: 1px solid rgba(77, 224, 255, 0.14);
  font-size: 12px;
  letter-spacing: 0.14em;
  white-space: nowrap;
  color: var(--ink);
  pointer-events: none;
  opacity: 0;
  transition: none;
}
.tutorial-hint .label {
  color: var(--cyan-d);
  margin-right: 8px;
}
.tutorial-hint .text {
  color: var(--ink);
  text-transform: uppercase;
}

/* -------- Prompt above interactable -------- */
.prompt {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 4px 8px;
  background: rgba(6, 8, 14, 0.85);
  border: 1px solid var(--cyan);
  color: var(--ink);
  font-size: 11px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  box-shadow: none;
}
.prompt .key { color: var(--cyan); font-weight: 700; margin-right: 4px; }

.area-chip {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 12px;
  background: rgba(6, 8, 14, 0.86);
  border: 1px solid rgba(77, 224, 255, 0.35);
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  pointer-events: none;
}

/* -------- Floating damage/credit pop text -------- */
.floaters {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.float-text {
  position: absolute;
  transform: translate(-50%, -100%);
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.04em;
  /* Crisp edge instead of color glow (world uses nearest-filtered art). */
  text-shadow:
    1px 0 0 #000, -1px 0 0 #000, 0 1px 0 #000, 0 -1px 0 #000;
  image-rendering: pixelated;
  white-space: nowrap;
}

body.visual-clarity #stage canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* -------- Toast -------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: 16%;
  transform: translate(-50%, 0);
  padding: 8px 16px;
  background: rgba(6, 8, 14, 0.9);
  border: 1px solid rgba(77, 224, 255, 0.6);
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.12em;
  box-shadow: none;
  transition: opacity 0.25s ease-out;
}

/* -------- Panels (shop/dialog/pause/gameover/victory/title) -------- */
.panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 360px;
  max-width: 560px;
  padding: 20px 26px;
  background: rgba(6, 8, 14, 0.94);
  border: 1px solid var(--cyan);
  color: var(--ink);
  box-shadow: 0 0 0 1px #0f1322 inset;
  pointer-events: auto;
}
.panel h2 {
  margin: 0 0 10px 0;
  color: var(--cyan);
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.panel .lines { margin: 0; padding: 0; list-style: none; }
.panel .lines li { padding: 2px 0; font-size: 13px; color: var(--ink); }
.panel .footer {
  margin-top: 14px;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* shop list */
.shop .header {
  display: flex; justify-content: space-between;
  color: var(--dim); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; margin-bottom: 10px;
}
.shop .header .c { color: var(--yellow); }
.shop .items { list-style: none; padding: 0; margin: 0; }
.shop .item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-left: 2px solid transparent;
  font-size: 13px;
  color: var(--ink);
}
.shop .item .cost { color: var(--yellow); min-width: 60px; text-align: right; letter-spacing: 0.1em; }
.shop .item .desc { color: var(--dim); font-size: 11px; letter-spacing: 0.06em; flex: 1; }
.shop .item.active {
  border-left-color: var(--cyan);
  background: rgba(77, 224, 255, 0.08);
  color: var(--ink);
}
.shop .item.disabled { opacity: 0.45; }
.shop .shop-count {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: -4px 0 10px 0;
}
.shop #shop-desc {
  margin-top: 10px;
  padding: 8px 10px 0 10px;
  border-top: 1px solid rgba(77, 224, 255, 0.2);
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.1em;
  min-height: 14px;
}

/* title screen */
.title {
  text-align: center;
  min-width: 440px;
}
.panel.title {
  background: rgba(8, 10, 16, 0.72);
  border-color: rgba(113, 201, 214, 0.82);
}
.title .logo {
  font-size: 28px;
  letter-spacing: 0.22em;
  color: var(--ink);
  margin-bottom: 4px;
}
.title .subtitle {
  color: var(--yellow);
  font-size: 11px;
  letter-spacing: 0.22em;
  margin-bottom: 24px;
}
.title .press {
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.2em;
  animation: titleBlink 1.1s ease-in-out infinite;
}
.title .controls {
  margin-top: 20px;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.12em;
  line-height: 1.7;
}
.title .controls b { color: var(--ink); font-weight: 600; }
.title .title-start-card {
  max-width: 300px;
  margin: 14px auto 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 203, 74, 0.24);
  background: rgba(255, 203, 74, 0.06);
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.12em;
  line-height: 1.8;
  text-align: left;
  text-transform: uppercase;
}
.title .title-start-card b { color: var(--yellow); }

@keyframes titleBlink { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* Feature 34: CONTINUE hint on the title screen. Sits below the primary
   PRESS X / ENTER line. Colored differently (yellow) so it reads as a
   distinct, secondary option rather than a repeat of the main action. */
.title .continue-hint {
  margin-top: 10px;
  color: var(--yellow);
  font-size: 11px;
  letter-spacing: 0.2em;
}
.title .chapter2-hint {
  margin-top: 8px;
  color: var(--pink);
  font-size: 11px;
  letter-spacing: 0.2em;
}
.title .title-save {
  max-width: 280px;
  margin: 12px auto 0;
  padding: 10px 12px;
  border: 1px solid rgba(113, 201, 214, 0.18);
  background: rgba(8, 10, 16, 0.55);
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--dim);
}
.title .title-save .head {
  color: var(--cyan);
  margin-bottom: 6px;
}
.title .title-save .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 3px 0;
}
.title .title-save .label { color: var(--cyan-d); }
.title .title-save .value { color: var(--ink); }

.gameover .logo { color: var(--red); text-shadow: 0 0 14px rgba(224, 74, 74, 0.6); }
.victory  .logo { color: var(--yellow); }

/* Feature 29: victory run-recap stats block. Sits between the subtitle and
   the PRESS X / ENTER line. Two-column flex rows (label left, value right)
   mirror the inventory/shop list styling so the panel feels consistent. */
.panel.victory .stats {
  list-style: none;
  padding: 0;
  margin: 12px auto 18px;
  max-width: 260px;
  text-align: left;
}
.panel.victory .stats li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid rgba(77, 224, 255, 0.15);
  font-size: 12px;
  letter-spacing: 0.16em;
}
.panel.victory .stats .label { color: var(--dim); }
.panel.victory .stats .val   { color: var(--ink); }
.panel.victory .run-card {
  max-width: 300px;
  margin: -4px auto 16px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 203, 74, 0.28);
  background: rgba(255, 203, 74, 0.06);
  text-align: left;
  text-transform: uppercase;
}
.panel.victory .run-card-head {
  color: var(--yellow);
  font-size: 13px;
  letter-spacing: 0.18em;
  margin-bottom: 6px;
}
.panel.victory .run-card-sub {
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}
.panel.victory .run-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.panel.victory .run-card-badges span {
  border: 1px solid rgba(77, 224, 255, 0.26);
  color: var(--cyan);
  padding: 3px 5px;
  font-size: 9px;
  letter-spacing: 0.1em;
}
.panel.victory .story {
  max-width: 280px;
  margin: 14px auto 18px;
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.12em;
  line-height: 1.8;
  text-transform: uppercase;
}
.panel.victory .story .line {
  margin: 4px 0;
}
.save-chip {
  position: absolute;
  top: 52px;
  right: 10px;
  padding: 6px 10px;
  border: 1px solid rgba(113, 201, 214, 0.3);
  background: rgba(8, 10, 16, 0.82);
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  pointer-events: none;
}

/* -------- Inventory / Quest Log -------- */
.panel.inventory { width: 480px; }
.panel.inventory .inventory-body {
  min-height: 300px;
  max-height: min(64vh, 480px);
  overflow-y: auto;
  padding-right: 4px; /* keep scrollbar off strokes */
  scrollbar-gutter: stable;
}
.panel.inventory .inventory-tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 10px 0;
}
.panel.inventory .inventory-tab {
  padding: 6px 10px;
  border: 1px solid rgba(77, 224, 255, 0.22);
  background: rgba(20, 24, 42, 0.8);
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.panel.inventory .inventory-tab.active {
  border-color: var(--cyan);
  background: rgba(77, 224, 255, 0.1);
  color: var(--ink);
}
.panel.inventory .char-top {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
.panel.inventory .char-portrait {
  width: 116px;
  min-height: 148px;
  padding: 16px 12px;
  background: rgba(20, 24, 42, 0.82);
  border: 1px solid rgba(77, 224, 255, 0.22);
  box-sizing: border-box;
}
.panel.inventory .char-portrait .sprite {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  image-rendering: pixelated;
  background-repeat: no-repeat;
  background-size: contain;
}
.panel.inventory .char-portrait .mode {
  color: var(--cyan);
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.panel.inventory .char-portrait .weapon-name {
  margin-top: 6px;
  color: var(--dim);
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.panel.inventory .char-columns {
  flex: 1 1 auto;
}
.panel.inventory .char-slots li,
.panel.inventory .char-stats li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 8px;
  border-left: 2px solid transparent;
  text-transform: uppercase;
}
.panel.inventory .char-slots li.active {
  border-left-color: var(--cyan);
  background: rgba(77, 224, 255, 0.08);
}
.panel.inventory .char-slots .label,
.panel.inventory .char-stats .label {
  color: var(--cyan-d);
  font-size: 11px;
  letter-spacing: 0.12em;
}
.panel.inventory .char-slots .value,
.panel.inventory .char-stats .value {
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.08em;
}
.panel .section { margin: 8px 0; }
.panel .shdr {
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.2em;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.panel .val {
  color: var(--ink);
  font-size: 13px;
}
.panel .subval {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.panel.inventory .location-section { margin-top: 10px; }
.panel.inventory .map-name {
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.2em;
  margin-bottom: 6px;
  text-align: center;
}
.panel.inventory .inv-item-lines li.inv-kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 5px 0 5px 2px;
  border-bottom: 1px solid rgba(77, 224, 255, 0.1);
  text-transform: none;
}
.panel.inventory .inv-kv .inv-kv-label {
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.1em;
}
.panel.inventory .inv-kv .inv-kv-value {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-align: right;
  min-width: 3.2em;
}
.panel.inventory .inv-kv .inv-kv-value.inv-val-highlight {
  color: var(--yellow);
}
.panel.inventory .inv-contract-line {
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.1em;
  line-height: 1.45;
  text-transform: none;
  margin: 0;
}
.panel.inventory .inv-contract-line.inv-contract-ready {
  color: var(--yellow);
}
.panel.inventory .inv-gear-section {
  margin-top: 8px;
}
.panel.inventory .inv-gear-hint {
  margin: 0 0 6px 0;
  line-height: 1.45;
}
.panel.inventory .inv-gear-pick {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 140px;
  overflow-y: auto;
}
.panel.inventory .inv-gear-pick li {
  margin: 0;
  padding: 0;
}
.panel.inventory .inv-gear-btn {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 4px 0;
  padding: 6px 8px;
  text-align: left;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(20, 24, 42, 0.75);
  border: 1px solid rgba(77, 224, 255, 0.22);
  border-radius: 0;
  cursor: pointer;
  image-rendering: pixelated;
}
.panel.inventory .inv-gear-btn:hover,
.panel.inventory .inv-gear-btn:focus-visible {
  border-color: var(--cyan);
  background: rgba(77, 224, 255, 0.1);
  outline: none;
}
.panel.inventory .inv-gear-btn.equipped {
  border-color: rgba(255, 203, 74, 0.45);
  color: var(--yellow);
}
.panel.inventory .inv-gear-empty {
  color: var(--dim);
  font-size: 12px;
  padding: 4px 0;
}
.panel.inventory .char-portrait .char-portrait-weapon {
  color: var(--ink);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 8px;
  line-height: 1.25;
}
.panel.inventory .char-portrait .char-portrait-focus {
  color: var(--dim);
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 8px;
  line-height: 1.35;
}
#inv-minimap {
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
  background: #0b0d14;
  border: 1px solid rgba(77,224,255,0.25);
}

/* -------- Feature 39: performance overlay --------
   Small monospace readout pinned to the top-right of the stage, just
   below the credits HUD chip. Backtick toggles it via hud-dom.js. Dim
   colors so it never competes with gameplay chrome. */
.perf-overlay {
  position: absolute;
  top: 56px;
  right: 12px;
  padding: 3px 8px;
  background: rgba(6, 8, 14, 0.72);
  border: 1px solid rgba(77, 224, 255, 0.25);
  color: var(--dim);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  pointer-events: none;
  white-space: nowrap;
}

/* -------- Global screen effects -------- */
.vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}
.visual-clarity .vignette {
  background: radial-gradient(ellipse at center, transparent 68%, rgba(0,0,0,0.24) 100%);
}
.fade {
  position: absolute; inset: 0;
  pointer-events: none;
  background: #000;
  opacity: 0;
  transition: none;
}

/* -------- Pause dim -------- */
.pause-dim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 1;
}

.hidden { display: none !important; }

/* -------- Feature 46: PACKETLOSS RELAY overlay --------
   Stage-scoped overlay that iframes an external BBS. Lives in both builds
   (2D + HD-2D). Uses a thin cyan border + topbar to fit the game's
   signal/carrier/sync aesthetic. The iframe sandbox settings are set on
   the element itself so we don't rely on CSS for security posture. */
.bbs-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  background: rgba(3, 4, 9, 0.98);
  border: 1px solid var(--cyan);
  box-shadow:
    0 0 0 1px #0f1322 inset,
    0 0 42px rgba(77, 224, 255, 0.28);
  /* Ensure the overlay catches clicks even though parents may be pointer-none. */
  pointer-events: auto;
}
.bbs-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #0b0d14;
  border-bottom: 1px solid rgba(77, 224, 255, 0.35);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  flex: 0 0 auto;
}
.bbs-topbar .bbs-title {
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(77, 224, 255, 0.45);
}
.bbs-topbar .bbs-hint {
  color: var(--dim);
  flex: 1 1 auto;
  text-align: right;
  margin-right: 12px;
}
.bbs-topbar .bbs-open-link {
  color: var(--cyan);
  text-decoration: none;
  border: 1px solid rgba(77, 224, 255, 0.35);
  padding: 4px 8px;
  margin-right: 10px;
  font-size: 10px;
  letter-spacing: 0.14em;
}
.bbs-topbar .bbs-open-link:hover,
.bbs-topbar .bbs-open-link:focus-visible {
  background: rgba(77, 224, 255, 0.12);
  color: var(--ink);
}
.bbs-topbar .bbs-close {
  background: transparent;
  border: 1px solid rgba(77, 224, 255, 0.5);
  color: var(--cyan);
  width: 24px;
  height: 22px;
  line-height: 18px;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  letter-spacing: 0;
  text-align: center;
}
.bbs-topbar .bbs-close:hover {
  background: rgba(77, 224, 255, 0.12);
  color: var(--ink);
}
.bbs-iframe {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: #000;
  display: block;
}
.relay-board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(7, 10, 19, 0.98), rgba(3, 4, 9, 0.98)),
    repeating-linear-gradient(to bottom, rgba(77,224,255,0.04) 0, rgba(77,224,255,0.04) 1px, transparent 1px, transparent 4px);
  box-sizing: border-box;
  overflow: hidden;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.relay-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex: 0 0 auto;
  border: 1px solid rgba(77, 224, 255, 0.22);
  background: rgba(11, 13, 20, 0.82);
  padding: 10px 12px;
}
.relay-kicker {
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.relay-sub {
  margin-top: 5px;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.relay-stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
  color: var(--yellow);
  font-size: 10px;
  letter-spacing: 0.14em;
  white-space: nowrap;
}
.relay-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid rgba(77, 224, 255, 0.22);
  background: rgba(3, 5, 10, 0.78);
  padding: 10px;
}
.relay-empty {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.08em;
  line-height: 1.6;
}
.relay-message {
  border-left: 2px solid rgba(77, 224, 255, 0.32);
  background: rgba(10, 14, 24, 0.74);
  margin-bottom: 8px;
  padding: 7px 9px;
}
.relay-message.relay-self {
  border-left-color: var(--yellow);
}
.relay-message.relay-system {
  border-left-color: var(--pink);
  background: rgba(35, 11, 28, 0.62);
}
.relay-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.relay-time {
  color: var(--dim);
}
.relay-text {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0.06em;
  overflow-wrap: anywhere;
}
.relay-form {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}
.relay-input {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  background: #070a12;
  border: 1px solid rgba(77, 224, 255, 0.4);
  padding: 9px 10px;
  font: 12px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  outline: none;
}
.relay-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(77,224,255,0.2), 0 0 18px rgba(77,224,255,0.16);
}
.relay-send {
  flex: 0 0 auto;
  color: var(--cyan);
  background: rgba(77, 224, 255, 0.08);
  border: 1px solid rgba(77, 224, 255, 0.55);
  padding: 0 14px;
  font: 11px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.16em;
  cursor: pointer;
}
.relay-send:hover,
.relay-send:focus-visible {
  color: var(--ink);
  background: rgba(77, 224, 255, 0.16);
}
.relay-send:disabled {
  opacity: 0.55;
  cursor: default;
}
.bbs-fallback {
  position: absolute;
  inset: 42px 0 0 0;   /* sit under the topbar */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(3, 4, 9, 0.98);
  text-align: center;
}
.bbs-fallback .bbs-fb-heading {
  color: var(--red);
  font-size: 16px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(224, 74, 74, 0.45);
}
.bbs-fallback .bbs-fb-body {
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.12em;
  max-width: 540px;
  line-height: 1.6;
}
.bbs-fallback .bbs-fb-link {
  color: var(--cyan);
  text-decoration: none;
  border: 1px solid var(--cyan);
  padding: 8px 14px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 8px;
}
.bbs-fallback .bbs-fb-link:hover {
  background: rgba(77, 224, 255, 0.12);
  color: var(--ink);
}
