:root {
  --bg: #10160e; --panel: rgba(14,22,12,0.86); --line: #3d5136; --ink: #e9f0e4;
  --dim: #9db092; --hot: #ffb347; --warm: #ff7a3d; --cool: #9fd7ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
#stage { position: relative; display: grid; height: 100%;
  grid-template-columns: 1fr 320px; grid-template-rows: 1fr auto; }
#gl { grid-column: 1; grid-row: 1 / span 2; width: 100%; height: 100%; display: block; background: #b8cbdd; }
#gl { touch-action: manipulation; cursor: pointer; }
#plan { touch-action: none; cursor: crosshair; }
#hud { position: absolute; top: 10px; left: 10px; z-index: 3; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 250px;
  backdrop-filter: blur(3px); }
#hud h1 { margin: 0 0 6px; font-size: 17px; letter-spacing: 0.02em; }
.grid { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; }
.grid.tel { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.lbl { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  align-self: center; }
.val { font-variant-numeric: tabular-nums; font-size: 13px; }
.val.big { font-size: 17px; color: var(--hot); font-weight: 600; }
#planwrap { grid-column: 2; grid-row: 1; background: var(--panel); border-left: 1px solid var(--line);
  padding: 10px 12px; display: flex; flex-direction: column; min-height: 0; }
#planwrap h2 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--dim); }
#plan { width: 100%; aspect-ratio: 1 / 1; border-radius: 8px; border: 1px solid var(--line);
  background: #2e4a26; }
.cap { color: var(--dim); font-size: 11px; margin: 6px 0 0; }
#controls { grid-column: 2; grid-row: 2; background: var(--panel); border-left: 1px solid var(--line);
  border-top: 1px solid var(--line); padding: 10px 12px 14px; overflow: auto; max-height: 52vh; }
.ctl { margin-bottom: 8px; }
.ctl label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--dim); margin-bottom: 2px; }
.ctl .v { float: right; color: var(--ink); text-transform: none; letter-spacing: 0;
  font-variant-numeric: tabular-nums; }
.ctl input[type=range] { width: 100%; accent-color: var(--warm); }
.ctl select { width: 100%; background: #1a2417; color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 6px; font: inherit; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
button { background: #2a3a24; color: var(--ink); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 10px; font: inherit; cursor: pointer; }
button:hover { background: #35492d; }
button:focus-visible { outline: 2px solid var(--hot); outline-offset: 2px; }
kbd { background: #16200f; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--dim); }
.msg { min-height: 2.4em; margin: 4px 0 6px; color: var(--cool); font-size: 12.5px; }
#again { width: 100%; margin-bottom: 8px; background: #3b5230; }
.scores { margin: 6px 0 0; padding-left: 20px; font-size: 12px; color: var(--dim);
  font-variant-numeric: tabular-nums; }
.scores li { margin: 1px 0; }
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(6,10,5,0.88); overflow: auto;
  padding: 24px 16px; }
.sheet[hidden] { display: none; }
.sheet-inner { max-width: 880px; margin: 0 auto; background: #16200f; border: 1px solid var(--line);
  border-radius: 12px; padding: 22px 26px 30px; position: relative; }
.sheet h2 { margin-top: 0; }
.sheet h3 { margin: 22px 0 6px; color: var(--hot); font-size: 15px; }
.sheet code { background: #0d1409; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.close { position: absolute; top: 14px; right: 16px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 4px 7px; text-align: left;
  vertical-align: top; }
.tbl th { color: var(--dim); text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
.src li { margin-bottom: 7px; }
.fine { color: var(--dim); font-size: 12px; }
.sheet a { color: var(--cool); }
@media (max-width: 900px) {
  #stage { grid-template-columns: 1fr; grid-template-rows: 52vh auto auto; }
  #gl { grid-column: 1; grid-row: 1; }
  #planwrap { grid-column: 1; grid-row: 2; border-left: 0; border-top: 1px solid var(--line);
    flex-direction: row; align-items: flex-start; gap: 12px; }
  #plan { width: 40vw; max-width: 220px; }
  #controls { grid-column: 1; grid-row: 3; border-left: 0; max-height: none; }
  #plan { width: 44vw; }
  /* phones: the HUD folds into two label/value columns so it no longer covers the field and the
     plan view (it was 320 px tall over a 295 px canvas at 320x568) */
  #hud { top: 6px; left: 6px; right: 6px; min-width: 0; padding: 6px 8px; }
  #hud h1 { font-size: 14px; margin-bottom: 2px; }
  .grid { grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 0 8px; }
  .grid.tel { margin-top: 4px; padding-top: 4px; }
  .lbl { font-size: 10px; }
  .val { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .val.big { font-size: 14px; }
}
@media (max-width: 900px) and (max-height: 500px) {
  /* landscape phones: field and plan view side by side so both stay on screen during a flight;
     the controls scroll inside the side column */
  #stage { grid-template-columns: 1fr 230px; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
  #gl { grid-column: 1; grid-row: 1 / span 2; }
  #planwrap { grid-column: 2; grid-row: 1; border-left: 1px solid var(--line); border-top: 0;
    flex-direction: column; padding: 6px 8px; }
  #planwrap h2, #planwrap .cap { display: none; }
  #plan { width: 100%; max-width: none; }
  #controls { grid-column: 2; grid-row: 2; border-left: 1px solid var(--line); overflow: auto; padding: 6px 8px; }
  #hud { right: auto; width: 300px; }
  .grid.tel { display: none; }
}
