/* The plane speaks B612, the typeface Airbus drew for cockpits. The world's place names are set in Caslon, as on an atlas. */
:root {
  --paper: #f6f2e7;
  --dim: rgba(246, 242, 231, 0.66);
  --faint: rgba(246, 242, 231, 0.3);
  --magenta: #ff479e;
  --night: #0b1730;
  --plane: "B612", "Helvetica Neue", Arial, sans-serif;
  --digits: "B612 Mono", ui-monospace, monospace;
  --atlas: "Libre Caslon Display", "Hoefler Text", Georgia, serif;
  --edge: clamp(18px, 3.2vw, 44px);
  --halo: 0 0 14px rgba(5, 14, 32, 0.55), 0 1px 2px rgba(5, 14, 32, 0.5);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #050b1a; }
body { font: 15px/1.45 var(--plane); color: var(--paper); -webkit-font-smoothing: antialiased; touch-action: none; user-select: none; }
[hidden] { display: none !important; }
p, h1, h2, ol, dl, dd { margin: 0; padding: 0; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.turns #view { cursor: grab; }
.place { font-family: var(--atlas); font-weight: 400; letter-spacing: 0.005em; }
.note { color: var(--dim); font-size: 13px; }
small { font-size: inherit; color: var(--dim); }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible { outline: 2px solid var(--magenta); outline-offset: 4px; }
.primary { background: var(--paper); color: var(--night); font-weight: 700; padding: 13px 22px 12px; border-radius: 2px; transition: background 0.15s; }
.primary:hover:not(:disabled) { background: #fff; }
.primary:disabled { background: none; color: var(--dim); font-weight: 400; padding-left: 0; cursor: default; }
.quiet { color: var(--paper); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 4px; }
.quiet:hover { text-decoration-color: var(--paper); }
.quiet:disabled { color: var(--dim); text-decoration: none; cursor: default; }
.go { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 26px; }
kbd { display: inline-block; min-width: 26px; padding: 3px 7px 2px; margin-right: 4px; border: 1px solid var(--faint); border-radius: 4px; font: 12px/1.5 var(--digits); text-align: center; }

#pilot { width: min(410px, calc(100% - 32px)); padding: 28px; border: 1px solid var(--faint); border-radius: 4px; background: var(--night); color: var(--paper); }
#pilot::backdrop { background: rgba(5, 11, 26, 0.64); }
#pilot form { display: grid; gap: 12px; }
#pilot-title { font-size: 42px; line-height: 1; }
#pilot label { margin-top: 8px; }
#pilot-name { width: 100%; padding: 10px 12px; margin-bottom: 4px; border: 1px solid var(--faint); border-radius: 2px; background: #050b1a; color: var(--paper); font: inherit; font-size: 16px; user-select: text; }
#pilot-name:focus-visible { outline: 2px solid var(--magenta); outline-offset: 2px; }
#pilot-enter { justify-self: start; }
#pilot-error { color: #ff9cc9; }

/* Title */
#title { position: fixed; inset: 0; display: flex; justify-content: space-between; align-items: flex-end; gap: 40px; padding: var(--edge);
  background: linear-gradient(to top, rgba(5, 12, 28, 0.82), rgba(5, 12, 28, 0.35) 38%, rgba(5, 12, 28, 0) 62%); text-shadow: var(--halo); }
#title .copy { max-width: 560px; }
h1 { font: 400 clamp(72px, 12vw, 168px)/0.86 var(--atlas); letter-spacing: -0.015em; margin-left: -0.04em; }
.modes { display: flex; gap: 0 30px; margin-top: 26px; font-size: clamp(27px, 2.7vw, 36px); line-height: 1.2; }
.modes button { color: var(--dim); padding-bottom: 3px; border-bottom: 1px solid transparent; transition: color 0.15s; }
.modes button:hover { color: var(--paper); }
.modes [aria-pressed="true"] { color: var(--paper); border-bottom-color: var(--paper); }
.lede { font-size: clamp(16px, 1.5vw, 19px); line-height: 1.5; max-width: 30em; margin: 16px 0 28px; }
#title .note { margin-top: 18px; }
#title .primary { text-shadow: none; }
.side { width: min(300px, 40vw); flex: none; }
.controls { display: grid; gap: 9px; margin-bottom: 14px; }
.controls div { display: flex; align-items: baseline; gap: 10px; line-height: 1.3; }
.controls dt { width: 76px; flex: none; }
#titleboard { margin-bottom: 30px; }

/* Leaderboard, on the title and at the end */
.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board caption { text-align: left; color: var(--dim); font-size: 13px; padding-bottom: 8px; }
.board td { padding: 5px 0; border-top: 1px solid rgba(246, 242, 231, 0.16); }
.board td.n, .board td.r { font-family: var(--digits); text-align: right; white-space: nowrap; }
.board td.r { color: var(--dim); font-size: 12px; padding-left: 12px; }
.board td.rank { width: 1.8em; color: var(--dim); font-family: var(--digits); }
.board tr.me td { color: var(--magenta); }
.board tr.flying td.n { color: var(--dim); }

/* In flight */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: var(--halo); }
.target { position: absolute; left: var(--edge); top: var(--edge); max-width: 46vw; }
.count { font-size: 13px; color: var(--dim); margin-bottom: 6px; }
#code { font: 700 clamp(40px, 5.6vw, 80px)/0.95 var(--plane); letter-spacing: 0.05em; }
#city { font-size: clamp(21px, 2.3vw, 31px); line-height: 1.12; margin-top: 10px; }
.sub { font-size: clamp(16px, 1.6vw, 21px); line-height: 1.25; color: var(--dim); margin-top: 4px; }
.from { font-size: 13px; margin-top: 16px; transition: opacity 1.2s; }
.from.gone { opacity: 0; }
#tape { position: absolute; left: 50%; top: calc(var(--edge) - 4px); width: 340px; height: 46px; margin-left: -170px; }
.fuel { position: absolute; right: var(--edge); top: var(--edge); text-align: right; }
.fuel p { font-size: 13px; }
#secs { font: 34px/1 var(--digits); }
.fuel i { display: block; width: 148px; height: 2px; margin: 9px 0 9px auto; background: var(--faint); }
.fuel b { display: block; height: 100%; width: 100%; margin-left: auto; background: var(--paper); transform-origin: right; }
.fuel.low #secs { color: var(--magenta); }
.fuel.low b { background: var(--magenta); }
.sofar { color: var(--dim); }
#quit, #turbo { pointer-events: auto; margin: 12px 0 0 14px; font-size: 13px; }
#turbo.on { color: var(--magenta); text-decoration-color: var(--magenta); }
.alt { position: absolute; left: var(--edge); bottom: var(--edge); font: 12px/1 var(--digits); }
.scale { position: relative; height: 168px; width: 1px; background: var(--faint); margin: 0 0 16px 3px; }
.scale u { position: absolute; left: 0; width: 6px; height: 1px; background: var(--dim); text-decoration: none; }
#needle { position: absolute; left: -3px; width: 13px; height: 2px; margin-top: -1px; background: var(--paper); font-weight: 400; }
#needle span { position: absolute; left: 24px; top: -6px; font-size: 13px; white-space: nowrap; }
#speed { color: var(--dim); }
#pace, #nudge { margin-top: 9px; color: var(--dim); font: 12px/1.3 var(--plane); white-space: pre-line; }
#nudge { margin-top: 3px; }
.keys { position: absolute; left: 0; right: 0; bottom: var(--edge); text-align: center; font-size: 13px; color: var(--dim); transition: opacity 1.5s; }
.keys.gone { opacity: 0; }
.keys kbd { margin: 0 3px 0 16px; }
.keys kbd + kbd { margin-left: 0; }
.touch { display: none; position: absolute; right: var(--edge); bottom: var(--edge); pointer-events: auto; width: 92px; height: 92px; border-radius: 50%;
  background: var(--magenta); color: #fff; font-weight: 700; text-shadow: none; }
#look { right: calc(var(--edge) + 108px); width: 76px; height: 76px; background: rgba(11, 23, 48, 0.6); border: 1px solid var(--faint); font-weight: 400; font-size: 13px; }
#look.on { background: var(--paper); color: var(--night); }
.touched { display: none; }
/* A race is flown at one height and one speed, so what dives, climbs, hurries or gives up is put away. */
.race .solo, .race #pace, .race #nudge, .race #turbo, .race #quit, .race #release { display: none; }
.race .from { max-width: 30em; }
/* With the cockpit up, the heading, height and speed are read off its panel, and what sat along the bottom stands on its coaming. */
.deck #tape, .deck .scale, .deck #speed { display: none; }
.deck .alt, .deck .keys, .deck .touch { bottom: calc(var(--lift) + 14px); }
.deck #pace { margin: 0; }
@media (pointer: coarse) { .touch { display: block; } .keys, .keyed { display: none; } .touched { display: inline; } }

/* The bombsight's hairlines: they stop short of the centre, where the rings on the ground are. */
#cross { position: fixed; left: 50%; top: 50%; width: 0; height: 0; opacity: 0; pointer-events: none; }
#cross i { position: absolute; background: var(--paper); box-shadow: 0 0 6px rgba(5, 14, 32, 0.6); }
#cross i:nth-child(1), #cross i:nth-child(2) { width: 1px; height: min(26vh, 240px); left: 0; }
#cross i:nth-child(1) { bottom: 9vh; }
#cross i:nth-child(2) { top: 9vh; }
#cross i:nth-child(3), #cross i:nth-child(4) { height: 1px; width: min(26vh, 240px); top: 0; }
#cross i:nth-child(3) { right: 9vh; }
#cross i:nth-child(4) { left: 9vh; }

#flash { position: fixed; inset: 0; opacity: 0; pointer-events: none; }
/* A race: the other planes' names, beside them or at the edge of the view they are out of, and the count to the off. */
#tags { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.tag { position: absolute; left: 0; top: 0; font: 700 12px/1 var(--plane); letter-spacing: 0.05em; white-space: nowrap; text-shadow: var(--halo); will-change: transform; }
.tag i { display: none; width: 0; height: 0; margin-right: 7px; border: 4px solid transparent; border-left: 8px solid currentColor; border-right: 0; }
.tag.out i { display: inline-block; }
#lights { position: fixed; left: 0; right: 0; top: 15vh; text-align: center; font-size: clamp(84px, 12vw, 164px); line-height: 1; text-shadow: var(--halo); pointer-events: none; }
#pin b, #drops b { font: 700 0.7em var(--plane); letter-spacing: 0.05em; margin-right: 0.55em; }
#pin { position: fixed; left: 0; top: 0; font-size: 26px; line-height: 1; white-space: nowrap; pointer-events: none; text-shadow: var(--halo); will-change: transform; }

/* After a drop */
#reveal { position: fixed; left: 0; right: 0; bottom: 0; padding: 120px var(--edge) var(--edge); display: grid; justify-items: center; gap: 4px; text-align: center; pointer-events: none;
  background: linear-gradient(to top, rgba(5, 12, 28, 0.8), rgba(5, 12, 28, 0)); text-shadow: var(--halo); animation: rise 0.5s ease-out both; }
.why { font-size: 13px; color: var(--dim); min-height: 1.45em; }
.result { display: flex; align-items: baseline; gap: 0.5em; }
.km { font-size: clamp(44px, 6.4vw, 92px); line-height: 1.05; }
.km small { font-size: 0.42em; }
.pts { font: clamp(20px, 2.2vw, 30px)/1 var(--digits); color: var(--magenta); }
#tally { margin-top: 6px; }
#tally b { font-weight: 400; margin-left: 1.4em; }
#tally b:first-child { margin-left: 0; }
#next { margin-top: 18px; text-shadow: none; pointer-events: auto; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* The day's result */
#summary { position: fixed; inset: 0 auto 0 0; width: min(520px, 100%); padding: var(--edge); overflow-y: auto; display: flex; flex-direction: column; justify-content: flex-end; gap: 0;
  background: linear-gradient(to right, rgba(5, 12, 28, 0.9), rgba(5, 12, 28, 0.72) 70%, rgba(5, 12, 28, 0)); text-shadow: var(--halo); animation: rise 0.6s ease-out both; }
.total { font-size: clamp(96px, 13vw, 176px); line-height: 0.9; margin: 6px 0 22px -0.03em; }
.total small { font: 15px var(--plane); }
#drops { list-style: none; margin-bottom: 26px; }
#drops li { display: grid; grid-template-columns: 1fr auto 3.2em; gap: 14px; align-items: baseline; padding: 7px 0; border-top: 1px solid rgba(246, 242, 231, 0.16); }
#drops .place { font-size: 21px; line-height: 1.15; }
#drops .d { font: 12px var(--digits); color: var(--dim); }
#drops .s { font: 15px var(--digits); text-align: right; }
#board { margin-bottom: 26px; }
#summary .primary { text-shadow: none; }

#toast { position: fixed; left: 50%; top: 38%; transform: translateX(-50%); max-width: min(420px, 86vw); padding: 14px 18px; background: var(--night); border-left: 3px solid var(--magenta); font-size: 14px; }
#toast a { color: var(--paper); }

@media (max-width: 760px) {
  #title { flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 26px; }
  .side { width: 100%; }
  #titleboard, .controls { display: none; }
  #tape { top: auto; bottom: calc(var(--edge) + 120px); }
  .target { max-width: 62vw; }
  #lights { top: 36vh; }
  #summary { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  #reveal, #summary { animation: none; }
}
