:root{color-scheme:dark;font-family:system-ui,-apple-system,Segoe UI,sans-serif;background:#071124;color:#edf3ff}
*{box-sizing:border-box}[hidden]{display:none!important}body{margin:0}.stage{max-width:1040px;margin:auto;padding:clamp(10px,2vw,24px);min-height:100dvh;display:flex;flex-direction:column;gap:10px}
h1{font-size:clamp(1.4rem,4vw,2rem);margin:.18rem 0}p{margin:0;color:#c2d0e8;line-height:1.45}.eyebrow{color:#82d1eb;font-size:.84rem;letter-spacing:.02em}
.panel{background:#101e38;border:1px solid #314363;border-radius:15px;padding:12px}
.scene-panel{padding:10px}.scene-toolbar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:7px;margin-bottom:8px}.view-toggle{display:flex;gap:5px;flex-wrap:wrap}
button,select,input{font:inherit}button,select{background:#1e3357;border:1px solid #54709b;border-radius:10px;color:#fff;min-height:42px;padding:8px 12px}button{cursor:pointer}button:hover{background:#2e4a78}button[aria-pressed="true"]{background:#22647f;border-color:#8bdfff}
button:focus-visible,select:focus-visible,input:focus-visible,canvas:focus-visible{outline:3px solid #ffe08e;outline-offset:2px}
.viewport{position:relative;background:radial-gradient(ellipse at 40% 25%,#13274a 0%,#061023 76%);border:1px solid #294466;border-radius:12px;overflow:hidden;min-height:205px}
#eclipse-canvas{display:block;width:100%;height:clamp(235px,40dvh,450px);touch-action:none;cursor:grab}#eclipse-canvas:active{cursor:grabbing}
.observer-view{display:grid;place-items:center;height:clamp(235px,40dvh,450px);padding:5px}.observer-view svg{display:block;width:100%;height:100%;max-width:780px}.scene-fallback{position:absolute;bottom:8px;left:8px;right:8px;border-radius:8px;background:#142c4eeb;color:#ffe2a5;padding:8px;font-size:.87rem}
.view-caption{font-size:.82rem;margin:7px 0 2px}.shadow-toggle{display:flex;align-items:center;gap:5px;color:#d6e2f8;font-size:.88rem}.shadow-toggle input{height:20px;width:20px;accent-color:#6bd5ef}
.result{display:flex;flex-wrap:wrap;justify-content:space-between;gap:8px;align-items:center}.result p{font-size:.95rem}#status{font-weight:700;color:#ffe2a5}
.controls{display:grid;gap:10px;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:end}.controls label{display:flex;flex-direction:column;gap:5px;color:#d9e5ff;font-size:.9rem;min-width:0}
.controls select{max-width:100%;width:100%}.controls .timeline-wrap{grid-column:1/-1}.timeline-wrap{display:flex;flex-direction:column;gap:2px}.timeline-label{display:flex;justify-content:space-between;align-items:center;gap:12px}.timeline-label label{display:block}.timeline-label output{font-variant-numeric:tabular-nums;color:#ffe1a0}
.actions{display:flex;gap:8px;flex-wrap:wrap}#play{background:#235c68}input[type=range]{width:100%;min-height:34px;accent-color:#ffd86a;cursor:pointer}
small{display:block;color:#b6c5dd;line-height:1.4}.safety{border-left:3px solid #fbbf71;padding-left:12px}
.stage:fullscreen{max-width:none;width:100%;height:100dvh;min-height:0;overflow:auto;padding:8px 12px}.stage:fullscreen .scene-panel{flex:1;min-height:155px}.stage:fullscreen #eclipse-canvas,.stage:fullscreen .observer-view{height:clamp(155px,31dvh,530px)}
.stage:fullscreen .controls{position:sticky;bottom:0;z-index:3;background:#101e38;box-shadow:0 -9px 19px #071124dd;max-height:48dvh;overflow-y:auto}
@media(max-width:600px){.heading p{font-size:.85rem}.scene-toolbar button{font-size:.86rem;padding:6px 9px}.view-caption{font-size:.78rem}.result p{font-size:.87rem}}
@media(max-width:390px){.stage{gap:8px;padding:8px}.panel{padding:8px}.scene-toolbar{gap:6px}.scene-toolbar button{font-size:.8rem;min-height:40px;padding:6px 8px}
 #eclipse-canvas,.observer-view{height:clamp(215px,36dvh,340px)}.controls{grid-template-columns:1fr 1fr;gap:6px}.controls label{font-size:.82rem}.controls button,.controls select{min-height:44px;padding:7px 8px}
 .controls .actions{grid-column:1/-1}.actions button{flex:1}.stage:fullscreen .scene-panel{min-height:135px}.stage:fullscreen #eclipse-canvas,.stage:fullscreen .observer-view{height:clamp(135px,27dvh,270px)}
 .stage:fullscreen .controls{max-height:56dvh;grid-template-columns:1fr 1fr}}
/* Kids Mode is a separate lightweight SVG teaching stage; no realistic controls. */
.mode-toggle{display:flex;gap:7px;flex-wrap:wrap;margin:10px 0 2px}
.mode-toggle button{min-width:116px}
.kids-panel{display:grid;gap:12px}
.kids-topbar{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.kids-topbar label{display:grid;gap:5px;min-width:0;color:#dce7fc;font-size:.9rem}
.kids-topbar select{width:100%;min-width:0}
.kids-scene{min-height:170px;border-radius:15px;overflow:hidden;background:#111f45}
.kids-scene svg{display:block;width:100%;height:auto;max-height:380px}
.kids-caption{font-size:1rem;min-height:3em;color:#f4e9ce}
.kids-timeline{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:5px 12px;align-items:center}
.kids-timeline input{grid-column:1/-1;min-height:42px}
.kids-timeline output{text-align:right;font-variant-numeric:tabular-nums}
.kids-actions{display:flex;flex-wrap:wrap;gap:8px}
.kids-actions button{flex:1;min-width:85px;min-height:46px}
#kids-play{background:#236775}#kids-replay{background:#504d86}
.stage:fullscreen .kids-panel{flex:1;min-height:0;overflow-y:auto}
.stage:fullscreen .kids-scene svg{max-height:36dvh}
.stage:fullscreen .kids-actions{position:sticky;bottom:0;background:#101e38;padding:6px 0;z-index:4}
@media(max-width:390px){
 .kids-panel{gap:8px}.kids-topbar{grid-template-columns:1fr 1fr;gap:6px}
 .kids-topbar label{font-size:.79rem}
 .kids-topbar select{padding:6px 5px;font-size:.83rem}
 .kids-actions{gap:5px}.kids-actions button{min-width:75px;padding:6px;font-size:.86rem}
 .stage:fullscreen .kids-scene svg{max-height:26dvh}
 .stage:fullscreen .kids-panel{padding-bottom:6px}
}

/* Realistic mode: Space/Orbit on the LEFT, permanent Observer View on the RIGHT. */
.stage{max-width:1260px}
.comparison-grid{display:grid;grid-template-columns:minmax(0,1.05fr) minmax(0,1fr);align-items:stretch;gap:12px;min-width:0}
.comparison-grid>.panel{min-width:0;display:flex;flex-direction:column;gap:7px}
.comparison-grid .viewport{min-height:0}
.comparison-grid #eclipse-canvas,.comparison-grid .observer-view,.comparison-grid .space-fallback{height:clamp(240px,34dvh,390px)}
.comparison-grid .observer-view{min-width:0;display:grid;place-items:center;padding:7px;background:radial-gradient(ellipse at 40% 25%,#13274a,#061023 76%);border:1px solid #294466;border-radius:12px;overflow:hidden}
.comparison-grid .observer-view svg,.comparison-grid .space-fallback svg{display:block;width:100%;height:100%}
.observer-heading{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;min-height:42px;padding:6px 0}
.observer-live{font-size:.79rem;color:#a4dded}
.observer-result{display:grid;gap:6px;border-top:1px solid #314363;padding-top:10px}
.space-fallback{width:100%;display:grid;place-items:center;background:#0d1833}
.stage:fullscreen .comparison-grid{flex:1 0 auto}
.stage:fullscreen .comparison-grid #eclipse-canvas,.stage:fullscreen .comparison-grid .observer-view,.stage:fullscreen .comparison-grid .space-fallback{height:clamp(160px,30dvh,440px)}
@media(max-width:800px){
 .comparison-grid{grid-template-columns:minmax(0,1fr);gap:8px}
 .comparison-grid #eclipse-canvas,.comparison-grid .observer-view,.comparison-grid .space-fallback{height:clamp(215px,32dvh,330px)}
 .stage:fullscreen .comparison-grid{flex:0 0 auto}
 .stage:fullscreen .comparison-grid #eclipse-canvas,.stage:fullscreen .comparison-grid .observer-view,.stage:fullscreen .comparison-grid .space-fallback{height:clamp(130px,20dvh,220px)}
}
@media(max-width:390px){
 .comparison-grid #eclipse-canvas,.comparison-grid .observer-view,.comparison-grid .space-fallback{height:clamp(180px,29dvh,270px)}
 .observer-heading{min-height:35px;padding:2px 0}
 .observer-live{font-size:.73rem}
 .stage:fullscreen .comparison-grid #eclipse-canvas,.stage:fullscreen .comparison-grid .observer-view,.stage:fullscreen .comparison-grid .space-fallback{height:clamp(112px,17dvh,170px)}
}

/* M6: ONE unified General Mode control panel, before both views. */
.mode-toggle{margin:10px 0 2px}
.controls{display:flex;flex-direction:column;align-items:stretch;gap:10px;min-width:0}
.playback-row{display:grid;grid-template-columns:minmax(170px,1fr) auto;align-items:end;gap:12px}
.playback-row .speed-control{min-width:0}
.playback-row .actions{display:flex;flex-wrap:wrap;align-items:end;gap:8px}
.playback-row .actions button{min-height:50px;white-space:nowrap}
.control-selectors{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.control-selectors label{min-width:0}
.controls .timeline-wrap{width:100%;min-width:0}
.controls #play.primary-play,#kids-play.primary-play{display:inline-flex;align-items:center;justify-content:center;gap:10px;min-height:50px;padding:10px 22px;background:#247c69;border:1px solid #77d9c6;color:#fff;font-weight:700;box-shadow:0 2px 12px #12383166}
.controls #play.primary-play[aria-pressed="true"],#kids-play.primary-play[aria-pressed="true"]{background:#235d78;border-color:#9cddf2}
.primary-play::before{content:"▶";font-size:.96em;line-height:1}
.primary-play[aria-pressed="true"]::before{content:"Ⅱ"}
.kids-startbar{display:flex;align-items:center;gap:14px;flex-wrap:wrap;padding:4px 0}
#kids-start-caption{font-size:.89rem;color:#d3e4fb}
/* In fullscreen, the SAME controls remain at the top and scroll within the
   bar on short phones. No bottom playback duplicates. */
.stage:fullscreen #general-controls{position:sticky;top:0;bottom:auto;z-index:5;max-height:56dvh;overflow-y:auto;background:#101e38;box-shadow:0 8px 16px #071124dd}
@media(max-width:700px){
  .playback-row{grid-template-columns:minmax(0,1fr);gap:8px}
  .playback-row .actions{display:flex;gap:6px}
  .playback-row .actions button{flex:1;min-width:0;padding:8px 11px}
}
@media(max-width:440px){
  .playback-row .actions{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:6px}
  .playback-row .actions #play{grid-column:1/-1;width:100%}
  .control-selectors{grid-template-columns:minmax(0,1fr);gap:7px}
  .controls #play.primary-play{width:100%}
  .stage:fullscreen #general-controls{max-height:60dvh}
}
