:root {
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e2e0db;
  --accent: #8a3b2a;
  --accent-ink: #ffffff;
  --right: #1f7a4d;
  --right-bg: #e6f4ec;
  --wrong: #b3261e;
  --wrong-bg: #fbeaea;
  --pick: #fff3d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --series-1: #3987e5;
    --series-2: #d95926;
    --bg: #161617;
    --card: #222224;
    --ink: #ececee;
    --muted: #9a9aa0;
    --line: #38383c;
    --accent: #d77a5f;
    --accent-ink: #161617;
    --right: #5fcf95;
    --right-bg: #173325;
    --wrong: #ff8a80;
    --wrong-bg: #3a1c1c;
    --pick: #3a3220;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 17px; line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 680px; margin: 0 auto; padding: 16px 16px 80px; }
h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 12px 16px; cursor: pointer; min-height: 48px;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.link { border: 0; background: none; padding: 6px 4px; min-height: 0; color: var(--accent); text-decoration: underline; }
button:disabled { opacity: .45; cursor: default; }
.sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sizes button { font-size: 22px; font-weight: 700; padding: 18px 0; }
.sizes button small { display: block; font-size: 13px; font-weight: 400; color: inherit; opacity: .8; }
select, input[type=text], textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 120px; font-size: 14px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.meta { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stem { white-space: pre-wrap; font-size: 18px; margin: 0 0 14px; }
.stem-img { max-width: 100%; border-radius: 8px; margin-bottom: 12px; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; display: flex; gap: 10px; align-items: flex-start; white-space: pre-wrap; }
.opt b { min-width: 1.4em; }
.opt.pick { background: var(--pick); border-color: var(--accent); }
.opt.right { background: var(--right-bg); border-color: var(--right); }
.opt.wrong { background: var(--wrong-bg); border-color: var(--wrong); }
.chip { min-height: 36px; padding: 6px 14px; border-radius: 999px; font-size: 15px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.feedback { margin-top: 14px; padding: 14px; border-radius: 12px; }
.feedback.right { background: var(--right-bg); }
.feedback.wrong { background: var(--wrong-bg); }
.feedback .head { font-weight: 700; margin-bottom: 6px; }
.feedback .right-t { color: var(--right); }
.feedback .wrong-t { color: var(--wrong); }
.feedback p { white-space: pre-wrap; margin: 6px 0; }
.source { font-size: 13px; color: var(--muted); margin-top: 8px; }
.next { position: sticky; bottom: 12px; margin-top: 14px; width: 100%; }
.big { font-size: 40px; font-weight: 800; margin: 4px 0; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--muted); }
.err { color: var(--wrong); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button.on { border-color: var(--accent); background: var(--pick); font-weight: 700; }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 15px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw;
}
#toast.show { opacity: .95; }
#savefail { position: sticky; top: 0; z-index: 10; background: var(--wrong); color: #fff; padding: 10px 16px; font-size: 15px; text-align: center; }

/* 풀이 방식 · 제한 시간 */
.seg2, .seg3 { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg2 button, .seg3 button { border: 0; border-radius: 0; min-height: 40px; padding: 8px 14px; background: var(--card); }
.seg2 button + button, .seg3 button + button { border-left: 1px solid var(--line); }
.seg2 button.on, .seg3 button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg2 { display: flex; }
.seg2 button { flex: 1; }
.limit input { width: 5.5em; min-height: 40px; padding: 6px 8px; display: inline-block; }

/* CBT — 국시원 K-CBT 기능을 따른 시험 화면(디자인은 새로 짬) */
main.wide { max-width: none; padding: 0; }
.cbt { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: var(--bg); }
.cbt-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.cbt-who { font-weight: 600; }
.cbt-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex: 1; }
.cbt-tools .seg3 button { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.cbt-tools .chip { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.cbt-time { font-variant-numeric: tabular-nums; font-weight: 700; margin-left: auto; white-space: nowrap; }
.cbt-time.low { color: var(--wrong); }
.cbt-body { flex: 1; display: flex; gap: 0; min-height: 0; }
.cbt-qs { flex: 1; padding: 14px 16px 90px; display: grid; gap: 14px; align-content: start; }
.cbt.two .cbt-qs { grid-template-columns: 1fr 1fr; }
.cbt-q { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.cbt-qhead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cbt-qhead .chip { min-height: 32px; padding: 4px 12px; font-size: 14px; }
.cbt-no { font-size: 1.1em; }
.cbt .stem { font-size: 1em; }
.cbt-q { font-size: 18px; }
.fs-80 .cbt-q { font-size: 14.4px; }
.fs-125 .cbt-q { font-size: 22.5px; }
.cbt-qs.hl .stem { cursor: text; user-select: text; -webkit-user-select: text; }
.cbt-qs.hl .stem::selection { background: #ffe066; }
mark { background: #ffe066; color: inherit; padding: 0 1px; border-radius: 2px; }
@media (prefers-color-scheme: dark) { mark { background: #7a6300; } }
.cbt-opts { display: grid; gap: 8px; }
.cbt-opt { display: flex; gap: 6px; align-items: stretch; }
.cbt-pick { flex: 1; text-align: left; display: flex; gap: 10px; align-items: flex-start; white-space: pre-wrap; font-size: inherit; }
.cbt-pick b { min-width: 1.4em; }
.cbt-opt.sel .cbt-pick { background: var(--pick); border-color: var(--accent); font-weight: 600; }
.cbt-opt.sel .cbt-pick b { color: var(--accent); }
.cbt-opt.struck .cbt-pick span { text-decoration: line-through; color: var(--muted); }
.cbt-x { min-width: 56px; padding: 6px 8px; font-size: 13px; color: var(--muted); }
.cbt-memo { margin-bottom: 10px; min-height: 80px; }
.stem-img { cursor: zoom-in; }
.cbt-sheet { width: 300px; flex: none; background: var(--card); border-left: 1px solid var(--line); padding: 12px;
  position: sticky; top: 52px; align-self: flex-start; max-height: calc(100vh - 52px); overflow: auto; }
.cbt-sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cbt-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 10px; }
.cbt-tabs button { min-height: 36px; padding: 4px; font-size: 13px; }
.cbt-tabs button.on { border-color: var(--accent); background: var(--pick); font-weight: 700; }
.cbt-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.cbt-grid button { min-height: 44px; padding: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; line-height: 1.2; }
.cbt-grid button b { font-size: 15px; min-height: 1.2em; color: var(--accent); }
.cbt-grid button.done { background: var(--bg); }
.cbt-grid button.chk { border-color: #d39b00; box-shadow: inset 0 -3px 0 #d39b00; }
.cbt-grid button.cur { outline: 2px solid var(--accent); outline-offset: -2px; }
.cbt-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); }
.cbt-foot button { flex: 1; }
.zoom { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.zoom img { max-width: 96vw; max-height: 96vh; }
.only-wide { display: none; }
@media (min-width: 900px) {
  .only-wide { display: inline-flex; }
  .not-wide { display: none !important; }
  .cbt-foot { right: 300px; }
}
@media (max-width: 899px) {
  .cbt-sheet { position: fixed; inset: auto 0 0 0; width: auto; max-height: 75vh; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; z-index: 15; transform: translateY(105%); transition: transform .2s; top: auto; box-shadow: 0 -8px 24px rgba(0,0,0,.15); }
  .cbt-sheet.open { transform: none; }
  .cbt-tools { order: 3; flex-basis: 100%; }
}
#notice { position: fixed; top: 12px; left: 50%; transform: translate(-50%, -150%); z-index: 30; background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 12px; font-weight: 600; transition: transform .25s; max-width: 92vw; cursor: pointer; }
#notice.show { transform: translate(-50%, 0); }

/* 로그인 · 머리줄 · 상태 줄 */
.head { margin-bottom: 6px; }
.head h1 { margin: 8px 0; }
.field { display: block; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.field input { margin-top: 4px; color: var(--ink); }
input[type=password] {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
.ok { color: var(--right); }
.big-name { font-size: 20px; font-weight: 700; margin: 4px 0; }
#statusbar { display: none; position: sticky; top: 0; z-index: 10; background: var(--ink); color: var(--bg); padding: 8px 16px; font-size: 14px; text-align: center; }
#statusbar.show { display: block; }
#statusbar.bad { background: var(--wrong); color: #fff; }
#statusbar .link { color: inherit; }
button.danger { color: var(--wrong); border-color: var(--wrong); }
.mono { font-family: ui-monospace, Menlo, monospace; }
.badge-on { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }

/* 게임 */
.games { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
button.game { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 14px; }
button.game b { font-size: 17px; }
button.game small { color: var(--muted); font-size: 13px; }
.rules { margin: 0 0 8px; padding-left: 20px; }
.rules li { margin: 4px 0; }
.lives { color: var(--wrong); font-size: 20px; letter-spacing: 2px; }
.lives i { color: var(--line); font-style: normal; }
.score { font-size: 18px; }
.bets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bets button { display: flex; flex-direction: column; align-items: center; font-weight: 700; }
.bets button small { font-weight: 400; font-size: 12px; color: var(--muted); }
.points { font-size: 20px; font-weight: 800; margin: 14px 0 0; }
.right-t { color: var(--right); }
.wrong-t { color: var(--wrong); }

/* 방 대결 */
.code-in { text-transform: uppercase; letter-spacing: 3px; font-family: ui-monospace, Menlo, monospace; font-size: 20px; }
.room-code { text-align: center; font-family: ui-monospace, Menlo, monospace; font-size: 40px; font-weight: 800; letter-spacing: 6px; }
button.roomrow { width: 100%; display: flex; gap: 10px; align-items: center; text-align: left; margin-bottom: 8px; min-height: 52px; }
button.roomrow b { font-family: ui-monospace, Menlo, monospace; }
tr.me td { font-weight: 700; background: var(--pick); }

/* 모으기 */
.mastery { margin-bottom: 12px; }
.mastery .bar { margin-top: 4px; }
.bingo { display: grid; gap: 6px; margin-top: 8px; }
.bingo.s3 { grid-template-columns: repeat(3, 1fr); }
.bingo.s2 { grid-template-columns: repeat(2, 1fr); }
.bingo div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 6px; text-align: center; min-height: 72px; display: flex; flex-direction: column; justify-content: center; }
.bingo div span { font-size: 14px; font-weight: 600; word-break: keep-all; }
.bingo div small { font-size: 12px; color: var(--muted); }
.bingo div.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bingo div.on small { color: inherit; opacity: .85; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.badges div { border: 1px dashed var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; opacity: .55; }
.badges div b { display: block; font-size: 14px; }
.badges div small { font-size: 12px; color: var(--muted); }
.badges div.on { opacity: 1; border-style: solid; border-color: var(--accent); background: var(--pick); }

/* 관리 */
.urow { border-bottom: 1px solid var(--line); padding: 6px 0; margin: 0; }
.urow summary { color: var(--ink); }
.urow .row button { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.bankrow { border-bottom: 1px solid var(--line); padding: 8px 0; }
.bankrow button { min-height: 40px; padding: 6px 12px; }
@media print {
  .noprint, #statusbar, #toast { display: none !important; }
  body, main { background: #fff; color: #000; padding: 0; }
  .card { border: 0; padding: 0; }
  table.slips td, table.slips th { border: 1px solid #000; padding: 10px; font-size: 16px; }
}
a { color: var(--accent); }

/* CBT 실시간 채점 · 문항 시간 · 실전 모의고사 */
.cbt-opt.right .cbt-pick { background: var(--right-bg); border-color: var(--right); }
.cbt-opt.wrong .cbt-pick { background: var(--wrong-bg); border-color: var(--wrong); }
.cbt-grid button.ok { box-shadow: inset 0 -3px 0 var(--right); }
.cbt-grid button.ok b { color: var(--right); }
.cbt-grid button.no { box-shadow: inset 0 -3px 0 var(--wrong); }
.cbt-grid button.no b { color: var(--wrong); }
.cbt-qtime { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); white-space: nowrap; }
.cbt-qtime.over { color: var(--wrong); font-weight: 700; }
.cbt-q .feedback { margin-top: 12px; }
.opts-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.opts-row > span { min-width: 2.5em; }
.sizes.four { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sizes.four button { font-size: 17px; padding: 12px 0; }
.sizes.four button small { font-size: 11px; }
table.bp select { min-height: 36px; padding: 4px 6px; font-size: 14px; }
table.bp input.bp-w { width: 4.5em; min-height: 36px; padding: 4px 6px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }

/* 내 실력 그래프 — 색은 시각화 검사(색각이상·대비) 통과: 밝은 #2a78d6·#eb6834 / 어두운 #3987e5·#d95926 */
.chart { position: relative; max-width: 480px; margin: 8px 0; }
.chart svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ref { stroke: var(--muted); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .endv { fill: var(--ink); font-size: 11px; font-weight: 600; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--series-1); }
.chart .line.s2 { stroke: var(--series-2); }
.chart .dot { stroke: var(--card); stroke-width: 2; }
.chart .dot.s1 { fill: var(--series-1); }
.chart .dot.s2 { fill: var(--series-2); }
.chart .bar { fill: var(--series-1); }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .tip { position: absolute; top: -4px; transform: translateY(-100%); background: var(--ink); color: var(--bg); font-size: 13px; padding: 6px 10px; border-radius: 8px; pointer-events: none; max-width: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend .key { display: inline-block; width: 16px; height: 2px; vertical-align: middle; margin-right: 6px; border-radius: 1px; }
.legend .key.s1 { background: var(--series-1); }
.legend .key.s2 { background: var(--series-2); }
details.tbl { margin-top: 4px; }
