:root {
  --ink: #eef3f8;
  --dim: #9fb0c2;
  --glass: rgba(10, 16, 24, 0.62);
  --line: rgba(160, 200, 255, 0.18);
  --cyan: #6fd8ff;
  --amber: #ffb547;
  --red: #ff5a5f;
  --green: #6ee7a8;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b1016; color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

.panel { position: fixed; background: var(--glass); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; backdrop-filter: blur(6px); }
.tl { top: 16px; left: 16px; min-width: 230px; }
.tr { top: 16px; right: 16px; text-align: right; min-width: 150px; }
#phase { font-weight: 700; letter-spacing: 0.12em; font-size: 12px; color: var(--cyan); }
#hint { color: var(--dim); font-size: 13px; margin: 2px 0 8px; }
.big { font: 700 34px/1 var(--mono); }
.big small { font-size: 12px; color: var(--dim); margin-left: 6px; }
#alt { font: 13px var(--mono); color: var(--dim); white-space: pre; margin-top: 4px; }
.meter { height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--cyan); border-radius: 3px; }

.bottom { bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 18px; align-items: center; }
.quad { display: grid; grid-template-columns: 22px 22px; grid-template-rows: 30px 30px; gap: 8px 14px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; }
.quad i { border-radius: 50%; background: #1d2a36; box-shadow: inset 0 0 0 2px #2c3d4d; }
.rates { display: grid; gap: 6px; }
.rate { display: grid; grid-template-columns: 18px 220px 18px 46px; align-items: center; gap: 6px; font: 12px var(--mono); }
.rate b { color: var(--dim); text-align: center; }
.rate span { color: var(--dim); font-size: 10px; letter-spacing: 0.1em; }
.track { position: relative; height: 10px; background: rgba(255, 255, 255, 0.08); border-radius: 5px; }
.track::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: rgba(255, 255, 255, 0.35); }
.track i { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; background: var(--amber); border-radius: 5px; }
.side { display: grid; gap: 8px; min-width: 150px; }
#attitude { font: 700 14px var(--mono); }
.fuel { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 6px; font-size: 10px; color: var(--dim); letter-spacing: 0.1em; }

#message { position: fixed; top: 22%; left: 0; right: 0; text-align: center; font: 800 52px/1.1 system-ui, sans-serif;
  letter-spacing: 0.06em; text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6); pointer-events: none; opacity: 0; transition: opacity 0.25s; }
#message.on { opacity: 1; }
#message small { display: block; font-size: 18px; font-weight: 600; color: var(--dim); letter-spacing: 0.1em; margin-top: 6px; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(6, 10, 15, 0.55); }
.card { background: rgba(10, 16, 24, 0.86); border: 1px solid var(--line); border-radius: 14px; padding: 26px 30px;
  max-width: 720px; width: calc(100% - 32px); max-height: calc(100% - 32px); overflow: auto; }
h1 { margin: 0 0 6px; font-size: 34px; letter-spacing: 0.08em; }
h1 em { font-style: normal; color: var(--cyan); }
h3 { margin: 12px 0 6px; font-size: 12px; letter-spacing: 0.12em; color: var(--cyan); text-transform: uppercase; }
.lead { color: var(--dim); margin: 0 0 6px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cols p { margin: 4px 0; }
.small { color: var(--dim); font-size: 12px; }
kbd { font: 12px var(--mono); padding: 1px 6px; border: 1px solid #3a4d61; border-bottom-width: 2px; border-radius: 4px; background: #121c27; }
button { margin-top: 12px; width: 100%; padding: 12px; font: 700 15px system-ui, sans-serif; letter-spacing: 0.06em;
  color: #061018; background: var(--cyan); border: 0; border-radius: 8px; cursor: pointer; }

#result { position: fixed; top: 112px; right: 16px; max-width: 420px; }
#result .grade { font: 800 40px/1 system-ui, sans-serif; letter-spacing: 0.08em; }
#result .total { font: 700 22px var(--mono); color: var(--dim); margin: 4px 0 14px; }
#result .row { display: grid; grid-template-columns: 1fr 90px 60px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
#result .row .v { font-family: var(--mono); text-align: right; color: var(--dim); }
#result .row .p { font-family: var(--mono); text-align: right; }
#result .row .meter { grid-column: 1 / -1; height: 4px; }
#result .note { color: var(--amber); font-size: 13px; margin-top: 10px; }
#result .foot { color: var(--dim); font-size: 12px; margin-top: 14px; }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 4px; }
.level { margin: 0; padding: 10px 12px; display: grid; gap: 4px; align-content: start; text-align: left;
  font: 13px/1.35 system-ui, sans-serif; letter-spacing: 0; color: var(--ink); background: #121c27; border: 1px solid var(--line); }
.level b { font-size: 14px; letter-spacing: 0.04em; }
.level span { color: var(--dim); }
.level em { font: 12px var(--mono); color: var(--cyan); }
.level.on { border-color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan); }
pre#selftest { position: fixed; inset: 16px; overflow: auto; margin: 0; padding: 16px; background: var(--glass);
  border-radius: 10px; font: 12px/1.45 var(--mono); }

@media (max-width: 760px) {
  .bottom { flex-wrap: wrap; justify-content: center; gap: 10px 18px; width: calc(100% - 32px); }
  .rates { order: 3; width: 100%; }
  .rate { grid-template-columns: 18px 1fr 18px 46px; }
  #result { left: 16px; right: 16px; max-width: none; }
  .cols, .levels { grid-template-columns: 1fr; }
}

/* Result card actions. They also work by click on a desktop. */
.acts { display: flex; gap: 8px; margin-top: 12px; }
.acts button, .menu button { flex: 1; width: auto; margin: 0; padding: 9px 6px; font-size: 13px; letter-spacing: 0.04em;
  color: var(--ink); background: #121c27; border: 1px solid var(--line); }

/* Touch screens (main.js sets body.touch): a stick and pads in place of the keys. touch-action stops page
   zoom and scroll; the cards still scroll, because each card is its own scroll container. */
.touch { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body:not(.touch) .touch-only, .touch .keys-only { display: none !important; }
.menu { display: flex; gap: 6px; margin-top: 8px; }
.menu button { padding: 7px 8px; font-size: 11px; }
.stick { position: fixed; left: 24px; bottom: 24px; width: 136px; height: 136px; border-radius: 50%;
  background: rgba(10, 16, 24, 0.45); border: 1px solid var(--line); }
.stick i { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px; border-radius: 50%;
  background: rgba(111, 216, 255, 0.22); border: 2px solid var(--cyan); pointer-events: none; }
.stick b { position: absolute; font-size: 13px; line-height: 1; color: var(--dim); pointer-events: none; }
.stick b.on { color: var(--cyan); }
.stick [data-hold=KeyW] { top: 8px; left: 50%; transform: translateX(-50%); }
.stick [data-hold=KeyS] { bottom: 8px; left: 50%; transform: translateX(-50%); }
.stick [data-hold=KeyA] { left: 9px; top: 50%; transform: translateY(-50%); }
.stick [data-hold=KeyD] { right: 9px; top: 50%; transform: translateY(-50%); }
.pads { position: fixed; right: 24px; bottom: 24px; width: 176px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pad { display: grid; place-content: center; justify-items: center; height: 60px; border-radius: 14px;
  background: rgba(10, 16, 24, 0.45); border: 1px solid var(--line); font: 700 24px/1 system-ui, sans-serif; }
.pad small { font-size: 9px; letter-spacing: 0.14em; color: var(--dim); margin-top: 3px; }
.pad.thrust { grid-column: 1 / -1; height: 64px; font-size: 15px; letter-spacing: 0.14em; }
.pad.on { background: rgba(111, 216, 255, 0.35); border-color: var(--cyan); }

/* The flight panel sits between the stick and the pads. */
.touch .tl { min-width: 0; max-width: 40vw; }
.touch .bottom { bottom: 12px; display: grid; grid-template-areas: "quad side" "quad rates"; gap: 6px 12px; padding: 8px 12px; width: auto; }
.touch .quad { grid-area: quad; align-self: center; grid-template-columns: 16px 16px; grid-template-rows: 22px 22px; gap: 6px 10px; padding: 5px 8px; }
.touch .side { grid-area: side; display: flex; align-items: center; gap: 12px; min-width: 0; }
.touch .fuel { flex: 1; grid-template-columns: 30px 1fr; }
.touch .rates { grid-area: rates; order: 0; width: auto; gap: 4px; }
.touch .rate { grid-template-columns: 14px 110px 14px 34px; gap: 4px; }
.touch .rate span { font-size: 9px; }
.touch .levels { grid-template-columns: repeat(3, 1fr); }
.touch .cols { grid-template-columns: 1fr 1fr; }
.touch #hud:has(#result:not([hidden])) :is(#touch, #flight) { display: none; }
#rotate { display: none; text-align: center; background: #0b1016; }
@media (max-width: 700px) {   /* keep the flight panel clear of the thumbs */
  .stick { left: 16px; bottom: 16px; width: 124px; height: 124px; }
  .pads { right: 16px; bottom: 16px; width: 156px; }
}
@media (orientation: portrait) and (max-width: 600px) { .touch #rotate { display: grid; } }

/* Phones on their side are short. */
@media (max-height: 500px) {
  .card { padding: 16px 20px; }
  h1 { font-size: 26px; }
  h3 { margin-top: 8px; }
  .levels { margin: 10px 0 2px; }
  .level { font-size: 12px; }
  button { margin-top: 8px; padding: 10px; }
  #message { font-size: 34px; }
  #message small { font-size: 14px; }
  #result { top: 12px; right: 12px; max-height: calc(100% - 24px); padding: 14px 18px; }
  #result .grade { font-size: 28px; }
  #result .total { margin-bottom: 8px; }
  #result .row { margin: 3px 0; }
}
