@font-face {
  font-family: "Iansui";
  src: url("./fonts/iansui-chinese-traditional.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: light;
  --ink: #17384b;
  --deep: #102d3e;
  --muted: #5d707b;
  --paper: #f4f2ec;
  --surface: #fbfaf7;
  --line: #ccd3d2;
  --blue: #15546d;
  --gold: #bd995e;
  font-family: "Noto Sans TC", "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; height: 100dvh; overflow: hidden; position: fixed; inset: 0; overscroll-behavior: none; }
body { background: var(--paper); user-select: none; touch-action: none; }
#viewport { position: fixed; inset: 0; overflow: hidden; background: var(--paper); }
#screen { position: absolute; left: 50%; top: 50%; width: 1080px; height: 1920px; overflow: hidden; background: var(--paper); container-type: size; transform: translate(-50%, -50%) scale(var(--kta-scale, 1)); transform-origin: center; }
#board { overflow: hidden; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; min-height: 44px; border: 0; transition: background .2s, color .2s, box-shadow .2s; }
button:disabled { opacity: .5; cursor: wait; }
button:active:not(:disabled) { filter: brightness(.92); }
:focus-visible { outline: 3px solid #0876b0; outline-offset: 4px; }
button svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.7; }

#board {
  position: relative;
  z-index: 1;
  width: 1080px;
  height: 1920px;
  display: grid;
  grid-template-rows: auto minmax(0, 1.1fr) minmax(0, 1fr) auto;
  gap: 1.8cqh;
  padding: 2cqh 4cqw 1.5cqh;
  background: var(--paper);
}
.masthead, .footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.masthead { min-width: 0; border-bottom: 1px solid var(--line); padding-bottom: 1.05cqh; }
.masthead-brand {
  display: flex;
  align-items: center;
  width: clamp(240px, 28cqw, 490px);
  min-height: 44px;
  padding: 0;
  background: transparent;
  text-align: left;
}
.masthead-brand img { display: block; width: 100%; height: auto; }
.masthead-brand:disabled { opacity: 1; cursor: default; }
.masthead-meta { display: grid; gap: .35cqh; justify-items: end; text-align: right; color: var(--muted); font-size: clamp(8px, .78cqh, 14px); line-height: 1.45; letter-spacing: .15em; }
.masthead-meta strong { color: var(--ink); font-size: clamp(9px, .92cqh, 16px); font-weight: 600; letter-spacing: .19em; }

#stage { min-width: 0; min-height: 0; display: grid; place-items: center; container-type: size; }
#frame { position: relative; width: min(100cqw, calc(100cqh * 3 / 2)); aspect-ratio: 3 / 2; background: var(--surface); box-shadow: 0 14px 42px #14334b20; }
#view { width: 100%; height: 100%; display: block; background: #dce6ec; }

#deck { display: grid; grid-template-columns: .96fr 1.04fr; align-items: stretch; gap: clamp(28px, 5cqw, 84px); min-height: 0; }
#promo, #console { min-width: 0; min-height: 0; }
#promo { position: relative; }
.inspector-scene { position: absolute; inset: 0; overflow: hidden; background: transparent; border: 0; box-shadow: none; }
.inspector-scene-image, .inspector-drawing-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.inspector-scene-image { z-index: 0; object-fit: contain; opacity: 1; filter: grayscale(.16) saturate(.56) contrast(.94) brightness(1.02); }
#inspectorScene[data-motion="enabled"] .inspector-scene-image { opacity: .42; filter: grayscale(.32) saturate(.42) contrast(.93) brightness(1.03); }
.inspector-drawing-canvas { z-index: 1; opacity: 0; pointer-events: none; filter: grayscale(.16) saturate(.56) contrast(.96) brightness(1.02); will-change: opacity; }
.inspector-scene-image, .inspector-drawing-canvas { -webkit-mask-image: radial-gradient(ellipse 49% 44% at 50% 50%, #000 84%, transparent 100%); mask-image: radial-gradient(ellipse 49% 44% at 50% 50%, #000 84%, transparent 100%); }
.inspector-caption { position: absolute; z-index: 3; left: 5.5%; right: 5.5%; bottom: 4.2%; display: grid; gap: .35cqh; color: #243845; pointer-events: none; }
.scene-kicker { display: flex; align-items: center; gap: .65em; color: #7f7055; font-size: clamp(9px, .82cqh, 14px); font-weight: 600; letter-spacing: .2em; }
.scene-kicker::before { content: ""; width: 1.25em; height: 1px; background: #ad9568; }
.scene-title { font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif; font-size: clamp(15px, 1.55cqh, 27px); letter-spacing: .08em; text-shadow: 0 1px 2px #f6f2e7b8; }

@media (prefers-reduced-motion: reduce) {
  .inspector-drawing-canvas { display: none; }
  .inspector-scene-image { opacity: 1 !important; }
}

#console { display: grid; align-content: center; gap: 1.6cqh; }
#bar { display: grid; gap: 1.25cqh; }
.control-heading { display: flex; align-items: baseline; gap: .85em; min-width: 0; }
#bar > .control-heading:not(:first-child) { margin-top: .8cqh; }
.control-heading h2 { white-space: nowrap; font-size: clamp(16px, 2.1cqh, 36px); margin: 0; font-weight: 600; letter-spacing: .03em; }
.step { color: var(--gold); font-family: Georgia, serif; font-size: clamp(12px, 1.4cqh, 24px); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .1em; }
#backgrounds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(8px, 1cqw, 20px); }
#backgrounds button { display: grid; gap: .55em; padding: 0 0 .55em; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); background: transparent; text-align: left; min-width: 0; }
#backgrounds button[aria-pressed="true"] { border-bottom-color: var(--gold); color: var(--ink); box-shadow: none; background: transparent; }
#backgrounds button[aria-pressed="true"] b { color: var(--gold); }
#backgrounds img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; transition: filter .25s, transform .25s; }
#backgrounds button:hover img { filter: saturate(1.08); transform: translateY(-2px); }
#backgrounds span { display: flex; align-items: baseline; gap: .45em; padding: 0; font-size: clamp(12px, 1.25cqh, 24px); white-space: nowrap; }
#backgrounds span b { color: #81909a; font-family: Georgia, serif; font-size: .86em; font-variant-numeric: tabular-nums; font-weight: 500; }
#shutter { display: flex; justify-content: center; align-items: center; gap: .7em; position: relative; overflow: hidden; background: linear-gradient(112deg, var(--deep), #17455a); color: white; font-size: clamp(19px, 2.5cqh, 46px); font-weight: 600; letter-spacing: .04em; border-radius: 2px; padding: .75em 1.1em; min-height: 7cqh; width: 100%; box-shadow: 0 8px 22px #102d3e22; }
#shutter::before { content: ""; position: absolute; inset-block: 22%; left: 0; width: 3px; background: var(--gold); }
#shutter > svg, #shutter > span:not(.button-sheen) { position: relative; z-index: 1; }
#shutter > .button-arrow { margin-left: auto; font-weight: 400; }
.button-sheen { position: absolute; z-index: 0; top: -35%; bottom: -35%; left: -20%; width: 20%; transform: skewX(-18deg); opacity: 0; pointer-events: none; background: linear-gradient(90deg, transparent, #f4dfb488, transparent); will-change: transform, opacity; }
#shutter:hover { background: linear-gradient(112deg, #16465c, #20647a); }
.capture-note { font-size: clamp(12px, 1.4cqh, 25px); line-height: 1.6; text-align: left; color: var(--muted); margin: -.25cqh 0 0; }
#countdown { font-size: clamp(72px, 16cqh, 280px); text-align: center; font-weight: 500; line-height: 1.2; font-variant-numeric: tabular-nums; }
#countdown::after { content: '看向鏡頭，留下此刻'; display: block; font-size: clamp(14px, 2cqh, 36px); letter-spacing: .1em; }
#after { display: grid; align-content: center; gap: clamp(16px, 1.8cqh, 30px); min-height: 0; }
#pickup { display: grid; gap: 1.15cqh; width: 100%; }
#pickup .control-heading { padding-bottom: .65cqh; border-bottom: 1px solid var(--line); }
.pickup-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .95fr); align-items: center; gap: clamp(14px, 2cqw, 28px); }
.pickup-copy { min-width: 0; }
.pickup-expiry { margin: 0 0 .7em; color: var(--muted); font-size: clamp(12px, 1.25cqh, 22px); line-height: 1.5; }
#pickupStatus { margin: 0; color: var(--muted); font-size: clamp(12px, 1.4cqh, 25px); line-height: 1.5; }
.pickup-qr-shell { position: relative; justify-self: end; width: min(100%, 28cqh); aspect-ratio: 1; padding: 8px; border: 1px solid var(--line); border-radius: 2px; background: #fff; }
#pickupQr { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.pickup-qr-placeholder { position: absolute; inset: 8px; display: grid; align-content: center; justify-items: center; gap: .35em; border: 1px dashed var(--line); border-radius: 2px; color: var(--muted); background: var(--paper); }
.pickup-qr-placeholder span { color: var(--gold); font-family: Georgia, serif; font-size: clamp(34px, 4cqh, 64px); letter-spacing: .08em; }
#uploadRetry { margin-top: .9em; padding: .5em .8em; border: 1px solid var(--line); border-radius: 2px; color: var(--ink); background: var(--surface); font-size: clamp(13px, 1.15cqh, 18px); }
#uploadRetry:hover { border-color: var(--gold); }
#retake { display: flex; justify-content: flex-start; align-items: center; gap: .7em; position: relative; overflow: hidden; background: linear-gradient(112deg, var(--deep), #17455a); color: white; font-size: clamp(19px, 2.5cqh, 46px); font-weight: 600; letter-spacing: .04em; border-radius: 2px; padding: .75em 1.1em; min-height: 7cqh; width: 100%; box-shadow: 0 8px 22px #102d3e22; }
#retake::before { content: ""; position: absolute; inset-block: 22%; left: 0; width: 3px; background: var(--gold); }
#retake > svg, #retake > span { position: relative; z-index: 1; }
#retake .retake-arrow { margin-left: auto; font-weight: 400; }
#retake:hover { background: linear-gradient(112deg, #16465c, #20647a); }

.footer { justify-content: flex-start; border-top: 1px solid var(--line); padding-top: 1cqh; font-family: "Iansui", "Noto Sans TC", serif; font-size: clamp(14px, 1.45cqh, 26px); color: var(--ink); letter-spacing: .01em; }
#settings { position: absolute; z-index: 8; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 1000px); height: 66cqh; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 0 clamp(18px, 2.5cqw, 36px) 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px 8px 0 0; box-shadow: 0 -12px 70px #14334b33; scroll-padding-top: 80px; }
.settings-header { position: sticky; top: 0; background: var(--paper); z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 0 9px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.settings-header .eyebrow { margin: 0 0 4px; color: var(--blue); font-size: 11px; font-weight: 600; letter-spacing: .16em; }
#settings h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: .06em; }
#settings .settings-header h2 { margin: 0; font-size: 22px; }
#settings .note { font-size: clamp(11px, 1cqh, 17px); line-height: 1.35; color: var(--muted); margin: 0 0 4px; }
#settings .settings-group { border-top: 1px solid var(--line); padding: 9px 0 3px; margin: 8px 0 0; }
#settings .settings-group h2 { font-size: clamp(15px, 1.35cqh, 22px); color: var(--ink); margin: 0 0 8px; padding: 0; border: 0; }
#settings .settings-group .note { margin: -2px 0 7px; }
#settings .setting-help { color: var(--muted); font-size: clamp(11px, 1cqh, 17px); margin: -2px 0 0; }
#settings .compact { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 5px 14px; align-items: end; }
#settings .span2 { grid-column: 1 / -1; }
#settings label.field { display: block; font-size: clamp(13px, 1.05cqh, 18px); margin: 0; }
#settings :is(input[type="text"], select) { width: 100%; min-height: clamp(40px, 2.5cqh, 48px); border: 1px solid #8298a7; background: white; color: var(--ink); border-radius: 3px; padding: 4px 9px; margin-top: 2px; user-select: text; }
#settings input[type="range"] { width: 100%; min-height: 24px; display: block; accent-color: var(--blue); }
#settings input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--blue); }
#settings label:has(input[type="checkbox"]), #settings .color-field { display: flex; align-items: center; justify-content: space-between; min-height: 30px; }
#settings input[type="color"] { width: 52px; height: 32px; border: 1px solid var(--line); background: white; padding: 2px; }
#settings output, #settings .field > span { float: right; color: var(--blue); font-variant-numeric: tabular-nums; }
#settings button { padding: 10px 20px; background: var(--ink); color: white; border-radius: 2px; font-size: 16px; }
#rotation { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
#rotation button { background: white; color: var(--ink); border: 1px solid var(--line); }
#rotation button[aria-pressed="true"] { background: var(--blue); color: white; }
#settings .actions { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
#settings #resetSettings { background: white; color: var(--ink); border: 1px solid var(--line); }
#problem { position: absolute; top: 16px; left: 4cqw; right: 4cqw; z-index: 9; padding: 20px; border-radius: 4px; color: white; background: #673b2b; box-shadow: 0 8px 40px #0003; }
#problem p { font-size: clamp(16px, 2cqh, 32px); line-height: 1.5; }
#problem button { padding: 10px 24px; border-radius: 2px; color: var(--ink); background: white; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .button-sheen { display: none !important; }
}
