:root {
  --bg: #06050b;
  --ink: #f4efe3;
  --dim: rgba(244, 239, 227, 0.64);
  --gold: #f6dc8e;
  --gold-deep: #b8903f;
  --line: rgba(246, 220, 142, 0.28);
  --glass: rgba(12, 9, 24, 0.62);
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --latin: "Cinzel", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); overscroll-behavior: none; }
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ── 相機／3D 畫布 ── */
#ar { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #000; touch-action: none; }
#ar canvas { display: block; }
#ar video.cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#ar canvas.over { position: absolute; top: 0; left: 0; }
#ar.shake { animation: shake 0.5s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translate(-2px, 1px); }
  20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-9px, 3px); }
  40%, 60% { transform: translate(9px, -3px); }
}
/* 放在 #hud 裡（WebXR 的 DOM overlay 只顯示 #hud），z-index -1＝壓在 HUD 下、3D 上 */
#flash { position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 45%, #fff 0%, var(--c, #fff) 38%, transparent 85%); }
#flash.go { animation: flash 0.75s ease-out; }
@keyframes flash { 0% { opacity: 0.95; } 100% { opacity: 0; } }

/* ── 開場 ── */
#intro {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; overflow-x: hidden;
  padding: calc(40px + var(--safe-t)) 16px calc(32px + var(--safe-b));
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(122, 76, 255, 0.28), transparent 70%),
    radial-gradient(ellipse 70% 40% at 50% 100%, rgba(246, 180, 80, 0.14), transparent 70%),
    var(--bg);
  display: flex; flex-direction: column; align-items: center; gap: 28px; text-align: center;
}
.sigil { position: absolute; top: -120px; left: 50%; width: 560px; height: 560px; margin-left: -280px; pointer-events: none; opacity: 0.5; }
.sigil i { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid var(--line); }
.sigil i:nth-child(1) { border-style: dashed; animation: spin 60s linear infinite; }
.sigil i:nth-child(2) { inset: 60px; border-width: 1px; border-color: rgba(181, 123, 255, 0.35); animation: spin 40s linear infinite reverse; }
.sigil i:nth-child(3) { inset: 120px; background: repeating-conic-gradient(from 0deg, rgba(246, 220, 142, 0.18) 0 1deg, transparent 1deg 10deg);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%, #000 70%, transparent 71%); mask: radial-gradient(circle, transparent 62%, #000 63%, #000 70%, transparent 71%);
  animation: spin 90s linear infinite; border: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#intro > * { flex-shrink: 0; } /* 內容比畫面高時別把卡片列壓扁（overflow-x:auto 的列 min-height 會變 0） */
#intro header { position: relative; }
.kicker { margin: 0 0 10px; font-family: var(--latin); font-weight: 700; letter-spacing: 0.32em; font-size: 12px; color: var(--gold); opacity: 0.85; }
h1 { margin: 0; font-family: var(--serif); font-weight: 900; font-size: clamp(56px, 17vw, 96px); line-height: 1; letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fff8e1 0%, var(--gold) 45%, var(--gold-deep) 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 24px rgba(246, 200, 110, 0.35)); }
h1 span { font-family: var(--latin); font-size: 0.62em; margin-left: 0.12em; letter-spacing: 0.02em; }
.lead { margin: 16px auto 0; max-width: 30em; color: var(--dim); font-size: 15px; line-height: 1.75; }

#roster { list-style: none; margin: 0; padding: 4px 16px 10px; display: flex; gap: 12px; overflow-x: auto; max-width: 100vw; scroll-snap-type: x mandatory; scrollbar-width: none; }
#roster::-webkit-scrollbar { display: none; }
#roster li { flex: 0 0 104px; scroll-snap-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#roster img { width: 104px; height: 104px; object-fit: cover; border-radius: 10px; border: 2px solid var(--gold-deep);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 8px 26px -6px var(--c), inset 0 0 0 1px rgba(255, 255, 255, 0.2); }
#roster b { font-family: var(--serif); font-size: 14px; white-space: nowrap; }
#roster small { font-family: var(--latin); font-size: 11px; color: var(--dim); letter-spacing: 0.06em; }

.cta { display: flex; flex-direction: column; gap: 12px; width: min(100%, 360px); }
.primary { border: 0; border-radius: 14px; padding: 16px 20px; font-family: var(--serif); font-weight: 900; font-size: 22px; letter-spacing: 0.1em; color: #1a1206;
  background: linear-gradient(180deg, #fff3c4 0%, var(--gold) 40%, #d9a94a 100%);
  box-shadow: 0 10px 30px -8px rgba(246, 200, 110, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.8), inset 0 -2px 0 rgba(120, 80, 20, 0.4);
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform 0.15s; }
.primary small { font-family: var(--sans); font-weight: 600; font-size: 12px; letter-spacing: 0.05em; opacity: 0.7; }
.primary:active { transform: scale(0.97); }
.second { border: 1.5px solid var(--gold-deep); border-radius: 14px; padding: 13px 18px; font-family: var(--serif); font-weight: 900; font-size: 19px; letter-spacing: 0.08em; color: var(--gold);
  background: linear-gradient(180deg, rgba(246, 220, 142, 0.14), rgba(246, 220, 142, 0.03));
  box-shadow: 0 0 26px -10px rgba(246, 200, 110, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex; flex-direction: column; align-items: center; gap: 3px; transition: transform 0.15s; }
.second small { font-family: var(--sans); font-weight: 600; font-size: 12px; letter-spacing: 0.05em; color: var(--dim); }
.second:active { transform: scale(0.97); }
.ghost { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; background: rgba(255, 255, 255, 0.03); color: var(--ink); font-size: 15px; }
.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; width: min(100%, 420px); text-align: left; }
.how li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.6; color: var(--dim); }
.how b { flex: 0 0 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-family: var(--latin); font-size: 13px; color: var(--gold); border: 1px solid var(--line); }
.how em { font-style: normal; color: var(--gold); }
.nocard { margin: 0; max-width: 420px; font-size: 13px; line-height: 1.7; color: var(--dim); }
.nocard a { color: var(--gold); }
#intro footer { margin-top: auto; font-size: 11px; color: rgba(244, 239, 227, 0.38); line-height: 1.6; }

/* ── HUD ── */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud button, #hud a, .tray { pointer-events: auto; }
.top { position: absolute; top: calc(10px + var(--safe-t)); left: 16px; right: 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lp { min-width: 104px; padding: 6px 12px 7px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; flex-direction: column; line-height: 1.1; }
.lp.me { border-color: rgba(108, 192, 255, 0.55); box-shadow: inset 0 0 18px -8px #6cc0ff; }
.lp.foe { text-align: right; border-color: rgba(255, 106, 106, 0.55); box-shadow: inset 0 0 18px -8px #ff6a6a; }
.lp.me small { color: #9fd4ff; }
.lp.foe small { color: #ffa3a3; }
.lp small { font-size: 11px; color: var(--dim); letter-spacing: 0.12em; }
.lp b { font-family: var(--latin); font-size: 26px; font-weight: 900; color: var(--gold); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.lp.hit { animation: lphit 0.6s; }
@keyframes lphit { 0% { transform: scale(1.12); border-color: #ff6161; box-shadow: 0 0 24px #ff6161; } 100% { transform: none; } }
.mid { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
#turn { font-family: var(--serif); font-weight: 900; font-size: 14px; letter-spacing: 0.06em; white-space: nowrap; padding: 4px 12px; border-radius: 99px;
  color: var(--c, var(--gold)); background: var(--glass); border: 1px solid var(--c, var(--line)); box-shadow: 0 0 14px -4px var(--c, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#models { font-size: 11px; color: var(--dim); padding: 4px 10px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); transition: opacity 0.6s 1s; }
#models.done { opacity: 0; }
.tools { position: absolute; top: calc(70px + var(--safe-t)); right: 16px; display: flex; gap: 8px; }
.tools button { height: 36px; min-width: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); font-size: 13px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#btn-reset.pulse { border-color: var(--gold); color: var(--gold); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(246, 220, 142, 0.15); } }

#scan { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; opacity: 0; transition: opacity 0.4s; text-align: center; }
#scan.on { opacity: 1; }
#scan .frame { position: relative; width: min(58vw, 280px); aspect-ratio: 59 / 86; }
#scan .frame i { position: absolute; width: 34px; height: 34px; border: 3px solid var(--gold); filter: drop-shadow(0 0 6px rgba(246, 220, 142, 0.7)); }
#scan .frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
#scan .frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
#scan .frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
#scan .frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
#scan .sweep { position: absolute; left: 6%; right: 6%; height: 2px; top: 10%; background: linear-gradient(90deg, transparent, var(--gold), transparent);
  box-shadow: 0 0 14px var(--gold); animation: sweep 2.2s ease-in-out infinite alternate; }
@keyframes sweep { to { top: 90%; } }
#scan p { margin: 8px 0 0; font-family: var(--serif); font-weight: 900; font-size: 20px; letter-spacing: 0.08em; text-shadow: 0 2px 12px #000; }
#scan small { color: var(--dim); font-size: 13px; text-shadow: 0 1px 8px #000; }

#banner { position: absolute; left: 16px; right: 16px; top: 19%; text-align: center; opacity: 0; transform: scale(0.9); }
#banner.show { animation: banner 1.6s cubic-bezier(.2, .9, .3, 1.2) forwards; }
@keyframes banner { 0% { opacity: 0; transform: scale(1.5); letter-spacing: 0.4em; } 18% { opacity: 1; transform: scale(1); letter-spacing: 0.08em; } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1); } }
#banner .t { font-family: var(--serif); font-weight: 900; font-size: min(64px, calc(84vw / var(--len, 5))); white-space: nowrap; color: #fff; letter-spacing: 0.08em;
  text-shadow: 0 0 18px var(--c), 0 0 42px var(--c), 0 3px 0 rgba(0, 0, 0, 0.6); }
#banner .s { margin-top: 6px; font-family: var(--serif); font-weight: 900; font-size: clamp(18px, 5.4vw, 28px); color: var(--gold); text-shadow: 0 2px 10px #000, 0 0 20px rgba(0, 0, 0, 0.8); }

#floaters { position: absolute; inset: 0; }
.floater { position: absolute; transform: translate(-50%, -50%); font-family: var(--latin); font-weight: 900; font-size: 46px; color: var(--c);
  text-shadow: 0 0 14px var(--c), 0 3px 0 #000; animation: floater 1.5s ease-out forwards; white-space: nowrap; }
@keyframes floater { 0% { opacity: 0; transform: translate(-50%, -20%) scale(1.8); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -180%) scale(1); } }

.bottom { position: absolute; left: 0; right: 0; bottom: calc(14px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 16px; }
#hint { max-width: 420px; padding: 8px 14px; border-radius: 10px; background: var(--glass); border: 1px solid var(--line); font-size: 13px; color: var(--dim); text-align: center;
  opacity: 0; transition: opacity 0.3s; }
#hint.on { opacity: 1; }
#hint:empty { display: none; }
#actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.atk { pointer-events: auto; min-width: 140px; padding: 10px 16px; border-radius: 14px; border: 1.5px solid var(--c); display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: linear-gradient(180deg, rgba(20, 14, 38, 0.82), rgba(8, 6, 18, 0.9)); box-shadow: 0 0 22px -4px var(--c), inset 0 0 18px -8px var(--c);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: transform 0.12s, opacity 0.2s; }
.atk .who { font-size: 12px; color: var(--dim); }
.atk .what { font-family: var(--serif); font-weight: 900; font-size: 18px; letter-spacing: 0.06em; }
.atk:active { transform: scale(0.95); }
.atk:disabled { opacity: 0.4; }
.atk.end { --c: rgba(246, 220, 142, 0.5); min-width: 0; justify-content: center; font-family: var(--serif); font-weight: 900; font-size: 16px; letter-spacing: 0.08em; color: var(--gold);
  box-shadow: none; background: var(--glass); }
.wait { padding: 12px 22px; border-radius: 14px; border: 1.5px solid #ff6a6a; background: rgba(40, 8, 12, 0.72); color: #ffb3b3; font-family: var(--serif); font-weight: 900;
  font-size: 17px; letter-spacing: 0.1em; box-shadow: 0 0 22px -6px #ff6a6a; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: pulse 1.4s infinite; }

.tray { display: flex; gap: 8px; overflow-x: auto; max-width: 100%; padding: 2px; scrollbar-width: none; }
.tray::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 99px; border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-size: 13px; white-space: nowrap; }
.chip img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.chip.on { border-color: #6cc0ff; box-shadow: 0 0 14px -2px #6cc0ff; color: #fff; }
.chip.foe { border-color: #ff6a6a; color: #ffb3b3; }
.chip:disabled { opacity: 0.45; }
.chip.on:disabled, .chip.foe:disabled { opacity: 0.9; }
.tray-label { flex: 0 0 auto; align-self: center; font-size: 12px; color: var(--dim); letter-spacing: 0.1em; padding: 0 2px; }

#loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(6, 5, 11, 0.7); font-size: 15px; color: var(--dim); }
.spin { width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
#error { position: absolute; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); margin: 0 auto; max-width: 380px; padding: 24px; border-radius: 16px; background: #120e20;
  border: 1px solid var(--line); text-align: center; pointer-events: auto; }
#error h2 { margin: 0 0 8px; font-family: var(--serif); color: var(--gold); }
#error p { margin: 0 0 16px; line-height: 1.7; color: var(--dim); font-size: 14px; }
#error button { border: 0; border-radius: 10px; padding: 10px 20px; background: var(--gold); color: #1a1206; font-weight: 700; }

body[data-mode="demo"] .bottom { bottom: calc(10px + var(--safe-b)); }
/* ── 開場：選牌組 ── */
.decks { display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; width: min(100%, 360px); }
.decks > span { font-size: 12px; color: var(--dim); letter-spacing: 0.1em; width: 100%; }
.decks button { flex: 1 1 0; border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; background: rgba(255, 255, 255, 0.03); font-family: var(--serif); font-weight: 900;
  font-size: 18px; letter-spacing: 0.08em; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--dim); transition: all 0.15s; }
.decks button small { font-family: var(--sans); font-weight: 600; font-size: 11px; letter-spacing: 0.02em; opacity: 0.8; }
.decks button.on { border-color: var(--gold); color: var(--gold); background: rgba(246, 220, 142, 0.1); box-shadow: 0 0 18px -6px rgba(246, 200, 110, 0.8); }

/* ── 真實決鬥 ── */
body.duel #actions, body.duel #tray, body.duel #scan { display: none !important; }
body.duel .bottom { bottom: calc(166px + var(--safe-b)); }
.lp .info { display: block; font-style: normal; font-size: 10px; color: var(--dim); letter-spacing: 0.02em; margin-top: 3px; white-space: nowrap; }
.lp .info:empty { display: none; }
.lp .info span { white-space: nowrap; }
.lp .info span + span::before { content: '・'; }
#duel-ui { position: absolute; inset: 0; pointer-events: none; }
#phase { position: absolute; top: calc(114px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 3px; border-radius: 99px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#phase:empty { display: none; }
#phase span { font-size: 11px; padding: 3px 7px; border-radius: 99px; color: var(--dim); white-space: nowrap; }
#phase span.on { background: var(--c, var(--gold)); color: #0a0712; font-weight: 800; }
#log { position: absolute; top: calc(148px + var(--safe-t)); left: 10px; max-width: min(64vw, 340px); display: flex; flex-direction: column; gap: 2px; }
#log div { font-size: 11.5px; line-height: 1.35; padding: 2px 8px; border-left: 2px solid var(--c, var(--line)); background: rgba(8, 6, 18, 0.58); border-radius: 0 6px 6px 0;
  color: rgba(244, 239, 227, 0.9); }
#log div:nth-child(2) { opacity: 0.72; }
#log div:nth-child(n+3) { opacity: 0.45; }
#dbar { position: absolute; left: 0; right: 0; bottom: calc(8px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 8px; }
#dbtns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 0 10px; min-height: 44px; align-items: flex-end; }
#dbtns .atk { min-width: 0; padding: 8px 14px; }
#dbtns .atk .what { font-size: 15px; }
#hand { display: flex; justify-content: center; padding: 0 12px; width: 100%; pointer-events: none; }
.hc { flex: 0 0 64px; padding: 0; border: 0; background: none; position: relative; pointer-events: auto; transition: transform 0.15s; }
.hc + .hc { margin-left: min(-4px, calc((100vw - 24px - var(--n, 5) * 64px) / (var(--n, 5) - 1))); }
.hc img { width: 64px; height: 93px; border-radius: 5px; display: block; border: 1.5px solid rgba(0, 0, 0, 0.7); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6); }
.hc.can img { border-color: #6cc0ff; box-shadow: 0 0 0 1px #6cc0ff, 0 0 16px 2px rgba(108, 192, 255, 0.6); }
.hc:active { transform: translateY(-10px) scale(1.05); z-index: 2; }
.hc.new { animation: dealIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes dealIn { from { transform: translateY(46px) scale(0.7); opacity: 0; } }
#sheet { position: absolute; inset: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: center; background: rgba(4, 3, 10, 0.42); pointer-events: auto; }
#sheet.must { background: rgba(4, 3, 10, 0.6); }
#sheet .panel { width: min(100% - 16px, 520px); max-height: 74vh; overflow-y: auto; margin-bottom: calc(8px + var(--safe-b)); padding: 14px 14px 12px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(24, 18, 44, 0.97), rgba(12, 9, 24, 0.98)); border: 1px solid var(--line); box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6); animation: sheetUp 0.22s ease-out; }
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0; } }
#sheet header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
#sheet header > div { flex: 1; min-width: 0; }
#sheet h3 { margin: 0; font-family: var(--serif); font-size: 18px; color: var(--gold); line-height: 1.4; }
#sheet .sub { margin: 3px 0 0; font-size: 12.5px; color: var(--dim); }
#sheet .sub:empty { display: none; }
#sheet .x { flex: 0 0 auto; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); border-radius: 10px; width: 34px; height: 34px; }
#sheet.must .x { display: none; }
#sheet .body { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035); font-size: 14px; line-height: 1.45; }
.row .th { display: flex; gap: 3px; flex: 0 0 auto; }
.row .th:empty { display: none; }
.row .th img { width: 34px; height: 50px; border-radius: 3px; object-fit: cover; }
.row.act { justify-content: center; border-color: rgba(108, 192, 255, 0.6); background: rgba(60, 130, 220, 0.16); font-family: var(--serif); font-weight: 900; font-size: 16px;
  letter-spacing: 0.06em; color: #d6ecff; padding: 11px 10px; }
.row.pass { justify-content: center; color: var(--dim); }
.row:active { transform: scale(0.98); }
.info { display: flex; gap: 12px; align-items: flex-start; }
.info img { width: 116px; flex: 0 0 auto; border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); }
.info b { font-family: var(--serif); font-size: 19px; color: #fff; display: block; line-height: 1.3; }
.info small { color: var(--dim); font-size: 11px; }
.info p { margin: 6px 0 0; font-size: 13px; line-height: 1.6; color: rgba(244, 239, 227, 0.88); white-space: pre-line; }
.info p.meta { color: var(--gold); }
.why { margin: 2px 0 0; font-size: 12.5px; color: var(--dim); text-align: center; }
.info .why { text-align: left; }
.reveal { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.reveal img { width: 76px; border-radius: 5px; }
#cast { position: absolute; left: 50%; top: 46%; width: min(40vw, 190px); transform: translate(-50%, -50%); pointer-events: none; }
#cast img { width: 100%; border-radius: 8px; display: block; box-shadow: 0 0 0 2px var(--c), 0 0 40px 6px var(--c); }
#cast.go { animation: cast 1.5s cubic-bezier(0.2, 0.9, 0.3, 1) forwards; }
@keyframes cast { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotateY(90deg); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotateY(0); }
  75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -62%) scale(0.9); } }
body:not([data-mode="ar"]) #models { display: none; }
body.duel #banner { top: 30%; }
/* ── 手機相容 ── */
/* iPhone 連點兩下會放大整頁：按鈕／手牌／選單改成 manipulation（照樣能點、能捲，不會觸發雙擊縮放） */
button, #sheet, #hand, #log { touch-action: manipulation; }
#sheet .panel { overscroll-behavior: contain; }
/* 開場頁最上面的提示（boot.js：瀏覽器太舊、App 內建瀏覽器、載入失敗） */
#notice { position: relative; z-index: 1; width: min(100%, 420px); padding: 12px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.65; text-align: left;
  background: rgba(246, 220, 142, 0.1); border: 1px solid var(--gold-deep); color: var(--ink); }
#notice b { color: var(--gold); }
#notice.bad { background: rgba(255, 97, 97, 0.12); border-color: #ff6161; }
#notice.bad b { color: #ffb3b3; }
/* 錯誤／離開 AR：蓋在決鬥選單上面 */
#error, #xrback { z-index: 9; }
#xrback { position: absolute; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); margin: 0 auto; max-width: 380px; padding: 24px; border-radius: 16px; background: #120e20;
  border: 1px solid var(--line); text-align: center; pointer-events: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7); }
#xrback h2 { margin: 0 0 8px; font-family: var(--serif); color: var(--gold); }
#xrback p { margin: 0 0 16px; line-height: 1.7; color: var(--dim); font-size: 14px; }
#error .btns, #xrback .btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#error .btns button, #xrback .btns button { border: 0; border-radius: 10px; padding: 10px 20px; background: var(--gold); color: #1a1206; font-weight: 700; }
#error .btns .alt, #xrback .btns .quit { background: transparent; color: var(--gold); border: 1px solid var(--gold-deep); }
#btn-simple { pointer-events: auto; padding: 9px 16px; border-radius: 99px; border: 1px solid var(--gold); background: rgba(40, 30, 8, 0.8); color: var(--gold); font-size: 14px; font-weight: 700;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
/* 真實決鬥的頂列：直式手機寬度不夠放「血量＋回合＋四顆工具」→ 工具收進中間的選單；血量框的手牌／牌組／墓地可以換行 */
#btn-menu { display: none; }
body.duel .top { align-items: flex-start; }
body.duel .lp { flex: 1 1 0; min-width: 0; max-width: 160px; }
body.duel .lp .info { white-space: normal; line-height: 1.3; }
body.duel .mid { flex: 0 0 auto; gap: 6px; padding-top: 2px; }
body.duel #turn { font-size: 12.5px; padding: 3px 10px; }
body.duel #btn-menu { display: block; height: 30px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--glass); font-size: 12.5px; white-space: nowrap;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
body.duel #btn-menu[aria-expanded="true"] { border-color: var(--gold); color: var(--gold); }
body.duel .tools { display: none; top: calc(72px + var(--safe-t)); left: 50%; right: auto; transform: translateX(-50%); z-index: 7; padding: 8px; border-radius: 14px;
  background: rgba(12, 9, 24, 0.95); border: 1px solid var(--line); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.6); flex-wrap: wrap; justify-content: center; width: max-content; max-width: calc(100vw - 32px); }
body.duel .tools.open { display: flex; }
@media (min-width: 720px) {
  .lp b { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .sigil i, #scan .sweep { animation: none; }
}
