:root{
  --bg:#111113;
  --panel:#1c1c20;
  --text:#f5f5f4;
  --muted:#a8a8a8;
  --accent:#ff5a4e;
  --ok:#4ade80;
  --line:#2e2e34;
  --radius:20px;
  --font:"PingFang TC","Noto Sans TC","Microsoft JhengHei",-apple-system,BlinkMacSystemFont,sans-serif;
}

*{ box-sizing:border-box; }

html, body{
  margin:0;
  height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:var(--font);
  overflow:hidden;
  -webkit-user-select:none;
  user-select:none;
  cursor:default;
}

.app{
  position:relative;
  width:100vw;
  height:100vh;
}

.screen{
  position:absolute;
  inset:0;
  display:none;
  padding:4vh 4vw;
}

.app[data-screen="loading"] .screen-loading,
.app[data-screen="idle"] .screen-idle,
.app[data-screen="frame"] .screen-frame,
.app[data-screen="shoot"] .screen-shoot,
.app[data-screen="result"] .screen-result{
  display:flex;
}

.big-hint{
  font-size:clamp(22px, 3.4vw, 44px);
  font-weight:800;
  margin:0;
  text-align:center;
}

.hint{
  font-size:clamp(16px, 1.8vw, 24px);
  color:var(--muted);
  margin:0;
  text-align:center;
}

.hint.small{ font-size:clamp(13px, 1.3vw, 18px); }

.pulse{ animation:pulse 1.6s ease-in-out infinite; }

@keyframes pulse{
  0%, 100%{ opacity:1; }
  50%{ opacity:.45; }
}

.screen-title{
  font-size:clamp(24px, 3vw, 40px);
  margin:0;
  text-align:center;
}

/* ---- 準備中 ---- */
.screen-loading{ align-items:center; justify-content:center; }

/* ---- 待機 ---- */
.screen-idle{ align-items:center; justify-content:center; }

.idle-inner{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:3vh;
  width:100%;
  height:100%;
}

.event-name{
  font-size:clamp(30px, 5vw, 68px);
  margin:0;
  letter-spacing:.04em;
}

.idle-samples{
  flex:1;
  min-height:0;
  display:flex;
  gap:2vw;
  align-items:center;
  justify-content:center;
}

.idle-samples img{
  height:100%;
  max-height:62vh;
  aspect-ratio:1181/1748;
  object-fit:cover;
  border-radius:8px;
  box-shadow:0 12px 40px rgba(0,0,0,.5);
  transform:rotate(var(--tilt, 0deg));
  background:#fff;
}

/* ---- 選相框 ---- */
.screen-frame{
  flex-direction:column;
  align-items:center;
  justify-content:space-between;
  gap:2vh;
}

.frame-list{
  flex:1;
  min-height:0;
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:3vw;
}

.frame-card{
  height:72%;
  aspect-ratio:1181/1748;
  border-radius:10px;
  overflow:hidden;
  opacity:.4;
  transform:scale(.86);
  transition:transform .2s ease, opacity .2s ease, box-shadow .2s ease;
  background:#fff;
  position:relative;
}

.frame-card img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

.frame-card span{
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  padding:8px;
  background:rgba(0,0,0,.6);
  color:#fff;
  font-weight:800;
  text-align:center;
  font-size:clamp(14px, 1.6vw, 22px);
}

.frame-card.active{
  height:88%;
  opacity:1;
  transform:scale(1);
  box-shadow:0 0 0 5px var(--accent), 0 18px 50px rgba(0,0,0,.6);
}

/* ---- 拍照 ---- */
.screen-shoot{
  gap:3vw;
  align-items:stretch;
}

.shoot-main{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2.4vh;
}

.progress{
  display:flex;
  gap:12px;
}

.progress span{
  width:18px;
  height:18px;
  border-radius:50%;
  border:3px solid var(--muted);
}

.progress span.done{ background:var(--ok); border-color:var(--ok); }
.progress span.now{ border-color:var(--accent); background:var(--accent); }

.live{
  position:relative;
  width:min(100%, calc(70vh * var(--aspect, 1.77)));
  aspect-ratio:var(--aspect, 1.77);
  border-radius:16px;
  overflow:hidden;
  background:#000;
  box-shadow:0 0 0 4px #fff;
}

.live video{
  width:100%;
  height:100%;
  object-fit:cover;
  object-position:50% 40%;
  transform:scaleX(-1);
  display:block;
}

.review-shot{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:none;
}

.live.reviewing .review-shot{ display:block; }

.countdown{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  font-size:clamp(90px, 18vw, 240px);
  font-weight:900;
  color:#fff;
  text-shadow:0 8px 40px rgba(0,0,0,.6);
  pointer-events:none;
}

.live-guide{
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(to right, rgba(255,255,255,.12) 1px, transparent 1px) 33.33% 0 / 33.33% 100% no-repeat,
    linear-gradient(to right, rgba(255,255,255,.12) 1px, transparent 1px) 66.66% 0 / 33.33% 100% no-repeat;
}

.shoot-side{
  width:min(26vw, calc(86vh * 1181 / 1748));
  display:flex;
  align-items:center;
}

.mini-preview{
  width:100%;
  aspect-ratio:1181/1748;
  border-radius:8px;
  background:#fff;
  box-shadow:0 12px 40px rgba(0,0,0,.5);
}

/* ---- 成品 ---- */
.screen-result{
  align-items:center;
  justify-content:center;
  gap:5vw;
}

.result-preview{
  height:88vh;
  aspect-ratio:1181/1748;
  border-radius:8px;
  background:#fff;
  box-shadow:0 18px 60px rgba(0,0,0,.6);
}

.result-side{
  display:flex;
  flex-direction:column;
  gap:2vh;
  max-width:32vw;
}

/* ---- 閃光、確認、提示 ---- */
.flash{
  position:fixed;
  inset:0;
  background:#fff;
  opacity:0;
  pointer-events:none;
}

.flash.on{ animation:flash .45s ease-out; }

@keyframes flash{
  0%{ opacity:.95; }
  100%{ opacity:0; }
}

.overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.75);
  display:grid;
  place-items:center;
  z-index:20;
}

.overlay[hidden]{ display:none; }

.overlay-card{
  background:var(--panel);
  border-radius:var(--radius);
  padding:5vh 5vw;
  text-align:center;
}

.overlay-card h2{ font-size:clamp(26px, 3vw, 40px); margin:0 0 1vh; }
.overlay-card p{ margin:0 0 1vh; font-size:clamp(16px, 1.8vw, 22px); }

.toast{
  position:fixed;
  left:50%;
  bottom:4vh;
  transform:translateX(-50%);
  background:rgba(0,0,0,.85);
  border:1px solid var(--line);
  padding:12px 22px;
  border-radius:999px;
  font-size:16px;
  z-index:30;
}

/* ---- 工作人員 ---- */
.staff-hotspot{
  position:fixed;
  left:0;
  top:0;
  width:70px;
  height:70px;
  background:transparent;
  border:0;
  z-index:40;
}

.staff-dialog{
  background:var(--panel);
  color:var(--text);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:24px;
  user-select:text;
  -webkit-user-select:text;
}

.staff-dialog::backdrop{ background:rgba(0,0,0,.7); }
.staff-dialog.wide{ width:min(1000px, 94vw); max-height:92vh; }
.staff-dialog h2{ margin:0 0 12px; }

.pin-form{ display:flex; flex-direction:column; gap:12px; min-width:280px; }

.staff-head, .staff-foot, .row{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
}

.staff-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(210px, 1fr));
  gap:14px;
  margin:12px 0;
}

fieldset{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px 14px;
  display:flex;
  flex-direction:column;
  gap:10px;
  margin:0 0 12px;
}

legend{ padding:0 6px; color:var(--muted); font-weight:700; }

label{ display:flex; flex-direction:column; gap:4px; font-size:14px; }
label.check{ flex-direction:row; align-items:center; gap:8px; }

input[type="number"], input[type="password"], select{
  background:#0e0e10;
  color:var(--text);
  border:1px solid var(--line);
  border-radius:10px;
  padding:8px 10px;
  font:inherit;
}

.btn{
  border:0;
  border-radius:999px;
  padding:10px 18px;
  background:var(--accent);
  color:#fff;
  font:inherit;
  font-weight:800;
  cursor:pointer;
}

.btn.ghost{ background:#2a2a30; }
.btn.danger{ background:#7f1d1d; }

.error{ color:#fca5a5; margin:0; }

.stats{
  display:grid;
  grid-template-columns:auto auto;
  gap:4px 14px;
  margin:0;
  font-size:14px;
}

.stats dt{ color:var(--muted); }
.stats dd{ margin:0; font-weight:800; text-align:right; }

.sessions{
  display:flex;
  gap:10px;
  overflow-x:auto;
  padding-bottom:6px;
}

.sessions figure{
  margin:0;
  flex:0 0 auto;
  width:110px;
  text-align:center;
  font-size:12px;
  color:var(--muted);
}

.sessions img{
  width:100%;
  aspect-ratio:1181/1748;
  object-fit:cover;
  border-radius:6px;
  background:#fff;
  display:block;
  margin-bottom:4px;
}

.sessions button{ margin-top:4px; padding:4px 10px; font-size:12px; }

/* ================= 按鈕 ================= */
kbd{
  display:inline-block;
  margin-left:10px;
  padding:2px 8px;
  border-radius:6px;
  border:1px solid rgba(255,255,255,.35);
  font:600 .55em/1.6 var(--font);
  vertical-align:middle;
  opacity:.85;
}

.btn-main, .btn-ghost{
  position:relative;
  border:0;
  border-radius:999px;
  font:800 clamp(18px, 2vw, 28px) var(--font);
  color:#fff;
  padding:.7em 1.6em;
  cursor:pointer;
  overflow:hidden;
  transition:transform .08s ease, filter .15s ease;
}

.btn-main{
  background:var(--accent);
  box-shadow:0 10px 30px rgba(255,90,78,.35);
}

.btn-main.big{ font-size:clamp(22px, 2.6vw, 36px); width:100%; }

.btn-ghost{
  background:#2a2a30;
  font-weight:700;
}

.btn-main:hover, .btn-ghost:hover{ filter:brightness(1.08); }
.btn-main:active, .btn-ghost:active, .btn-arrow:active, .btn-round:active, .shutter:active{ transform:scale(.96); }
.is-pressed{ transform:scale(.96); filter:brightness(1.15); }

.pulse-ring{ animation:ring 1.8s ease-out infinite; }

@keyframes ring{
  0%{ box-shadow:0 0 0 0 rgba(255,90,78,.55); }
  100%{ box-shadow:0 0 0 26px rgba(255,90,78,0); }
}

.action-bar{
  display:flex;
  gap:18px;
  align-items:center;
  justify-content:center;
}

/* 拍照畫面依階段顯示不同按鈕 */
.screen-shoot .action-bar{ display:none; }
.screen-shoot[data-phase="ready"] .action-bar[data-phase="ready"],
.screen-shoot[data-phase="countdown"] .action-bar[data-phase="ready"],
.screen-shoot[data-phase="review"] .action-bar[data-phase="review"]{ display:flex; }

.shoot-hint{
  font-size:clamp(20px, 2.6vw, 34px);
  font-weight:800;
  margin:0;
  text-align:center;
  min-height:1.4em;
}

/* 快門鍵 */
.shutter{
  position:relative;
  width:clamp(88px, 10vw, 120px);
  aspect-ratio:1;
  border:0;
  padding:0;
  background:transparent;
  cursor:pointer;
  transition:transform .08s ease;
}

.shutter svg{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  transform:rotate(-90deg);
}

.shutter .ring-bg{ fill:none; stroke:rgba(255,255,255,.9); stroke-width:6; }
.shutter .ring{
  fill:none;
  stroke:var(--accent);
  stroke-width:6;
  stroke-linecap:round;
  stroke-dasharray:289;
  stroke-dashoffset:289;
}

.shutter-core{
  position:absolute;
  inset:13%;
  border-radius:50%;
  background:var(--accent);
  display:grid;
  place-items:center;
  color:#fff;
  font:900 clamp(18px, 2vw, 26px) var(--font);
}

.shutter[disabled]{ cursor:default; }
.shutter[disabled] .shutter-core{ background:#55262a; font-size:clamp(28px, 3.4vw, 44px); }

.key-hint{ color:var(--muted); font-size:18px; }

/* 自動接受倒數條 */
.auto-bar{
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  height:5px;
  background:rgba(0,0,0,.25);
}

.auto-bar span{
  display:block;
  height:100%;
  width:100%;
  background:#fff;
  transform-origin:left;
}

/* 選相框 */
.frame-stage{
  flex:1;
  min-height:0;
  width:100%;
  display:flex;
  align-items:center;
  gap:2vw;
}

.btn-arrow{
  flex:0 0 auto;
  width:clamp(56px, 6vw, 80px);
  aspect-ratio:1;
  border-radius:50%;
  border:0;
  background:#2a2a30;
  color:#fff;
  font:400 clamp(36px, 4vw, 56px)/1 var(--font);
  cursor:pointer;
}

.frame-card{ cursor:pointer; }

/* 成品 */
.result-side{ align-items:stretch; min-width:280px; }

.stepper{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:22px;
}

.btn-round{
  width:64px;
  height:64px;
  border-radius:50%;
  border:0;
  background:#2a2a30;
  color:#fff;
  font:700 34px/1 var(--font);
  cursor:pointer;
}

.btn-round[disabled]{ opacity:.3; cursor:default; }

.stepper-value{
  font:900 clamp(48px, 5vw, 72px)/1 var(--font);
  min-width:1.2em;
  text-align:center;
}

.row-buttons{
  display:flex;
  gap:12px;
  justify-content:center;
}

.row-buttons .btn-ghost{ font-size:clamp(15px, 1.5vw, 20px); padding:.6em 1.2em; }

/* 列印中 */
.print-card{ min-width:min(520px, 86vw); }

.print-anim{
  position:relative;
  width:160px;
  height:150px;
  margin:0 auto 18px;
}

.printer-body{
  position:absolute;
  left:10px;
  right:10px;
  top:20px;
  height:60px;
  border-radius:14px;
  background:#e7e5e4;
  z-index:2;
}

.printer-body::after{
  content:"";
  position:absolute;
  left:24px;
  right:24px;
  bottom:12px;
  height:6px;
  border-radius:3px;
  background:#57534e;
}

.printer-paper{
  position:absolute;
  left:40px;
  right:40px;
  top:66px;
  height:0;
  background:#fff;
  border-radius:0 0 4px 4px;
  box-shadow:0 6px 18px rgba(0,0,0,.35);
  transition:height .4s linear;
  z-index:1;
}

.print-bar{
  height:10px;
  border-radius:999px;
  background:#2a2a30;
  overflow:hidden;
  margin-top:14px;
}

.print-bar span{
  display:block;
  height:100%;
  width:0;
  background:var(--ok);
  transition:width .4s linear;
}

/* 選相框：版面修正（卡片不可蓋住標題和按鈕） */
.screen-frame{ padding:3vh 4vw; }
.frame-stage{ height:100%; }
.frame-list{ height:100%; max-height:100%; overflow:hidden; }
.frame-card{ height:78%; max-height:78%; }
.frame-card.active{ height:94%; max-height:94%; }
kbd{ font-size:.62em; }
.key-hint kbd{ font-size:16px; }
