/* Signing station (55" touchscreen, iPad backup). Single fixed screen, no page scroll. */
:root {
  --navy: #0b2f57;
  --navy-2: #12467a;
  --teal: #19b3c2;
  --teal-soft: #d8f3f5;
  --ink: #14234f;
  --paper: #ffffff;
  --muted: #5d7387;
  --ok: #16a37a;
  --warn: #c7771b;
  --danger: #c23b3b;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  overscroll-behavior: none;
  background: #062244; color: var(--paper); font-family: var(--font);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button, input { font: inherit; }
[hidden] { display: none !important; }

.screen { position: fixed; inset: 0; display: grid; place-items: center; }

/* Pairing */
.pair-card {
  width: min(92vw, 460px); background: var(--paper); color: var(--navy);
  border-radius: 18px; padding: 32px; display: grid; gap: 12px;
}
.pair-card h1 { margin: 0; font-size: 26px; }
.pair-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.pair-card label { font-weight: 700; margin-top: 8px; }
.pair-card input {
  font-size: 20px; padding: 12px 14px; border-radius: 10px;
  border: 2px solid #c7d6e2; background: #ffffff; color: var(--navy);
  -webkit-user-select: text; user-select: text;
}

/* Buttons sized for fingers on a 55" panel and on an iPad */
.btn {
  appearance: none; border: 2px solid rgba(255,255,255,.55); background: rgba(255,255,255,.08);
  color: var(--paper); border-radius: 14px; padding: 14px 22px; min-height: 56px;
  font-size: clamp(16px, 1.4vw, 22px); font-weight: 600; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .38; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #032634; }
.btn.big { min-height: 72px; font-size: clamp(18px, 1.7vw, 26px); }
.btn.ghost { border-color: transparent; background: transparent; }
.pair-card .btn { color: #032634; }
.btn:focus-visible { outline: 3px solid #ffd76a; outline-offset: 3px; }

/* Wall: 16:9 board fitted into the screen */
.board { touch-action: none; position: relative; width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16 / 9; }
.board img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.hit {
  position: absolute; border: 0; padding: 0; margin: 0; background: transparent;
  border-radius: 8px; cursor: pointer;
}
.hit:active { background: rgba(25,179,194,.18); }
.hit.signed { box-shadow: inset 0 0 0 2px rgba(22,163,122,.55); }
.hit.pending { box-shadow: inset 0 0 0 2px rgba(199,119,27,.75); }
.hit canvas { position: absolute; left: 0; width: 100%; pointer-events: none; }
.hit .badge {
  position: absolute; right: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ok); color: #fff; font-size: 14px; line-height: 22px; text-align: center; font-weight: 700;
}
.hit.pending .badge { background: var(--warn); }
.board.debug .hit { outline: 2px dashed #f0f; }

.status-bar {
  position: fixed; right: 14px; bottom: 10px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: rgba(255,255,255,.85); background: rgba(6,34,68,.55);
  padding: 4px 10px; border-radius: 99px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.dot.off { background: var(--danger); }
.admin-corner { position: fixed; left: 0; top: 0; width: 90px; height: 90px; }

/* Overlays */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, #134f86 0%, #062244 70%);
  touch-action: none;
}
.sign-layout, .done-layout {
  display: grid; grid-template-columns: auto minmax(260px, 30vw); gap: clamp(20px, 3vw, 56px);
  align-items: center; padding: 3vh 3vw; max-width: 100vw;
}
.cert-wrap { position: relative; width: min(92vh, 62vw); aspect-ratio: 1; }
.cert { display: block; width: 100%; height: 100%; border-radius: 10px; box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.cert.small { width: min(80vh, 50vw); height: auto; aspect-ratio: 1; }
.pad { position: absolute; touch-action: none; cursor: crosshair; border-radius: 10px; outline: 2px dashed rgba(255,255,255,.4); outline-offset: -2px; }
.pad.attn { box-shadow: 0 0 0 4px #ffd76a; }
.pad-hint {
  position: absolute; pointer-events: none; color: rgba(255,255,255,.6);
  font-size: clamp(14px, 1.4vw, 24px); display: grid; place-items: center; text-align: center;
}

.side { display: grid; gap: 14px; align-content: center; }
.eyebrow { margin: 0; letter-spacing: .12em; font-size: 14px; color: #9fe3ea; font-weight: 700; }
.eyebrow.ok { color: #7ff0c6; }
.eyebrow.warn { color: #ffc56a; }
.side h2, .done-side h2 { margin: 0; font-size: clamp(22px, 2.3vw, 38px); line-height: 1.3; text-wrap: balance; }
.en { margin: 0; color: #b9d7e6; font-size: clamp(14px, 1.2vw, 20px); }
.hint { margin: 0; color: #cfe3ee; line-height: 1.6; font-size: clamp(14px, 1.15vw, 19px); }
.notice { margin: 0; color: #8fb0c4; font-size: 13px; }
.actions { display: grid; gap: 12px; margin-top: 8px; }
.actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.done-side { display: grid; gap: 16px; justify-items: start; }
.qr-box { display: flex; gap: 18px; align-items: center; background: #fff; color: var(--navy); border-radius: 16px; padding: 16px; }
.qr-box canvas { width: clamp(150px, 15vw, 260px); height: auto; image-rendering: pixelated; }
.qr-box p { margin: 0; font-size: clamp(15px, 1.2vw, 20px); line-height: 1.6; font-weight: 600; }
.msg { margin: 0; line-height: 1.6; color: #ffd9a8; font-size: clamp(14px, 1.15vw, 19px); }
.pair-card .msg { color: var(--danger); }

/* Idle countdown */
.idle { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(4,20,40,.72); }
.idle-card { background: #fff; color: var(--navy); border-radius: 20px; padding: 28px 40px; text-align: center; display: grid; gap: 6px; }
.idle-card p { margin: 0; font-size: 22px; }
.idle-num { font-size: 88px !important; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.idle-card .btn { margin-top: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 40;
  background: #fff; color: var(--navy); padding: 12px 20px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: 90vw;
}

/* Portrait (iPad held upright): stack */
@media (orientation: portrait) {
  .sign-layout, .done-layout { grid-template-columns: 1fr; justify-items: center; }
  .cert-wrap { width: min(94vw, 46vh); }
  .cert.small { width: min(80vw, 46vh); }
  .side, .done-side { width: min(94vw, 640px); gap: 10px; }
  .side .hint, .side .notice { display: none; }
  .btn.big { min-height: 60px; }
}
@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
