:root {
  --bg: #04050a;
  --neon: #00f0ff;
  --pink: #ff2e93;
  --text: #cfe9ff;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; }
#globe { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
header { position: fixed; top: max(16px, env(safe-area-inset-top)); left: 16px; pointer-events: none; }
header h1 { font-size: 14px; letter-spacing: 0.4em; color: var(--neon);
  text-shadow: 0 0 12px var(--neon); }
header p { font-size: 11px; opacity: 0.6; margin-top: 4px; }
#panel { position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 320px; padding: 14px 16px; border: 1px solid var(--neon); border-radius: 12px;
  background: rgba(4, 5, 10, 0.75); backdrop-filter: blur(8px);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.25); }
#panel h2 { font-size: 16px; color: var(--neon); margin-bottom: 6px; }
#p-bpm { color: var(--pink); margin-top: 4px; font-size: 22px; text-shadow: 0 0 10px var(--pink); }
footer { position: fixed; top: max(16px, env(safe-area-inset-top)); right: 16px; width: 140px; font-size: 11px; text-align: right; }
footer input { width: 100%; accent-color: var(--neon); margin-top: 4px; }
#cityview { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; background: var(--bg); }
button { font: inherit; font-size: 11px; color: var(--neon); background: none; border: 1px solid var(--neon); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
#enter { margin-top: 10px; }
#tip { position: fixed; z-index: 12; pointer-events: none; font-size: 11px; line-height: 1.4; padding: 8px 10px; max-width: 220px;
  background: rgba(4, 5, 10, 0.9); border: 1px solid var(--pink); border-radius: 8px; color: var(--text); }
#tip b { color: var(--neon); }
#loading { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); transition: opacity 0.6s; }
#loading.done { opacity: 0; pointer-events: none; }
#loading span { font-size: 48px; color: var(--pink); text-shadow: 0 0 20px var(--pink); animation: beat 0.9s infinite; }
#loading p { margin-top: 16px; font-size: 14px; letter-spacing: 0.4em; color: var(--neon); text-shadow: 0 0 12px var(--neon); }
#loading small { margin-top: 8px; font-size: 11px; opacity: 0.6; }
@keyframes beat { 0%, 40%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(1.1); } }
#panel { left: 0; top: 0; right: auto; bottom: auto; width: 220px; max-width: none; transform: translate(-50%, -100%); }
#panel::after { content: ''; position: absolute; left: 50%; bottom: -7px; width: 12px; height: 12px; margin-left: -6px;
  background: rgba(4, 5, 10, 0.9); border: solid var(--neon); border-width: 0 1px 1px 0; transform: rotate(45deg); }
#cityinfo { z-index: 11; }
#loading.error span { animation-duration: 0.3s; color: #ff5b5b; }
#loading small { max-width: 280px; text-align: center; line-height: 1.5; }
#cityinfo { position: fixed; top: max(16px, env(safe-area-inset-top)); left: 16px; display: flex; align-items: center; gap: 24px; color: var(--text); }
#cityinfo b { color: var(--neon); font-size: 14px; text-shadow: 0 0 10px var(--neon); }
#cityinfo .back { border: 0; padding: 6px 0; font-size: 13px; }
#legend { position: fixed; z-index: 11; top: max(16px, env(safe-area-inset-top)); right: 16px; font-size: 11px; color: var(--text);
  background: rgba(4, 5, 10, 0.75); padding: 10px 12px; border: 1px solid var(--neon); border-radius: 12px; }
#legend div { display: flex; align-items: center; gap: 8px; line-height: 1.8; }
#legend [hidden] { display: none; }
#legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
#legend i.plane { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 50% 75%, 0 100%); }
#cityinfo[hidden] { display: none; }
#cityinfo { gap: 12px; align-items: stretch; }
#cityinfo .back, #cityinfo b { font-size: 12px; text-shadow: none; display: flex; align-items: center;
  background: rgba(4, 5, 10, 0.75); padding: 10px 12px; border: 1px solid var(--neon); border-radius: 12px; }
#cityinfo b { font-weight: normal; }
#cityinfo b { position: fixed; left: 50%; transform: translateX(-50%); top: max(16px, env(safe-area-inset-top)); }
#cityinfo b { font-size: 15px; padding: 10px 18px; }
#p-bpm small { font-size: 10px; opacity: 0.6; text-shadow: none; color: var(--text); }
.dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75%, 100% { content: '...'; } }
#p-wx { margin-top: 2px; font-size: 11px; opacity: 0.8; }
#mute { position: fixed; top: max(16px, env(safe-area-inset-top)); right: 16px; background: rgba(4, 5, 10, 0.75); padding: 8px 12px; border-radius: 12px; }
#key { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); font-size: 10px; opacity: 0.7; pointer-events: none; }
#key i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 4px 0 8px; }
#iss-find { pointer-events: auto; cursor: pointer; text-decoration: underline; margin-left: 4px; color: var(--neon); }
#cityinfo #radar-toggle { font-size: 12px; background: rgba(4, 5, 10, 0.75); padding: 10px 12px; border: 1px solid var(--neon); border-radius: 12px; }
#p-aq { font-size: 11px; opacity: 0.8; }
#tools { position: fixed; top: max(16px, env(safe-area-inset-top)); right: 16px; display: flex; gap: 8px; }
#tools button { background: rgba(4, 5, 10, 0.75); padding: 8px 12px; border-radius: 12px; }
#tools #mute { position: static; }
#tip .fact { margin-top: 1.4em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#jump { pointer-events: auto; margin-top: 8px; font: inherit; font-size: 11px; color: var(--text); background: rgba(4, 5, 10, 0.75);
  border: 1px solid var(--neon); border-radius: 12px; padding: 6px 10px; cursor: pointer; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  #loading span { animation: none; }
  #loading { transition: none; }
  .dots::after { animation: none; content: '...'; }
}
#tonight { position: fixed; z-index: 11; left: 16px; bottom: 36px; max-width: 270px; font-size: 11px; line-height: 1.5; color: var(--text);
  background: rgba(4, 5, 10, 0.75); padding: 10px 12px; border: 1px solid var(--neon); border-radius: 12px; }
#tonight .tn-title { color: var(--neon); font-size: 12px; margin-bottom: 6px; }
#tonight .tn-row { display: flex; align-items: center; gap: 12px; }
#tonight .moon { flex: none; }
#tonight b { font-weight: normal; color: var(--text); font-size: 12px; }
#tonight[hidden] { display: none; }
#tonight .tn-head { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; margin-bottom: 6px; }
#tonight .tn-head .tn-title { margin: 0; }
#tonight .more { background: none; border: 0; padding: 0; font: inherit; font-size: 11px; color: var(--neon); opacity: 0.85;
  text-decoration: underline; text-underline-offset: 3px; cursor: help; white-space: nowrap; }
#tonight .more:hover, #tonight .more:focus-visible { opacity: 1; }
#tonight { max-width: 330px; }

/* ---- phones and narrow windows ---- */
#menu, #legend-toggle { display: none; }
#legend[hidden] { display: none !important; }
@media (max-width: 700px) {
  header h1 { letter-spacing: 0.25em; font-size: 13px; }
  #tools { flex-direction: column; align-items: flex-end; }
  #menu { display: block; }
  #tools:not(.open) button:not(#menu) { display: none; }
  #key { left: 16px; right: 16px; font-size: 9px; line-height: 1.9; }
  #cityinfo { right: 16px; flex-wrap: wrap; gap: 8px; align-items: center; }
  #cityinfo .back { order: 1; }
  #cityinfo #radar-toggle { order: 2; }
  #cityinfo #legend-toggle { order: 3; display: block; background: rgba(4, 5, 10, 0.75); border: 1px solid var(--neon); border-radius: 12px; }
  #cityinfo b { order: 4; position: static; transform: none; flex: 1 1 100%; font-size: 12px; padding: 8px 12px; }
  #cityinfo .back, #cityinfo #radar-toggle, #cityinfo #legend-toggle { font-size: 11px; padding: 8px 10px; }
  #legend { display: none; left: auto; right: 16px; top: 120px; }
  #legend.open { display: block; }
  #tonight { max-width: calc(100vw - 32px); }
  #tonight .more { padding: 10px 6px; margin: -10px -6px; touch-action: manipulation; } /* bigger tap target */
  #tip.sheet { left: 16px !important; right: 16px; top: auto !important; max-width: none !important; max-height: 50vh; overflow: auto; }
}

/* phone header polish: boxes hug their text, Legend sits on the right */
@media (max-width: 700px) {
  #cityinfo #legend-toggle { margin-left: auto; }
  #cityinfo b { flex: 0 1 auto; max-width: 100%; }
  #tip.sheet { right: auto; width: fit-content; max-width: calc(100vw - 32px) !important; }
}

/* phones: center the city and weather box under the buttons */
@media (max-width: 700px) {
  #cityinfo b { margin-inline: auto; text-align: center; justify-content: center; }
}

/* the page itself never pinch-zooms (the globe and map keep their own zoom), so the buttons can't get zoomed out of reach */
html, body { touch-action: pan-x pan-y; }

/* ---- Solar System (zoomed out) ---- */
#solar { position: fixed; inset: 0; z-index: 9; pointer-events: none; font-size: 11px; }
#solar[hidden] { display: none; }
#solar button { pointer-events: auto; background: rgba(4, 5, 10, 0.75); color: var(--text); border: 1px solid var(--neon); border-radius: 12px;
  padding: 8px 12px; font: inherit; cursor: pointer; }
#solar button.on { background: var(--neon); color: var(--bg); }
#solar .s-info { position: absolute; left: 16px; bottom: 36px; max-width: 280px; line-height: 1.5; padding: 10px 12px; border: 1px solid var(--neon);
  border-radius: 12px; background: rgba(4, 5, 10, 0.75); }
#solar .s-info[hidden] { display: none; }
#solar .s-info b { color: var(--neon); font-size: 13px; font-weight: normal; display: block; margin-bottom: 4px; }
#solar .s-bar { position: absolute; left: 16px; right: 16px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 48px); display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#solar .s-bar button { padding: 6px 10px; }
#solar .s-time { position: absolute; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; justify-content: center; }
#solar .s-time input { flex: 1; max-width: 360px; accent-color: var(--neon); pointer-events: auto; }
#solar .s-time span { min-width: 90px; text-align: center; }
body.space #key, body.space #panel { display: none !important; }
@media (max-width: 900px) { #solar .s-info { bottom: 130px; max-width: calc(100vw - 32px); } } /* clear of the planet buttons and slider */
#solar .s-home { position: absolute; left: 16px; top: calc(max(16px, env(safe-area-inset-top)) + 24px); }
body.space #jump { display: none; } /* jumping to a city from out here would break the view, so Back to Earth takes its place */
