/* ==========================================================================
   Fonts, palette, and root tokens
   ========================================================================== */

:root {
  /* Body text */
  --font-body: "roboto", "Roboto", "Helvetica Neue", Arial,
               system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Headings / display */
  --font-display: "Carbon", "T26 Carbon", "Carbon T26",
                  "OCR A Std", "Consolas", "SFMono-Regular", "Menlo", monospace;

  /* Brand palette */
  --nasa-blue:     #0B3D91;  /* primary backgrounds */
  --nasa-red:      #FD3D21;  /* alerts */
  --nasa-white:    #FFFFFF;  /* primary text/icons */

  --starlight:     #BFC7D5;  /* secondary text / inactive */
  --cosmic-teal:   #00A9A5;  /* positive / hover / focus */
  --solar-gold:    #FFB547;  /* achievements / highlights */
  --nebula-purple: #6B4C9A;  /* secondary action */
  --plasma-pink:   #FF3CAC;  /* boosts / specials */

  /* Layout surfaces */
  --bg-body:       #000000;           /* page canvas behind iframe */
  --overlay-80:    rgba(0,0,0,.80);   /* global dimmer behind modal */
  --panel:         rgba(11,16,30,.95);/* modal panel surface */

  /* Framing bars */
  --frame-thickness: 75px;
  --frame-color:     #070c10;

  /* Effects */
  --ring:           color-mix(in srgb, var(--cosmic-teal) 65%, transparent);
  --chip-fg:        color-mix(in srgb, var(--cosmic-teal) 85%, white);
  --chip-bg:        color-mix(in srgb, var(--cosmic-teal) 12%, transparent);
  --chip-border:    color-mix(in srgb, var(--cosmic-teal) 30%, transparent);
  --pulse-color:    var(--cosmic-teal);

  --track-tight:   -0.005em;
  --track-wide:     0.06em;
}

/* Global text defaults */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-body);
  color: var(--nasa-white);
  font-family: var(--font-body);
  line-height: 1.45;
  letter-spacing: var(--track-tight);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings */
h1, h2, h3, h4, h5, h6,
.modal-title {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: var(--track-wide);
}

/* ==========================================================================
   Layout
   ========================================================================== */

iframe {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

#overlayBorder {
  position: fixed;
  inset: 0;
  border-top: var(--frame-thickness) solid var(--frame-color);
  border-bottom: var(--frame-thickness) solid var(--frame-color);
  border-left: 0;
  border-right: 0;
  box-sizing: border-box;
  z-index: 5000;
  pointer-events: none;
}

/* ==========================================================================
   Primary navigation button
   ========================================================================== */

#menuBtn {
  position: fixed;
  top: 3%;
  left: 3%;
  z-index: 9999;
  cursor: pointer;

  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.05em;
  font-size: 20px;

  background: rgba(11,61,145,.92);
  color: var(--nasa-white);
  border: 0;
  border-radius: 6px;
  padding: 20px 32px;
  backdrop-filter: blur(4px);
  transition: background 120ms ease, transform 120ms ease;
}
#menuBtn:hover { background: rgba(0,169,165,.95); transform: translateY(-1px); }
#menuBtn:active { transform: translateY(0); }
#menuBtn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* ==========================================================================
   Info button
   ========================================================================== */

#infoBtn{
  /* placement */
  position: fixed;
  right: 5%;
  top: 80%;
  transform: translateY(-50%);
  z-index: 11000;
  isolation: isolate;
  cursor: pointer;

  /* circular geometry and centring */
  width: 12rem;
  height: 12rem;
  border-radius: 50%;
  display: grid;
  place-items: center;

  /* type system */
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0;

  /* surface and baseline shadow */
  background: rgba(11,61,145,.92);
  color: var(--nasa-white);
  border: 0;
  backdrop-filter: blur(4px);
  box-shadow: 0 6px 20px rgba(0,0,0,.4);

  /* animation + interaction */
  animation: infoPulse 4.2s ease-in-out infinite;
  transition: background 120ms ease, transform 120ms ease;
}
#infoBtn:hover  { background: rgba(0,169,165,.95); transform: translateY(calc(-50% - 1px)); }
#infoBtn:active { transform: translateY(-50%); }
#infoBtn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* Expanding halo behind the control */
#infoBtn::before{
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  z-index: -1;
  box-shadow: 0 0 0 0 var(--pulse-color);
  opacity: .55;
  animation: infoRing 4.2s ease-out infinite;
}

/* ==========================================================================
   Switch button 
   ========================================================================== */

#switchBtn {
  /* placement */
  position: fixed;
  right: 10%; 
  top: 65%; 
  transform: translateY(-50%);
  z-index: 11000;
  cursor: pointer;
  --pulse-color: var(--nasa-red);

  /* smaller circular geometry */
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  display: grid;
  place-items: center;

  /* type system */
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0;

  /* surface and shadow */
  background: rgba(253, 61, 33, 0.92);
  color: var(--nasa-white);
  border: 0;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0,0,0,.35);

  /* animation + interaction */
  animation: infoPulse 4.2s ease-in-out infinite;
  transition: background 120ms ease, transform 120ms ease;
}
#switchBtn:hover  { background: rgba(223, 108, 93, 0.95); transform: translateY(calc(-50% - 1px)); }
#switchBtn:active { transform: translateY(-50%); }
#switchBtn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

#switchBtn::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  z-index: -1;
  box-shadow: 0 0 0 0 rgba(253,61,33,0.6);
  opacity: 0.25;
  animation: switchRing 3s ease-out infinite;
  animation: infoRing 4.2s ease-out infinite;
}

@keyframes switchRing {
  0%   { box-shadow: 0 0 0 0 rgba(253,61,33,0.4); }
  100% { box-shadow: 0 0 0 12px rgba(253,61,33,0); }
}

/* ==========================================================================
   Modal overlays for content and settings
   ========================================================================== */

/* Overlay */
#protoModal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: none;
  background: var(--overlay-80);
}

/* Panel */
#protoModal .modal-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(1500px, 88vw);
  max-height: min(100vh, 1000px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: var(--panel);
  color: var(--nasa-white);
  border: 1px solid color-mix(in srgb, var(--starlight) 25%, transparent);
  border-radius: 16px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.55);
}

/* Prefer dynamic viewport height on browsers that support it */
@supports (height: 100dvh) {
  #protoModal .modal-panel {
    max-height: min(90dvh, 900px);
  }
}

/* Header */
#protoModal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(11,16,30,.90);
  border-bottom: 1px solid color-mix(in srgb, var(--starlight) 18%, transparent);
}
#protoModal .modal-title {
  margin: 0;
  font-size: 24px;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: var(--track-wide);
}

#modalClose {
  background: transparent;
  color: var(--nasa-white);
  border: 0;
  font-size: 24px;
  line-height: 1;
  padding: 2px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease;
}
#modalClose:hover { background: rgba(255,255,255,0.08); }
#modalClose:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

#protoModal .modal-body {
  display: grid;
  grid-template-columns: 1.25fr 2.0fr;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

/* Left column */
#protoModal .desc {
  overflow: auto;
  padding-right: 6px;
}
#protoModal .desc h3 {
  margin: 8px 0 8px 0;
  font-size: 16px;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: var(--track-wide);
}
#protoModal .desc p,
#protoModal .desc li,
#protoModal .media-caption {
  font-family: var(--font-body);
  color: var(--starlight);
  font-size: 14px;
  line-height: 1.5;
}
#protoModal .desc ul { margin: 8px 0 0 18px; }

/* Right column */
#protoModal .media-wrap {
  min-height: 0;
  height: 100%;
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 8px;
}

#protoModal .media-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  grid-auto-flow: row dense;
  gap: 12px;

  align-content: start;
  align-items: stretch;
  min-height: 0;
  height: 100%;
  overflow: auto;
}

/* Thumbnail: button reset and layout container */
#protoModal .thumb{
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--starlight) 18%, transparent);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 120ms ease, transform 120ms ease;
}
#protoModal .thumb:hover{ 
  border-color: color-mix(in srgb, var(--cosmic-teal) 40%, transparent);
  transform: translateY(-1px);
}
#protoModal .thumb:focus-visible{
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

#protoModal .thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Lightbox overlay inside the protoModal layer */
#lightbox{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 12100;
  background: rgba(0,0,0,.86);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#lightboxImg{
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--starlight) 25%, transparent);
  box-shadow: 0 30px 60px rgba(0,0,0,.6);
}

#lightboxClose{
  position: absolute;
  top: 14px;
  right: 16px;
  border: 0;
  background: transparent;
  color: var(--nasa-white);
  font-size: 28px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease;
}
#lightboxClose:hover{ background: rgba(255,255,255,0.08); }
#lightboxClose:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* Mobile: fewer columns, larger taps */
@media (max-width: 900px){
  #protoModal .media-grid{ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
@media (max-width: 600px){
  #protoModal .media-grid{ grid-template-columns: repeat(2, 1fr); }
}

#protoModal .media-item {
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: #0b101e;
  border: 1px solid color-mix(in srgb, var(--starlight) 18%, transparent);
  border-radius: 12px;
  overflow: hidden;
  scroll-snap-align: center;
  box-shadow: 0 10px 24px rgba(0,0,0,0.45);
}

#protoModal .media-item img,
#protoModal .media-item video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#protoModal .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}
#protoModal .chip {
  font-size: 12px;
  color: var(--chip-fg);
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  padding: 4px 8px;
  border-radius: 999px;
}

   /* ==========================================================================
   Pause / Settings Menu
   ========================================================================== */

/* Overlay layer for pause menu */
#menuModal{
  position: fixed;
  inset: 0;
  z-index: 13000;
  display: none;
  background: var(--overlay-80);
}

#menuModal .menu-panel{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(320px, 48vw, 560px);
  max-height: min(90vh, 700px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: var(--panel);
  color: var(--nasa-white);
  border: 1px solid color-mix(in srgb, var(--starlight) 25%, transparent);
  border-radius: 16px;
  box-shadow: 0 30px 60px rgba(0,0,0,.55);
}

/* Header */
#menuModal .menu-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(11,16,30,.90);
  border-bottom: 1px solid color-mix(in srgb, var(--starlight) 18%, transparent);
}
#menuModal .menu-title{
  margin: 0;
  font-size: 20px;
  font-family: var(--font-display);
  letter-spacing: var(--track-wide);
}
#menuClose{
  background: transparent;
  color: var(--nasa-white);
  border: 0;
  font-size: 24px;
  line-height: 1;
  padding: 2px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease;
}
#menuClose:hover{ background: rgba(255,255,255,.08); }
#menuClose:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* Body layout: vertical stack */
#menuModal .menu-body{
  padding: 16px;
  display: grid;
  gap: 12px;
  overflow: auto;
}

/* Buttons */
.menu-btn{
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  font-size: 24px;
  border: 0;
  border-radius: 10px;
  padding: 32px 16px;
  color: var(--nasa-white);
  background: rgba(11,61,145,.92);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}
.menu-btn:hover{ transform: translateY(-1px); background: rgba(0,169,165,.95); } /* teal */
.menu-btn:active{ transform: translateY(0); }
.menu-btn:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--ring); }

.menu-btn-primary{
  background: #FD3D21;
  font-weight: 700;
}

/* Section box for controls */
.menu-section{
  margin-top: 6px;
  border: 1px solid color-mix(in srgb, var(--starlight) 18%, transparent);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.menu-row{
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
}
.menu-label{
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  font-size: 16px;
}
.menu-value{
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  font-size: 14px;
  color: var(--starlight);
}

/* Toggle buttons (ON/OFF) */
.menu-toggle{
  min-width: 80px;
  text-align: center;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  font-size: 16px;
  border: 1px solid color-mix(in srgb, var(--starlight) 25%, transparent);
  border-radius: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,.06);
  color: var(--nasa-white);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.menu-toggle[aria-pressed="true"]{
  background: color-mix(in srgb, var(--cosmic-teal) 35%, transparent);
  border-color: color-mix(in srgb, var(--cosmic-teal) 55%, transparent);
}
.menu-toggle:hover{ transform: translateY(-1px); }
.menu-toggle:active{ transform: translateY(0); }
.menu-toggle:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--ring); }

.fov-range{
  -webkit-appearance: none;
  width: 220px;
  height: 12px;
  background: color-mix(in srgb, var(--starlight) 35%, transparent);
  border-radius: 999px;
  outline: none;
}
.fov-range::-webkit-slider-thumb{
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--nasa-white);
  border: 2px solid var(--cosmic-teal);
  box-shadow: 0 0 0 2px rgba(0,0,0,.15);
  cursor: pointer;
}
.fov-range::-moz-range-track{
  height: 8px;
  background: color-mix(in srgb, var(--starlight) 35%, transparent);
  border-radius: 999px;
}
.fov-range::-moz-range-thumb{
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--nasa-white);
  border: 2px solid var(--cosmic-teal);
  box-shadow: 0 0 0 2px rgba(0,0,0,.15);
  cursor: pointer;
}

/* Mobile: anchor panel to safe areas */
@media (max-width: 600px){
  #menuModal .menu-panel{
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    left: 50%;
    transform: translate(-50%, 0);
    height: auto;
    max-height: none;
    width: min(96vw, 560px);
  }
  .menu-row{ grid-template-columns: 1fr 1fr auto; }
}

/* ==========================================================================
   Scoreboard overlay and speed indicator
   ========================================================================== */

/* Scoreboard styling */
#scoreboard {
  position: absolute;
  top: 3%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 9000;
}

#score-label {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: thin;
  color: #FFFFFF;
}

#score-value {
  font-family: var(--font-display);
  font-size: 3.6rem;
  font-weight: bold;
  color: #FD3D21;
}

/* Speedometer styling */
#speedometer {
  position: absolute;
  bottom: 3%;
  left: 3%;
  text-align: left;
  z-index: 9000;
}

#speed-label {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: thin;
  color: #FFFFFF;
}

#speed-value {
  font-family: var(--font-display);
  font-size: 3.6rem;
  font-weight: bold;
  color: #FD3D21;
}

/* ==========================================================================
   Meters overlay
   ========================================================================== */

#meters {
  position: absolute;
  bottom: 3%;
  left: 3%;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 300px;
  background-color: rgba(11, 16, 30, 0.7);
  padding: 1%;
  border-radius: 6px;
}

.meter {
  color: #fff;
  font-family: var(--font-display);
  font-size: 1rem;
}

.meter-label {
  display: block;
  margin-bottom: 4px;
}

.meter-bar {
  width: 100%;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #0B3D91, #FD3D21);
  width: 50%;
  transition: width 0.5s ease;
}

/* Half-size on mobile */
@media (max-width: 768px) {
  #meters {
    width: 120px;
  }
  .meter-label {
    font-size: 0.8rem;
  }
  .meter-bar {
    height: 8px;
  }
}

/* ==========================================================================
   NavTrax teaser (Space Station)
   ========================================================================== */

#navtrax-teaser{
  position: absolute;
  top: 8%;
  right: 3%;
  z-index: 9000;
  width: 280px;
  display: grid;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 6px;
  font-family: var(--font-display);
  color: #fff;
}

#navtrax-teaser .teaser-img{
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  transition: transform 120ms ease, border-color 120ms ease;
}
#navtrax-teaser .teaser-img:hover{
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--cosmic-teal) 45%, transparent);
}
#navtrax-teaser .teaser-img img{
  display: block;
  width: 100%;
  height: auto;
  margin-top: 24px;
}

#navtrax-teaser .teaser-text{
  display: block;
  padding: 8px 10px;
  margin-top: 16px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--starlight) 18%, transparent);
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
#navtrax-teaser .teaser-text:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,0.08);
  border-color: color-mix(in srgb, var(--cosmic-teal) 45%, transparent);
}

/* Smaller on mobile */
@media (max-width: 768px){
  #navtrax-teaser{
    width: 125px;
    padding: 8px 12px;
    margin-top: 100%;
    margin-right: 50%;
  }
  #navtrax-teaser .teaser-text{ font-size: 10px; }
}

/* ==========================================================================
   Mission guide
   ========================================================================== */

#mission-guide{
  position: absolute;
  top: 8%;
  right: 3%;
  z-index: 9000;
  background-color: rgba(11,16,30,0.8);
  padding: 12px 16px;
  border-radius: 6px;
  width: 280px;
  font-family: var(--font-display);
  color: #fff;
}

#mission-guide .mission-hint{
  margin: 0 0 12px 0;
  font-family: var(--font-heading);
  font-size: 14px;
  color: var(--starlight, #BFC7D5);
}

.mission-toggle {
  text-align: center;
  padding: 8px;
  margin-top: 8px;
  background: #222;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.mission-toggle:hover {
  background: #444;
}

.missions-list{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.mission-card{
  background: rgba(255,255,255,0.06);
  border: 1px solid color-mix(in srgb, var(--starlight, #BFC7D5) 18%, transparent);
  border-radius: 10px;
  padding: 10px;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
  cursor: pointer;
}

.mission-card:hover{
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--cosmic-teal, #3CCFCF) 45%, transparent);
  background: rgba(255,255,255,0.08);
}

.mission-card:focus-within{
  outline: none;
  box-shadow: 0 0 0 3px var(--ring, rgba(60,207,207,.35));
}

.mission-card .mission-title{
  font-size: 1.2rem;
  color: #FFB547;
  font-weight: bold;
  margin: 0 0 4px 0;
}

.mission-card .mission-title[role="button"]{
  outline: none;
}

.mission-desc{
  font-size: 0.95rem;
  margin: 0 0 8px 0;
  color: #ccc;
}

.mission-tasks{
  list-style: none;
  padding: 0;
  margin: 0;
}

.mission-tasks li{
  position: relative;
  padding-left: 20px;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.mission-tasks li::before{
  content: "•";
  position: absolute;
  left: 0;
  color: #FD3D21;
}

/* Smaller on mobile */
@media (max-width: 768px){
  #mission-guide{
    width: 200px;
    padding: 8px 12px;
  }
  #mission-guide .mission-hint {
    font-size: 0.8rem;
  }
  .mission-toggle {
    font-size: 10px;
    padding: 8px;
  }
  .mission-card .mission-title{
    font-size: 1.05rem;
  }
  .mission-desc,
  .mission-tasks li{
    font-size: 0.8rem;
  }
}

/* ==========================================================================
   Mission video modals (match protoModal look & feel)
   ========================================================================== */

.mission-modal{
  position: fixed;
  inset: 0;
  z-index: 12500;
  display: none;
  background: rgba(0,0,0,0.8);
}

.mission-panel{
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(1200px, 92vw);
  max-height: min(90vh, 820px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: rgba(11,16,30,0.98);
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--starlight, #BFC7D5) 25%, transparent);
  border-radius: 16px;
  box-shadow: 0 30px 60px rgba(0,0,0,.55);
}

.mission-header{
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px;
  background: rgba(11,16,30,.90);
  border-bottom: 1px solid color-mix(in srgb, var(--starlight, #BFC7D5) 18%, transparent);
}

.mission-modal-title{
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: var(--track-wide, 0.04em);
  font-size: 20px;
}

.mission-close{
  background: transparent; color: #fff;
  border: 0; font-size: 24px; line-height: 1;
  padding: 2px 8px; border-radius: 8px; cursor: pointer;
  transition: background 120ms ease;
}
.mission-close:hover{ background: rgba(255,255,255,.08); }
.mission-close:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--ring, rgba(60,207,207,.35)); }

.mission-body{
  padding: 12px; min-height: 0; display: grid;
}

.mission-video-wrap{
  width: 100%; height: 100%;
  aspect-ratio: 16 / 9;
  display: grid; align-items: center; justify-items: center;
}

.mission-video{
  width: 100%; height: 100%;
  border: 0; border-radius: 12px;
  background: #0b101e;
  box-shadow: 0 10px 24px rgba(0,0,0,0.45);
}

/* Mobile-friendly panel sizing */
@media (max-width: 600px){
  .mission-panel{
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    left: 50%; transform: translate(-50%, 0);
    height: auto; max-height: none; width: min(96vw, 720px);
  }
}

/* ===============================
   Hi‑Scores overlay
   =============================== */

#hiscores {
  position: absolute;
  top: 6%;
  left: 0;
  right: 0;
  bottom: 0;
  width: 80%;
  margin: 0 auto;
  overflow-y: scroll;
  scrollbar-width: none;
  padding: 20px;
  box-sizing: border-box;
}

.hiscores-header {
  text-align: center;
  margin-bottom: 20px;
}

#hiscores::-webkit-scrollbar {
  display: none;
}

#hiscores::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 4px;
}

#hiscores::-webkit-scrollbar-track {
  background: transparent;
}

#hiscores .group + .group {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--starlight) 22%, transparent);
}

.section-title {
  margin: 0 0 8px 0;
  font-family: var(--font-display);
  letter-spacing: var(--track-wide);
  font-size: 16px;
  color: var(--solar-gold);
  opacity: 0.95;
}

/* Slightly denser grids on very wide screens */
@media (min-width: 1200px) {
  .boards { grid-template-columns: 1fr 1fr; }
}

.hiscores-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.hiscores-logo {
  max-width: 250px;
  margin-bottom: 10px;
}

.hiscores-header h1 {
  margin: 0;
  text-align: center;
}

#hiscores .subtitle {
  margin: 0;
  color: var(--starlight);
  font-size: 14px;
  font-family: var(--font-body);
}

.boards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.board {
  background: rgba(255,255,255,0.06);
  border: 1px solid color-mix(in srgb, var(--starlight) 18%, transparent);
  border-radius: 12px;
  padding: 12px;
}

.board-title {
  margin: 0 0 10px 0;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: var(--track-wide);
  color: var(--nasa-white);
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-tag {
  font-family: var(--font-display);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.game-tag.game-sweep {
  color: var(--chip-fg);
  background: var(--chip-bg);
  border-color: var(--chip-border);
}
.game-tag.game-nav {
  color: var(--nasa-white);
  background: color-mix(in srgb, var(--nebula-purple) 28%, transparent);
  border-color: color-mix(in srgb, var(--nebula-purple) 42%, transparent);
}

.entries {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.entry .name {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--nasa-white);
}
.entry .score {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: var(--track-wide);
  color: var(--nasa-red);
}

/* top three subtle highlight */
.entries li:nth-child(1) { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--solar-gold) 55%, transparent); }
.entries li:nth-child(2) { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--starlight) 45%, transparent); }
.entries li:nth-child(3) { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cosmic-teal) 40%, transparent); }

/* Responsive */
@media (max-width: 900px) {
  #hiscores { inset: 8% 4% auto 4%; }
  .boards { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  #hiscores { inset: 10% 3% auto 3%; padding: 12px; }
  #hiscores h1 { font-size: 20px; }
  .board-title { font-size: 16px; }
  .entry .name { font-size: 13px; }
  .entry .score { font-size: 14px; }
}

/* ==========================================================================
   Login popup styles
   ========================================================================== */

/* Backdrop */
#loginPopup.popup-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 46, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

/* Panel */
#loginPopup .popup-panel {
  background: #0B0F2E;
  padding: 20px;
  border-radius: 8px;
  width: 300px;
  color: #fff;
  font-family: var(--font-body);
}

/* Labels & Inputs */
#loginPopup label {
  display: block;
  margin-top: 10px;
}

#loginPopup input {
  width: 95%;
  padding: 6px;
  margin-top: 4px;
  border: none;
  border-radius: 4px;
}

/* Buttons */
#loginPopup .popup-buttons {
  margin-top: 25px;
  display: flex;
  gap: 10px;
}

#loginPopup button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 16px;
}

#loginSubmit {
  background: #0B3D91;
  color: white;
  transition: background 0.2s ease, transform 0.1s ease;
}

#loginSubmit:hover {
  background: #1456c2;
  transform: translateY(-2px);
}

#loginReset {
  background: #FFB547;
  color: black;
  transition: background 0.2s ease, transform 0.1s ease;
}

#loginReset:hover {
  background: #ffcc74;
  transform: translateY(-2px);
}

/* ==========================================================================
   Responsiveness and mobile adjustments
   ========================================================================== */

@media (max-width: 900px) {
  #protoModal .modal-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  #protoModal .media-item {
    flex-basis: 100%;
    max-width: 100%;
  }
}

@media (max-width: 600px){
  #infoBtn{
    top: auto;
    bottom: 5%;
    right: 5%;
    transform: none;

    width: 6rem;
    height: 6rem;

    font-size: clamp(8px, 4.5vw, 12px);
    letter-spacing: 0.02em;
  }

  #infoBtn::before{
    inset: -6px;
  }

  #switchBtn:hover  { transform: translateY(-1px); }
  #switchBtn:active { transform: translateY(0); }

    #switchBtn{
    top: auto;
    bottom: 20%;
    right: 8%;
    transform: none;
    width: 5rem;
    height: 5rem;
    font-size: clamp(8px, 4.5vw, 10px);
    letter-spacing: 0.02em;
  }

  #switchBtn::before{
    inset: -6px;
  }

  #switchBtn:hover  { transform: translateY(-1px); }
  #switchBtn:active { transform: translateY(0); }

  #protoModal .modal-panel{
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    left: 50%;
    transform: translate(-50%, 0);
    height: auto;
    max-height: none;
    width: min(96vw, 720px);
  }

  #protoModal .modal-body{
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  #score-label,
  #speed-label {
    font-size: 1.1rem;
  }

  #score-value,
  #speed-value {
    font-size: 1.6rem;
  }

  #mission-guide {
    position: absolute;
    top: 2%;
    right: 1%;
  }
}

/* ==========================================================================
   Platform polish and utility styles
   ========================================================================== */

#protoModal .media-track::-webkit-scrollbar { height: 8px; }
#protoModal .media-track::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--starlight) 35%, transparent);
  border-radius: 99px;
}
#protoModal .media-track::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--starlight) 12%, transparent);
  border-radius: 99px;
}

/* ==========================================================================
   Optional utility classes for future buttons/highlights
   ========================================================================== */

.btn-danger {
  background: var(--nasa-red);
  color: var(--nasa-white);
}
.btn-secondary {
  background: var(--nebula-purple);
  color: var(--nasa-white);
}
.highlight-gold {
  color: var(--solar-gold);
}

/* ==========================================================================
   Keyframes for animated effects
   ========================================================================== */

/* Ambient glow cycle on info button */
@keyframes infoPulse{
  0%, 100% {
    box-shadow:
      0 0 0 0 rgba(0,0,0,0),
      0 6px 20px rgba(0,0,0,0.40);
  }
  50% {
    box-shadow:
      0 0 30px 10px color-mix(in srgb, var(--pulse-color) 55%, transparent),
      0 6px 24px rgba(0,0,0,0.45);
  }
}

/* Glowing ring effect on info button */
@keyframes infoRing{
  0%   { transform: scale(1);   box-shadow: 0 0 0 0  color-mix(in srgb, var(--pulse-color) 40%, transparent); opacity: .55; }
  70%  { transform: scale(1.8); box-shadow: 0 0 0 16px color-mix(in srgb, var(--pulse-color) 0%,  transparent); opacity: 0; }
  100% { transform: scale(1.8); box-shadow: 0 0 0 16px transparent; opacity: 0; }
}

@media (prefers-reduced-motion: reduce){
  #infoBtn{ animation: none; }
  #infoBtn::before{ animation: none; }
}
