:root {
  --bg: #f5f5f3; --card: #fff; --ink: #111214; --muted: #62666c; --line: #e3e3df; --soft: #f0f0ed;
  --accent: #111214; --accent-ink: #fff; --navy: #111214; --silver-a: #c9ced3; --silver-b: #7f878f; --good: #1d8350; --bad: #c8372a; --warn: #a76a00;
  --good-bg: #e7f4ec; --bad-bg: #fbe9e6; --warn-bg: #fdf3dc; --rx: #3d5bd9;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1012; --card: #17191c; --ink: #f1f2f3; --muted: #9a9fa6; --line: #2a2d31; --soft: #1f2225;
    --accent: #f4f5f6; --accent-ink: #111214; --navy: #f1f2f3; --good: #5fd08f; --bad: #ff7a6b; --warn: #f2c25b;
    --good-bg: #133326; --bad-bg: #3a1c1c; --warn-bg: #3a2f14; --rx: #8ea6ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1012; --card: #17191c; --ink: #f1f2f3; --muted: #9a9fa6; --line: #2a2d31; --soft: #1f2225;
  --accent: #f4f5f6; --accent-ink: #111214; --navy: #f1f2f3; --good: #5fd08f; --bad: #ff7a6b; --warn: #f2c25b;
  --good-bg: #133326; --bad-bg: #3a1c1c; --warn-bg: #3a2f14; --rx: #8ea6ff; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", sans-serif; word-break: keep-all; overflow-wrap: anywhere; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { letter-spacing: -0.03em; line-height: 1.3; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.good { color: var(--good); font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 16px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--ink); }
.btn.wide { width: 100%; }
.btn.armed { background: var(--navy); border-color: var(--navy); color: var(--bg); }
.btn:disabled { opacity: .5; cursor: progress; }
.input { width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 11px 13px; font-size: 16px; }
.input:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.label { display: block; font-size: 14px; font-weight: 700; margin: 12px 0 6px; }
.row { display: flex; gap: 8px; }
.msg { min-height: 22px; font-size: 14px; margin: 8px 0 0; }
.msg.bad { color: var(--bad); } .msg.good { color: var(--good); } .msg.wait { color: var(--muted); }
.pill { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; }
.pill.strong { background: var(--navy); color: var(--bg); border-color: var(--navy); }
.eyebrow { color: var(--accent); font-weight: 800; font-size: 13px; letter-spacing: .06em; }

/* 브랜드 */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand b { font-size: 19px; letter-spacing: -0.04em; }
.brand.big { gap: 14px; margin-bottom: 20px; }
.brand.big b { font-size: 26px; display: block; line-height: 1.2; }
.brand.big small { color: var(--muted); font-size: 14px; font-weight: 600; }
.brand .mark { height: 46px; width: auto; color: var(--ink); flex: none; }
.brand.big .mark { height: 72px; }

/* 로그인 */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.authbox { width: min(420px, 100%); }
.authcard h1 { font-size: 24px; margin: 0 0 4px; }
.authcard .btn { margin-top: 12px; }
.authlink { display: block; text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }

/* 머리 */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1120px; margin: 0 auto; padding: 16px 20px; }
.account { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--muted); min-width: 0; }
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.shell { max-width: 1120px; margin: 0 auto; padding: 4px 20px 60px; }

/* 로비 */
.hero { padding: 24px 0 26px; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); margin: 8px 0 10px; letter-spacing: -0.05em; }
.hero h1 em { font-style: normal; background: linear-gradient(180deg, var(--silver-a), var(--silver-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { max-width: 560px; margin: 0; }
.resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; border-color: var(--accent); }
.resume small { display: block; }
.lobbygrid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; margin-bottom: 16px; }
.startcard .btn.primary { margin-top: 16px; padding: 14px; font-size: 17px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 15px; }
.steps b { margin-right: 6px; }
.rankcard { margin-bottom: 16px; }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cardhead h2 { margin: 0; }
.tabs { display: flex; gap: 4px; background: var(--soft); border-radius: 10px; padding: 3px; }
.tab { border: 0; background: transparent; border-radius: 8px; padding: 6px 12px; font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px #0002; }
.ranklist { list-style: none; margin: 8px 0 0; padding: 0; }
.ranklist li { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 10px 6px; border-top: 1px solid var(--line); }
.ranklist li.me { background: var(--soft); border-radius: 10px; }
.ranklist .n { font-weight: 800; color: var(--accent); }
.ranklist .who small { display: block; color: var(--muted); font-size: 12px; }
.ranklist .pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); font-size: 15px; }
.history li:first-child { border-top: 0; }
.history .tag { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.tag.ok { background: var(--good-bg); color: var(--good); } .tag.no { background: var(--bad-bg); color: var(--bad); } .tag.ing { background: var(--warn-bg); color: var(--warn); }
.history button { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; font-weight: 600; }

/* 진료 */
.gamebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.gamebar #leaveBtn { padding-left: 0; margin-right: auto; }
.gamegrid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.side { display: grid; gap: 16px; position: sticky; top: 12px; }
.cc { background: var(--soft); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.cc small { color: var(--accent); font-weight: 800; font-size: 12px; letter-spacing: .05em; }
.cc p { margin: 2px 0 0; font-size: 17px; font-weight: 600; }
.chartlog { list-style: none; margin: 0 0 6px; padding: 0; counter-reset: c; }
.chartlog li { position: relative; padding: 10px 0 10px 16px; border-left: 2px solid var(--line); margin-left: 6px; }
.chartlog li::before { content: ""; position: absolute; left: -6px; top: 17px; width: 10px; height: 10px; border-radius: 50%; background: var(--card); border: 2px solid var(--muted); }
.chartlog li.rx::before { border-color: var(--rx); background: var(--rx); }
.chartlog li.acc::before { border-color: var(--bad); background: var(--bad); }
.chartlog li.mark::before { border-color: var(--good); background: var(--good); }
.chartlog li.new { animation: fade .35s ease; }
.chartlog .q { font-weight: 700; display: block; }
.chartlog li.rx .q { color: var(--rx); }
.chartlog .q .prep { font-weight: 600; font-size: 12px; color: var(--warn); background: var(--warn-bg); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.chartlog .a { display: block; }
.chartlog li.mark .q { color: var(--good); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.orderbox { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; padding: 0; list-style: none; }
.chip { border: 1px solid var(--line); background: var(--soft); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--muted); }
.memo li { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); font-size: 14px; font-weight: 600; cursor: default; }
.memo li button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 999px; }
.memo li button:hover { color: var(--bad); }
.memo li.empty { background: none; border: 0; padding: 0; font-weight: 400; color: var(--muted); }
#finalBtn { margin-top: 8px; }
.dxname { font-size: 21px; margin: 2px 0; }

/* 결과 */
.result, .talk { margin-bottom: 16px; }
.verdict { border-radius: 12px; padding: 12px 16px; font-weight: 700; margin-bottom: 16px; }
.verdict.good { background: var(--good-bg); color: var(--good); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.verdict small { display: block; font-weight: 500; margin-top: 2px; }
.answer h2 { font-size: 28px; margin: 0; }
.explain { margin: 12px 0 16px; }
.treatbox { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.treatbox h3 { display: flex; justify-content: space-between; gap: 8px; }
.treatbox ul { list-style: none; margin: 0 0 8px; padding: 0; }
.treatbox li { display: grid; grid-template-columns: 24px 1fr auto; gap: 6px; padding: 7px 0; border-top: 1px solid var(--line); }
.treatbox li:first-child { border-top: 0; }
.treatbox li small { display: block; color: var(--muted); }
.treatbox .ok { color: var(--good); } .treatbox .miss { color: var(--bad); } .treatbox .harm { color: var(--warn); }
.treatbox p { margin: 8px 0 0; }
.clues summary { cursor: pointer; font-weight: 700; }
.clues ol { margin: 8px 0 0; padding-left: 22px; }
.resultactions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.talklog { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.talklog li { padding: 10px 14px; border-radius: 14px; max-width: 88%; }
.talklog li.me { background: var(--navy); color: var(--bg); justify-self: end; }
.talklog li.ai { background: var(--soft); }
.talklog li.wait { color: var(--muted); }
.game-done .gamegrid { grid-template-columns: 1fr; }
.game-done .side, .game-done .orderbox { display: none; }

@media (max-width: 860px) {
  .gamegrid, .lobbygrid { grid-template-columns: 1fr; }
  .side { position: static; }
}
@media (max-width: 520px) {
  .top { padding: 12px 16px; }
  .shell { padding: 0 16px 48px; }
  .card { padding: 18px 16px; border-radius: 16px; }
  .account span { max-width: 90px; }
  .ranklist li { grid-template-columns: 28px 1fr auto; }
}

/* 모드 고르기 */
.modes { display: grid; gap: 8px; }
.mode { text-align: left; border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.mode b { display: block; font-size: 15px; }
.mode small { color: var(--muted); font-size: 13px; }
.mode[aria-checked="true"] { border-color: var(--accent); background: var(--card); box-shadow: inset 0 0 0 1px var(--accent); }

/* 환자 상태 */
.vital { display: inline-flex; align-items: center; gap: 6px; }
.vital i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.vital span { color: var(--muted); font-weight: 500; }
.vital.s-improving i, .vital.s-recovered i { background: var(--good); }
.vital.s-stable i { background: #6f9fd8; }
.vital.s-worse i { background: var(--warn); }
.vital.s-critical i, .vital.s-dead i { background: var(--bad); animation: blink 1s infinite; }
.vital.s-critical { border-color: var(--bad); color: var(--bad); }
@keyframes blink { 50% { opacity: .25; } }
.chartlog .t { color: var(--muted); font-size: 12px; font-weight: 500; margin-left: 6px; }
.chartlog .course { display: block; margin-top: 4px; font-size: 14px; color: var(--warn); }
.chartlog li.s-critical .course, .chartlog li.s-dead .course { color: var(--bad); font-weight: 600; }
.chartlog li.s-improving .course, .chartlog li.s-recovered .course { color: var(--good); }
.talklog li .at { display: block; font-size: 11px; opacity: .7; }
.talklog li.pending { opacity: .75; }
.game-done #talk, #talk { margin-top: 16px; }
.verdict.warn { background: var(--warn-bg); color: var(--warn); }
.history .mtag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; margin-left: 6px; }

/* 기록·최고 기록 */
.bestbox { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.bestlist { list-style: none; margin: 8px 0 0; padding: 0; }
.bestlist li button { width: 100%; display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; padding: 10px 4px; cursor: pointer; }
.bestlist li:first-child button { border-top: 0; }
.bestlist li.me button { background: var(--soft); border-radius: 10px; }
.bestlist .n { font-weight: 800; }
.bestlist small { display: block; color: var(--muted); font-size: 12px; }
.bestlist .pts { font-weight: 800; font-variant-numeric: tabular-nums; }
.gate h2 { margin-bottom: 4px; }
.strip { display: flex; height: 10px; border-radius: 6px; overflow: hidden; margin: 14px 0; background: var(--soft); }
.strip i { display: block; height: 100%; min-width: 3px; }
.strip .s-improving, .strip .s-recovered { background: var(--good); }
.strip .s-stable { background: #6f9fd8; } .strip .s-worse { background: var(--warn); }
.strip .s-critical, .strip .s-dead { background: var(--bad); } .strip .s-none { background: var(--line); }
.chartlog li.mark.wrong::before { border-color: var(--bad); background: var(--bad); }
.chartlog li.mark.wrong .q { color: var(--bad); }

/* ---------- 미니멀 로비 (10/1) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.shell.narrow { max-width: 520px; }
.title { font-size: clamp(26px, 6vw, 34px); line-height: 1.3; letter-spacing: -0.045em; margin: 40px 0 32px; font-weight: 800; }
.resume { display: block; width: 100%; text-align: left; border: 0; border-radius: 12px; background: var(--soft); padding: 14px 16px; font-weight: 700; cursor: pointer; margin-bottom: 24px; }
.resume span { color: var(--muted); font-weight: 500; }
.start { display: grid; gap: 10px; }
.start .input { background: var(--card); border-color: var(--line); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 12px; padding: 4px; gap: 4px; }
.seg .mode { border: 0; background: transparent; border-radius: 9px; padding: 9px; font-weight: 700; color: var(--muted); cursor: pointer; text-align: center; box-shadow: none; }
.seg .mode[aria-checked="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px #0002; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.hint.center { text-align: center; }
.start .btn.primary { padding: 14px; font-size: 16px; margin-top: 6px; }
.rules { margin: 28px 0 0; border-top: 1px solid var(--line); padding-top: 14px; }
.rules summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; list-style: none; }
.rules summary::-webkit-details-marker { display: none; }
.rules summary::after { content: " +"; }
.rules[open] summary::after { content: " −"; }
.rules .steps { margin-top: 10px; font-size: 14px; color: var(--muted); gap: 6px; }
.list { margin-top: 36px; }
.listhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.listhead h2 { font-size: 14px; color: var(--muted); font-weight: 700; margin: 0; letter-spacing: 0; }
.list .tabs { background: none; padding: 0; gap: 12px; }
.list .tab { padding: 0; background: none; box-shadow: none; font-size: 13px; }
.list .tab[aria-selected="true"] { background: none; box-shadow: none; color: var(--ink); }
.list .ranklist li { border-top: 0; border-bottom: 1px solid var(--line); padding: 12px 0; grid-template-columns: 28px 1fr auto; }
.list .ranklist li.me { background: none; font-weight: 700; }
.list .ranklist .n { color: var(--muted); font-weight: 600; }
.list .history li { border-top: 0; border-bottom: 1px solid var(--line); padding: 12px 0; }
.list .history .tag, .list .history .mtag { font-weight: 600; background: none; border: 0; padding: 0; margin-left: 8px; font-size: 12px; }
.top { max-width: 1120px; }
.account { font-size: 13px; }
.msg:empty { display: none; }
body.on-lobby .top { max-width: 552px; }
.list .empty-row { color: var(--muted); font-size: 14px; padding: 12px 0; list-style: none; }
.list .ranklist li.empty-row, .list .history li.empty-row { display: block; }

/* ---------- 미니멀 진료·결과·기록 화면 (10/1) ---------- */
#game .card, #replay .card { border: 0; background: transparent; padding: 0; border-radius: 0; box-shadow: none; }
#game .gamegrid { gap: 56px; }
#game .side { gap: 32px; border-left: 1px solid var(--line); padding-left: 28px; }
#game h3, #game .side h3 { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
#game .side hr { display: none; }
.gamebar { gap: 14px; margin-bottom: 28px; }
.gamebar .pill { border: 0; background: none; padding: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.gamebar .pill.strong { color: var(--ink); font-weight: 800; font-size: 14px; }
.gamebar .vital span { font-weight: 500; }
.gamebar .vital.s-critical { color: var(--bad); }
.cc { background: none; padding: 0; margin-bottom: 24px; border-radius: 0; }
.cc small { color: var(--muted); }
.cc p { font-size: 19px; line-height: 1.5; }
.chartlog li { border-left-color: var(--line); }
.orderbox { margin-top: 20px; padding-top: 20px; }
.orderbox h3 { font-size: 13px; }
.chips { gap: 6px; margin: 8px 0 12px; }
.chip { background: none; border: 1px solid var(--line); font-weight: 500; font-size: 13px; padding: 5px 11px; }
#talk { margin-top: 48px !important; border-top: 1px solid var(--line) !important; padding-top: 24px !important; }
#talk h2, #result h3 { font-size: 13px; color: var(--muted); font-weight: 700; }
#result { margin-bottom: 40px; }
.treatbox { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 16px 0 0; }
.bestbox { border-top: 1px solid var(--line); }
.verdict { border-radius: 10px; }
@media (max-width: 860px) { #game .side { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 24px; } #game .gamegrid { gap: 32px; } }
.memo li.empty { display: none; }
#memoForm { margin-bottom: 28px; }
.chip.wait { color: var(--muted); border-style: dashed; }
.chartlog li.wait::before { border-color: var(--muted); background: var(--muted); }
.chartlog li.wait .q { color: var(--muted); }
#dxPanel.callout { outline: 2px solid var(--good); outline-offset: 10px; border-radius: 6px; }
