/* Px437 IBM VGA 9x16, The Ultimate Oldschool PC Font Pack by VileR (int10h.org), CC BY-SA 4.0 */
@font-face {
  font-family: "IBM VGA";
  src: url("/fonts/Px437_IBM_VGA_9x16.ttf") format("truetype");
  font-display: block;
}

:root {
  --bg: #000;
  --panel: #0b0b0b;
  --line: #2a2a2a;
  --fg: #e8e8e8;
  --dim: #8a8a8a;
  --accent: #ffff55;   /* EGA yellow */
  --warn: #ff5555;     /* EGA light red */
  --ok: #55ff55;       /* EGA light green */
  --vga: "IBM VGA", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overscroll-behavior: none; }
body {
  font-family: var(--vga); font-size: 18px; line-height: 1.35;
  touch-action: manipulation; -webkit-text-size-adjust: 100%;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
input, textarea, select { user-select: text; -webkit-user-select: text; }
button { font-family: var(--vga); touch-action: manipulation; }
[hidden] { display: none !important; }

.screen {
  min-height: 100%;
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  padding-bottom: max(28px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---- ARM */
#arm { display: flex; align-items: stretch; justify-content: stretch; height: 100%; }
.arm-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  background: #000; color: var(--accent); border: 3px solid var(--accent); border-radius: 10px; cursor: pointer;
}
.arm-big { font-size: min(26vw, 22vh); line-height: 0.95; text-align: center; }
.arm-small { font-size: 18px; color: var(--dim); }

/* ---- DIAL */
#dial { max-width: 560px; margin: 0 auto; display: grid; gap: 22px; align-content: start; }
.topbar { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--dim); flex-wrap: wrap; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.dot.off { background: var(--warn); }
.here { color: var(--fg); }
.sync { margin-left: auto; font-size: 13px; font-variant-numeric: tabular-nums; }

.channel { display: grid; justify-items: center; gap: 4px; }
.ch-label, .h, .part-label, .field > span { font-size: 14px; letter-spacing: 0.12em; color: var(--dim); }
.ch-row { display: flex; align-items: center; gap: 12px; width: 100%; justify-content: center; }
.ch-step {
  width: 72px; height: 72px; flex: 0 0 auto; font-size: 44px; line-height: 1;
  background: var(--panel); color: var(--fg); border: 2px solid var(--line); border-radius: 10px;
}
.ch-num {
  width: 3.2ch; min-width: 0; text-align: center; font-family: var(--vga); font-size: 104px; line-height: 1;
  background: transparent; color: var(--accent); border: 0; border-bottom: 3px solid var(--line); padding: 0; border-radius: 0;
  caret-color: var(--accent);
}
.ch-num:focus { outline: none; border-bottom-color: var(--accent); }
.ch-name { font-size: 22px; color: var(--fg); letter-spacing: 0.08em; min-height: 1.3em; }

textarea {
  width: 100%; min-height: 6.2em; resize: none; font-family: var(--vga); font-size: 22px; line-height: 1.3;
  background: var(--panel); color: var(--fg); border: 2px solid var(--line); border-radius: 8px; padding: 12px;
}
textarea[readonly] { color: var(--accent); border-style: dashed; }
textarea:disabled { opacity: 0.6; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.note { font-size: 14px; color: var(--dim); min-height: 1em; }
.note.warn { color: var(--warn); }

.seg { display: flex; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  flex: 1 1 0; min-height: 58px; font-size: 20px; background: var(--panel); color: var(--dim); border: 0;
  border-right: 2px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed=true] { background: var(--accent); color: #000; }
.seg button:disabled { opacity: 0.5; }
.formation { display: grid; gap: 8px; }
.part-row { display: grid; gap: 6px; }

.start {
  width: 100%; min-height: 128px; font-size: 64px; letter-spacing: 0.06em;
  background: var(--accent); color: #000; border: 0; border-radius: 12px;
}
.start:active { filter: brightness(0.8); }
.start:disabled { background: #333; color: #777; }
.go { display: grid; gap: 10px; }
.run-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  min-height: 60px; font-size: 20px; padding: 10px 16px; border-radius: 8px; border: 0;
  background: var(--accent); color: #000;
}
.btn.ghost { background: transparent; color: var(--fg); border: 2px solid var(--line); }
.btn.ghost[aria-pressed=true] { border-color: var(--accent); color: var(--accent); }
.btn.warn { background: var(--warn); color: #000; }
.btn:disabled { opacity: 0.5; }
.wide { width: 100%; }
.conduct, .solo { display: grid; gap: 10px; }

.field { display: grid; gap: 4px; min-width: 0; }
.field input, .field select {
  width: 100%; min-height: 56px; font-family: var(--vga); font-size: 22px;
  background: var(--panel); color: var(--fg); border: 2px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.check { display: flex; align-items: center; gap: 12px; min-height: 56px; font-size: 18px; }
.check input { width: 30px; height: 30px; accent-color: var(--accent); }

details { border: 2px solid var(--line); border-radius: 8px; padding: 0 14px; }
details[open] { padding-bottom: 14px; }
summary { min-height: 58px; display: flex; align-items: center; font-size: 20px; letter-spacing: 0.1em; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+ "; color: var(--accent); white-space: pre; }
details[open] summary::before { content: "− "; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 8px 0; }

/* phones strip: one small black phone per knot */
.phones { display: grid; gap: 10px; }
.phone-line { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.phone-line.dim { opacity: 0.35; }
.phone {
  flex: 0 0 auto; width: 34px; height: 72px; background: #000; border: 2px solid #333; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; font-size: 40px; line-height: 1; color: #fff;
}
.phone.space { border-style: dashed; }

.share { display: grid; gap: 10px; justify-items: center; }
.share-url { font-size: 24px; color: var(--accent); word-break: break-all; text-align: center; }
.qr { background: #fff; padding: 10px; border-radius: 6px; line-height: 0; }
.qr svg, .qr img { display: block; width: 200px; height: 200px; image-rendering: pixelated; }

.help ol { margin: 6px 0 0; padding-left: 1.4em; display: grid; gap: 6px; font-size: 16px; color: var(--dim); }

/* ---- RUN */
#stage {
  position: fixed; inset: 0; background: #000; z-index: 50;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: none; overscroll-behavior: none;
}
#gc { position: absolute; left: 0; top: 0; display: block; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  background: #000; color: var(--warn); border: 2px solid var(--warn); border-radius: 8px;
  padding: 10px 16px; font-size: 18px; max-width: calc(100% - 32px); text-align: center;
}

#wakeVid { position: fixed; width: 1px; height: 1px; opacity: 0.01; left: 0; bottom: 0; pointer-events: none; }

/* signature button under the words: appends the Wib&Wob face to the last line */
.sign-btn { justify-self: start; margin-top: 8px; min-height: 56px; padding: 0 18px; background: transparent; color: var(--fg);
  border: 2px solid var(--line); border-radius: 10px; font-size: 20px; }
.sign-btn:active { border-color: var(--accent); color: var(--accent); }

/* face glyphs: close knots, one phone-width apart, so the phones touch in the strip as in the photo */
.phone.close { margin-left: -6px; border-color: #3a3a1a; }
.phone.close + .phone.close { margin-left: -8px; }

/* ---- guides: install + checklist */
.guide { max-width: 560px; margin: 0 auto; display: grid; gap: 22px; align-content: start; }
.guide-head { display: grid; gap: 8px; padding-top: 6px; }
.kicker { font-size: 14px; letter-spacing: 0.14em; color: var(--dim); }
.guide-title { margin: 0; font-weight: 400; font-size: 40px; line-height: 1.02; color: var(--accent); letter-spacing: 0.02em; }
.lede { margin: 0; font-size: 18px; color: var(--fg); }
.ico { width: 1.25em; height: 1.25em; vertical-align: -0.28em; color: var(--accent); display: inline-block; }
.steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; font-size: 19px; }
.steps ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }
.steps li { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; }
.steps .n { width: 44px; height: 44px; border: 2px solid var(--accent); color: var(--accent); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 22px; }
.steps small { display: block; margin-top: 4px; font-size: 15px; color: var(--dim); }
.steps b { color: var(--accent); font-weight: 400; }
.steps p { margin: 0; }
.guide-foot { display: grid; gap: 8px; }
.pointer { position: sticky; bottom: 0; margin-bottom: calc(-1 * max(28px, env(safe-area-inset-bottom, 0px)));
  padding: 26px 4px max(10px, env(safe-area-inset-bottom, 0px)); display: grid; justify-items: end; gap: 2px;
  background: linear-gradient(to bottom, rgba(0,0,0,0), #000 55%); color: var(--accent); pointer-events: none; }
.pointer span { font-size: 13px; color: var(--dim); letter-spacing: 0.1em; }
.pointer b { font-weight: 400; font-size: 34px; line-height: 1; animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }

.checks { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.checks > li { border: 2px solid var(--line); border-radius: 10px; display: grid; }
.checks > li.done { border-color: #4a4a1a; }
.tick { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start; text-align: left; width: 100%;
  background: transparent; color: var(--fg); border: 0; padding: 14px; font-size: 16px; line-height: 1.35; }
.tick .box { width: 32px; height: 32px; border: 2px solid var(--dim); border-radius: 6px; margin-top: 2px; position: relative; }
.checks > li.done .box { background: var(--accent); border-color: var(--accent); }
.checks > li.done .box::after { content: ""; position: absolute; left: 9px; top: 3px; width: 8px; height: 16px;
  border: solid #000; border-width: 0 4px 4px 0; transform: rotate(45deg); }
.tick .body { display: grid; gap: 6px; }
.tick .body > b { font-weight: 400; font-size: 20px; color: var(--fg); letter-spacing: 0.04em; }
.checks > li.done .body > b { color: var(--accent); }
.tick .body > span { color: var(--dim); }
.live { color: var(--ok) !important; font-size: 15px; }
.live.bad { color: var(--warn) !important; }
.test-btn { margin: 0 14px 14px 66px; }
html.is-ios .android, html.is-android .ios { display: none; }

/* ---- readiness row on the dial */
.ready { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; width: 100%; text-align: left;
  background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--dim);
  font-size: 14px; letter-spacing: 0.06em; min-height: 52px; }
.rd { display: inline-flex; align-items: center; gap: 6px; }
.rd::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--dim); }
.rd.ok { color: var(--fg); } .rd.ok::before { background: var(--ok); }
.rd.bad { color: var(--warn); } .rd.bad::before { background: var(--warn); }
.rd-more { margin-left: auto; color: var(--accent); }

/* ---- scheduled run */
.wait { border: 2px solid var(--accent); border-radius: 12px; padding: 14px; display: grid; justify-items: center; gap: 4px; text-align: center; }
.wait-k { font-size: 14px; letter-spacing: 0.14em; color: var(--dim); }
.wait-t { font-size: 64px; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.wait-in { font-size: 24px; color: var(--fg); font-variant-numeric: tabular-nums; }
.later { margin-top: 4px; }
.later-body { display: grid; gap: 10px; }
.at-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.at-row .btn { min-height: 56px; }
input[type=time] { -webkit-appearance: none; appearance: none; }

/* ---- turn upright */
.turn { position: fixed; inset: 0; z-index: 40; background: #000; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 24px max(24px, env(safe-area-inset-right, 0px)) 24px max(24px, env(safe-area-inset-left, 0px)); text-align: center; }
.turn[hidden] { display: none !important; }
.turn-phone { width: 46px; height: 84px; border: 4px solid var(--accent); border-radius: 10px; animation: upright 1.8s ease-in-out infinite; }
@keyframes upright { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0deg); } }
.turn-big { font-size: 40px; color: var(--accent); }
.turn-small { font-size: 18px; color: var(--fg); max-width: 32ch; }
.toast.calm { color: var(--accent); border-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .pointer b, .turn-phone { animation: none; } }
.arm-next { font-size: 16px; color: var(--fg); text-align: center; line-height: 1.5; letter-spacing: 0.06em; }
.soundbar { position: fixed; z-index: 30; left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px)); width: auto; min-height: 64px; box-shadow: 0 0 0 6px #000; display: grid; gap: 2px; justify-items: center; background: var(--accent); color: #000;
  border: 0; border-radius: 10px; font-size: 20px; letter-spacing: 0.04em; padding: 10px; }
.soundbar small { font-size: 13px; letter-spacing: 0; }
