/* ====== 人間認定試験 — クラシック CRT / ドット絵スタイル ====== */
:root {
  --bg: #0b0b12; --bg2: #13131d; --panel: #171724; --line: #5c5c84; --white: #f1f1f8; --text: #e4e4ee; --muted: #8d8daa;
  --green: #58f898; --magenta: #f878f8; --yellow: #f8b800; --red: #f85858; --cyan: #3cbcfc;
  --jp: "DotGothic16", "Zen Kaku Gothic New", "Hiragino Sans", sans-serif; --px: "Press Start 2P", "DotGothic16", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--jp); font-size: 18px; color: var(--text); background: var(--bg);
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 24px 24px; overflow: hidden; image-rendering: pixelated; -webkit-font-smoothing: none;
}
body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 200; background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 160px rgba(0,0,0,.65); }
#app { height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }
button { font-family: var(--jp); cursor: pointer; }

.win { background: var(--panel); border: 3px solid var(--white); box-shadow: inset 0 0 0 2px var(--bg), inset 0 0 0 4px var(--line), 6px 6px 0 #000; }
.pxbtn { font-family: var(--jp); font-size: 18px; color: var(--white); background: var(--bg2); border: 3px solid var(--white); box-shadow: 4px 4px 0 #000; padding: 10px 18px; }
.pxbtn:hover { background: #22223a; }
.pxbtn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000; }
.pxbtn.primary { background: var(--green); color: #0b0b12; }
.pxbtn.primary:hover { background: #8dffb8; }
.pxbtn.big { font-size: 24px; padding: 16px 36px; }
.pxbtn.ghost { color: var(--muted); border-color: var(--line); box-shadow: none; }
.pxbtn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.px-robot { display: inline-block; vertical-align: middle; }
.px-eye { transform-box: fill-box; transform-origin: center; animation: pxblink 5s steps(1) infinite; }
.px-lamp { animation: pxlamp 1.2s steps(1) infinite; }
.px-idle { animation: bob 1.2s steps(2) infinite; }
.px-dead .px-eye { opacity: .15; animation: none; }
@keyframes pxblink { 0%, 92% { transform: scaleY(1); } 93%, 97% { transform: scaleY(.1); } 98%, 100% { transform: scaleY(1); } }
@keyframes pxlamp { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .25; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes slidein { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; border-bottom: 3px solid var(--line); background: #000; }
.logo { white-space: nowrap; font-family: var(--px); font-size: 12px; color: var(--green); text-shadow: 3px 3px 0 #0a3a1c; }
.logo .jp { font-family: var(--jp); font-size: 22px; margin-left: 10px; color: var(--white); text-shadow: 3px 3px 0 #2a2a44; }
.topbar-center { display: flex; gap: 10px; }
.pill { white-space: nowrap; font-family: var(--px); font-size: 10px; padding: 8px 12px; border: 3px solid var(--line); background: var(--bg2); color: var(--white); }
.pill-phase { border-color: var(--yellow); color: var(--yellow); font-family: var(--jp); font-size: 16px; padding: 5px 12px; }
.icon-btn { background: var(--bg2); border: 3px solid var(--line); color: var(--text); padding: 4px 10px; font-size: 16px; }

/* ---------- screens */
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#lobby, #rules, #resultScreen { align-items: center; justify-content: center; overflow: auto; padding: 16px; }
.lobby-card { max-width: 760px; width: 100%; padding: 34px 36px; text-align: center; }
.lobby-card h1 { margin: 0 0 6px; font-family: var(--px); font-size: 16px; color: var(--green); text-shadow: 4px 4px 0 #0a3a1c; }
.lobby-card h1 .jp { display: block; font-family: var(--jp); font-size: 44px; color: var(--white); text-shadow: 4px 4px 0 #2a2a44; margin-top: 10px; }
.lobby-bots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 10px; }
.lobby-bots .px-robot:nth-child(2n) { animation-delay: .6s; }
.tagline { color: var(--muted); line-height: 1.7; margin: 0 0 18px; }
.rules { text-align: left; margin: 0 auto 22px; padding: 14px 18px 14px 36px; color: var(--text); line-height: 1.8; background: #000; border: 2px solid var(--line); }
.rules b { color: var(--yellow); }
.lobby-buttons { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 14px; margin-top: 18px; line-height: 1.6; }

/* ---------- story */
#story { align-items: center; justify-content: center; cursor: pointer; padding: 16px; }
.story-inner { width: min(860px, 100%); height: min(640px, 100%); background: #000; border: 3px solid var(--line); box-shadow: inset 0 0 0 2px #0b0b12, inset 0 0 0 4px #2a2a44, 0 0 60px rgba(88,248,152,.08); display: flex; flex-direction: column; padding: 22px 28px; }
.story-head { font-family: var(--px); font-size: 11px; color: var(--green); border-bottom: 2px dashed var(--line); padding-bottom: 12px; margin-bottom: 16px; }
.story-head span { font-family: var(--jp); font-size: 15px; color: var(--muted); }
.story-text { flex: 1; overflow-y: auto; font-size: 20px; line-height: 1.9; white-space: pre-wrap; }
.story-para { margin-bottom: 22px; }
.story-text { scroll-behavior: smooth; }
.story-para:not(.done)::after { content: "▮"; color: var(--green); animation: blink .5s steps(1) infinite; }
.story-para.done:last-child::after { content: " ▼"; color: var(--green); animation: blink .8s steps(1) infinite; }
.story-foot { display: flex; justify-content: space-between; align-items: center; border-top: 2px dashed var(--line); padding-top: 12px; margin-top: 12px; }
.story-hint { color: var(--muted); font-size: 14px; }

/* ---------- exam */
#exam { padding: 14px 18px; overflow: auto; }
.exam-grid { display: grid; grid-template-columns: 1fr 300px; gap: 14px; flex: 1; min-height: 0; }
.exam-main { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.examiner { display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 12px 16px; align-items: center; }
.ex-sprite { background: #000; border: 3px solid var(--green); display: grid; place-items: center; height: 96px; }
.ex-name { font-family: var(--px); font-size: 9px; color: var(--green); margin-bottom: 6px; }
.ex-text { font-size: 19px; line-height: 1.6; min-height: 48px; }
.ex-text.typing::after { content: "▮"; color: var(--green); animation: blink .5s steps(1) infinite; }
.question { padding: 12px 18px; font-size: 24px; color: var(--white); animation: slidein .2s steps(2); }
.question small { display: block; font-family: var(--px); font-size: 9px; color: var(--yellow); margin-bottom: 8px; letter-spacing: .05em; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt { position: relative; text-align: left; font-size: 19px; padding: 12px 14px 12px 48px; min-height: 64px; line-height: 1.4; }
.opt .key { position: absolute; left: 12px; top: 10px; font-family: var(--px); font-size: 14px; color: var(--yellow); }
.opt.picked { border-color: var(--cyan); background: #0e2434; }
.opt.correct { border-color: var(--green); background: #0f2a1a; }
.opt.wrong { border-color: var(--red); background: #2a0f12; animation: shake .3s steps(3); }
.opt .marks { position: absolute; right: 8px; bottom: 6px; display: flex; gap: 3px; }
.opt .marks span { width: 20px; height: 20px; background: #000; border: 2px solid var(--c); display: grid; place-items: center; }
.opt:disabled { cursor: default; transform: none; box-shadow: 4px 4px 0 #000; }
.timerwrap { display: flex; align-items: center; gap: 12px; }
.timerbar { flex: 1; height: 10px; background: #000; border: 2px solid var(--line); overflow: hidden; }
.timerbar i { display: block; height: 100%; width: 100%; background: repeating-linear-gradient(90deg, var(--cyan) 0 10px, #000 10px 12px); transition: width .2s linear; }
.timerbar i.urgent { background: repeating-linear-gradient(90deg, var(--red) 0 10px, #000 10px 12px); }
.timer { font-family: var(--px); font-size: 16px; color: var(--cyan); min-width: 54px; text-align: right; }
.timer.urgent { color: var(--red); animation: blink .4s steps(1) infinite; }
.nextwrap { display: flex; justify-content: flex-end; }

.exam-side { min-height: 0; overflow: auto; }
.card { padding: 12px 14px; }
.card-title { font-family: var(--px); font-size: 9px; color: var(--yellow); margin-bottom: 10px; letter-spacing: .05em; }
.card-title small { font-family: var(--jp); font-size: 12px; color: var(--muted); }
.rivals { display: flex; flex-direction: column; gap: 10px; }
.rival { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: start; background: #000; border: 2px solid var(--line); padding: 8px; animation: slidein .2s steps(2); }
.rival.you { border-color: var(--magenta); }
.rival .r-sprite { background: var(--bg2); border: 2px solid var(--c); display: grid; place-items: center; height: 44px; }
.rival .r-name { color: var(--c); font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.rival .r-name small { color: var(--muted); font-size: 11px; }
.rival .r-score { font-family: var(--px); font-size: 10px; color: var(--white); }
.rival .r-say { font-size: 14px; line-height: 1.45; color: var(--text); margin-top: 4px; min-height: 18px; }
.rival .r-say.typing::after { content: "▮"; color: var(--c); animation: blink .5s steps(1) infinite; }
.rival .r-say .pick { color: var(--yellow); font-family: var(--px); font-size: 9px; margin-right: 4px; }
.rival.correct .r-say .pick { color: var(--green); }
.rival.wrong .r-say .pick { color: var(--red); }

/* ---------- banner */
.banner { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 150; }
.banner .b-inner { font-family: var(--jp); font-size: clamp(44px, 8vw, 96px); color: var(--white); text-align: center; text-shadow: 6px 6px 0 #000, 0 0 24px var(--green); background: rgba(0,0,0,.85); padding: 18px 56px; border-top: 4px solid var(--green); border-bottom: 4px solid var(--magenta); animation: bannerIn 1.4s steps(10) forwards; }
.banner .b-inner small { display: block; font-family: var(--px); font-size: 14px; color: var(--yellow); margin-top: 12px; letter-spacing: .2em; }
.banner .b-inner.bad { text-shadow: 6px 6px 0 #000, 0 0 24px var(--red); border-top-color: var(--red); }
@keyframes bannerIn { 0% { transform: scale(.4); opacity: 0; } 15% { transform: scale(1.1); opacity: 1; } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.05); } }

/* ---------- result */
.result-card { max-width: 900px; width: 100%; padding: 32px; text-align: center; }
.result-title { font-family: var(--px); font-size: clamp(24px, 5vw, 48px); animation: pop .3s steps(3); line-height: 1.4; }
.result-title.human { color: var(--green); text-shadow: 6px 6px 0 #0a3a1c; }
.result-title.ai { color: var(--red); text-shadow: 6px 6px 0 #4a1010; }
.result-sub { color: var(--muted); margin: 14px 0 22px; font-size: 18px; line-height: 1.6; }
.cert { margin: 0 auto 22px; max-width: 560px; background: #000; border: 3px solid var(--yellow); padding: 18px 22px; text-align: left; box-shadow: 6px 6px 0 #000; position: relative; }
.cert .c-head { font-family: var(--px); font-size: 10px; color: var(--yellow); letter-spacing: .1em; border-bottom: 2px dashed var(--line); padding: 0 80px 10px 0; margin-bottom: 12px; line-height: 1.6; }
.cert .c-row { display: flex; justify-content: space-between; font-size: 17px; margin: 6px 0; }
.cert .c-row b { color: var(--white); }
.cert .c-rank { font-family: var(--px); font-size: 40px; position: absolute; right: 18px; top: 14px; }
.cert.fail { border-color: var(--red); }
.result-table table { width: 100%; border-collapse: collapse; margin-bottom: 22px; font-size: 16px; background: #000; border: 3px solid var(--line); }
.result-table th, .result-table td { padding: 8px 10px; border-bottom: 2px solid #22223a; }
.result-table th { color: var(--yellow); font-family: var(--px); font-size: 9px; font-weight: normal; }
.result-table td.name { text-align: left; color: var(--c); display: flex; align-items: center; gap: 8px; }
.result-table td.num { font-family: var(--px); font-size: 11px; color: var(--white); }
.result-table .you { background: #2a1030; }
.result-table .dots { font-family: var(--px); font-size: 10px; letter-spacing: 2px; }
.result-table .dots .o { color: var(--green); } .result-table .dots .x { color: var(--red); }

@media (max-width: 900px) {
  .exam-grid { grid-template-columns: 1fr; }
  .exam-side { max-height: 240px; }
  .options { grid-template-columns: 1fr; }
  .logo .jp { display: none; }
}

/* ---------- 問題タイプ別 */
.options.two { grid-template-columns: 1fr 1fr; }
.options.two .opt { min-height: 84px; font-size: 22px; }
.options.yomi { grid-template-columns: 1fr; }
.yomi-row { display: flex; gap: 10px; align-items: stretch; }
.yomi-row input { flex: 1; font-family: var(--jp); font-size: 24px; padding: 10px 14px; background: var(--bg2); color: var(--white); border: 3px solid var(--line); outline: none; caret-color: var(--green); }
.yomi-row input:focus { border-color: var(--white); }
.yomi-row input:disabled { opacity: .7; }
.yomi-hint { color: var(--muted); font-size: 14px; }
.yomi-result { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.yomi-result .ya { background: #000; border: 2px solid var(--line); padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; font-size: 17px; }
.yomi-result .ya.ok { border-color: var(--green); } .yomi-result .ya.ng { border-color: var(--red); }
.yomi-result .ya .who { color: var(--c); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.question .blank { display: inline-block; min-width: 3em; border-bottom: 3px solid var(--yellow); color: var(--yellow); text-align: center; }
.question .kanji { font-size: 40px; display: block; margin: 6px 0 2px; letter-spacing: .1em; }
.story-head.end { color: var(--yellow); }
.story-head.bad { color: var(--red); }

/* ---------- 話し手の肖像 */
.story-stage { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; animation: slidein .2s steps(2); }
.story-stage .st-portrait { width: 84px; height: 84px; background: #000; border: 3px solid var(--line); display: grid; place-items: center; box-shadow: 4px 4px 0 #000; }
.story-stage .st-name { font-family: var(--jp); font-size: 16px; color: var(--yellow); border: 2px solid var(--line); padding: 4px 10px; background: #000; }
.ex-sprite { height: 104px; }
.examiner { grid-template-columns: 104px 1fr; }

.rules li.muted { color: var(--muted); font-size: 13px; }
