:root { --panel-w: 305px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: radial-gradient(ellipse at 48% 51%, #141d2a 0%, #0a101a 47%, #05070d 82%);
}
.stage-head { position: relative; z-index: 2; text-align: center; padding: 19px 10px 0; }
.stage-head h2 { margin: 0; font-size: 19px; font-weight: 680; color: var(--accent); }
.stage-head p { margin: 2px 0 13px; color: #aebbd0; font-size: 13px; }
.scene-tabs { display: flex; justify-content: center; gap: 5px; }
button { touch-action: manipulation; }
.scene-tabs button, .action, .stage-foot #panelToggle {
  font: inherit;
  color: var(--accent);
  background: #101620;
  border: 1px solid #454039;
  border-radius: 7px;
  min-height: 36px;
  padding: 5px 11px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
}
.scene-tabs button[aria-pressed=true], .action[aria-pressed=true] {
  background: var(--accent);
  color: #161005;
  border-color: var(--accent);
  font-weight: 650;
}
.scene-tabs button:hover, .action:hover, .stage-foot #panelToggle:hover { border-color: var(--accent); }
button:focus-visible, .learn-fab:focus-visible { outline: 2px solid #ffe8ae; outline-offset: 3px; }
button:disabled { opacity: .55; cursor: default; }

#view { position: relative; min-height: 0; margin: 0 12px; }
#world, #tags, #mapView { position: absolute; inset: 0; }
#world canvas { cursor: grab; touch-action: none; }
#world canvas:active { cursor: grabbing; }
#tags { pointer-events: none; }
.pin { position: absolute; width: 0; height: 0; top: 0; left: 0; }
.pin-dot, .pin-leader, .pin-button { position: absolute; left: 0; top: 0; }
.pin-dot { width: 7px; height: 7px; transform: translate(-50%, -50%); border-radius: 50%; background: var(--mark); box-shadow: 0 0 0 2px #080e18c0; }
.pin-leader { height: 1px; background: var(--mark); opacity: .7; transform-origin: left center; }
.pin-button {
  background: #0b121de8;
  border: 1px solid color-mix(in srgb, var(--mark), #0e1624 57%);
  color: var(--mark);
  white-space: nowrap;
  font: inherit;
  font-weight: 650;
  font-size: 12px;
  border-radius: 6px;
  padding: 5px 9px;
  pointer-events: auto;
  cursor: pointer;
}
.pin-button:hover, .pin-button[aria-pressed=true] { color: #14100b; background: var(--mark); border-color: var(--mark); }
.pin-button::after { content: ""; position: absolute; inset: -7px -3px; }
.pin:has(.pin-button:hover), .pin:has(.pin-button:focus-visible), .pin:has(.pin-button[aria-pressed=true]) { z-index: 2; }

.stage-bottom { padding: 0 12px 12px; position: relative; z-index: 3; }
#crossControls, #mapControls { margin-inline: auto; width: min(100%, 650px); }
#stageCaption { min-height: 52px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 0 6px 8px; }
#captionLabel { color: #f2deb0; font-size: 15px; font-weight: 650; }
#captionText { color: #acb9ce; font-size: 12px; }
.timeline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 55px auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #2d3748;
  background: #0c131e;
  border-radius: 10px;
  padding: 6px 8px;
}
.timeline output { text-align: center; color: #e4d3ae; }
.timeline-range { min-width: 0; display: flex; align-items: center; }
.timeline input { margin: 0; min-height: 40px; cursor: ew-resize; }
.timeline input::-webkit-slider-runnable-track { height: 5px; border-radius: 8px; background: linear-gradient(to right, #ffc94a var(--progress, 78%), #354354 var(--progress, 78%)); }
.timeline input::-webkit-slider-thumb { margin-top: -5px; }
.stage-foot { display: flex; justify-content: center; gap: 9px; margin-top: 9px; }
.stage-foot .learn-fab, .stage-foot #panelToggle { position: static; transform: none; min-height: 36px; align-items: center; }
.stage-foot .learn-fab { display: inline-flex; color: #b4c0d0; }
.stage-foot .learn-fab:hover { color: var(--accent); }

#mapView { display: grid; align-content: center; justify-items: center; }
#plateMap {
  max-width: 900px;
  width: min(100%, (100dvh - 357px) * 2);
  min-width: min(100%, 315px);
  aspect-ratio: 2;
  border-radius: 10px;
  outline: 1px solid #536174;
  background: #142535;
  touch-action: manipulation;
}
#mapTip { margin: 12px 0 0; min-height: 18px; color: #c3cfe2; font-size: 12px; text-align: center; }
.plate-buttons, .example-buttons { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.example-buttons { margin-top: 7px; }
.plate-button::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--swatch); border-radius: 50%; margin-right: 5px; }
#unavailable { position: absolute; inset: 30% 10px auto; margin: 0; text-align: center; color: #bac9df; }

#panel { background: #101621; }
#panel h1 { margin-top: 3px; }
#panelClose { display: none; }
#panel h2 { font-size: 14px; }
.feature-list { display: flex; flex-wrap: wrap; gap: 5px; }
.feature-list .action { padding-inline: 9px; }
.observation { color: #c1cce0; min-height: 46px; margin: 9px 0 14px; font-size: 13px; line-height: 1.6; }
#panel .legend-heading { margin-top: 16px; }
.rock-key { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0; margin: 3px 0 13px; color: #adbacd; font-size: 12px; }
.rock-key li { display: flex; gap: 7px; align-items: center; }
.rock-key span { width: 12px; height: 7px; border-radius: 2px; border: 1px solid #fff2; }

@media (max-width: 760px) {
  #stage { display: grid; }
  .stage-head { padding-top: 12px; }
  .stage-head h2 { font-size: 16px; }
  .stage-head p { margin: 2px 0 7px; font-size: 12px; }
  .scene-tabs button, .action { min-height: 42px; }
  .scene-tabs button { padding-inline: 10px; }
  #view { margin-inline: 6px; }
  .pin-button { font-size: 11px; }
  .pin-button::after { inset: -9px -5px; }
  .stage-bottom { padding-inline: 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .stage-foot #panelToggle { display: inline-flex; z-index: auto; }
  .stage-foot .learn-fab, .stage-foot #panelToggle { min-height: 42px; }
  .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
  #panel .panel-head h1 { margin: 0; font-size: 16px; }
  #panelClose { display: block; }
  #panel.collapsed { visibility: hidden; }
  #panel { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  #stageCaption { min-height: 61px; }
  #captionLabel { font-size: 14px; }
  .timeline { gap: 6px; padding: 3px 6px; }
  .timeline output { font-size: 11px; }
  .plate-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .example-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .example-buttons .action, .plate-buttons .action { padding-inline: 4px; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .stage-head { padding-top: 7px; }
  .stage-head p { margin-bottom: 4px; }
  .stage-foot { margin-top: 5px; }
  #stageCaption { min-height: 53px; padding-bottom: 4px; }
  #mapTip { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  #panel { transition: none; }
}
