* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--paper);
  font-family: var(--font-text); font-weight: 800; user-select: none; -webkit-user-select: none; touch-action: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }

/* the camera picture and the 3D overlay share one box and one object-fit, so they line up */
#stage { position: fixed; inset: 0; overflow: hidden; background: #000; }
#video, #bg > *, #gl { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
#video { visibility: hidden; }
#video.on { visibility: visible; }
#marks { position: absolute; inset: 0; pointer-events: none; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; pointer-events: none;
  padding: max(12px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom)); }
.screen > * { pointer-events: auto; }

/* ---------- home ---------- */
#home { justify-content: space-between; pointer-events: auto;
  background:
    radial-gradient(120% 60% at 0% 0%, color-mix(in srgb, var(--sun) 55%, transparent), transparent 60%),
    radial-gradient(120% 60% at 100% 100%, color-mix(in srgb, var(--moon) 70%, transparent), transparent 60%),
    var(--ink); }
.home-top { text-align: center; padding-top: 6vh; }
.logo { display: inline-flex; align-items: center; gap: 10px; }
.orb { width: 54px; height: 54px; border-radius: 50%; display: block; box-shadow: inset -6px -8px 0 rgba(0,0,0,.18); }
.orb.sun { background: var(--sun); }
.orb.moon { background: var(--moon); }
.vs { font: 400 22px/1 var(--font-display); color: var(--paper); opacity: .8; }
h1 { font: 400 clamp(56px, 17vw, 96px)/0.95 var(--font-display); margin: 14px 0 0; letter-spacing: .5px;
  text-shadow: 0 4px 0 rgba(0,0,0,.25); }
.home-cast { flex: 1; display: grid; place-items: center; min-height: 0; }
#homeCast #gl { position: static; width: 100%; height: 100%; max-height: none; object-fit: contain; }
.home-cast { position: relative; }
.home-actions { display: flex; flex-direction: column; gap: var(--gap); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }

.btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: var(--tap);
  border-radius: var(--r-btn); font: 400 24px/1 var(--font-display); text-decoration: none; color: var(--ink);
  transition: transform .12s ease; }
.btn:active { transform: scale(.96); }
.btn.main { min-height: 76px; font-size: 32px; background: var(--sun); box-shadow: 0 6px 0 var(--sun-deep); }
.btn.quiet { background: rgba(255, 247, 232, .14); color: var(--paper); font-size: 22px; }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* ---------- HUD ---------- */
.top { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 48px; height: 48px; border-radius: 50%; background: var(--glass); display: grid; place-items: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.icon-btn svg { width: 24px; height: 24px; fill: var(--paper); }
.turn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; height: 52px; border-radius: var(--r-chip);
  background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font: 400 26px/1 var(--font-display); transition: background .3s; }
.turn.sun { background: var(--sun); color: var(--ink); }
.turn.moon { background: var(--moon); color: #fff; }
.ticon { width: 26px; height: 26px; display: none; }
.ticon svg { width: 100%; height: 100%; }
.turn.sun .ticon, .turn.moon .ticon { display: block; }
.score { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; border-radius: 14px; background: var(--glass); min-width: 48px; }
.score .r { display: flex; gap: 4px; justify-content: center; }
.score i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; display: block; opacity: .9; }
.score .sun { color: var(--sun); } .score .moon { color: #b7a5ff; }
.score i.won { background: currentColor; }

.prompt { align-self: center; margin-top: auto; margin-bottom: 10px; padding: 10px 20px; border-radius: var(--r-chip);
  background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font: 400 24px/1 var(--font-display); text-align: center; pointer-events: none; }
.prompt:empty { visibility: hidden; }
.prompt.warn { background: var(--hp-low); color: #fff; }

.sheet { display: flex; flex-direction: column; gap: 10px; }
.sheet:empty { display: none; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chips.six { grid-template-columns: repeat(6, 1fr); gap: 6px; }
.chip { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 8px;
  border-radius: 18px; background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 3px solid transparent; transition: transform .15s, border-color .15s, opacity .2s; }
.chip .face { width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.9); display: grid; place-items: center; overflow: hidden; }
.chips.six .chip .face { width: 40px; height: 40px; }
.chip .face img { width: 100%; height: 100%; object-fit: cover; }
.chip .face svg { width: 60%; height: 60%; }
.chip .nm { font: 400 16px/1 var(--font-display); white-space: nowrap; }
.chips.six .chip .nm { font-size: 12px; }
.chip .bar { width: 82%; height: 8px; border-radius: 4px; background: rgba(0,0,0,.35); overflow: hidden; }
.chip .bar b { display: block; height: 100%; background: var(--hp-high); border-radius: 4px; transition: width .4s; }
.chip .bar b.low { background: var(--hp-low); }
.chip .cd { position: absolute; top: 4px; right: 6px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--ink);
  font-size: 13px; display: grid; place-items: center; padding: 0 5px; }
.chip .lv { position: absolute; top: 4px; left: 6px; font: 400 13px/1 var(--font-display); color: var(--sun); }
.chip .tick { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--hp-high);
  display: grid; place-items: center; }
.chip .tick svg { width: 14px; height: 14px; fill: none; stroke: var(--ink); stroke-width: 4; }
.chip.sun { border-color: color-mix(in srgb, var(--sun) 35%, transparent); }
.chip.moon { border-color: color-mix(in srgb, var(--moon) 45%, transparent); }
.chip.sel.sun { border-color: var(--sun); transform: translateY(-6px); background: color-mix(in srgb, var(--sun) 35%, var(--ink)); }
.chip.sel.moon { border-color: #a58cff; transform: translateY(-6px); background: color-mix(in srgb, var(--moon) 45%, var(--ink)); }
.chip.out { opacity: .35; }
.chip.ko { opacity: .35; filter: grayscale(1); }
.chip.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translateY(-4px); } }

.actions { display: flex; flex-direction: column; gap: 8px; }
.actions:empty { display: none; }
.act-row { display: flex; gap: 8px; }
.act-row > * { flex: 1; }
.act { min-height: var(--tap); border-radius: var(--r-btn); display: flex; align-items: center; justify-content: center; gap: 8px;
  font: 400 24px/1 var(--font-display); background: rgba(255,247,232,.16); color: var(--paper);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: transform .12s; padding: 0 10px; }
.act:active { transform: scale(.96); }
.act.hit { min-height: 72px; font-size: 28px; background: var(--fire); color: #fff; box-shadow: 0 5px 0 #a8341a; }
.act.go { min-height: 72px; font-size: 30px; background: var(--sun); color: var(--ink); box-shadow: 0 5px 0 var(--sun-deep); }
.act.go.moon { background: var(--moon); color: #fff; box-shadow: 0 5px 0 var(--moon-deep); }
.act[disabled] { opacity: .4; pointer-events: none; }
.act .tag { font: 900 15px/1 var(--font-text); padding: 4px 8px; border-radius: 10px; background: rgba(255,255,255,.25); }
.act .mini { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.9); overflow: hidden; flex: none; display: grid; place-items: center; }
.act .mini img { width: 100%; height: 100%; object-fit: cover; }
.act .mini svg { width: 60%; height: 60%; }
.act .ic { width: 26px; height: 26px; flex: none; }

/* marks over the 3D view (positioned by main.js) */
.mk { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); will-change: transform; pointer-events: none; }
.hp { width: 46px; height: 9px; border-radius: 5px; background: rgba(20, 12, 28, .7); padding: 2px; border: 1.5px solid rgba(255,255,255,.7); }
.hp b { display: block; height: 100%; border-radius: 3px; background: var(--hp-high); transition: width .35s; }
.hp b.low { background: var(--hp-low); }
.hp.sun { border-color: var(--sun); } .hp.moon { border-color: #a58cff; }
.hp .shield { position: absolute; right: -14px; top: -6px; width: 16px; height: 16px; }
.pop { font: 400 30px/1 var(--font-display); color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.45), 0 0 10px rgba(0,0,0,.4);
  animation: pop 1.3s ease-out forwards; white-space: nowrap; text-align: center; }
.pop small { display: block; font: 900 14px/1.1 var(--font-text); color: var(--sun); }
.pop.heal { color: var(--hp-high); }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -60%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -110%) scale(1.15); }
  70% { opacity: 1; transform: translate(-50%, -160%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -200%) scale(1); } }
.back { font: 400 15px/1 var(--font-display); background: var(--hp-low); color: #fff; padding: 6px 10px; border-radius: 12px; }

.banner { position: fixed; left: 0; right: 0; top: 34%; padding: 22px 16px; text-align: center; pointer-events: none;
  font: 400 clamp(40px, 12vw, 64px)/1 var(--font-display); animation: banner 1.6s ease-out forwards; }
.banner.sun { background: var(--sun); color: var(--ink); }
.banner.moon { background: var(--moon); color: #fff; }
.banner small { display: block; font: 800 18px/1.3 var(--font-text); margin-top: 6px; }
.banner.stay { animation: bannerIn .4s ease-out forwards; }
@keyframes banner { 0% { transform: scaleY(0); } 12% { transform: scaleY(1.05); } 18%, 80% { transform: scaleY(1); opacity: 1; } 100% { opacity: 0; transform: scaleY(.9); } }
@keyframes bannerIn { 0% { transform: scaleY(0); } 70% { transform: scaleY(1.05); } 100% { transform: scaleY(1); } }

.debug { position: fixed; left: 8px; top: 70px; font: 11px/1.3 ui-monospace, monospace; background: rgba(0,0,0,.6); padding: 6px 8px;
  border-radius: 8px; white-space: pre; pointer-events: none; color: #cfe; }

/* scanning frame */
.scanframe { position: absolute; left: 50%; top: 46%; width: 78vw; aspect-ratio: 297 / 210; transform: translate(-50%, -50%);
  pointer-events: none; }
.scanframe i { position: absolute; width: 36px; height: 36px; border: 5px solid var(--paper); opacity: .9; animation: breathe 1.6s ease-in-out infinite; }
.scanframe i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.scanframe i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 12px 0 0; }
.scanframe i:nth-child(3) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }
.scanframe i:nth-child(4) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 12px; }
@keyframes breathe { 50% { transform: scale(1.12); } }

.tgt { display: flex; justify-content: center; margin-bottom: 2px; animation: bob .7s ease-in-out infinite; }
.tgt svg { width: 22px; height: 15px; fill: var(--fire); stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.mk > .hp { position: relative; }
