/* A dark field, as under a snow microscope: the ice is the only bright thing.
   Readings are set in a mono face, sentences in a serif. */
:root {
  --bg: #070b14; --deep: #0b1120; --ink: #eef3fa; --mute: #9eb0cc; --dim: #66758f; --line: rgba(158, 176, 204, .2);
  --gold: #ffd17a;
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --out: cubic-bezier(.16, 1, .3, 1);
}
* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.5 var(--serif); -webkit-font-smoothing: antialiased; }
::selection { background: var(--gold); color: #1a1408; }
a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }

/* the way home, and what this is */
.nav { position: absolute; z-index: 4; top: max(16px, env(safe-area-inset-top)); left: 16px; right: 16px; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; pointer-events: none; }
.nav > * { pointer-events: auto; }
.back { padding: 9px 14px; border: 1px solid var(--line); border-radius: 99px; background: rgba(238, 243, 250, .95); color: #0a0f1c; text-decoration: none;
  font: 500 .72rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; transition: background .2s; }
.back:hover { background: var(--gold); color: #0a0f1c; }
.nav .label { margin: 0; font: 400 .72rem/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.nav .label b { font-weight: 500; color: var(--ink); }

/* the stage: the air on a rail at the left, the crystal in the rest */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 372px); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: 'scene where' 'scene panel';
  height: 100svh; min-height: 600px; }
.scene { grid-area: scene; position: relative; min-width: 0; overflow: hidden; }
.scene canvas#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
.scene .kept { position: absolute; left: 0; top: 60px; width: 100%; height: calc(100% - 60px); object-fit: contain; }
.live .scene .kept { display: none; }
.rail { position: absolute; left: 12px; top: 64px; bottom: 14px; width: 196px; cursor: ns-resize; touch-action: none; border-radius: 6px; display: none; }
.live .rail { display: block; }
.rail canvas { width: 100%; height: 100%; display: block; }
.empty .scene::after { content: 'no crystal'; position: absolute; left: calc(50% + 104px); top: 50%; transform: translate(-50%, -50%); font: 400 .72rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }

.where { grid-area: where; padding: 84px 28px 0 12px; }
.status { margin: 0 0 18px; font: 400 .78rem/1.5 var(--mono); color: var(--mute); max-width: 34ch; min-height: 3em; }
.town { margin: 0; font: 400 clamp(2.5rem, 4.2vw, 3.5rem)/1 var(--serif); letter-spacing: -.015em; font-variation-settings: 'opsz' 72; }
.when { margin: 10px 0 0; font: 400 .78rem/1.5 var(--mono); color: var(--mute); }

.panel { grid-area: panel; padding: 26px 28px 22px 12px; display: flex; flex-direction: column; gap: 20px; min-height: 0; overflow: auto; }
.reading { min-height: 6.4rem; }
.kind { margin: 0; font: 400 1.34rem/1.25 var(--serif); font-style: italic; color: var(--ink); max-width: 22ch; text-wrap: balance; }
.nums { margin: 10px 0 0; font: 400 .76rem/1.55 var(--mono); color: var(--mute); max-width: 36ch; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; }
.bar button, dialog .close { appearance: none; border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 10px 15px; border-radius: 99px; cursor: pointer;
  font: 500 .74rem/1 var(--mono); letter-spacing: .04em; transition: border-color .2s, background .2s, color .2s; min-height: 38px; }
.bar button:hover, dialog .close:hover { border-color: var(--ink); }
.bar button:disabled { opacity: .35; cursor: default; }
.bar #again { background: var(--ink); color: #0a0f1c; border-color: var(--ink); min-width: 8.4em; }
.bar #again:hover { background: var(--gold); border-color: var(--gold); }

.diagram { margin: auto 0 0; }
.diagram svg { display: block; width: 100%; height: auto; overflow: visible; }
.diagram figcaption { margin-top: 8px; font: 400 .72rem/1.5 var(--mono); color: var(--mute); }
.diagram .zone { fill: rgba(158, 176, 204, .07); }
.diagram .zl, .diagram .ax { font: 400 10.5px var(--mono); fill: var(--mute); }
.diagram .axis { stroke: rgba(158, 176, 204, .55); stroke-width: 1; }
.diagram .tick { stroke: rgba(158, 176, 204, .55); stroke-width: 1; }
.diagram .grid { stroke: rgba(158, 176, 204, .12); stroke-width: 1; }
.diagram .water { fill: none; stroke: rgba(158, 176, 204, .6); stroke-width: 1; stroke-dasharray: 2 3; }
.diagram .cdot { fill: var(--gold); stroke: var(--bg); stroke-width: 2; }
html:not(.live) .diagram, html:not(.live) .bar, html:not(.live) .reading { display: none; }

/* the notes under the stage */
.notes { border-top: 1px solid var(--line); padding: 56px 28px 72px; }
.notes .in { max-width: 1060px; margin: 0 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 34px 56px; }
.notes h2 { margin: 0 0 10px; font: 500 .72rem/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.notes p { margin: 0 0 12px; max-width: 58ch; color: #d6e0ef; }
.notes .wide { grid-column: 1 / -1; }
.notes table { border-collapse: collapse; font: 400 .78rem/1.4 var(--mono); color: #d6e0ef; width: 100%; max-width: 620px; font-variant-numeric: tabular-nums; }
.notes th, .notes td { text-align: right; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.notes th { font-weight: 500; color: var(--mute); }
.notes td:last-child, .notes th:last-child { text-align: left; white-space: normal; padding-right: 0; }
.notes .scroll { overflow-x: auto; }
.notes caption { text-align: left; padding-bottom: 10px; color: var(--mute); caption-side: top; }
.foot { margin: 40px auto 0; max-width: 1060px; font: 400 .74rem/1.6 var(--mono); color: var(--dim); }

/* the list of towns */
dialog { width: min(720px, calc(100vw - 24px)); max-height: min(82svh, 760px); padding: 0; border: 1px solid var(--line); border-radius: 14px; background: #0c1322; color: var(--ink); }
dialog::backdrop { background: rgba(4, 7, 13, .72); backdrop-filter: blur(3px); }
dialog .head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; background: #0c1322; border-bottom: 1px solid var(--line); }
dialog .head p { margin: 0; font: 400 1.25rem/1.2 var(--serif); }
dialog .body { padding: 6px 20px 22px; }
dialog h3 { margin: 18px 0 6px; font: 500 .72rem/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
dialog ul { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 24px; }
dialog li { break-inside: avoid; }
dialog li button { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 0 10px; align-items: baseline; text-align: left; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); cursor: pointer; }
dialog li button:hover .n { color: var(--gold); }
dialog li .n { font: 400 1.04rem/1.25 var(--serif); }
dialog li .c { grid-column: 1; font: 400 .72rem/1.4 var(--mono); color: var(--dim); }
dialog li .w { grid-column: 2; grid-row: 1 / span 2; align-self: center; font: 400 .72rem/1.3 var(--mono); color: var(--mute); text-align: right; }
dialog li button[aria-current] .n::after { content: ' ·'; color: var(--gold); }
dialog .none { margin: 16px 0 0; color: var(--mute); }

/* only the crystal and its rail, for the share image */
.bare .nav, .bare .where, .bare .panel, .bare .notes, .bare dialog { display: none !important; }
.bare .stage { display: block; height: 100svh; min-height: 0; }
.bare .scene { position: absolute; inset: 0; }
.bare .rail { top: 14px; }
.nogl .rail { display: none; }

@media (max-width: 899px) {
  .stage { display: block; height: auto; min-height: 0; }
  .where { padding: 68px 16px 0; }
  @media (max-width: 440px) { .where { padding-top: 98px; } }
  .status { margin-bottom: 10px; min-height: 0; max-width: none; }
  .town { font-size: clamp(2.1rem, 9.5vw, 3rem); }
  .when { margin-top: 6px; }
  .scene { height: min(104vw, 64svh); margin-top: 8px; }
  .rail { left: 2px; top: 6px; bottom: 6px; width: 66px; }
  .scene .kept { top: 0; height: 100%; }
  .empty .scene::after { left: calc(50% + 33px); }
  .panel { padding: 12px 16px 28px; overflow: visible; gap: 16px; }
  .reading { min-height: 6.2rem; }
  .kind { font-size: 1.22rem; max-width: none; }
  .nums { max-width: none; }
  .bar button { flex: 1 1 auto; }
  .diagram { margin-top: 10px; }
  .notes { padding: 40px 16px 56px; }
  .notes .in { grid-template-columns: 1fr; gap: 28px; }
  dialog ul { columns: 1; }
}
@media (min-width: 900px) and (max-height: 700px) {
  .where { padding-top: 70px; }
  .town { font-size: 2.3rem; }
  .status { margin-bottom: 10px; }
  .panel { padding-top: 16px; gap: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
