﻿/* 番号、あった？：夜の自習室（濃紺）＋方眼ノート＋蛍光ペン */
:root {
  --night: #0e1726;
  --night2: #16233a;
  --paper: #f5f8fc;
  --grid: #dde6f1;
  --ink: #1b2433;
  --ink-soft: #5b6779;
  --red: #e5484d;
  --yellow: #ffe94d;
  --green: #7cf08a;
  --pink: #ff7ac8;
  --gold1: #ffe27a;
  --gold2: #ffb300;
  --rainbow: linear-gradient(90deg, #ff5f6d, #ffc371, #f9f871, #7cf08a, #4fc3f7, #b388ff, #ff7ac8);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", "Meiryo", sans-serif;
  --pad-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--night); color: #fff; font-family: var(--font); }
body { overscroll-behavior: none; }
/* 画面揺れの演出で #app ごと動いても、横スクロールが出ないように（clip はスクロール領域を作らない） */
html, body { overflow-x: clip; }
body.in-x { --pad-bottom: calc(env(safe-area-inset-bottom, 0px) + 56px); }
button { font-family: inherit; cursor: pointer; }
#app { max-width: 440px; margin: 0 auto; min-height: 100dvh; position: relative; overflow: hidden; user-select: none; -webkit-user-select: none; }
.screen { display: none; min-height: 100dvh; padding: 16px 16px calc(16px + var(--pad-bottom)); }
.screen.active { display: flex; flex-direction: column; }
.fine { font-size: 11px; color: #8d9ab0; line-height: 1.6; margin: 10px 0 0; }
.center { text-align: center; }

/* ボタン */
.btn-main {
  width: 100%; border: 0; border-radius: 12px; padding: 18px 16px; font-size: 19px; font-weight: 800; letter-spacing: .04em;
  color: var(--ink); background: var(--yellow); box-shadow: 0 5px 0 #c9b41f; transition: transform .06s, box-shadow .06s;
}
.btn-main:active { transform: translateY(4px); box-shadow: 0 1px 0 #c9b41f; }
.btn-main:disabled { opacity: .45; }
.btn-sub {
  flex: 1; border: 2px solid #3a4b68; border-radius: 12px; background: var(--night2); color: #fff; padding: 13px 8px; font-size: 15px; font-weight: 700;
}
.btn-sub:active { background: #22324f; }
.btn-link { background: none; border: 0; color: #9fb4d6; text-decoration: underline; font-size: 13px; padding: 10px; margin-top: 6px; }
.icon-btn { background: var(--night2); border: 1px solid #33445f; color: #cfd9ea; border-radius: 8px; font-size: 12px; padding: 7px 10px; }

/* タイトル */
.title-wrap { display: flex; flex-direction: column; align-items: stretch; gap: 0; margin: auto 0; padding-top: 12px; }
.title-kicker { color: #9fb4d6; font-size: 13px; font-weight: 700; margin: 0 0 6px; letter-spacing: .1em; }
.title-main { font-size: 58px; line-height: 1.08; margin: 0 0 18px; font-weight: 900; letter-spacing: .02em; }
.title-board {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: var(--paper); border-radius: 6px; padding: 12px;
  color: var(--ink); font-weight: 800; font-size: 18px; text-align: center; font-variant-numeric: tabular-nums;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 14px 14px; transform: rotate(-1.2deg); margin-bottom: 18px;
}
.title-board .hl { background: linear-gradient(transparent 35%, var(--pink) 35%, var(--pink) 90%, transparent 90%); animation: hlpulse 1.6s infinite; }
@keyframes hlpulse { 50% { filter: brightness(1.15); transform: scale(1.08); } }
.title-lead { color: #d5deec; font-size: 14px; line-height: 1.8; margin: 0 0 18px; }
.name-label { font-size: 12px; color: #9fb4d6; margin-bottom: 6px; }
.name-input {
  font-family: inherit; font-size: 18px; padding: 12px 14px; border-radius: 10px; border: 2px solid #33445f; background: var(--night2); color: #fff; margin-bottom: 14px;
}
.name-input:focus { outline: none; border-color: var(--yellow); }
.title-record { text-align: center; color: #cfd9ea; font-size: 13px; min-height: 1em; margin: 12px 0 0; }

/* プレイ */
.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.turn-label { font-size: 22px; font-weight: 900; }
.turn-dots { display: flex; gap: 5px; margin-top: 6px; }
.turn-dots i { width: 22px; height: 6px; border-radius: 2px; background: #2a3a55; display: block; }
.turn-dots i.done { background: var(--yellow); }
.turn-dots i.now { background: #fff; }
.turn-dots i.ronin { background: #6c7a92; }

.status { display: flex; gap: 10px; align-items: stretch; margin-bottom: 10px; }
.status-main { flex: 1; background: var(--night2); border-radius: 12px; padding: 10px 14px; }
.status-cap { font-size: 12px; color: #9fb4d6; }
.hensachi { font-size: 46px; font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hensachi.up { animation: pop .35s; color: var(--yellow); }
@keyframes pop { 40% { transform: scale(1.12); } }
.rank { font-size: 11px; color: #9fb4d6; margin-top: 2px; font-variant-numeric: tabular-nums; line-height: 1.4; }
.rank b { display: block; font-size: 17px; color: #fff; }
.judge-box { width: 104px; background: var(--paper); color: var(--ink); border-radius: 12px; padding: 8px; text-align: center; display: flex; flex-direction: column; justify-content: space-between; }
.judge-target { font-size: 10px; color: var(--ink-soft); line-height: 1.3; min-height: 26px; }
.judge {
  width: 58px; height: 58px; margin: 2px auto 0; border: 4px solid var(--red); border-radius: 50%; color: var(--red);
  font-size: 34px; font-weight: 900; line-height: 50px; transform: rotate(-8deg);
}
.judge.stamp { animation: stamp .35s ease-out; }
@keyframes stamp { 0% { transform: rotate(-8deg) scale(2.2); opacity: 0; } 70% { transform: rotate(-8deg) scale(.92); opacity: 1; } 100% { transform: rotate(-8deg) scale(1); } }

.zone-banner {
  text-align: center; font-weight: 900; font-size: 15px; letter-spacing: .1em; padding: 6px; border-radius: 8px; margin-bottom: 8px;
  background: linear-gradient(90deg, #ff3d7f, #ffb300, #ff3d7f); background-size: 200% 100%; animation: zoneflow 1.2s linear infinite; color: #1b0a12;
}
@keyframes zoneflow { to { background-position: -200% 0; } }
body.zone .status-main { box-shadow: 0 0 0 2px #ff3d7f inset, 0 0 24px #ff3d7f55; }

.note {
  background: var(--paper); color: var(--ink); border-radius: 10px; padding: 8px 10px;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 16px 16px; box-shadow: 0 8px 22px #0007;
}
.row { display: grid; grid-template-columns: 38px 1fr 74px; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px dashed #c9d5e5; }
.row:last-child { border-bottom: 0; }
.subj { font-size: 22px; font-weight: 900; text-align: center; }
.reel {
  height: 36px; border-radius: 6px; background: #fff; border: 2px solid #c9d5e5; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 17px;
}
.reel .ink { position: absolute; left: 6px; right: 6px; top: 9px; bottom: 9px; border-radius: 3px; transform-origin: left center; }
.reel .lbl { position: relative; z-index: 1; }
.reel.spin .ink { animation: none; }
.reel.p0 .ink { background: repeating-linear-gradient(90deg, #cbd3de 0 6px, transparent 6px 12px); height: 3px; top: 16px; bottom: auto; }
.reel.p1 .ink { background: var(--yellow); }
.reel.p2 .ink { background: var(--green); }
.reel.p3 .ink { background: var(--pink); }
.reel.p4 .ink { background: linear-gradient(90deg, var(--gold1), var(--gold2), var(--gold1)); background-size: 200% 100%; animation: shine 1s linear infinite; }
.reel.p5 .ink { background: var(--rainbow); background-size: 200% 100%; animation: shine .8s linear infinite; }
@keyframes shine { to { background-position: -200% 0; } }
.reel.swipe .ink { animation: swipe .28s ease-out; }
.reel.p4.swipe .ink, .reel.p5.swipe .ink { animation: swipe .28s ease-out, shine 1s linear infinite; }
@keyframes swipe { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.reel.reach { border-color: var(--gold2); box-shadow: 0 0 0 3px #ffb30066; animation: reachshake .12s infinite; }
@keyframes reachshake { 50% { transform: translateX(1px); } }
.reel.p4, .reel.p5 { border-color: var(--gold2); }
.row.head { padding: 0 0 4px; font-size: 10px; font-weight: 700; color: #7b889c; border-bottom: 1px solid #c9d5e5; }
.row.head div:nth-child(2) { text-align: center; }
.row.head div:nth-child(3) { text-align: right; }
.gainbox { text-align: right; line-height: 1.1; }
.sh { font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; }
.gain { font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; min-height: 15px; color: #7b889c; }
.gain.up { color: #0f9d58; }
.gain.down { color: #d93a4a; }
.gain.big { color: #c77700; }
.reel .lbl { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 15px; color: var(--ink); text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.reel.p0 .lbl { color: #9aa6b8; text-shadow: none; }

.yokoku { min-height: 50px; margin: 8px 0 0; display: flex; align-items: center; justify-content: center; text-align: center; }
.yokoku .card { padding: 10px 14px; border-radius: 10px; font-weight: 800; font-size: 15px; animation: yk .4s ease-out; color: var(--ink); }
.yokoku .y1 { background: var(--pink); }
.yokoku .y2 { background: linear-gradient(90deg, var(--gold1), var(--gold2)); }
.yokoku .y3 { background: var(--rainbow); }
.yokoku .msg { color: #cfd9ea; font-size: 14px; font-weight: 700; animation: yk .3s; }
@keyframes yk { from { transform: translateY(8px) scale(.9); opacity: 0; } }
.bottom { margin-top: 6px; padding-top: 0; padding-bottom: 120px; }
.hint { text-align: center; font-size: 11px; color: #6f7f99; margin: 8px 0 0; }

/* 分かれ道 */
.overlay { position: fixed; inset: 0; background: #050a14cc; display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.overlay[hidden] { display: none; }
.choice-box { width: 100%; max-width: 440px; background: var(--night2); border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + var(--pad-bottom)); animation: up .3s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.choice-q { font-size: 19px; font-weight: 900; margin: 0 0 14px; line-height: 1.5; }
.choice-opts { display: flex; flex-direction: column; gap: 10px; }
.opt { text-align: left; background: var(--paper); color: var(--ink); border: 0; border-radius: 12px; padding: 14px 16px; box-shadow: 0 4px 0 #9aabc3; }
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 #9aabc3; }
.opt b { display: block; font-size: 18px; margin-bottom: 3px; }
.opt span { font-size: 13px; color: var(--ink-soft); line-height: 1.5; }

/* 全画面の演出 */
.flash { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; pointer-events: none; }
.flash[hidden] { display: none; }
.flash.black { background: #000; animation: fadein .25s; }
.flash.zone { background: radial-gradient(circle, #ff3d7fcc, #ffb30066 50%, transparent 70%); animation: zoneflash .9s ease-out; }
@keyframes zoneflash { from { transform: scale(.4); opacity: 0; } 30% { opacity: 1; } }
@keyframes fadein { from { opacity: 0; } }
.flash .big { font-size: 44px; font-weight: 900; letter-spacing: .06em; text-shadow: 0 0 20px #fff8; animation: pop .5s; }
.flash .small { font-size: 15px; margin-top: 10px; color: #ffe; }
.flash.rainbow-text .big { background: var(--rainbow); -webkit-background-clip: text; background-clip: text; color: transparent; }
.shake { animation: shake .35s; }
@keyframes shake { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, 0); } }

/* 本番・合格発表 */
.exam-inner { display: flex; flex-direction: column; flex: 1; justify-content: center; padding-bottom: 40px; }
.exam-title { font-size: 22px; font-weight: 900; margin: 6px 0 4px; }
.exam-sub { color: #cfd9ea; font-size: 14px; margin: 0 0 16px; line-height: 1.6; }
.luck-reel {
  height: 120px; border-radius: 14px; background: var(--paper); color: var(--ink); display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 900; margin: 20px 0; border: 4px solid #c9d5e5;
}
.luck-reel.l4 { border-color: var(--gold2); background: linear-gradient(90deg, var(--gold1), var(--gold2)); }
.luck-reel.l3 { background: var(--green); }
.luck-reel.l0 { background: #9aa6b8; color: #2a3140; }
.luck-reel.l1 { background: #c8d0dc; }
.board-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.board-head .univ { font-size: 17px; font-weight: 900; }
.board-head .kind { font-size: 12px; color: #9fb4d6; }
.my-num { background: var(--night2); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.my-num b { font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: .06em; }
.board {
  height: 250px; overflow: hidden; position: relative; border-radius: 6px; background: #fdfdfb; color: var(--ink);
  box-shadow: 0 10px 24px #0008; border: 6px solid #2b3647;
}
.board::before, .board::after { content: ""; position: absolute; left: 0; right: 0; height: 40px; z-index: 2; pointer-events: none; }
.board::before { top: 0; background: linear-gradient(#fdfdfb, transparent); }
.board::after { bottom: 0; background: linear-gradient(transparent, #fdfdfb); }
.board-list { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.brow { display: grid; grid-template-columns: repeat(4, 1fr); height: 50px; align-items: center; text-align: center; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.brow span.near { color: #9a2a2e; }
.brow span.found { background: linear-gradient(transparent 30%, var(--pink) 30%, var(--pink) 88%, transparent 88%); animation: hlpulse 1s infinite; }
.brow span.tease { background: linear-gradient(transparent 30%, #ffe94d99 30%, #ffe94d99 88%, transparent 88%); }
.brow span.gap { color: var(--red); font-size: 16px; }
.board-msg { text-align: center; min-height: 64px; margin-top: 14px; }
.board-msg .verdict { font-size: 40px; font-weight: 900; animation: pop .5s; }
.board-msg .verdict.pass { color: var(--yellow); text-shadow: 0 0 18px #ffe94d88; }
.board-msg .verdict.fail { color: #9aa6b8; }
.board-msg .say { font-size: 16px; color: #cfd9ea; font-weight: 700; }

/* 結果 */
.result-wrap { display: flex; flex-direction: column; }
.card-img { width: 100%; border-radius: 12px; box-shadow: 0 10px 30px #000a; background: var(--night2); aspect-ratio: 4 / 5; -webkit-touch-callout: default; user-select: auto; -webkit-user-select: auto; }
.result-btns { display: flex; gap: 10px; margin: 14px 0 12px; }
.timeline { display: flex; gap: 3px; justify-content: center; margin: 16px 0 6px; }
.timeline div { font-size: 10px; color: #9fb4d6; text-align: center; flex: 1; min-width: 0; white-space: nowrap; }
.timeline i { display: block; height: 10px; border-radius: 2px; margin-bottom: 3px; background: #2a3a55; }
.timeline i.p1 { background: var(--yellow); } .timeline i.p2 { background: var(--green); } .timeline i.p3 { background: var(--pink); }
.timeline i.p4 { background: var(--gold2); } .timeline i.p5 { background: var(--rainbow); }
.to-students { font-size: 12px; color: #9fb4d6; text-align: center; line-height: 1.7; margin: 10px 0 0; }

/* 確率と出典 */
.sources { align-items: stretch; }
.sources-box { width: 100%; max-width: 440px; background: var(--paper); color: var(--ink); display: flex; flex-direction: column; max-height: 100dvh; margin: 0 auto; }
.sources-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--grid); }
.sources-head h2 { margin: 0; font-size: 19px; }
.sources-head .icon-btn { background: var(--ink); color: #fff; }
.sources-body { overflow-y: auto; padding: 4px 16px calc(24px + var(--pad-bottom)); font-size: 13px; line-height: 1.7; user-select: text; -webkit-user-select: text; }
.sources-body h3 { font-size: 15px; margin: 18px 0 6px; }
.sources-body table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sources-body th, .sources-body td { border-bottom: 1px solid var(--grid); padding: 6px 4px; text-align: left; vertical-align: top; }
.sources-body th { color: var(--ink-soft); font-weight: 700; }
.sources-body .fine { color: var(--ink-soft); }
.src-list { padding-left: 18px; margin: 6px 0; }
.src-list a { color: #2a62c9; }

.haptic { position: fixed; left: -9999px; top: 0; opacity: 0; pointer-events: none; }

/* 合格の紙吹雪（蛍光ペンの色） */
.confetti { position: fixed; top: -20px; width: 10px; height: 18px; z-index: 40; pointer-events: none; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); opacity: .9; } }

/* 設定示唆 */
.yokoku .shisa { padding: 10px 14px; border-radius: 10px; font-weight: 800; font-size: 14px; animation: yk .4s ease-out; color: var(--ink); line-height: 1.5; }
.yokoku .shisa small { display: block; font-size: 12px; font-weight: 900; }
.yokoku .s1 { background: #dfe7f2; }
.yokoku .s2 { background: linear-gradient(90deg, var(--gold1), var(--gold2)); }
.yokoku .s3 { background: var(--rainbow); background-size: 200% 100%; animation: yk .4s ease-out, shine 1s linear infinite; }

/* たられば */
.tarareba { background: var(--paper); color: var(--ink); border-radius: 10px; padding: 12px 14px; margin: 14px 0 0; box-shadow: 0 8px 22px #0007; }
.tarareba h3 { margin: 0 0 8px; font-size: 15px; }
.tarareba h3 span { background: linear-gradient(transparent 55%, var(--yellow) 55%); }
.tarareba ul { margin: 0; padding: 0; list-style: none; }
.tarareba li { font-size: 13px; line-height: 1.6; padding: 7px 0; border-top: 1px dashed #c9d5e5; }
.tarareba li:first-child { border-top: 0; padding-top: 0; }
.tarareba li b { font-size: 15px; }
.tarareba .big { font-size: 17px; font-weight: 900; }

/* 偏差値の節目・合格圏に入ったとき */
.flash.mile { background: radial-gradient(circle, #ffd34dcc, #ffb30055 50%, transparent 72%); animation: zoneflash .9s ease-out; }
.flash.mile .big { color: #fff; text-shadow: 0 2px 0 #c77700, 0 0 24px #fff; }
.flash.tierup { background: radial-gradient(circle, #7cf08acc, #4fc3f755 50%, transparent 72%); animation: zoneflash .9s ease-out; }
.flash.tierup .big { font-size: 34px; color: #fff; text-shadow: 0 2px 0 #1b7a3a, 0 0 24px #fff; }

/* 連打したときにダブルタップで拡大されないようにする（ピンチでの拡大はできる） */
html, body, button, .screen, .overlay { touch-action: manipulation; }
button { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
