:root {
  color-scheme: dark;
  --bg: #040814;
  --safe-top: max(env(safe-area-inset-top), 8px);
  --safe-right: max(env(safe-area-inset-right), 8px);
  --safe-bottom: max(env(safe-area-inset-bottom), 8px);
  --safe-left: max(env(safe-area-inset-left), 8px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  /* Classic Orbit (default theme). The art already has its own vignette and a calm centre;
     only a faint spotlight is added behind the bowl. "cover" fills the screen, keeps the
     aspect ratio and stays centred. Theme variants live in css/content.css. */
  background:
    radial-gradient(ellipse 22% 34% at 50% 56%, rgba(102, 220, 255, 0.10), transparent 100%),
    url('../assets/backgrounds/classic.webp') center center / cover no-repeat,
    #03030c;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    var(--safe-top)
    var(--safe-right)
    var(--safe-bottom)
    var(--safe-left);
  --modal-backdrop-alpha: 0;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background: rgba(0, 0, 0, var(--modal-backdrop-alpha));
  transition: opacity 140ms ease, visibility 140ms ease;
}

body.is-modal-dimmed::before {
  opacity: 1;
  visibility: visible;
}

#game-shell {
  position: relative;
  z-index: 10;
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  width: min(
    calc(100vw - var(--safe-left) - var(--safe-right) - 4px),
    calc((100dvh - var(--safe-top) - var(--safe-bottom) - 4px) * 0.6667)
  );
  height: min(
    calc(100dvh - var(--safe-top) - var(--safe-bottom) - 4px),
    calc((100vw - var(--safe-left) - var(--safe-right) - 4px) * 1.5)
  );
  aspect-ratio: 2 / 3;
  display: grid;
  place-items: center;
}

.privacy-policy-modal {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.privacy-policy-modal.is-visible {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.privacy-policy-modal__backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 18%, rgba(114, 228, 255, 0.16), transparent 30%),
    linear-gradient(180deg, rgba(2, 7, 19, 0.56), rgba(1, 4, 12, 0.86));
  backdrop-filter: blur(8px);
}

.privacy-policy-modal__card {
  position: relative;
  z-index: 1;
  width: min(100%, 760px);
  height: min(100%, 840px);
  min-height: min(620px, calc(100% - 16px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
  border: 16px solid transparent;
  border-image: url("../assets/ui/metal/panel.webp") 54 72 fill stretch;
  background:
    linear-gradient(180deg, rgba(7, 16, 39, 0.98) 0%, rgba(4, 12, 28, 0.98) 100%);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 18px rgba(112, 231, 255, 0.08);
}

.privacy-policy-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.privacy-policy-modal__header h2 {
  margin: 4px 0 0;
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  color: #f3fbff;
}

.privacy-policy-modal__eyebrow {
  margin: 0;
  color: #8deaff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.privacy-policy-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(112, 231, 255, 0.24);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  background: center / 100% 100% no-repeat url("../assets/ui/metal/action-blue.webp");
  color: #f3fbff;
  font: 800 0.95rem/1 Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  padding: 12px 18px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.privacy-policy-modal__close:hover {
  transform: translateY(-1px);
  border-color: rgba(150, 240, 255, 0.38);
  filter: brightness(1.18);
}

.privacy-policy-modal__close:active {
  transform: translateY(0);
}

.privacy-policy-modal__close:focus-visible {
  outline: 2px solid #79ddf4;
  outline-offset: -4px;
}

.privacy-policy-modal__frame-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(112, 231, 255, 0.18);
  background: rgba(2, 7, 18, 0.75);
}

.privacy-policy-modal__frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #040814;
}

@media (orientation: landscape) {
  body {
    padding: 0;
  }

  #game-shell {
    width: 100vw;
    height: 100dvh;
    aspect-ratio: auto;
  }

  #game-shell::before,
  #game-shell::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 12px;
    pointer-events: none;
    z-index: 40;
    background:
      linear-gradient(180deg,
        rgba(215, 251, 255, 0) 0,
        rgba(215, 251, 255, 0.88) 1px,
        rgba(88, 203, 255, 0.96) 2px,
        rgba(88, 203, 255, 0.48) 4px,
        rgba(36, 79, 185, 0.84) 7px,
        rgba(36, 79, 185, 0) 11px);
    filter:
      drop-shadow(0 0 1px rgba(180, 245, 255, 0.55))
      drop-shadow(0 0 3px rgba(84, 168, 255, 0.22));
  }

  #game-shell::before {
    top: clamp(16px, 2.1vh, 24px);
  }

  #game-shell::after {
    bottom: clamp(16px, 2.1vh, 24px);
    transform: scaleY(-1);
  }
}


#game-shell::before,
#game-shell::after {
  content: none;
}

@media (orientation: landscape) and (max-height: 540px) {
  #viewport-progress {
    bottom: 8px;
    padding: 0 10px;
  }

  .viewport-progress__panel {
    --orb-base-size: clamp(24px, 5vh, 30px);
    --panel-pad-x: 10px;
    --panel-pad-top: 7px;
    --panel-pad-bottom: 8px;
    width: min(calc(100% - 18px), 500px);
  }
}

@media (orientation: landscape) and (max-height: 430px) {
  #viewport-progress {
    bottom: 6px;
    padding: 0 8px;
  }

  .viewport-progress__panel {
    --orb-base-size: clamp(21px, 5.4vh, 26px);
    --panel-pad-x: 8px;
    --panel-pad-top: 6px;
    --panel-pad-bottom: 7px;
    width: min(calc(100% - 14px), 460px);
  }
}

#game {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
}

#game canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  image-rendering: auto !important;
  touch-action: none;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

canvas:focus,
#game-shell:focus,
#game:focus {
  outline: none !important;
}

#viewport-progress {
  position: absolute;
  left: 50%;
  top: auto;
  bottom: calc(var(--safe-bottom) + 10px);
  transform: translateX(-50%);
  z-index: 45;
  display: flex;
  justify-content: center;
  padding-bottom: 1px;
  width: 100%;
  pointer-events: none;
  padding: 0 14px;
  transition: top 120ms ease, opacity 120ms ease, z-index 120ms ease;
}

body.is-modal-dimmed #game {
  z-index: 0;
}

body.is-modal-dimmed #viewport-progress {
  z-index: 45;
}

.viewport-progress__panel {
  --orb-base-size: clamp(34px, 4vw, 40px);
  --panel-pad-x: 14px;
  --panel-pad-top: clamp(8px, calc(var(--orb-base-size) * 0.24), 11px);
  --panel-pad-bottom: clamp(9px, calc(var(--orb-base-size) * 0.28), 12px);
  width: min(calc(100% - 28px), 560px);
  min-height: calc(var(--orb-base-size) + var(--panel-pad-top) + var(--panel-pad-bottom));
  border-radius: clamp(20px, calc(var(--orb-base-size) * 0.58), 23px);
  padding: var(--panel-pad-top) var(--panel-pad-x) var(--panel-pad-bottom);
  background:
    linear-gradient(180deg, rgba(7, 13, 29, 0.70) 0%, rgba(6, 11, 25, 0.84) 100%);
  border: 1.25px solid rgba(112, 231, 255, 0.22);
  box-shadow:
    0 0 0 1px rgba(255, 150, 221, 0.04) inset,
    0 10px 24px rgba(3, 8, 22, 0.34),
    0 0 12px rgba(112, 231, 255, 0.05),
    0 0 18px rgba(128, 86, 255, 0.04);
  backdrop-filter: blur(10px);
  transition:
    width 120ms ease,
    min-height 120ms ease,
    border-radius 120ms ease,
    opacity 120ms ease;
}

#viewport-progress.is-dimmed .viewport-progress__panel {
  opacity: 0.92;
}

.viewport-progress__row {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0;
  align-items: center;
}

.viewport-progress__item {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  padding-bottom: 0;
  transform: translateZ(0);
}

.viewport-progress__orb-wrap {
  width: var(--orb-base-size);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03) 44%, transparent 74%);
  transform-origin: center bottom;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.viewport-progress__orb {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 5px rgba(112, 231, 255, 0.08));
}

.viewport-progress__orb--ring {
  z-index: 0;
}

.viewport-progress__orb:not(.viewport-progress__orb--ring) {
  z-index: 1;
}

.viewport-progress__item.is-current .viewport-progress__orb-wrap {
  transform: translateY(-1px);
}

.viewport-progress__item.is-current .viewport-progress__orb {
  filter:
    drop-shadow(0 0 7px rgba(112, 231, 255, 0.12))
    drop-shadow(0 0 10px rgba(255, 232, 152, 0.10));
}

.viewport-progress__item.is-hidden .viewport-progress__orb-wrap {
  background: radial-gradient(circle at 35% 30%, rgba(76, 108, 146, 0.10), rgba(13, 19, 43, 0.1) 56%, transparent 74%);
}

.viewport-progress__item.is-hidden .viewport-progress__orb {
  opacity: 0.18;
  filter: grayscale(0.96) saturate(0.26) brightness(0.48);
}

@media (max-width: 900px) and (orientation: portrait) {
  #game-shell {
    width: min(
      calc(100vw - var(--safe-left) - var(--safe-right) - 4px),
      calc((100dvh - var(--safe-top) - var(--safe-bottom) - 4px) * 0.675)
    );
    height: min(
      calc(100dvh - var(--safe-top) - var(--safe-bottom) - 4px),
      calc((100vw - var(--safe-left) - var(--safe-right) - 4px) * 1.5)
    );
    aspect-ratio: 2 / 3;
  }

  .viewport-progress__panel {
    --orb-base-size: clamp(31px, 4.2vw, 36px);
    --panel-pad-x: 12px;
    width: min(calc(100% - 24px), 528px);
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  body {
    padding:
      var(--safe-top)
      var(--safe-right)
      var(--safe-bottom)
      var(--safe-left);
  }

  #game-shell {
    width: min(
      calc(100vw - var(--safe-left) - var(--safe-right) - 2px),
      calc((100dvh - var(--safe-top) - var(--safe-bottom) - 2px) * 0.69)
    );
    height: min(
      calc(100dvh - var(--safe-top) - var(--safe-bottom) - 2px),
      calc((100vw - var(--safe-left) - var(--safe-right) - 2px) * 1.5)
    );
  }

  #viewport-progress {
    bottom: calc(var(--safe-bottom) + 8px);
    padding: 0 10px;
  }

  .viewport-progress__panel {
    --orb-base-size: clamp(29px, 4.8vw, 34px);
    --panel-pad-x: 8px;
    width: min(calc(100% - 14px), 492px);
  }
}

@media (max-width: 480px) and (orientation: portrait) {
  body {
    padding:
      var(--safe-top)
      var(--safe-right)
      var(--safe-bottom)
      var(--safe-left);
  }

  #game-shell {
    width: min(
      calc(100vw - var(--safe-left) - var(--safe-right) - 4px),
      calc((100dvh - var(--safe-top) - var(--safe-bottom) - 4px) * 0.71)
    );
    height: min(
      calc(100dvh - var(--safe-top) - var(--safe-bottom) - 4px),
      calc((100vw - var(--safe-left) - var(--safe-right) - 4px) * 1.5)
    );
  }

  #viewport-progress {
    bottom: calc(var(--safe-bottom) + 6px);
    padding: 0 6px;
  }

  .viewport-progress__panel {
    --orb-base-size: clamp(26px, 5.2vw, 31px);
    --panel-pad-x: 6px;
    width: min(calc(100% - 8px), 460px);
  }
}

@media (max-width: 720px) {
  .privacy-policy-modal {
    padding: 10px;
  }

  .privacy-policy-modal__card {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 16px;
    border-radius: 20px;
  }

  .privacy-policy-modal__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .privacy-policy-modal__close {
    width: 100%;
    justify-content: center;
  }
}

/* ---- Visual pass 20261110: discovery strip reads as an evolution ladder ---- */
.viewport-progress__panel {
  background: linear-gradient(180deg, rgba(8, 16, 36, 0.86) 0%, rgba(5, 10, 24, 0.94) 100%);
  border: 1.5px solid rgba(112, 231, 255, 0.34);
}
.viewport-progress__item.is-discovered .viewport-progress__orb {
  filter: drop-shadow(0 0 6px rgba(112, 231, 255, 0.28));
}
/* Undiscovered planets show as dark silhouettes instead of near-invisible dots. */
.viewport-progress__item.is-hidden .viewport-progress__orb {
  opacity: 0.55;
  filter: grayscale(1) brightness(0.16) drop-shadow(0 0 1px rgba(150, 200, 255, 0.55));
}
/* Next planet to discover: soft gold pulse. */
.viewport-progress__item.is-next .viewport-progress__orb-wrap {
  box-shadow: 0 0 0 2px rgba(255, 212, 94, 0.55), 0 0 14px rgba(255, 212, 94, 0.35);
  animation: orbit-next-pulse 1.6s ease-in-out infinite;
}
@keyframes orbit-next-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 212, 94, 0.45), 0 0 8px rgba(255, 212, 94, 0.2); }
  50% { box-shadow: 0 0 0 2px rgba(255, 212, 94, 0.85), 0 0 16px rgba(255, 212, 94, 0.45); }
}
.viewport-progress__item.is-hidden .viewport-progress__orb {
  filter: grayscale(1) brightness(0.24) drop-shadow(0 0 1px rgba(150, 200, 255, 0.6));
}
.viewport-progress__item.is-next.is-hidden .viewport-progress__orb {
  opacity: 0.9;
  filter: grayscale(0.6) brightness(0.55) drop-shadow(0 0 4px rgba(255, 212, 94, 0.5));
}

/* ---- Privacy Policy in the same cockpit frame as Your Orbit (9-slice assets/ui/cockpit-frame.webp).
   Fixed header (title once + compact Close ✕); only the statement inside the reading surface scrolls. */
.privacy-policy-modal__card {
  width: min(100%, 860px);
  height: min(100%, 760px);
  min-height: 0;
  gap: 12px;
  padding: 2px 10px 10px;
  clip-path: none;
  border: 40px solid transparent;
  border-image: url("../assets/ui/cockpit-frame.webp") 96 fill / 40px stretch;
  background: none;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55), inset 0 10px 18px rgba(0, 0, 0, 0.45), inset 0 -6px 14px rgba(0, 0, 0, 0.35);
}
.privacy-policy-modal__header {
  flex-direction: row;
  align-items: center;
  padding: 0 0 12px;
  border-bottom: 1px solid rgba(101, 201, 237, 0.15);
}
.privacy-policy-modal__header h2 {
  margin: 4px 0 0;
  font: 700 30px/1.1 Inter, Arial, sans-serif;
  color: #e7f6ff;
}
.privacy-policy-modal__close {
  width: auto;
  clip-path: none;
  border: 1px solid #437e9c;
  border-radius: 6px;
  background: #122d4c;
  color: #dff6ff;
  font: 700 13px/1 Inter, Arial, sans-serif;
  padding: 11px 16px;
  box-shadow: none;
  transition: background 120ms ease, border-color 120ms ease;
}
.privacy-policy-modal__close:hover {
  transform: none;
  filter: none;
  border-color: #97e9ff;
  background: #1b4062;
}
.privacy-policy-modal__close:focus-visible {
  outline: 2px solid #ffe5a0;
  outline-offset: 3px;
}
.privacy-policy-modal__frame-wrap {
  border-radius: 4px;
  border: 1px solid rgba(92, 164, 255, 0.2);
  background: #040c1e;
}
.privacy-policy-modal__frame {
  background: #040c1e;
}
@media (max-height: 650px) {
  .privacy-policy-modal__card { border-width: 28px; border-image-width: 28px; }
}

/* ---- No selecting or dragging anywhere in the game interface (menus, Your Orbit, HUD, previews,
   thumbnails). Buttons, links, scrolling and keyboard focus keep working. See also js/main.js. ---- */
html,
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
img,
svg,
canvas,
a {
  -webkit-user-drag: none;
}
input,
textarea,
[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}
