:root {
  --bg: #050814;
  --panel: rgba(8, 14, 36, 0.78);
  --gold: #f0c75e;
  --cyan: #7ee7ff;
  --pink: #ff8bd1;
  --text: #eef4ff;
  --muted: #9aa8c7;
  --line: rgba(126, 231, 255, 0.28);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", sans-serif;
}

.stars-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(88, 40, 160, 0.35), transparent 55%),
    radial-gradient(900px 500px at 90% 10%, rgba(20, 90, 160, 0.28), transparent 50%),
    radial-gradient(800px 600px at 50% 100%, rgba(180, 80, 20, 0.16), transparent 55%),
    #050814;
  pointer-events: none;
}

.stars-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff, transparent),
    radial-gradient(1px 1px at 30% 80%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 70% 30%, #fff, transparent),
    radial-gradient(1px 1px at 90% 60%, #cde, transparent),
    radial-gradient(1px 1px at 50% 50%, #fff, transparent),
    radial-gradient(1px 1px at 15% 65%, #9cf, transparent),
    radial-gradient(1.4px 1.4px at 82% 18%, #fff, transparent);
  opacity: 0.7;
}

#app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 18px;
  padding: 12px 16px;
}

.cabinet {
  width: min(560px, calc((100vh - 24px) * 0.62), calc(100vw - 340px));
  height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1a1430, #0c1024 30%, #090b18);
  border: 1px solid rgba(240, 199, 94, 0.35);
  border-radius: 22px;
  box-shadow:
    0 0 0 4px #0a0c18,
    0 0 0 6px rgba(240, 199, 94, 0.25),
    0 30px 80px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.backglass {
  padding: 14px 16px 10px;
  background:
    linear-gradient(180deg, rgba(255, 180, 60, 0.12), transparent 70%),
    linear-gradient(90deg, rgba(80, 40, 140, 0.4), rgba(10, 30, 80, 0.2));
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--gold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
}

.backglass-title h1,
.overlay-card h2,
.info-card h2 {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.backglass-title h1 {
  font-size: 22px;
  margin-top: 2px;
  background: linear-gradient(90deg, #fff, #f0c75e 55%, #7ee7ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.hud-cell {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
}

.hud-label {
  display: block;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.hud-cell strong {
  font-family: "Orbitron", sans-serif;
  font-size: 16px;
  color: var(--cyan);
}

.playfield-wrap {
  position: relative;
  background: #000;
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#game {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  aspect-ratio: 641 / 1140;
  object-fit: contain;
  cursor: crosshair;
}

.plunger-hint {
  position: absolute;
  left: 18px;
  right: 90px;
  top: 14px;
  bottom: auto;
  text-align: center;
  font-size: 12px;
  color: #d7ecff;
  background: rgba(8, 16, 40, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: 0.25s ease;
}

.plunger-hint.show {
  opacity: 1;
  transform: none;
}

.controls-bar {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  gap: 8px;
  padding: 10px 12px 6px;
  align-items: center;
}

.flip-btn,
.play-btn,
.ctrl-icon {
  font-family: "Manrope", sans-serif;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #223056, #12182c);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 8px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.flip-btn:active,
.play-btn:active {
  transform: translateY(1px);
  filter: brightness(1.15);
}

.ctrl-icon {
  width: 42px;
  padding: 10px 0;
}


.play-btn {
  margin-top: 8px;
  width: 100%;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #f0c75e, #c4841e);
  color: #1a1204;
  border-color: #ffe7a4;
}

.keys-hint {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 0 12px 12px;
}

.log-panel {
  width: min(300px, 28vw);
  align-self: stretch;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  backdrop-filter: blur(12px);
}

.log-panel h2 {
  font-family: "Orbitron", sans-serif;
  font-size: 15px;
  margin-bottom: 6px;
}

.log-lead {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

#atlas {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#atlas li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: #66758f;
}

#atlas li.found {
  color: var(--text);
  background: rgba(126, 231, 255, 0.08);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
  flex-shrink: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(3, 6, 16, 0.72);
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(28, 24, 58, 0.96), rgba(10, 14, 32, 0.96));
  border: 1px solid rgba(240, 199, 94, 0.4);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.overlay-card p {
  color: #c9d6ee;
  line-height: 1.5;
  margin: 8px 0 0;
}

.how {
  margin: 14px 0 6px 18px;
  color: var(--muted);
  line-height: 1.7;
}

kbd {
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  background: #11162a;
  color: var(--cyan);
}

.info-card {
  width: min(500px, 100%);
}

.info-visual {
  height: 110px;
  border-radius: 14px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

.planet-orb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
}

.info-type {
  color: var(--gold) !important;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.stats div {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 8px 10px;
}

.stats dt {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stats dd {
  font-weight: 700;
  margin-top: 2px;
}

.info-text {
  font-size: 14px;
}

@media (max-width: 1100px) {
  #app {
    flex-direction: column;
    overflow: auto;
    height: auto;
    min-height: 100%;
  }

  .cabinet,
  .log-panel {
    width: min(560px, 100%);
    height: auto;
  }

  .cabinet {
    height: min(920px, calc(100vh - 24px));
  }

  html, body {
    overflow: auto;
  }
}

@media (max-width: 640px) {
  .hud {
    grid-template-columns: repeat(2, 1fr);
  }

  .keys-hint {
    display: none;
  }
}

.info-visual {display:flex;align-items:center;justify-content:center;min-height:180px;background:#111c35;color:#9aabc7;border:1px dashed #536582;}
.info-visual img {width:100%;height:220px;object-fit:contain;}

.location-picker {display:flex;gap:8px;align-items:center;flex-wrap:wrap;color:#c9d9ef;font-size:13px;}
.location-picker select {background:#152139;color:#fff;border:1px solid #536582;border-radius:8px;padding:8px;max-width:100%;}

#game:focus {outline:none;}

/* Compact header gives the recovered height to the proportional playfield. */
.backglass {display:flex;align-items:stretch;gap:10px;padding:8px;flex-shrink:0;}
.location-tile {flex:1;min-width:0;text-align:left;border:1px solid var(--line);border-radius:12px;padding:10px 12px;color:var(--text);background-size:cover;background-position:center 24%;cursor:pointer;}
.location-tile .eyebrow {display:block;font-size:8px;letter-spacing:.12em;}
#location-title {display:block;font-size:clamp(12px,1.5vw,19px);font-weight:800;margin-top:4px;}
.hud {display:grid;grid-template-columns:repeat(2,minmax(65px,1fr));margin:0;align-items:stretch;}
.hud-cell {display:flex;flex-direction:column;justify-content:center;min-width:65px;padding:6px;}
#atlas li {display:block;padding:0;}
#atlas button {width:100%;display:flex;align-items:center;gap:8px;text-align:left;font:inherit;color:inherit;padding:9px 8px;background:transparent;border:1px solid transparent;border-radius:10px;cursor:pointer;}
#atlas button:disabled {cursor:default;opacity:.7;}
#atlas button:enabled:hover {background:rgba(126,231,255,.12);border-color:var(--line);}
button:focus-visible {outline:2px solid var(--cyan);outline-offset:3px;}
.location-dialog {width:min(700px,100%);max-height:90vh;overflow:auto;}
#location-options {display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin:20px 0;}
.location-option {position:relative;overflow:hidden;min-height:150px;border:1px solid var(--line);border-radius:12px;background:#0a1024;color:var(--text);cursor:pointer;text-align:left;padding:0 0 12px;}
.location-option img {width:100%;height:115px;object-fit:cover;object-position:center 25%;display:block;margin-bottom:10px;}
.location-option span,.location-option small {display:block;margin:0 10px;}
.location-option small {color:var(--muted);margin-top:5px;}
.location-option[aria-pressed=true] {border-color:var(--gold);box-shadow:0 0 0 1px var(--gold);}
@media(max-width:640px) {#location-options {grid-template-columns:repeat(2,1fr);} .backglass {gap:6px;} .hud {gap:5px;grid-template-columns:repeat(2,minmax(55px,1fr));} .hud-cell {min-width:55px;} .hud-label {font-size:8px;} #location-title {font-size:13px;} }

.info-card {max-height:90vh;overflow:auto;}
.info-fact {margin-top:12px;font-size:14px;font-weight:700;color:#ffe08a;}
.info-question {margin-top:10px;font-size:14px;color:#b9dfff;}

.info-photo-credit {font-size:11px;color:var(--muted);margin:-6px 0 10px;}
.info-photo-credit a {color:inherit;}

/* Smartphone layout: reserve space for thumbs and keep the complete table visible. */
.mobile-atlas-toggle, .mobile-atlas-close { display: none; }
.controls-bar { flex-shrink: 0; }
.controls-bar button, #game { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.flip-btn.held { background: #335581; border-color: var(--cyan); }
@media (max-width: 640px), (max-height: 500px) and (pointer: coarse) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  #app { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); gap: 0; align-items: center; }
  .cabinet { width: 100%; max-width: 560px; height: 100%; min-height: 0; border-radius: 0; box-shadow: none; }
  .backglass { padding: 5px 8px; }
  .location-tile { padding: 6px 8px; min-height: 44px; }
  .keys-hint { display: none; }
  .mobile-atlas-toggle, .mobile-atlas-close { display: block; flex-shrink: 0; min-height: 44px; border: 1px solid var(--line); background: #111c35; color: var(--text); font: inherit; padding: 6px 12px; }
  .mobile-atlas-close { margin: 0 0 16px auto; border-radius: 10px; }
  .controls-bar { grid-template-columns: 56px minmax(0, 1fr) 56px; gap: 6px; padding: 6px 8px 8px; }
  .controls-bar button { min-height: 56px; font-size: 13px; padding: 8px 4px; }
  .ctrl-icon { width: 44px; }
  .log-panel { display: none; position: fixed; inset: 0; z-index: 15; width: 100%; max-width: none; height: 100%; border-radius: 0; background: #080e24; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
  .log-panel.mobile-open { display: block; }
  .overlay { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .overlay-card { padding: 16px; max-height: 100%; overflow: auto; overscroll-behavior: contain; }
  .info-visual { min-height: 100px; height: 120px; }
  .info-visual img { height: 120px; }
  #btn-eject { position: sticky; bottom: 0; min-height: 48px; }
  .location-dialog { max-height: 100%; }
}
@media (max-width: 640px), (max-height: 500px) and (pointer: coarse) {
  .keys-hint:first-of-type { display: block; flex-shrink: 0; font-size: 10px; padding: 3px 8px; }
}

/* Three thumb controls: round flippers around the rectangular launcher. */
#btn-left, #btn-right {
  width: 56px;
  height: 56px;
  min-height: 56px;
  border-radius: 50%;
  padding: 0;
  font-size: 22px;
  display: grid;
  place-items: center;
}
#btn-plunger {
  min-height: 48px;
  border-radius: 10px;
  font-weight: 800;
}

/* Single solar table: compact HUD, maximum playfield, discovered-object strip. */
#app { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; align-items: center; }
html, body { overflow: hidden; }
.cabinet { width: min(560px, calc((100dvh - 24px) * .62), calc(100vw - 32px)); height: calc(100dvh - 24px); min-height: 0; }
.backglass { padding: 5px 8px; }
.hud { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.hud-cell { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 10px; min-height: 36px; }
.hud-label { font-size: 10px; }
.hud-cell strong { font-size: 18px; }
.collection-strip { flex-shrink: 0; min-height: 48px; margin: 4px 8px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; }
#atlas { display: flex; flex-direction: row; gap: 4px; height: 46px; padding: 1px 4px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
#atlas::-webkit-scrollbar { display: none; }
#atlas li.found { flex: 0 0 auto; padding: 0; background: transparent; }
#atlas button { display: flex; align-items: center; gap: 7px; width: auto; height: 42px; padding: 0 10px; border-radius: 999px; white-space: nowrap; color: var(--text); }
.atlas-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px rgba(255,255,255,.55); }
.atlas-name { font-size: 11px; }
#atlas button:focus-visible { outline-offset: -3px; }
#completion { padding: 4px 8px 8px; text-align: center; font-size: 12px; }
#completion .play-btn { min-height: 44px; }
@media (max-width: 640px), (max-height: 500px) and (pointer: coarse) {
  .cabinet { width: 100%; height: 100%; max-width: 560px; }
  .hud-cell { min-width: 0; padding: 4px 8px; min-height: 32px; }
  .hud-label { font-size: 9px; }
  .hud-cell strong { font-size: 16px; }
}

/* End-of-game atlas lives on the playfield and remains usable on small screens. */
.completion-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: clamp(8px, 3vw, 22px);
  background: rgba(3, 6, 16, .8);
  backdrop-filter: blur(3px);
}
.completion-overlay[hidden] { display: none; }
.completion-card {
  width: min(100%, 540px);
  max-height: 100%;
  overflow: auto;
  padding: clamp(12px, 3vw, 22px);
  border: 1px solid rgba(240, 199, 94, .58);
  border-radius: 16px;
  background: linear-gradient(150deg, #21183b, #090e20 82%);
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
  text-align: center;
}
.completion-summary { color: #d5def2; font-size: clamp(12px, 2.8vw, 16px); margin-bottom: 12px; }
.completion-summary strong { color: var(--cyan); font-family: "Orbitron", sans-serif; }
#completion-atlas { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(4px, 1.2vw, 8px); margin: 0 0 14px; }
#completion-atlas li { min-width: 0; }
#completion-atlas button {
  width: 100%; min-height: clamp(34px, 6vh, 48px); padding: 5px 3px;
  border: 1px solid var(--line); border-radius: 8px; background: rgba(126,231,255,.07);
  color: var(--text); font: 700 clamp(9px, 2.5vw, 13px)/1.15 "Manrope", sans-serif;
  overflow-wrap: anywhere; cursor: pointer; touch-action: manipulation;
}
#completion-atlas button:active { background: rgba(126,231,255,.2); }
#btn-restart { width: 100%; min-height: 48px; font-size: clamp(15px, 4vw, 20px); touch-action: manipulation; }
