@font-face { font-family: Poppins; font-weight: 400; font-display: swap; src: url(/fonts/poppins-regular.woff2) format("woff2"); }
@font-face { font-family: Poppins; font-weight: 500; font-display: swap; src: url(/fonts/poppins-medium.woff2) format("woff2"); }
@font-face { font-family: Poppins; font-weight: 600; font-display: swap; src: url(/fonts/poppins-semibold.woff2) format("woff2"); }
@font-face { font-family: Poppins; font-weight: 700; font-display: swap; src: url(/fonts/poppins-bold.woff2) format("woff2"); }

:root {
  --fm-yellow: #ffcc04;
  --fm-orange: #f8971d;
  --fm-blue: #0085c9;
  --fm-green: #00ac4e;
  --fm-red: #ee343a;
  --fm-ink: #2d2926;
  --fm-soft-ink: #5b5753;
  --fm-line: #e5e1d8;
  --fm-paper: #fff8f0;
  --fm-white: #ffffff;
  --shadow-raised-card: 0 10px 24px rgba(45, 41, 38, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--fm-paper); color: var(--fm-ink); font: 400 16px/1.4 Poppins, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.noscript { padding: 24px; }

.type-display { margin: 0; font-size: clamp(40px, 5.4vw, 78px); font-weight: 700; line-height: 1.04; }
.type-section-title { margin: 0; font-size: clamp(24px, 2.6vw, 30px); font-weight: 700; line-height: 1.27; }
.type-subsection-title { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.25; }
.type-text-link { color: var(--fm-blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }

.button-primary { background: var(--fm-orange); color: var(--fm-ink); border: 2px solid var(--fm-ink); border-radius: 999px; padding: 12px 26px; font-weight: 700; min-height: 48px; }
.button-primary:hover { filter: brightness(1.05); }
.button-primary:disabled { opacity: .6; cursor: progress; }
.button-primary.big { font-size: 20px; padding: 14px 34px; min-height: 56px; }
.button-quiet { background: var(--fm-white); border: 1.5px solid var(--fm-line); border-radius: 999px; padding: 8px 16px; font-weight: 600; min-height: 40px; }
.button-quiet:hover { border-color: var(--fm-ink); }
.link { background: none; border: 0; padding: 0; color: var(--fm-blue); text-decoration: underline; font-weight: 500; }
:focus-visible { outline: 3px solid var(--fm-blue); outline-offset: 2px; }

.top { padding: 16px max(16px, env(safe-area-inset-left)); display: flex; align-items: center; gap: 12px; }
.logo { height: 40px; width: auto; }
.logo.small { height: 30px; }
.spacer { flex: 1; }

/* Home */
.home { max-width: 760px; margin: 0 auto; padding: 8px 16px 48px; }
.lead { font-size: 18px; color: var(--fm-soft-ink); margin: 14px 0 28px; }
.choices { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .choices { grid-template-columns: 1fr; } }
.choice { text-align: left; background: var(--fm-white); border: 2px solid var(--fm-ink); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-raised-card); display: flex; flex-direction: column; gap: 6px; }
.choice:hover { background: #fffdf9; transform: translateY(-1px); }
.choice-title { font-weight: 700; font-size: 19px; }
.choice-text { color: var(--fm-soft-ink); font-size: 15px; }
.join { margin: 32px 0 8px; background: var(--fm-white); border: 1.5px solid var(--fm-line); border-radius: var(--radius); padding: 18px; }
.join-row { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.join-row input { flex: 1 1 200px; min-width: 0; font-size: 22px; letter-spacing: .08em; text-transform: uppercase; padding: 10px 14px; border: 2px solid var(--fm-ink); border-radius: 10px; background: var(--fm-paper); }
.msg { min-height: 1.4em; margin: 8px 0 0; color: var(--fm-red); font-weight: 500; }
.about { margin-top: 18px; }
.about summary { cursor: pointer; font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 8px; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--fm-ink); border-bottom: 2px solid var(--fm-ink); transform: rotate(45deg); margin-top: -4px; transition: transform .15s; }
.about[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.about ul { color: var(--fm-soft-ink); padding-left: 20px; }
.foot { margin-top: 28px; font-size: 13px; color: var(--fm-soft-ink); }
.ver { margin-left: 10px; }

/* Status pill */
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--fm-line); color: var(--fm-ink); }
.pill[data-kind="ok"] { background: var(--fm-green); color: var(--fm-white); }
.pill[data-kind="wait"] { background: var(--fm-yellow); }
.pill[data-kind="bad"] { background: var(--fm-red); color: var(--fm-white); }

/* Big screen */
.screen { min-height: 100%; display: flex; flex-direction: column; }
.bar { border-bottom: 1.5px solid var(--fm-line); background: var(--fm-white); }
.pairing { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 16px; gap: 10px; }
.qr { width: min(46vh, 80vw); aspect-ratio: 1; background: #fff; border: 2px solid var(--fm-ink); border-radius: var(--radius); padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.or { margin: 8px 0 0; color: var(--fm-soft-ink); font-size: 18px; }
.code { margin: 0; font-size: clamp(36px, 6vw, 72px); font-weight: 700; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.hint { color: var(--fm-soft-ink); font-size: 15px; }
.board { flex: 1; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); grid-template-rows: auto auto 1fr; gap: 18px 24px; padding: 20px max(16px, 3vw); }
@media (max-width: 860px) { .board { grid-template-columns: 1fr; } }
.bignum-wrap { grid-row: span 2; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; background: var(--fm-white); border: 2px solid var(--fm-ink); border-radius: var(--radius); padding: 18px 28px; box-shadow: var(--shadow-raised-card); }
.bignum { font-size: clamp(120px, 24vw, 340px); font-weight: 700; line-height: .95; font-variant-numeric: tabular-nums; }
.bigcap { font-size: clamp(22px, 3vw, 40px); font-weight: 700; }
.of { color: var(--fm-soft-ink); font-weight: 500; }
.when { margin-top: 6px; color: var(--fm-soft-ink); }
.map { position: relative; aspect-ratio: 16 / 9; background: var(--fm-white); border: 1.5px solid var(--fm-line); border-radius: var(--radius); overflow: hidden; }
.dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: var(--fm-line); border: 2px solid var(--fm-soft-ink); }
.dot.up { background: var(--fm-green); border-color: var(--fm-ink); width: 24px; height: 24px; margin: -12px 0 0 -12px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--fm-green); }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; flex: 1 1 260px; }
.field input, .field select { font-weight: 400; font-size: 16px; padding: 9px 12px; border: 1.5px solid var(--fm-line); border-radius: 10px; background: var(--fm-white); }
.history { grid-column: 1 / -1; background: var(--fm-white); border: 1.5px solid var(--fm-line); border-radius: var(--radius); padding: 14px 18px; }
.history-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hist { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 28vh; overflow: auto; }
.hist li { display: flex; gap: 14px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--fm-line); flex-wrap: wrap; }
.hist li.empty { color: var(--fm-soft-ink); border: 0; }
.hist strong { font-size: 18px; min-width: 80px; }
.ht { color: var(--fm-soft-ink); font-size: 14px; }
.hl { font-size: 15px; }

/* Camera */
body[data-view="camera"], body[data-view="solo"] { background: #111; color: #fff; }
.camera { position: fixed; inset: 0; display: flex; flex-direction: column; background: #111; }
.stage { position: relative; flex: 1; overflow: hidden; min-height: 0; }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.mirror { transform: scaleX(-1); }
.hud { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 10px max(12px, env(safe-area-inset-left)); pointer-events: none; }
.hud > * { pointer-events: auto; }
.top-hud { top: 0; padding-top: max(10px, env(safe-area-inset-top)); justify-content: space-between; }
.hud-btn { background: rgba(0,0,0,.55); color: #fff; border: 1.5px solid rgba(255,255,255,.5); border-radius: 999px; padding: 8px 14px; font-weight: 600; min-height: 40px; }
.count-hud { bottom: 0; justify-content: flex-start; align-items: flex-end; }
.cnum { font-size: clamp(64px, 18vw, 140px); font-weight: 700; line-height: 1; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.ccap { font-size: 20px; font-weight: 700; padding-bottom: 12px; text-shadow: 0 2px 8px rgba(0,0,0,.7); }
.ccap .of { color: #eee; }
.loading, .problem { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(17,17,17,.82); gap: 8px; }
.loading p { margin: 0; font-weight: 600; }
.loading .bar { width: min(320px, 80%); height: 10px; background: #333; border-radius: 999px; overflow: hidden; }
.loading .bar div { height: 100%; width: 0; background: var(--fm-yellow); transition: width .2s; }
.small { font-size: 13px; color: inherit; opacity: .85; margin: 0; }
.problem p { max-width: 460px; font-size: 17px; }
.dock { display: flex; align-items: center; gap: 14px; padding: 12px max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom)); background: #1b1b1b; flex-wrap: wrap; }
.dock .button-quiet { background: #2a2a2a; color: #fff; border-color: #444; }
.dock .button-primary.big { flex: 1 1 auto; max-width: 420px; }
.settings { background: #1b1b1b; padding: 4px max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; max-height: 45vh; overflow: auto; }
.settings .field select { background: #2a2a2a; color: #fff; border-color: #444; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--fm-ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; z-index: 10; max-width: calc(100% - 32px); text-align: center; box-shadow: var(--shadow-raised-card); }
body[data-view="camera"] .toast, body[data-view="solo"] .toast { bottom: 110px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
