:root {
  --bg: #0a0a0c;
  --panel: #141417;
  --line: #2a2a30;
  --bone: #e9e5db;
  --dim: #8d8a83;
  --red: #c8102e;
  --red-hot: #ff2b4a;
  --ok: #7fbf8e;
  --mincho: 'Shippori Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --sans: -apple-system, 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Noto Sans Mono CJK JP', monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html { background: var(--bg); color-scheme: dark; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(120% 80% at 50% 0%, #17171b 0%, var(--bg) 60%);
  color: var(--bone);
  font: 16px/1.7 var(--sans);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow-x: hidden;
}
/* 走査線 */
body::after {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px);
}
body.danger::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 40;
  box-shadow: inset 0 0 120px 20px rgba(200, 16, 46, .45);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }
body.shake { animation: shake .45s; }
@keyframes shake {
  10%, 50%, 90% { transform: translate(-6px, 2px); }
  30%, 70% { transform: translate(6px, -2px); }
}

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 45; opacity: 0; }
#fx.hit { animation: fade 1.1s ease-out; --peak: .95;
  background:
    radial-gradient(circle at 18% 22%, #8c0016 0 38px, transparent 40px),
    radial-gradient(circle at 24% 30%, #8c0016 0 14px, transparent 16px),
    radial-gradient(circle at 78% 18%, #8c0016 0 26px, transparent 28px),
    radial-gradient(circle at 86% 30%, #8c0016 0 10px, transparent 12px),
    radial-gradient(circle at 70% 82%, #8c0016 0 44px, transparent 46px),
    radial-gradient(circle at 60% 90%, #8c0016 0 12px, transparent 14px),
    radial-gradient(circle at 12% 78%, #8c0016 0 22px, transparent 24px),
    radial-gradient(circle at 40% 8%, #8c0016 0 18px, transparent 20px),
    rgba(200, 16, 46, .35); }
#fx.strike { background: #fff; animation: fade .25s ease-out; --peak: .18; }
#fx.warn { background: var(--red); animation: fade .3s ease-out; --peak: .2; }
#fx.boom { background: #fff; animation: boom 1.2s ease-out; }
@keyframes fade { from { opacity: var(--peak, .55); } to { opacity: 0; } }
@keyframes boom { 0% { opacity: 1; } 15% { opacity: 1; background: #fff; } 40% { background: var(--red); opacity: .7; } 100% { opacity: 0; background: var(--red); } }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px 72px; }
section { display: flex; flex-direction: column; gap: 14px; }

h1, h2, h3, .stamp, .code, .say, .examiner p { font-family: var(--mincho); }
h1 { margin: 0; text-align: center; color: var(--bone); line-height: 1; }
h1 small { display: block; font-size: clamp(16px, 5vw, 22px); letter-spacing: .5em; margin-left: .5em; color: var(--dim); font-weight: 500; }
h1 span { display: block; font-size: clamp(64px, 21vw, 120px); letter-spacing: .08em; margin-left: .08em; text-shadow: 3px 0 var(--red); }
h1 b { color: var(--red-hot); text-shadow: 3px 0 #500; }
h2 { font-size: 30px; margin: 0; letter-spacing: .08em; }
h2.ok { color: var(--ok); }
h2.ng { color: var(--red-hot); }
h3 { text-align: left; margin: 18px 0 0; font-size: 20px; border-left: 3px solid var(--red); padding-left: 10px; }
.label { color: var(--dim); font-size: 12px; letter-spacing: .2em; margin: 0; }
.sub { text-align: center; color: var(--red-hot); letter-spacing: .3em; font-size: 13px; margin: -8px 0 0; }
.say { text-align: center; color: var(--dim); margin: 6px 0; }
.notice { color: var(--red-hot); text-align: center; margin: 0; }
.wait { color: var(--dim); text-align: center; min-height: 1.7em; margin: 0; font-size: 14px; }
.keys { color: var(--dim); text-align: center; font-size: 12px; margin: 0; }
@media (hover: none) { .keys { display: none; } }

button, input {
  font: inherit; color: inherit;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 14px 16px; min-height: 52px;
}
button { cursor: pointer; transition: transform .06s, border-color .15s, background .15s; touch-action: manipulation; }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; letter-spacing: .15em; }
button.primary:disabled { background: #3a1018; border-color: #3a1018; }
button.ghost { background: none; border: none; color: var(--dim); text-decoration: underline; }
input { width: 100%; text-align: center; letter-spacing: .1em; }
input:focus { outline: 2px solid var(--red); }
input.bad { border-color: var(--red-hot); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.row button { flex: 0 0 96px; }
.or { text-align: center; color: var(--dim); font-size: 12px; letter-spacing: .3em; margin-top: 10px; }

.mask { width: 92px; display: block; margin: 8px auto 0; filter: drop-shadow(0 6px 18px rgba(200,16,46,.35)); }
.title { padding-top: 4vh; }

/* 待合室 */
.code { font-size: 56px; text-align: center; letter-spacing: .25em; line-height: 1.1; color: var(--bone); }
#seats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seat { border: 1px dashed var(--line); border-radius: 4px; padding: 10px 12px; display: flex; flex-direction: column; color: var(--dim); }
.seat.on { border-style: solid; color: var(--bone); background: var(--panel); }
.seat .num { font-size: 11px; letter-spacing: .15em; color: var(--dim); }
.seat em { font-style: normal; font-size: 11px; color: var(--red-hot); }
#config, #go { display: flex; flex-direction: column; gap: 8px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button { padding: 8px 4px; font-size: 13px; min-height: 44px; }
.seg button.on, .game.on { border-color: var(--red); background: #1f0d12; opacity: 1; }
.games { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.game { text-align: left; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: baseline; padding: 10px; }
.game .no { font-family: var(--mincho); color: var(--red-hot); font-size: 20px; grid-row: span 2; }
.game small { color: var(--dim); font-size: 11px; line-height: 1.4; }
.game:not(.on) b { color: var(--dim); text-decoration: line-through; }

/* 上の帯 */
#bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: rgba(10,10,12,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
#hud { max-width: 640px; margin: 0 auto; padding: 6px 12px 8px; display: flex; flex-direction: column; gap: 6px; }
.sides { display: grid; grid-template-columns: 1fr 1fr; }
.who.me { padding-right: 10px; border-right: 1px solid var(--line); }
.who.foe { padding-left: 10px; }
.who { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.who.foe { text-align: right; }
.toprow { display: flex; align-items: baseline; gap: 8px; position: relative; }
.who.foe .toprow { flex-direction: row-reverse; }
.who .name { flex: 1; min-width: 0; font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who.me .name { color: var(--bone); }
.who.off .name { color: var(--red-hot); }
.who .n { font-family: var(--mincho); font-size: 28px; line-height: 1; font-weight: 800; color: var(--bone); }
.who .n small { font-size: 11px; color: var(--dim); margin-left: 3px; font-weight: 500; }
.who.me .n { color: var(--red-hot); }
.who.low .n { animation: pulse 1s ease-in-out infinite; }
.cells { display: flex; gap: 3px; }
.who.foe .cells { flex-direction: row-reverse; }
.cells i { flex: 1; height: 16px; background: #1e1e23; border: 1px solid #2c2c33; border-radius: 2px; }
.cells i.on { background: linear-gradient(180deg, #f3efe4, #c9c4b6); border-color: #e9e5db; }
.who.me .cells i.on { background: linear-gradient(180deg, #ff5a72, #b80d28); border-color: #ff8a9a; box-shadow: 0 0 6px rgba(255,43,74,.55); }
.who.low .cells i.on { animation: pulse .8s ease-in-out infinite; }
.cells i.gone { animation: gone .9s ease-out; }
@keyframes gone { 0% { background: #fff; transform: scale(1.6); } 100% { background: #1e1e23; transform: scale(1); } }
.dmg { position: absolute; right: 0; top: -4px; font: 800 22px var(--mincho); color: var(--red-hot); animation: dmg 1.2s ease-out forwards; pointer-events: none; }
.who.foe .dmg { right: auto; left: 0; }
@keyframes dmg { 0% { opacity: 1; transform: translateY(0) scale(1.4); } 100% { opacity: 0; transform: translateY(-26px) scale(1); } }
.chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
#timer { height: 4px; background: #1d1d21; }
#timer i { display: block; height: 100%; background: var(--bone); width: 0; margin: 0 auto; }
#timer.urgent i { background: var(--red-hot); }

/* 試験官 */
.examiner { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--red); padding: 10px 12px; border-radius: 4px; }
.examiner .mask { width: 44px; margin: 0; filter: none; }
.examiner p { margin: 0; font-size: 15px; line-height: 1.6; }

/* 問題 */
.qhead { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); letter-spacing: .1em; }
.qhead .cat, .hint .cat { color: var(--red-hot); }
.qtext { font-size: 18px; line-height: 1.75; margin: 0; white-space: pre-wrap; }
.qtext.small { font-size: 15px; }
.qtext.dim { color: var(--dim); }
.qtext.typing { min-height: 7em; }
.qtext.typing::after { content: '▍'; color: var(--red-hot); animation: pulse .8s steps(2) infinite; }
.cut { color: var(--dim); }
.code { }
pre.code { font: 13px/1.55 var(--mono); letter-spacing: 0; text-align: left; background: #050506; border: 1px solid var(--line); border-radius: 4px; padding: 12px; margin: 0; overflow-x: auto; white-space: pre; color: #d6d2c8; }
.decode pre.code, .reveal pre.code { font-size: 12.5px; }

.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; text-align: left; line-height: 1.5; }
.choice .key { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; font-size: 13px; color: var(--dim); }
.choice.chosen { border-color: var(--bone); background: #24242a; opacity: 1; }
.choice.chosen .key { background: var(--bone); color: var(--bg); }
.choice.struck { text-decoration: line-through; }
.choices.done .choice { border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; color: var(--dim); background: none; }
.choices.done .choice.right { color: var(--bone); border-color: var(--ok); }
.choices.done .choice.right .key { background: var(--ok); color: var(--bg); border-color: var(--ok); }
.chip { font-style: normal; font-size: 11px; border-radius: 99px; padding: 1px 8px; margin-left: 4px; white-space: nowrap; border: 1px solid; }
.chip.ok { color: var(--ok); }
.chip.ng { color: var(--red-hot); }
.count { text-align: center; color: var(--dim); margin: 0; font-size: 13px; }
.count span { font-family: var(--mincho); font-size: 26px; color: var(--bone); }

/* 早押し */
.buzzer { width: 168px; height: 168px; border-radius: 50%; margin: 8px auto 0; background: radial-gradient(circle at 35% 30%, #ff5a72, var(--red) 55%, #6d0818); border: 6px solid #2a0a10; color: #fff; font: 800 34px var(--mincho); letter-spacing: .2em; box-shadow: 0 10px 0 #2a0a10, 0 18px 40px rgba(200,16,46,.45); }
.buzzer:active { transform: translateY(8px) !important; box-shadow: 0 2px 0 #2a0a10; }

/* 単位ベット・押し付け */
.hint { display: flex; justify-content: space-between; border: 1px solid var(--line); padding: 14px; border-radius: 4px; font-size: 18px; }
.hint .lv { color: var(--bone); }
.bets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice.bet { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 18px 0; }
.choice.bet b { font: 800 40px/1 var(--mincho); }
.choice.bet small { color: var(--dim); }
.choice.bet.chosen { border-color: var(--red-hot); background: #1f0d12; }
.pick .choice { grid-template-columns: 1fr; text-align: center; font-size: 18px; padding: 18px; }
.stakes { display: flex; justify-content: space-between; font-size: 13px; color: var(--red-hot); }

/* 解読室 */
.gas { background: #1f0d12; border: 1px solid var(--red); color: var(--red-hot); text-align: center; padding: 8px; border-radius: 4px; animation: pulse 1s infinite; }

/* 時限爆弾 */
.bombbox { text-align: center; }
.bombbox .ball { width: 96px; height: 96px; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4a4a52, #111 60%); display: grid; place-items: center; font: 800 36px var(--mincho); color: var(--red-hot); animation: throb 1s ease-in-out infinite; box-shadow: 0 0 0 0 rgba(255,43,74,.5); }
.bombbox[data-heat='1'] .ball { animation-duration: .65s; }
.bombbox[data-heat='2'] .ball { animation-duration: .38s; }
.bombbox[data-heat='3'] .ball { animation-duration: .2s; background: radial-gradient(circle at 35% 30%, #7a2030, #200 60%); }
.bombbox:not(.mine) .ball { opacity: .45; transform: scale(.8); }
.bombbox p { margin: 8px 0 0; font-family: var(--mincho); }
.bombbox.mine p { color: var(--red-hot); }
@keyframes throb { 50% { transform: scale(1.12); box-shadow: 0 0 30px 6px rgba(255,43,74,.45); } }
#bombq { display: flex; flex-direction: column; gap: 12px; }
.bombnote { margin: 0; text-align: center; font-size: 14px; }
.bombnote.ok { color: var(--ok); }
.bombnote.ng { color: var(--red-hot); }

/* 説明・結果 */
.intro { padding-top: 5vh; text-align: center; }
.intro h2 { font-size: 44px; text-shadow: 2px 0 var(--red); animation: slam .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes slam { from { transform: scale(2.4); opacity: 0; } }
.intro .examiner { text-align: left; }
.rules { text-align: left; margin: 0; padding: 0 0 0 1.2em; color: var(--bone); }
.rules li { margin: 6px 0; }
.rules li::marker { color: var(--red-hot); }
.deltas { display: flex; gap: 8px; }
.deltas span { flex: 1; text-align: center; border: 1px solid var(--line); border-radius: 4px; padding: 8px; color: var(--dim); font-size: 14px; }
.deltas .minus { color: var(--red-hot); border-color: var(--red); background: #1f0d12; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card .exp { margin: 0; font-size: 14px; color: #c9c5bb; border-top: 1px dashed var(--line); padding-top: 10px; }
.card .ans { margin: 0; color: var(--ok); font-size: 14px; }
details.card summary { cursor: pointer; font-size: 14px; line-height: 1.6; }
details.card summary .chip { margin: 0 6px 0 0; }
details.card.miss { border-color: var(--red); }

/* 決着 */
.over { text-align: center; }
.stampbox { padding: 6vh 0 2vh; visibility: hidden; }
.over.show .stampbox { visibility: visible; }
.over.show .stamp { animation-play-state: running; }
.stamp { display: inline-block; animation-play-state: paused; font-size: clamp(56px, 20vw, 96px); font-weight: 800; letter-spacing: .1em; padding: 4px 24px; border: 8px double currentColor; border-radius: 10px; transform: rotate(-8deg); animation: slam .4s cubic-bezier(.2, 1.6, .4, 1) both; line-height: 1.3; }
.over.lost .stamp { color: var(--red-hot); text-shadow: 3px 0 #500, -3px 0 #033; animation: slam .4s cubic-bezier(.2, 1.6, .4, 1) both, glitch 2.4s steps(1) 1s infinite; }
.over.won .stamp { color: var(--ok); }
@keyframes glitch {
  0%, 100% { clip-path: none; transform: rotate(-8deg); }
  4% { clip-path: inset(20% 0 40% 0); transform: rotate(-8deg) translateX(-8px); }
  8% { clip-path: inset(60% 0 5% 0); transform: rotate(-8deg) translateX(8px); }
  12% { clip-path: none; transform: rotate(-8deg); }
}
.over .card { text-align: left; }
.stats { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats th, .stats td { border-bottom: 1px solid var(--line); padding: 8px 4px; text-align: center; font-weight: 400; }
.stats tr:first-child th { color: var(--dim); font-size: 12px; }

#foot { position: fixed; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 35; display: flex; gap: 8px; align-items: center; }
#net { color: var(--red-hot); font-size: 12px; }
#mute { min-height: 0; padding: 4px 10px; font-size: 11px; color: var(--dim); background: rgba(20,20,23,.85); }

@media (prefers-reduced-motion: reduce) {
  body.shake, .bombbox .ball, .over.lost .stamp, body.danger::before { animation: none; }
}

/* 出題前の数え */
.count-overlay { position: fixed; inset: 0; z-index: 38; display: grid; place-items: center; background: rgba(10,10,12,.97); font: 800 clamp(120px, 40vw, 220px)/1 var(--mincho); color: var(--red-hot); text-shadow: 0 0 40px rgba(255,43,74,.6); animation: pop .9s ease-out; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } 20% { opacity: 1; transform: scale(1); } }
.choice[data-locked], #buzzer[data-locked] { pointer-events: none; }

/* 戦績・連続 */
.record { text-align: center; color: var(--dim); font-size: 13px; margin: 0; letter-spacing: .05em; }
.streak { font-style: normal; color: var(--red-hot); font-size: 11px; margin-left: 6px; }
.cats { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.catrow { display: grid; grid-template-columns: 1fr 100px 40px; gap: 8px; align-items: center; font-size: 13px; }
.catname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--bone); }
.catbar { height: 8px; background: #1d1d21; border-radius: 2px; overflow: hidden; }
.catbar i { display: block; height: 100%; background: var(--ok); }
.catbar i.low { background: var(--red-hot); }
.catnum { text-align: right; color: var(--dim); }

/* 処刑 */
.veil { position: fixed; inset: 0; z-index: 60; background: #000; display: grid; place-items: center; animation: veil-in .6s; }
.veil p { font: 500 clamp(22px, 6vw, 34px) var(--mincho); letter-spacing: .3em; color: var(--bone); margin: 0; animation: veil-text 2s steps(12) both; overflow: hidden; white-space: nowrap; }
.veil.drop { animation: veil-out 1.2s forwards; }
@keyframes veil-in { from { opacity: 0; } }
@keyframes veil-text { from { width: 0; } to { width: 8.4em; } }
@keyframes veil-out { 30% { opacity: 1; background: #3a0008; } 100% { opacity: 0; } }

.source { margin: 0; font-size: 11px; color: var(--dim); }
.fine { font-size: 11px; color: var(--dim); text-align: center; line-height: 1.6; margin: 24px 0 0; }

/* 処刑方法の宣告 */
.brief { border: 1px solid var(--red); background: #140609; padding: 14px; border-radius: 4px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.brief h2 { font-size: 34px; color: var(--red-hot); text-shadow: none; animation: none; }
.brief .fine { margin: 0; }
.seg.six { grid-template-columns: repeat(3, 1fr); }

/* 処刑映像 */
.exec { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; }
.exec .rec { display: flex; align-items: center; gap: 8px; color: var(--red-hot); font-size: 13px; letter-spacing: .2em; font-family: var(--mincho); }
.exec .rec i { width: 12px; height: 12px; border-radius: 50%; background: var(--red-hot); animation: pulse 1s steps(2) infinite; }
.cam { width: 100%; aspect-ratio: 3 / 4; max-height: 55vh; object-fit: cover; background: #111; border: 2px solid #333; border-radius: 4px; filter: contrast(1.1) saturate(.6) sepia(.2); }
.cam.mirror { transform: scaleX(-1); }
.act-say { font-family: var(--mincho); font-size: 18px; margin: 0; color: var(--bone); }
.act-sub { margin: 0; color: var(--dim); font-size: 14px; }
.act-left { font-family: var(--mincho); font-size: 24px; color: var(--red-hot); }

.exec { justify-content: center; text-align: center; }
.exec .gag { font-size: clamp(48px, 17vw, 110px); letter-spacing: .05em; color: var(--red-hot); text-shadow: 4px 0 #500; animation: slam .35s cubic-bezier(.2, 1.6, .4, 1); }
.exec .examiner { text-align: left; }

.fine.links a { color: var(--dim); }
.page { max-width: 640px; margin: 0 auto; padding: 24px 16px 64px; }
.page h1 { font-size: 28px; text-align: left; letter-spacing: .1em; text-shadow: none; margin-bottom: 8px; }
.page h2 { font-size: 18px; margin-top: 28px; border-left: 3px solid var(--red); padding-left: 10px; }
.page p, .page li { font-size: 15px; color: #d6d2c8; }
.page a { color: var(--bone); }
.page .updated { color: var(--dim); font-size: 12px; }
