:root {
  --ink: #f6f4ee;
  --dim: rgba(246, 244, 238, 0.62);
  --line: rgba(246, 244, 238, 0.22);
  --accent: #ff5b1f;
  --font: "Helvetica Neue", Helvetica, "Inter", Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: #0b0d10; color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
canvas#view:active { cursor: grabbing; }
button, input { font: inherit; color: inherit; background: none; border: 0; outline: 0; }
button { cursor: pointer; }

#load { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--accent); transition: width 0.4s ease, opacity 0.6s ease; z-index: 5; }

/* ---- start screen */
#menu {
  position: fixed; inset: 0; z-index: 3; padding: clamp(28px, 5vw, 72px);
  display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: 14px;
  background: linear-gradient(90deg, rgba(8, 10, 13, 0.62) 0%, rgba(8, 10, 13, 0.28) 38%, rgba(8, 10, 13, 0) 62%);
  transition: opacity 0.5s ease;
  pointer-events: none;
}
#menu > * { pointer-events: auto; }
#menu.gone { opacity: 0; }
#menu.gone > * { pointer-events: none; }
#menu h1 {
  font-size: clamp(88px, 17vw, 260px); font-weight: 800; letter-spacing: -0.065em; line-height: 0.8;
  margin: 0 0 auto -0.05em; text-transform: uppercase; pointer-events: none;
}
.field { position: relative; }
.place { display: flex; align-items: baseline; gap: 14px; font-size: clamp(30px, 4.2vw, 56px); font-weight: 700; letter-spacing: -0.035em; padding: 0; }
.place em { font-style: normal; font-size: 0.34em; font-weight: 600; letter-spacing: 0.08em; color: var(--accent); }
.place::after { content: ""; width: 0.26em; height: 0.26em; border-right: 0.07em solid var(--ink); border-bottom: 0.07em solid var(--ink); transform: translateY(-0.2em) rotate(45deg); opacity: 0.6; }
#airportList, #planeList {
  position: absolute; bottom: calc(100% + 12px); left: 0; width: min(560px, 86vw); padding: 18px;
  background: rgba(10, 12, 15, 0.86); backdrop-filter: blur(18px); border: 1px solid var(--line);
}
#airportGrid, #planeGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 22px; }
#airportGrid button, #planeGrid button { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; font-size: 15px; font-weight: 600; text-align: left; border-bottom: 1px solid transparent; }
#airportGrid button span, #planeGrid button span { font-size: 11px; font-weight: 500; color: var(--dim); letter-spacing: 0.02em; }
#airportGrid button:hover, #planeGrid button:hover { border-bottom-color: var(--accent); }
#icao { margin-top: 14px; width: 100%; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
#icao::placeholder { color: var(--dim); }
.seg { display: flex; gap: 20px; }
.seg button { padding: 3px 0; font-size: 15px; font-weight: 600; color: var(--dim); border-bottom: 2px solid transparent; transition: color 0.15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { color: var(--ink); border-bottom-color: var(--accent); }
#metar { font-size: 13px; font-weight: 500; color: var(--dim); font-variant-numeric: tabular-nums; min-height: 1.3em; letter-spacing: 0.01em; }
#fly {
  margin-top: 10px; padding: 16px 64px 15px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; text-transform: uppercase;
  background: var(--accent); color: #0b0d10; transition: transform 0.12s ease, background 0.15s;
}
#fly:hover { transform: translateY(-2px); background: #ff7040; }

/* ---- in flight */
#hud { position: fixed; left: clamp(18px, 2.4vw, 36px); bottom: clamp(16px, 2.2vw, 30px); z-index: 2; pointer-events: none; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55); }
#hud .nums { display: flex; gap: 22px; font-size: 12px; font-weight: 600; color: var(--dim); letter-spacing: 0.04em; }
#hud .nums b { display: inline-block; min-width: 2.1ch; margin-right: 4px; font-size: 30px; font-weight: 800; letter-spacing: -0.04em; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
#hud .state { margin-top: 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; color: var(--dim); font-variant-numeric: tabular-nums; text-transform: uppercase; }
#hud .state i { font-style: normal; color: var(--accent); }
#toast {
  position: fixed; left: 50%; top: 13%; transform: translateX(-50%); z-index: 4; pointer-events: none;
  font-size: clamp(20px, 2.6vw, 34px); font-weight: 800; letter-spacing: -0.03em; text-align: center; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
  opacity: 0; transition: opacity 0.35s ease;
}
#toast.on { opacity: 1; }
#toast small { display: block; margin-top: 6px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; color: var(--dim); }
#keysBtn { position: fixed; right: clamp(18px, 2.4vw, 36px); bottom: clamp(16px, 2.2vw, 30px); z-index: 4; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
#keysBtn:hover { color: var(--ink); }
#keys {
  position: fixed; right: clamp(18px, 2.4vw, 36px); bottom: 58px; z-index: 4; padding: 18px 20px;
  background: rgba(10, 12, 15, 0.82); backdrop-filter: blur(18px); border: 1px solid var(--line);
  display: grid; grid-template-columns: auto auto auto auto; gap: 6px 16px; font-size: 13px; font-weight: 500;
}
#keys[hidden], #faults[hidden], #faultsBtn[hidden], #planeList[hidden], #airportList[hidden], #hud[hidden], #keysBtn[hidden] { display: none; }
#keys kbd { font: inherit; font-weight: 700; color: var(--ink); white-space: nowrap; }
#keys span { color: var(--dim); }
#credit { position: fixed; right: clamp(18px, 2.4vw, 36px); top: 12px; z-index: 2; font-size: 10px; color: rgba(246, 244, 238, 0.38); letter-spacing: 0.02em; pointer-events: none; text-align: right; max-width: 60vw; }
#credit a { color: inherit; text-decoration: none; pointer-events: auto; }
#credit a:hover { color: var(--ink); }
body.flying #credit { opacity: 0.7; }
body.record #credit a { pointer-events: none; }
#faultsBtn { position: fixed; right: calc(clamp(18px, 2.4vw, 36px) + 62px); bottom: clamp(16px, 2.2vw, 30px); z-index: 4; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
#faultsBtn:hover { color: var(--ink); }
#faults { position: fixed; right: clamp(18px, 2.4vw, 36px); bottom: 58px; z-index: 5; padding: 14px 18px; background: rgba(10, 12, 15, 0.82); backdrop-filter: blur(18px); border: 1px solid var(--line); display: grid; gap: 2px; }
#faults button { text-align: left; padding: 5px 0; font-size: 13px; font-weight: 600; color: var(--dim); }
#faults button:hover { color: var(--accent); }
#faults button:last-child { margin-top: 6px; color: var(--ink); }
body.record #menu, body.record #hud, body.record #toast, body.record #keysBtn, body.record #faultsBtn, body.record #keys, body.record #faults, body.record #credit, body.record #load { opacity: 0 !important; pointer-events: none; }
