:root {
  --bg: #101418; --fg: #e8ecf1; --dim: #9aa4b1; --card: #1a2028; --line: #2a323d;
  --accent: #3b9eff; --danger: #e0514f; --bar: rgba(10, 13, 17, .72);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.screen { position: fixed; inset: 0; }
.ver { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }

/* home */
#home { overflow: auto; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; align-items: center; }
.homeHead { display: flex; align-items: baseline; gap: 10px; margin-top: 8vh; }
.homeHead .logo { width: 30px; height: 30px; align-self: center; color: var(--accent); }
.homeHead h1 { font-size: 26px; margin: 0; font-weight: 650; }
.card { width: min(440px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { margin: 0; font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h2 svg { width: 20px; height: 20px; }
.big { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 18px; border-radius: 12px; background: #262e38; font-weight: 600; font-size: 17px; }
.big svg { width: 22px; height: 22px; }
.big.primary { background: var(--accent); color: #06111c; }
.big:active { filter: brightness(1.15); }
#joinForm { display: flex; gap: 8px; }
#joinForm input { flex: 1; min-width: 0; min-height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #0d1115; color: var(--fg); font-size: 18px; letter-spacing: .06em; text-transform: uppercase; }
#joinForm input::placeholder { text-transform: none; letter-spacing: 0; color: var(--dim); }
.hint { margin: 0; color: var(--dim); font-size: 14px; }
.hint.small { font-size: 13px; }
.msg { min-height: 1.4em; color: #ffb4a8; text-align: center; max-width: 440px; }

/* stage + video (cam preview and viewer share the layout) */
.stage { position: absolute; inset: 0; background: #000; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage video { position: absolute; left: 50%; top: 50%; object-fit: contain; transform-origin: center center; will-change: transform; background: #000; }
#viewVideo { cursor: grab; }
#stage.panning #viewVideo { cursor: grabbing; }

.top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 12px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,0)); pointer-events: none; }
.status { font-size: 14px; color: #dfe6ee; text-shadow: 0 1px 2px rgba(0,0,0,.8); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,.7); padding: 14px 18px; border-radius: 12px; text-align: center; max-width: 80vw; }

.bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: stretch; gap: 2px; padding: 6px 4px max(6px, env(safe-area-inset-bottom)); background: var(--bar); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.bar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; padding: 4px 2px; border-radius: 10px; font-size: 11.5px; color: #dfe6ee; }
.bar button svg { width: 24px; height: 24px; }
.bar button:active { background: rgba(255,255,255,.12); }
.bar button[aria-pressed="true"] { color: var(--accent); }
.bar button.danger { color: #ff9a97; }
.bar button[disabled] { opacity: .4; cursor: default; }
.bar button span { line-height: 1.15; text-align: center; }
.bar:not(.rows) button { min-height: 62px; } /* room for a two-line label, so every button in the bar has the same height */
/* Reset floats above Rotate for 3 s after each turn, fading out over its last 0.6 s (RESET_FADE_MS in app.js) */
.bar .rotSlot { flex: 1; position: relative; display: flex; }
.bar .rotSlot > button.floatReset { position: absolute; left: 0; right: 0; bottom: calc(100% + 14px); min-height: 52px; background: rgba(10, 13, 17, .88); border: 1px solid rgba(255, 255, 255, .2); border-radius: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, .5); }
.bar .rotSlot > button.floatReset:active { background: rgba(40, 48, 58, .95); }
.bar .rotSlot > button.floatReset.fading { opacity: 0; transition: opacity .6s ease-in; }
/* the cam's bar: two rows on a phone held upright, one row wherever there is room */
.bar.rows { flex-direction: column; }
.bar .row { display: flex; gap: 2px; }
@media (min-width: 640px), (orientation: landscape) {
  .bar.rows { flex-direction: row; }
  .bar .row { display: contents; }
}
body.fs .bar { opacity: .35; transition: opacity .3s; }
body.fs .bar:hover, body.fs .bar:focus-within { opacity: 1; }

/* overlays */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px 16px 84px; overflow: auto; background: rgba(0,0,0,.6); }
#cam .overlay { padding-bottom: 150px; } /* clear of the two-row bar */
@media (min-width: 640px), (orientation: landscape) { #cam .overlay { padding-bottom: 84px; } }
.overlay.dim { background: #000; cursor: pointer; }
.overlay.dim p { color: #444; font-size: 15px; text-align: center; margin: 0; }
.qrCard { background: #fff; color: #111; border-radius: 16px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(360px, 100%); margin: auto; }
#qrBox { width: min(280px, 70vw, 50vh); aspect-ratio: 1; }
/* a phone held sideways: the card goes wide so the code and the buttons stay above the bar */
@media (orientation: landscape) and (max-height: 500px) {
  .qrCard { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; justify-items: center; column-gap: 16px; width: auto; max-width: calc(100% - 32px); }
  #qrBox { grid-row: 1 / span 3; width: min(200px, 55vh); }
}
#qrBox svg { width: 100%; height: 100%; display: block; }
.codeRow { display: flex; align-items: center; gap: 10px; }
.code { font-size: 28px; font-weight: 700; letter-spacing: .18em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.iconBtn { width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: #333; background: #eef1f5; }
.iconBtn svg { width: 22px; height: 22px; }
.iconBtn:active { background: #dde3ea; }
.qrCard .hint { color: #555; text-align: center; }
.qrCard .hint.ok { color: #1a7f37; }
.small { padding: 8px 16px; border-radius: 10px; background: #eef1f5; color: #222; font-weight: 600; }

/* the QR scanner (SimpleVouchers' reticle) */
#scanner { position: fixed; inset: 0; z-index: 20; background: #000; }
#scanVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.reticle { position: absolute; left: 50%; top: 50%; width: min(66vw, 66vh); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); pointer-events: none; }

/* the last frame, kept on screen when the picture stops */
.stage canvas.still { position: absolute; left: 50%; top: 50%; object-fit: contain; transform-origin: center center; background: #000; pointer-events: none; }
.frozen { position: absolute; left: 50%; top: calc(max(8px, env(safe-area-inset-top)) + 36px); transform: translateX(-50%); background: rgba(224, 81, 79, .92); color: #fff; font-weight: 700; font-size: 15px; padding: 6px 14px; border-radius: 999px; white-space: nowrap; pointer-events: none; box-shadow: 0 2px 8px rgba(0,0,0,.4); }

/* the install pill, top right of the home screen (the box webui's #instb) */
.instBtn { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; background: var(--accent); color: #06111c; border: 1px solid transparent; border-radius: 8px; padding: 7px 12px; font-size: 14px; font-weight: 600; cursor: pointer; z-index: 2; }
.instHint { position: absolute; top: calc(max(12px, env(safe-area-inset-top)) + 44px); right: 12px; max-width: min(320px, calc(100% - 24px)); margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--fg); box-shadow: 0 6px 20px rgba(0,0,0,.5); z-index: 2; cursor: pointer; }
