/* VIVAT 3D の画面まわり。色は main.js が config の PALETTE から --c-* に流し込む。 */
:root {
  --font-num: "Chakra Petch", "Zen Kaku Gothic New", sans-serif;
  --font-ja: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --c-enemy: #ff3b2f; --c-ally: #35e0ff; --c-heavy: #ff9a1f; --c-gold: #ffd166; --c-white: #ffffff; --c-ok: #7dffb0;
  --ink: #0a0e16;
  --panel: rgba(10, 14, 22, .78);
  --line: rgba(255, 255, 255, .16);
  --dim: rgba(255, 255, 255, .64);
  --cut: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--ink); color: #fff; font-family: var(--font-ja); overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
#app { position: fixed; inset: 0; }
#stage, #hud { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#hud { cursor: crosshair; }
body[data-state="title"] #hud, body[data-state="result"] #hud { pointer-events: none; }

#camera-preview { position: absolute; right: 14px; bottom: calc(14px + var(--safe-bottom)); width: min(22vw, 190px);
  border: 1px solid var(--line); background: #000; opacity: .82; pointer-events: none; }
#camera-preview:empty { display: none; }
#camera-preview video { display: block; width: 100%; height: auto; }
video.mirror { transform: scaleX(-1); }
body:not([data-state="play"]):not([data-state="countdown"]) #camera-preview { display: none; }

#pause { position: absolute; left: 50%; bottom: calc(14px + var(--safe-bottom)); transform: translateX(-50%);
  width: 52px; height: 52px; border: 1px solid var(--line); background: var(--panel); color: #fff;
  font: 700 18px var(--font-num); cursor: pointer; clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px); }

#overlay { position: absolute; inset: 0; display: flex; touch-action: pan-y; }
#overlay[hidden] { display: none; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px;
  padding: calc(22px + var(--safe-top)) clamp(18px, 5vw, 56px) calc(22px + var(--safe-bottom)); }
h1, h2, h3, p, ul, ol, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
.eyebrow { font: 500 clamp(11px, 1.5vw, 14px) var(--font-num); letter-spacing: .32em; color: var(--c-gold); }
.meta { font-size: 14px; color: var(--dim); }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding-right: 4px; }

.btn { min-height: 56px; padding: 0 30px; border: 0; font: 900 20px var(--font-ja); color: #fff; cursor: pointer;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  transition: transform .12s, filter .12s; }
.btn:active { transform: translateY(2px) scale(.98); }
.btn:disabled { filter: grayscale(1) brightness(.55); cursor: default; }
.btn:focus-visible, .seg:focus-visible { outline: 3px solid var(--c-ally); outline-offset: 3px; }
.btn.primary { background: linear-gradient(180deg, var(--c-gold), #f08c1c); color: #1b1204; min-width: 220px; font-size: 24px; min-height: 68px; }
.btn.ghost { background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1px var(--line); backdrop-filter: blur(6px); }
.btn.small { min-height: 44px; padding: 0 18px; font-size: 16px; --cut: 10px; }

/* ---- タイトル */
.title { justify-content: space-between; background:
  linear-gradient(90deg, rgba(6, 9, 16, .86) 0%, rgba(6, 9, 16, .5) 46%, rgba(6, 9, 16, 0) 74%),
  linear-gradient(0deg, rgba(6, 9, 16, .7), rgba(6, 9, 16, 0) 34%); }
.title-block { display: flex; flex-direction: column; gap: clamp(10px, 2.2vh, 20px); margin-top: clamp(0px, 7vh, 80px); max-width: 720px; }
.logo { font: 700 clamp(64px, 15vw, 168px)/.86 var(--font-num); letter-spacing: .04em; color: #fff;
  text-shadow: 0 0 34px rgba(255, 180, 80, .45), 4px 4px 0 rgba(0, 0, 0, .55); }
.logo::after { content: ""; display: block; width: clamp(120px, 22vw, 260px); height: 6px; margin-top: 16px;
  background: linear-gradient(90deg, var(--c-enemy), var(--c-gold)); }
.tagline { font-size: clamp(17px, 2.4vw, 24px); font-weight: 700; word-break: keep-all; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: flex; flex-direction: column; gap: 1px; padding: 7px 14px 8px; background: var(--panel); border-left: 3px solid var(--c-gold); }
.chip b { font-size: 15px; }
.chip span { font-size: 11px; color: var(--dim); }
.chip.off { border-left-color: var(--line); opacity: .45; }
.stage-pick { display: flex; flex-direction: column; gap: 8px; }
.stage-pick h3 { font-size: 13px; color: var(--dim); letter-spacing: .08em; }
.stages { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.stage { width: 100%; min-height: 96px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 9px 12px 10px;
  background: var(--panel); border: 0; border-top: 3px solid var(--line); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.stage i { font: 700 13px var(--font-num); font-style: normal; letter-spacing: .12em; color: var(--c-gold); }
.stage b { font-size: 15px; line-height: 1.3; word-break: keep-all; }
.stage span { font: 500 10px var(--font-num); letter-spacing: .16em; color: var(--dim); }
.stage small { margin-top: auto; font-size: 11px; color: var(--dim); }
.stage.cleared { border-top-color: var(--c-ok); }
.stage[aria-pressed="true"] { border-top-color: var(--c-gold); background: rgba(255, 209, 102, .2); outline: 2px solid var(--c-gold); }
.stage:disabled { opacity: .42; cursor: not-allowed; }
.stage:focus-visible { outline: 3px solid #fff; }
@media (max-width: 900px) { .stages { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stage { min-height: 78px; } }

/* ---- 設定・較正・結果・一時停止の地 */
.settings, .calib, .result, .pause, .message { background: rgba(6, 9, 16, .88); backdrop-filter: blur(10px); }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bar h2, .pause h2 { font-size: clamp(24px, 4vw, 34px); font-weight: 900; }
.group { border: 0; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.group legend { padding: 0 12px 0 0; font-size: 14px; font-weight: 700; color: var(--c-gold); letter-spacing: .1em; }
.set-row { display: grid; grid-template-columns: minmax(150px, 1fr) 2fr; gap: 12px; align-items: center; }
.set-label b { display: block; font-size: 17px; }
.set-label small { display: block; font-size: 12px; color: var(--dim); line-height: 1.5; }
.segs { display: flex; flex-wrap: wrap; gap: 6px; }
.seg { flex: 1 1 78px; min-height: 46px; padding: 0 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .06);
  color: #fff; font: 700 15px var(--font-ja); cursor: pointer; }
.seg[aria-pressed="true"] { background: var(--c-gold); border-color: var(--c-gold); color: #1b1204; }
@media (max-width: 640px) { .set-row { grid-template-columns: 1fr; } }

.calib { align-items: center; text-align: center; }
.calib .bar { align-self: stretch; }
.video-frame { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; align-self: stretch; }
.video-frame video { max-width: 100%; max-height: 100%; width: auto; height: auto; border: 2px solid var(--c-gold); cursor: crosshair; touch-action: none; }
.video-frame.plain video { cursor: default; }
.status { font-size: clamp(17px, 2.6vw, 22px); font-weight: 700; }
.status.good { color: var(--c-ok); }
.calib .row { justify-content: center; }

.pause, .message { align-items: center; justify-content: center; text-align: center; gap: 26px; }
.message p { font-size: 20px; font-weight: 700; line-height: 1.8; max-width: 30em; }

.result-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; border-bottom: 2px solid var(--c-gold); padding-bottom: 12px; }
.result.fail .result-head { border-color: var(--c-enemy); }
.result-head h2 { font: 700 clamp(30px, 6vw, 60px)/1 var(--font-num); letter-spacing: .04em; margin-top: 6px; }
.rank { display: flex; flex-direction: column; align-items: center; min-width: 96px; padding: 6px 14px; background: var(--c-gold); color: #1b1204;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); }
.result.fail .rank { background: #c9d2dc; }
.rank span { font: 700 11px var(--font-num); letter-spacing: .3em; }
.rank b { font: 700 clamp(44px, 7vw, 68px)/1 var(--font-num); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; }
.stat { background: rgba(255, 255, 255, .06); padding: 9px 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.stat span { font-size: 12px; color: var(--dim); }
.stat b { font: 700 24px var(--font-num); }
.rts { display: flex; flex-direction: column; gap: 6px; }
.rt { display: grid; grid-template-columns: 10em 1fr 6.5em; gap: 10px; align-items: center; font-size: 14px; }
.rt i, .meter { display: block; height: 8px; background: rgba(255, 255, 255, .12); }
.rt em, .meter em { display: block; height: 100%; background: var(--c-ally); }
.rt b { font: 700 16px var(--font-num); text-align: right; }
.result h3 { font-size: 16px; color: var(--c-gold); letter-spacing: .08em; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.card { background: rgba(255, 255, 255, .07); border-top: 3px solid var(--c-gold); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.card-head b { display: block; font-size: 15px; white-space: nowrap; }
.card-head span { font-size: 12px; color: var(--dim); }
.card-score { font: 700 46px/1 var(--font-num); }
.meter em { background: linear-gradient(90deg, var(--c-gold), var(--c-ok)); }
.card small { font-size: 12px; color: var(--dim); line-height: 1.5; min-height: 1.5em; word-break: keep-all; }
.card.idle { border-top-color: var(--line); opacity: .55; }
.card.idle .card-score { font: 700 18px/2.55 var(--font-ja); }

@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }
