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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #030308;
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
}

/* ── Centered loading overlay ───────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 1px;
  color: rgba(140, 190, 255, 0.90);
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 3px;
  text-transform: uppercase;
  z-index: 100;
  pointer-events: none;
  text-shadow: 0 0 24px rgba(100, 150, 255, 0.55);
}
#loading-overlay.hidden { display: none; }
.ldot {
  opacity: 0;
  animation: ldot-blink 1.5s steps(1, end) infinite;
}
.ldot:nth-child(3) { animation-delay: 0.3s; }
.ldot:nth-child(4) { animation-delay: 0.6s; }
.ldot:nth-child(5) { animation-delay: 0.9s; }
@keyframes ldot-blink {
  0%, 100% { opacity: 0; }
  50%       { opacity: 1; }
}

/* ── Morphing gradient background (behind canvas) ───────────────────────────── */
#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #03030a;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  will-change: transform;
}

.blob-teal {
  width: 60vw; height: 60vw;
  background: radial-gradient(circle, rgba(0, 200, 170, 0.55) 0%, rgba(0, 130, 120, 0.20) 55%, transparent 75%);
  top: 15%; left: 20%;
  animation: blobA 20s ease-in-out infinite;
}
.blob-purple {
  width: 50vw; height: 50vw;
  background: radial-gradient(circle, rgba(100, 30, 220, 0.50) 0%, rgba(60, 10, 150, 0.18) 55%, transparent 75%);
  top: -15%; left: -12%;
  animation: blobB 26s ease-in-out infinite;
}
.blob-indigo {
  width: 45vw; height: 45vw;
  background: radial-gradient(circle, rgba(30, 60, 200, 0.45) 0%, rgba(15, 30, 120, 0.15) 55%, transparent 75%);
  bottom: -10%; right: -8%;
  animation: blobC 30s ease-in-out infinite;
}
.blob-rose {
  width: 30vw; height: 30vw;
  background: radial-gradient(circle, rgba(180, 20, 120, 0.30) 0%, rgba(120, 10, 80, 0.10) 55%, transparent 75%);
  top: 5%; right: 8%;
  animation: blobD 22s ease-in-out infinite;
}

@keyframes blobA {
  0%,100% { transform: translate(0,    0)    scale(1.00); }
  25%      { transform: translate(7vw, -8vh)  scale(1.12); }
  50%      { transform: translate(-5vw, 10vh) scale(0.91); }
  75%      { transform: translate(4vw,  4vh)  scale(1.06); }
}
@keyframes blobB {
  0%,100% { transform: translate(0,    0)    scale(1.00); }
  33%      { transform: translate(11vw, 13vh) scale(1.10); }
  66%      { transform: translate(3vw,  5vh)  scale(0.87); }
}
@keyframes blobC {
  0%,100% { transform: translate(0,    0)     scale(1.00); }
  40%      { transform: translate(-13vw,-9vh)  scale(1.14); }
  80%      { transform: translate(-6vw,-15vh)  scale(0.88); }
}
@keyframes blobD {
  0%,100% { transform: translate(0,   0)    scale(1.00); }
  50%      { transform: translate(-8vw, 9vh) scale(1.20); }
}

#canvas {
  display: block;
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
}

/* ── Left column toggle buttons ─────────────────────────────────────────────── */
#left-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
#nav-btn, #info-btn {
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 5px 10px;
  background: rgba(10, 10, 24, 0.82);
  border: 1px solid rgba(120, 160, 255, 0.28);
  border-radius: 5px;
  color: #88aadd;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, color 0.2s;
}
#nav-btn:hover, #info-btn:hover {
  border-color: rgba(140, 180, 255, 0.65);
  color: #aaccff;
}
#nav-popup.hidden, #info-panel.hidden { display: none; }

/* ── Left column: nav + info stacked ────────────────────────────────────────── */
#left-column {
  position: absolute;
  top: 110px;
  left: 18px;
  width: clamp(220px, 22vw, 280px);
  max-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 20;
  overflow: hidden;
}

/* ── Info panel (left side) ─────────────────────────────────────────────────── */
#info-panel {
  width: 100%;
  flex-shrink: 1;
  min-height: 0;
  overflow-y: auto;
  background: rgba(6, 6, 16, 0.78);
  border: 1px solid rgba(120, 160, 255, 0.18);
  border-radius: 10px;
  padding: 18px 20px 16px;
  color: rgba(200, 210, 240, 0.80);
  font-size: 13px;
  line-height: 1.65;
  backdrop-filter: blur(14px);
  z-index: 20;
  pointer-events: all;
  user-select: none;
}
#info-panel p {
  margin-bottom: 12px;
  color: rgba(180, 195, 230, 0.72);
}
#info-panel em { color: rgba(140, 190, 255, 0.90); font-style: normal; }
#info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
#info-title {
  font-size: 15px;
  font-weight: 600;
  color: rgba(220, 230, 255, 0.95);
  letter-spacing: 0.5px;
}
#info-close {
  background: none;
  border: none;
  color: #555;
  font-size: 18px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
#info-close:hover { color: #aaa; }
#info-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 11px;
  color: rgba(120, 140, 180, 0.65);
  letter-spacing: 0.3px;
}

/* ── Page title top-left ────────────────────────────────────────────────────── */
#page-title {
  position: absolute;
  top: 18px; left: 18px;
  font-family: 'Silkscreen', monospace;
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(220, 230, 255, 0.92);
  text-shadow: 0 0 24px rgba(100, 140, 255, 0.55),
               0 0 48px rgba(80, 120, 255, 0.25);
  line-height: 1.1;
  z-index: 20;
  pointer-events: none;
  user-select: none;
  padding: 8px 18px 10px;
}
#page-title::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(3, 3, 10, 0.42);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 8px;
  -webkit-mask-image: radial-gradient(ellipse 90% 85% at 46% 52%, black 35%, transparent 80%);
  mask-image: radial-gradient(ellipse 90% 85% at 46% 52%, black 35%, transparent 80%);
  z-index: -1;
}

/* ── HUD top-left ───────────────────────────────────────────────────────────── */
#hud {
  position: absolute;
  top: 82px; left: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #666;
  font-size: 13px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  z-index: 20;
  pointer-events: none;
  user-select: none;
}
#hud-label  { color: #aaa; font-weight: bold; }
#hud-check  { color: #4caf50; font-size: 13px; }
#hud-sep    { opacity: 0.4; }

/* ── Status bar top-right ───────────────────────────────────────────────────── */
#status-bar {
  position: absolute;
  top: 14px; right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 20;
  user-select: none;
}

#status-lines {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  padding: 6px 10px;
}
#status-lines::before {
  content: '';
  position: absolute;
  inset: -8px -16px;
  background: rgba(3, 3, 10, 0.42);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 6px;
  -webkit-mask-image:
    linear-gradient(to right,  transparent, black 10%, black 90%, transparent),
    linear-gradient(to bottom, transparent, black 12%, black 88%, transparent);
  mask-image:
    linear-gradient(to right,  transparent, black 10%, black 90%, transparent),
    linear-gradient(to bottom, transparent, black 12%, black 88%, transparent);
  -webkit-mask-composite: destination-in;
  mask-composite: intersect;
  z-index: -1;
  pointer-events: none;
}

#scrape-time,
#caps-refresh {
  color: #555;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  pointer-events: none;
}

#scrape-btn {
  background: rgba(10, 10, 24, 0.85);
  border: 1px solid rgba(100, 130, 255, 0.30);
  border-radius: 5px;
  color: #7799cc;
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 7px 14px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s, color 0.2s;
  backdrop-filter: blur(8px);
}
#scrape-btn:hover:not(:disabled) {
  border-color: rgba(100, 160, 255, 0.7);
  color: #aaccff;
}
#scrape-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
/* Tooltip for recently-scraped disabled state */
#scrape-btn.btn-recent[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  background: rgba(8, 8, 20, 0.96);
  border: 1px solid rgba(100, 130, 255, 0.22);
  border-radius: 5px;
  color: #8899bb;
  font-size: 10px;
  letter-spacing: 0.5px;
  padding: 5px 10px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 200;
  backdrop-filter: blur(8px);
}

/* ── Navigation popup (under HUD) ───────────────────────────────────────────── */
#nav-popup {
  width: 100%;
  flex-shrink: 0;
  background: rgba(6, 6, 16, 0.78);
  border: 1px solid rgba(120, 160, 255, 0.18);
  border-radius: 10px;
  padding: 12px 16px 10px;
  backdrop-filter: blur(14px);
  z-index: 20;
  pointer-events: all;
  user-select: none;
}
#nav-close {
  position: absolute;
  top: 6px; right: 8px;
  background: none;
  border: none;
  color: #555;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.15s;
  line-height: 1;
}
#nav-close:hover { color: #aaa; }
.nav-title {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: rgba(140, 170, 220, 0.55);
  text-transform: uppercase;
  margin-bottom: 9px;
  padding-right: 16px;
}
.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
  gap: 8px;
}
.nav-key {
  color: rgba(140, 190, 255, 0.80);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-desc {
  color: rgba(175, 190, 225, 0.60);
  font-size: 11px;
  text-align: right;
}

/* ── Notes from Skylar panel ────────────────────────────────────────────────── */
#notes-panel {
  position: absolute;
  bottom: 148px; right: 18px;
  width: 320px;
  background: rgba(6, 6, 16, 0.92);
  border: 1px solid rgba(120, 160, 255, 0.18);
  border-radius: 10px;
  padding: 16px 18px 14px;
  color: rgba(190, 205, 235, 0.80);
  font-size: 12px;
  line-height: 1.70;
  backdrop-filter: blur(14px);
  z-index: 30;
  pointer-events: all;
}
#notes-panel.hidden { display: none; }
#notes-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(220, 230, 255, 0.95);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
#notes-body p { margin-bottom: 9px; }
#notes-body p:last-child { margin-bottom: 0; }
#notes-body em { color: rgba(140, 190, 255, 0.90); font-style: normal; }
#notes-close {
  position: absolute;
  top: 8px; right: 10px;
  background: none;
  border: none;
  color: #555;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.15s;
}
#notes-close:hover { color: #aaa; }
.notes-link {
  color: #6688cc;
  text-decoration: none;
}
.notes-link:hover { color: #99bbff; text-decoration: underline; }

/* ── Bottom-right button shared base ────────────────────────────────────────── */
#notes-btn, #report-btn, #submit-news-btn {
  position: absolute;
  right: 18px;
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 5px;
  cursor: pointer;
  z-index: 20;
  backdrop-filter: blur(8px);
  display: inline-block;
  transition: border-color 0.2s, color 0.2s;
}

/* Notes from Skylar button */
#notes-btn {
  bottom: 108px;
  background: rgba(10, 10, 24, 0.82);
  border: 1px solid rgba(120, 160, 255, 0.28);
  color: #88aadd;
}
#notes-btn:hover { border-color: rgba(140, 180, 255, 0.65); color: #aaccff; }

/* Report Inaccuracy button */
#report-btn {
  bottom: 63px;
  background: rgba(20, 6, 6, 0.82);
  border: 1px solid rgba(255, 100, 60, 0.45);
  color: #ff7755;
}
#report-btn:hover { border-color: rgba(255, 130, 90, 0.80); color: #ffaa88; }

/* Submit news button */
#submit-news-btn {
  bottom: 18px;
  background: rgba(6, 14, 10, 0.82);
  border: 1px solid rgba(100, 200, 130, 0.35);
  color: #77bb99;
}
#submit-news-btn:hover { border-color: rgba(100, 220, 140, 0.75); color: #99ddbb; }

/* ── Costco scale toggle (bottom-left) ─────────────────────────────────────── */
#costco-toggle {
  position: absolute;
  bottom: 18px; left: 18px;
  background: rgba(10, 10, 24, 0.82);
  border: 1px solid rgba(200, 80, 80, 0.35);
  border-radius: 5px;
  color: #bb7777;
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 7px 14px;
  cursor: pointer;
  z-index: 20;
  transition: border-color 0.2s, color 0.2s;
  backdrop-filter: blur(8px);
}
#costco-toggle:hover {
  border-color: rgba(220, 80, 80, 0.75);
  color: #dd9999;
}

/* ── Edge amount labels (CSS2DObject) ───────────────────────────────────────── */
.edge-amount {
  color: rgba(160, 220, 180, 0.80);
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: rgba(6, 8, 18, 0.70);
  border: 1px solid rgba(100, 200, 130, 0.20);
  border-radius: 3px;
  padding: 1px 5px;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

/* ── Node labels (CSS2DObject) ──────────────────────────────────────────────── */
.node-label-wrap {
  text-align: center;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  line-height: 1.3;
}

.node-name {
  color: rgba(255, 255, 255, 0.92);
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow:
    0 0 8px rgba(0,0,0,1),
    0 0 14px rgba(0,0,0,1),
    0 0 22px rgba(0,0,0,0.9),
    0 0 6px rgba(80, 120, 255, 0.6);
}

.node-cap {
  color: rgba(180, 210, 255, 0.75);
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-top: 2px;
  text-shadow:
    0 0 6px rgba(0,0,0,1),
    0 0 12px rgba(0,0,0,0.9),
    0 0 20px rgba(0,0,0,0.8);
}

/* ── Scale reference label (CSS2DObject) ────────────────────────────────────── */
.costco-label {
  position: fixed;
  transform: translate(-50%, -100%);
  text-align: center;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  z-index: 6;
  line-height: 1.3;
}
.costco-name {
  color: rgba(255, 255, 255, 0.92);
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow:
    0 0 8px rgba(0,0,0,1),
    0 0 14px rgba(0,0,0,1),
    0 0 22px rgba(0,0,0,0.9);
}
.costco-sub {
  color: rgba(180, 210, 255, 0.55);
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 1px;
  text-shadow:
    0 0 6px rgba(0,0,0,1),
    0 0 12px rgba(0,0,0,0.9);
}
.costco-cap {
  color: rgba(180, 210, 255, 0.75);
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 11px;
  letter-spacing: 0.8px;
  margin-top: 2px;
  text-shadow:
    0 0 6px rgba(0,0,0,1),
    0 0 12px rgba(0,0,0,0.9);
}

/* ── Popup ──────────────────────────────────────────────────────────────────── */
#popup {
  position: absolute;
  width: 310px;
  background: rgba(8, 8, 18, 0.92);
  border: 1px solid rgba(100, 130, 255, 0.25);
  border-radius: 8px;
  padding: 14px 16px 12px;
  color: #ddd;
  font-size: 13px;
  line-height: 1.55;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6),
              0 0 0 1px rgba(255,255,255,0.04) inset;
  z-index: 100;
  pointer-events: all;
}
#popup.hidden { display: none; }

#popup-close {
  position: absolute;
  top: 8px; right: 10px;
  background: none;
  border: none;
  color: #555;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  transition: color 0.15s;
}
#popup-close:hover { color: #ccc; }

#popup-date {
  color: #555;
  font-size: 10px;
  letter-spacing: 1px;
  margin-bottom: 5px;
}
#popup-title {
  font-size: 16px;
  font-weight: bold;
  color: #89b4fa;
  margin-bottom: 8px;
  padding-right: 20px;
}
#popup-amount {
  color: #a6e3a1;
  font-size: 12px;
  margin-bottom: 7px;
}
#popup-snippet {
  color: #bbb;
  font-size: 10.5px;
  line-height: 1.65;
  margin-bottom: 10px;
  max-height: 90px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
#popup-source {
  font-size: 9.5px;
  color: #555;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 7px;
  word-break: break-all;
}
.popup-link {
  color: #6688cc;
  text-decoration: none;
  transition: color 0.15s;
}
.popup-link:hover {
  color: #99bbff;
  text-decoration: underline;
}
.popup-report-btn {
  display: inline-block;
  margin-top: 10px;
  font-size: 11px;
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #ff7755;
  text-decoration: none;
  border: 1px solid rgba(255, 100, 60, 0.55);
  border-radius: 4px;
  padding: 5px 12px;
  background: rgba(200, 50, 20, 0.10);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.popup-report-btn:hover {
  color: #ffaa88;
  border-color: rgba(255, 130, 90, 0.80);
  background: rgba(200, 60, 30, 0.20);
}

/* ══ MOBILE LAYOUT ════════════════════════════════════════════════════════════ */
/* html.mobile is set by inline <script> in <head> when innerWidth <= 768      */
/* Also fires on @media as a fallback for browsers that handle it correctly     */

#m-header, #m-scroll, #m-scene-controls { display: none; }

html.mobile #canvas {
  position: fixed !important;
  top: 0; left: 0;
  width: var(--mvw, 100vw) !important;
  height: var(--mvh, 100vh) !important;
}

html.mobile #page-title,
html.mobile #hud,
html.mobile #status-bar,
html.mobile #left-column,
html.mobile #notes-btn,
html.mobile #notes-panel,
html.mobile #report-btn,
html.mobile #submit-news-btn,
html.mobile #costco-toggle,
html.mobile #loading-overlay { display: none !important; }

html.mobile #popup {
  position: fixed !important;
  width: calc(var(--mvw, 100vw) * 0.60) !important;
  left: calc(var(--mvw, 100vw) * 0.20) !important;
  top: auto !important;
  bottom: 120px;
  z-index: 200;
  max-height: 55vh;
  overflow-y: auto;
}

/* ── Mobile header ──────────────────────────────────────────────────────────── */
html.mobile #m-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 110;
  padding: 10px 18px 20px;
  font-family: 'Silkscreen', monospace;
  font-weight: 700;
  color: rgba(220, 230, 255, 0.92);
  text-shadow: 0 0 16px rgba(100, 140, 255, 0.50);
  background: rgba(3, 3, 10, 0.90);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  /* mask fades out the bottom ~30% so the header feathers naturally */
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 0%, black 55%, transparent 100%);
  transition: opacity 0.35s;
  pointer-events: none;
  user-select: none;
}
html.mobile .m-hline1 {
  font-size: 28px;
  letter-spacing: 2px;
  text-align: left;
  line-height: 1.1;
  transition: font-size 0.35s, letter-spacing 0.35s;
}
html.mobile .m-hline2 {
  font-size: 28px;
  letter-spacing: 2px;
  text-align: right;
  line-height: 1.15;
  transition: font-size 0.35s, letter-spacing 0.35s;
}
html.mobile #m-header.scene-active {
  padding: 10px 18px 20px;
  opacity: 1;
}
html.mobile #m-header.scene-active .m-hline1,
html.mobile #m-header.scene-active .m-hline2 {
  font-size: 28px;
  letter-spacing: 2px;
}

/* ── Mobile scroll container ────────────────────────────────────────────────── */
html.mobile #m-scroll {
  display: block;
  position: fixed;
  top: 0; left: 0;
  width: var(--mvw, 100vw);
  height: var(--mvh, 100vh);
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  z-index: 10;
}

/* ── Intro section ──────────────────────────────────────────────────────────── */
html.mobile #m-intro {
  height: var(--mvh, 100vh);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  padding-top: 100px;
  box-sizing: border-box;
  position: relative;
  /* Fully opaque — 3D scene hidden until user scrolls to scene section */
  background: rgba(3, 3, 10, 0.97);
}

/* ── Scene section (transparent) ───────────────────────────────────────────── */
html.mobile #m-scene {
  height: var(--mvh, 100vh);
  scroll-snap-align: start;
  background: transparent;
  pointer-events: none;
}

/* ── Swipe hint ─────────────────────────────────────────────────────────────── */
html.mobile #m-swipe-hint {
  text-align: center;
  padding: 6px 0 2px;
  color: rgba(140, 190, 255, 0.35);
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Carousel ───────────────────────────────────────────────────────────────── */
html.mobile #m-carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
html.mobile #m-carousel::-webkit-scrollbar { display: none; }

html.mobile .m-slide {
  flex: 0 0 100%;
  width: 100%;
  scroll-snap-align: start;
  padding: 20px 26px 14px;
  box-sizing: border-box;
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
html.mobile .m-slide::-webkit-scrollbar { display: none; }

html.mobile .m-slide-title {
  font-family: 'Silkscreen', monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(220, 230, 255, 0.95);
  text-transform: uppercase;
  margin-bottom: 18px;
}

html.mobile .m-slide-body {
  color: rgba(180, 195, 230, 0.80);
  font-size: 13px;
  line-height: 1.70;
  text-align: center;
  max-width: 340px;
}
html.mobile .m-slide-body p { margin-bottom: 10px; }
html.mobile .m-slide-body p:last-child { margin-bottom: 0; }
html.mobile .m-slide-body em { color: rgba(140, 190, 255, 0.90); font-style: normal; }

html.mobile .m-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  width: 100%;
  max-width: 300px;
  text-align: left;
}
html.mobile .m-nav-row:last-child { border-bottom: none; }
html.mobile .m-nav-key {
  color: rgba(140, 190, 255, 0.85);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  flex-shrink: 0;
  margin-right: 14px;
}
html.mobile .m-nav-desc {
  color: rgba(175, 190, 225, 0.65);
  font-size: 12px;
  text-align: right;
}

/* ── Dots ───────────────────────────────────────────────────────────────────── */
html.mobile #m-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 8px 0 6px;
  flex-shrink: 0;
}
html.mobile .m-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(120, 140, 200, 0.28);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
html.mobile .m-dot.active {
  background: rgba(140, 190, 255, 0.82);
  transform: scale(1.25);
}

/* ── Status area ────────────────────────────────────────────────────────────── */
html.mobile #m-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 22px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}
html.mobile #m-scrape-status,
html.mobile #m-caps-status {
  color: #555;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
html.mobile #m-loading-status {
  color: rgba(140, 190, 255, 0.85);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
html.mobile #m-loading-status.hidden { display: none; }

/* ── Enter hint ─────────────────────────────────────────────────────────────── */
html.mobile #m-enter-hint {
  text-align: center;
  padding: 8px 0 14px;
  color: rgba(140, 190, 255, 0.55);
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  flex-shrink: 0;
  display: none;
}
html.mobile #m-enter-hint.show {
  display: block;
  animation: m-hint-pulse 2.2s ease-in-out infinite;
}
@keyframes m-hint-pulse {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 1.0;  }
}

/* ── Mobile scene controls ──────────────────────────────────────────────────── */
html.mobile #m-scene-controls {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

/* ── Scene-mode status bar (below header) ───────────────────────────────────── */
html.mobile #m-scene-status-bar {
  display: none !important;
  position: absolute;
  top: 90px; left: 0; right: 0;
  padding: 6px 16px 26px;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  pointer-events: auto;
  cursor: pointer;
  background: rgba(3, 3, 10, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 48%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 0%, black 48%, transparent 100%);
  transition: background 0.25s;
}
html.mobile #m-scene-scrape,
html.mobile #m-scene-caps {
  color: rgba(160, 185, 225, 0.85);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  overflow: hidden;
  max-height: 22px;
  opacity: 1;
  text-align: right;
  transition: max-height 0.28s ease, opacity 0.22s ease;
}
html.mobile #m-scene-status-chevron {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(130, 165, 220, 0.70);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 12px;
  border: 1px solid rgba(100, 140, 200, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  margin-top: 5px;
  transition: color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
html.mobile #m-scene-status-bar.collapsed {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  -webkit-mask-image: none !important;
  mask-image: none !important;
  padding: 8px 16px;
}
html.mobile #m-scene-status-bar.collapsed #m-scene-scrape,
html.mobile #m-scene-status-bar.collapsed #m-scene-caps {
  max-height: 0;
  opacity: 0;
}
html.mobile #m-scene-status-bar.collapsed #m-scene-status-chevron {
  color: rgba(130, 165, 220, 0.90);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.80);
}

/* ── Bottom backdrop for scale area ────────────────────────────────────────── */
html.mobile #m-scene-controls::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 75px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(3, 3, 10, 0.88) 55%
  );
  pointer-events: none;
  z-index: 0;
}
html.mobile #m-back-btn,
html.mobile #m-costco-toggle,
html.mobile #m-fab-wrap {
  position: relative;
  z-index: 1;
}

html.mobile #m-back-btn {
  position: absolute;
  bottom: 26px; left: 16px;
  top: auto; /* override any inherited top */
  background: rgba(10, 10, 24, 0.88);
  border: 1px solid rgba(100, 130, 255, 0.30);
  border-radius: 20px;
  color: #7799cc;
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 16px;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, color 0.2s;
}
html.mobile #m-back-btn:active { border-color: rgba(140, 180, 255, 0.65); color: #aaccff; }

/* ── Hide the old standalone costco toggle on mobile ──────────────────────── */
html.mobile #m-costco-toggle { display: none !important; }

/* ── Scale labels float above scene controls ────────────────────────────── */
html.mobile .costco-label { z-index: 60; }

/* ── Mobile scale reference circles (HTML, not 3D) ─────────────────────────── */
html.mobile #m-scale-row {
  position: absolute;
  bottom: 26px;
  left: 112px;
  display: none; /* JS sets to 'flex' when scaleVisible=true */
  align-items: flex-end;
  gap: 14px;
  pointer-events: none;
  z-index: 1;
}
html.mobile .m-scale-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
html.mobile .m-scale-ball {
  border-radius: 50%;
  flex-shrink: 0;
}
html.mobile .m-scale-name {
  font-family: 'Silkscreen', monospace;
  font-size: 7px;
  letter-spacing: 1px;
  color: rgba(200, 215, 255, 0.80);
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}
html.mobile .m-scale-cap {
  font-size: 7px;
  color: rgba(140, 160, 200, 0.55);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* ── HIDE SCALE pill (bottom-left) ─────────────────────────────────────────── */
html.mobile #m-costco-toggle {
  position: absolute;
  bottom: 26px; left: 16px;
  background: rgba(10, 10, 24, 0.85);
  border: 1px solid rgba(200, 80, 80, 0.35);
  border-radius: 20px;
  color: #bb7777;
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 14px;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: border-color 0.2s, color 0.2s;
}
html.mobile #m-costco-toggle:active { border-color: rgba(220,80,80,0.75); color: #dd9999; }
html.mobile .m-scale-icon { font-size: 13px; }

/* ── FAB: circle trigger + expanding action buttons ────────────────────────── */
html.mobile #m-fab-wrap {
  position: absolute;
  bottom: 22px; right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
  pointer-events: auto;
}

/* The three action buttons (hidden by default) */
html.mobile #m-fab-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  opacity: 0;
  transform: translateY(8px) scale(0.94);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
html.mobile #m-fab-actions.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Slight arc: each button offset a little more to the left */
html.mobile #m-fab-actions > *:nth-child(1) { margin-right: 0px; }
html.mobile #m-fab-actions > *:nth-child(2) { margin-right: 4px; }
html.mobile #m-fab-actions > *:nth-child(3) { margin-right: 8px; }
html.mobile #m-fab-actions > *:nth-child(4) { margin-right: 12px; }

/* Staggered reveal */
html.mobile #m-fab-actions > *:nth-child(1) { transition-delay: 0.00s; }
html.mobile #m-fab-actions > *:nth-child(2) { transition-delay: 0.04s; }
html.mobile #m-fab-actions > *:nth-child(3) { transition-delay: 0.08s; }
html.mobile #m-fab-actions > *:nth-child(4) { transition-delay: 0.12s; }

/* No ::before backdrop — shadow on each button instead (see box-shadow below) */

html.mobile #m-scale-btn,
html.mobile #m-scrape-btn,
html.mobile #m-report-btn,
html.mobile #m-submit-btn {
  font-family: 'Cal Sans', 'Helvetica Neue', sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 9px 18px;
  border-radius: 20px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.80), 0 2px 6px rgba(0, 0, 0, 0.60);
  transition: border-color 0.2s, color 0.2s;
}
html.mobile #m-scale-btn {
  background: rgba(6, 18, 18, 0.88);
  border: 1px solid rgba(60, 200, 200, 0.35);
  color: #55cccc;
}
html.mobile #m-scrape-btn {
  background: rgba(10, 10, 24, 0.88);
  border: 1px solid rgba(100, 130, 255, 0.35);
  color: #7799cc;
}
html.mobile #m-scrape-btn:disabled { opacity: 0.45; cursor: not-allowed; }
html.mobile #m-report-btn {
  background: rgba(20, 6, 6, 0.88);
  border: 1px solid rgba(255, 100, 60, 0.45);
  color: #ff7755;
}
html.mobile #m-submit-btn {
  background: rgba(6, 14, 10, 0.88);
  border: 1px solid rgba(100, 200, 130, 0.35);
  color: #77bb99;
}

/* FAB trigger circle */
html.mobile #m-fab-btn {
  width: 50px; height: 50px;
  border-radius: 50%;
  background: rgba(14, 14, 30, 0.90);
  border: 1px solid rgba(120, 160, 255, 0.35);
  color: #aaccff;
  font-size: 22px;
  letter-spacing: 1px;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, transform 0.2s;
  line-height: 1;
  padding-bottom: 4px;
}
html.mobile #m-fab-btn.open {
  border-color: rgba(140, 190, 255, 0.65);
  transform: rotate(90deg);
}

/* Fallback: also fire on real media query for non-Opera browsers */
@media (max-width: 768px) {
  html:not(.mobile) #canvas { position: fixed !important; top: 0; left: 0; width: 100vw !important; height: 100vh !important; }
  html:not(.mobile) #page-title, html:not(.mobile) #hud, html:not(.mobile) #status-bar,
  html:not(.mobile) #left-column, html:not(.mobile) #notes-btn, html:not(.mobile) #notes-panel,
  html:not(.mobile) #report-btn, html:not(.mobile) #submit-news-btn,
  html:not(.mobile) #costco-toggle { display: none !important; }
  html:not(.mobile) #m-header { display: flex; position: fixed; top: 0; left: 0; right: 0; z-index: 110; padding: 12px 18px 10px; font-family: 'Silkscreen', monospace; font-size: clamp(15px,5vw,22px); font-weight: 700; letter-spacing: 1.5px; color: rgba(220,230,255,0.92); background: rgba(3,3,10,0.60); backdrop-filter: blur(16px); pointer-events: none; user-select: none; border-bottom: 1px solid rgba(120,160,255,0.12); }
  html:not(.mobile) #m-scroll { display: block; position: fixed; inset: 0; overflow-y: auto; scroll-snap-type: y mandatory; z-index: 10; }
  html:not(.mobile) #m-intro { height: 100vh; scroll-snap-align: start; display: flex; flex-direction: column; padding-top: 58px; background: rgba(3,3,10,0.94); box-sizing: border-box; }
  html:not(.mobile) #m-scene { height: 100vh; scroll-snap-align: start; background: transparent; pointer-events: none; }
  html:not(.mobile) #m-carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; flex: 1; min-height: 0; scrollbar-width: none; }
  html:not(.mobile) .m-slide { flex: 0 0 100%; width: 100%; scroll-snap-align: start; padding: 18px 22px 12px; box-sizing: border-box; }
  html:not(.mobile) #m-dots { display: flex; justify-content: center; gap: 8px; padding: 8px 0 6px; flex-shrink: 0; }
  html:not(.mobile) .m-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(120,140,200,0.28); cursor: pointer; }
  html:not(.mobile) .m-dot.active { background: rgba(140,190,255,0.82); }
  html:not(.mobile) #m-status { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 22px 6px; border-top: 1px solid rgba(255,255,255,0.07); flex-shrink: 0; }
  html:not(.mobile) #m-enter-hint { display: none; text-align: center; padding: 8px 0 14px; color: rgba(140,190,255,0.55); font-size: 9px; letter-spacing: 2.5px; text-transform: uppercase; flex-shrink: 0; }
  html:not(.mobile) #m-enter-hint.show { display: block; }
}
