/* =========================
   게이머 에이징 커브 진단소 — 레트로 픽셀 병원 + 현대 게임 UI
   버튼·패널: Kenney Pixel UI Pack(CC0) 9-slice / 글꼴: Galmuri11(OFL)
   ========================= */
@font-face { font-family: Galmuri11; font-weight: 400; font-display: swap; src: url("./assets/clinic/fonts/Galmuri11.woff2") format("woff2"); }
@font-face { font-family: Galmuri11; font-weight: 700; font-display: swap; src: url("./assets/clinic/fonts/Galmuri11-Bold.woff2") format("woff2"); }

:root {
  --ink: #231a2b; --night: #1d1626; --night2: #2b2236; --cream: #fff7e8; --paper: #fbf3e2; --line: #e3d8c4;
  --mint: #5ec8b0; --red: #e8463c; --blue: #3c7ce8; --green: #2fae58; --yellow: #f2c230; --purple: #8b6fd1; --orange: #f08a3c;
  --muted: #a99fb5; --dim: #7a6f86; --safe-b: env(safe-area-inset-bottom, 0px);
  --font: Galmuri11, "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body.clinic {
  font-family: var(--font); color: var(--cream); background: var(--night);
  background-image: linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.025) 75%), linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.025) 75%);
  background-size: 48px 48px; background-position: 0 0, 24px 24px;
  min-height: 100vh; -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
button, input, select { font-family: inherit; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
a { color: var(--mint); }

/* ---------- 상단 ---------- */
.topbar { position: sticky; top: 0; z-index: 50; height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: rgba(29,22,38,.94); border-bottom: 3px solid var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.topbar .home { color: var(--cream); text-decoration: none; font-weight: 700; white-space: nowrap; }
.tb-title { flex: 1; text-align: center; font-size: 15px; color: var(--mint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { display: flex; align-items: center; gap: 8px; }
.ibtn { background: none; border: 0; color: var(--cream); font-size: 20px; cursor: pointer; padding: 6px; line-height: 1; }
body.in-test .topbar { display: none; }

main#app { max-width: 1040px; margin: 0 auto; padding: 16px 16px calc(24px + var(--safe-b)); }
body.in-test main#app { max-width: none; padding: 0; }
.screen { display: none; animation: scIn .3s ease; }
.screen.on { display: block; }
@keyframes scIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.boot-err { background: var(--red); padding: 12px; text-align: center; }

/* ---------- 픽셀 버튼 (Kenney 9-slice) ---------- */
.pbtn {
  --img: url("./assets/clinic/ui/grey.png"); --img-p: url("./assets/clinic/ui/grey_pressed.png"); --tc: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex-direction: column;
  min-height: 46px; padding: 6px 18px 10px; color: var(--tc); font-size: 16px; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 12px solid transparent; border-image: var(--img) 12 fill / 12px stretch; image-rendering: pixelated; background: none;
  transition: transform .08s; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.pbtn small { font-size: 12px; font-weight: 400; opacity: .85; }
.pbtn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.pbtn:active { border-image-source: var(--img-p); transform: translateY(2px); }
.pbtn:disabled { filter: grayscale(.8) brightness(.8); cursor: not-allowed; transform: none; }
.pbtn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.pbtn.green { --img: url("./assets/clinic/ui/green.png"); --img-p: url("./assets/clinic/ui/green_pressed.png"); --tc: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.pbtn.blue { --img: url("./assets/clinic/ui/blue.png"); --img-p: url("./assets/clinic/ui/blue_pressed.png"); --tc: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.pbtn.yellow { --img: url("./assets/clinic/ui/yellow.png"); --img-p: url("./assets/clinic/ui/yellow_pressed.png"); }
.pbtn.red { --img: url("./assets/clinic/ui/red.png"); --img-p: url("./assets/clinic/ui/red_pressed.png"); --tc: #fff; }
.pbtn.ghost { border: 3px solid rgba(255,247,232,.35); border-image: none; color: var(--cream); padding: 6px 14px; min-height: 40px; }
.pbtn.ghost:active { transform: translateY(1px); }
.pbtn.sm { min-height: 34px; font-size: 13px; padding: 3px 10px; }
.pbtn.big { min-height: 64px; font-size: 19px; }

/* ---------- 패널 ---------- */
.panel { background: var(--cream); color: var(--ink); padding: 20px; margin: 10px 0 16px; box-shadow: 0 0 0 4px var(--ink), 0 8px 0 4px rgba(0,0,0,.3); position: relative; }
.ph { margin: 0 0 16px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ph span { font-size: 24px; }
.ph small { font-size: 13px; color: var(--dim); font-weight: 400; }
.row-btns { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-top: 16px; }
.note { color: var(--dim); font-size: 13px; min-height: 1.2em; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 12px 0 0; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--green); }

/* ---------- 입구 ---------- */
.hero { position: relative; height: clamp(240px, 42vw, 400px); margin: -16px -16px 0; overflow: hidden; border-bottom: 4px solid var(--ink); }
.hero-cv { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-logo { position: absolute; left: 0; right: 0; top: 8%; text-align: center; text-shadow: 0 3px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -3px 0 var(--ink); pointer-events: none; }
.hero-logo small { display: inline-block; font-size: 12px; letter-spacing: .2em; color: var(--mint); background: var(--ink); padding: 3px 10px; text-shadow: none; }
.hero-logo h1 { margin: 10px 0 6px; font-size: clamp(28px, 6.4vw, 54px); line-height: 1.15; font-weight: 700; color: var(--cream); }
.hero-logo h1 span { color: var(--yellow); }
.hero-logo p { margin: 0; font-size: clamp(13px, 2.4vw, 18px); }
.hero-logo b { color: var(--mint); }
.menu { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 22px 0 10px; }
.menu-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.fine { text-align: center; color: var(--muted); font-size: 12px; }
.vs-banner { display: flex; align-items: center; gap: 12px; background: var(--yellow); color: var(--ink); padding: 12px 14px; margin-top: 16px; box-shadow: 0 0 0 4px var(--ink); animation: pulse 1.8s infinite; }
.vs-banner > div:nth-child(2) { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.vs-banner span { font-size: 13px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--ink), 0 0 0 9px rgba(242,194,48,.35); } }

/* ---------- 접수 ---------- */
.pf { display: grid; grid-template-columns: 230px 1fr; gap: 20px; }
.pf-char { display: flex; flex-direction: column; align-items: center; gap: 10px; background: #d9eee9; padding: 10px; box-shadow: inset 0 0 0 3px var(--ink); }
.pf-cv { width: 200px; height: 200px; }
.pf-fields { display: flex; flex-direction: column; gap: 12px; }
.fld { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 10px; font-size: 14px; }
.fld input { font-size: 18px; padding: 10px 12px; border: 3px solid var(--ink); background: #fff; color: var(--ink); width: 100%; min-width: 0; }
.fld input:focus { outline: 3px solid var(--mint); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 10px; font-size: 16px; border: 3px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--yellow); }
.pf-parts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.part { display: grid; grid-template-columns: 70px 34px 1fr 34px; align-items: center; gap: 4px; font-size: 13px; }
.part b { text-align: center; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part .arr { height: 34px; border: 2px solid var(--ink); background: #fff; cursor: pointer; font-size: 12px; color: var(--ink); }
.part .arr:active { background: var(--yellow); }
.pf-note { font-size: 12px; color: var(--dim); margin: 0; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.mode { text-align: left; padding: 14px; border: 3px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.mode b { font-size: 18px; } .mode span { font-size: 13px; } .mode small { color: var(--dim); }
.mode.on { background: var(--ink); color: var(--cream); box-shadow: 0 0 0 3px var(--yellow); }

/* ---------- 대기실 ---------- */
.hall { position: relative; height: clamp(200px, 34vw, 320px); margin: -16px -16px 0; border-bottom: 4px solid var(--ink); }
.hall-cv { width: 100%; height: 100%; display: block; }
.hall-call { position: absolute; left: 0; right: 0; margin: 0 auto; bottom: 14px; width: min(92%, 640px);   /* translateX 가운데 정렬은 scIn 애니메이션이 덮어써서 폰에서 화면이 옆으로 늘어났음 */ background: var(--cream); color: var(--ink); padding: 10px 14px; font-size: 15px; box-shadow: 0 0 0 3px var(--ink); animation: scIn .4s; }
.hall-last { background: #eef7f3; padding: 10px 12px; margin-bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; box-shadow: inset 0 0 0 3px var(--mint); }
.big-sc { font-size: 22px; font-weight: 700; color: hsl(calc(var(--s) * 1.2), 60%, 38%); }
.warn { color: var(--red); font-style: normal; font-size: 13px; }
.hall-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.hall-list li { display: grid; grid-template-columns: 28px 1fr auto; grid-template-rows: auto auto; align-items: center; gap: 0 8px; padding: 8px 10px; background: #fff; border: 3px solid var(--line); }
.hall-list .hl-n { grid-row: span 2; font-size: 18px; color: var(--dim); text-align: center; }
.hall-list small { grid-column: 2; color: var(--dim); font-size: 12px; }
.hall-list em { grid-row: 1 / span 2; grid-column: 3; font-style: normal; font-weight: 700; }
.hall-list .sc { color: hsl(calc(var(--s) * 1.2), 60%, 38%); font-size: 20px; }
.hall-list li.done { background: #f2fbf6; border-color: var(--mint); }
.hall-list li.now { border-color: var(--ink); box-shadow: 0 0 0 2px var(--yellow); }
.hall-list .go { background: var(--yellow); padding: 2px 6px; font-size: 12px; }

/* ---------- 검사실 ---------- */
#scTest.on { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding: var(--ad-top, 0px) var(--ad-right, 0px) var(--ad-bottom, 0px) var(--ad-left, 0px); box-sizing: border-box; }   /* 자동 광고(위·아래·옆 고정) 자리만큼 비켜서 배치 */
.test-head { height: 46px; flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--ink); border-bottom: 3px solid #000; }
.test-head b { font-size: 17px; color: var(--yellow); }
.test-head span { color: var(--muted); font-size: 14px; flex: 1; }
.room { position: relative; flex: 1; min-height: 0; background: #2b2236 center / cover no-repeat; image-rendering: pixelated; display: flex; flex-direction: column; }
.room::before { content: ""; position: absolute; inset: 0; background: rgba(23,16,30,.48); pointer-events: none; }
.stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.g-wrap { position: relative; flex: 1; min-height: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.g-cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.g-hud { position: absolute; left: 0; right: 0; top: 0; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.g-time { height: 10px; background: rgba(0,0,0,.45); box-shadow: 0 0 0 2px var(--ink); }
.g-time i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--yellow)); }
.g-stat { align-self: flex-end; background: rgba(35,26,43,.85); padding: 4px 10px; font-size: 15px; }
.g-pad { flex: 0 0 auto; display: flex; gap: 10px; padding: 10px 12px calc(12px + var(--safe-b)); background: rgba(23,16,30,.75); touch-action: none; position: relative; }
.g-big { flex: 1; height: clamp(90px, 18vh, 150px); font-size: 24px; font-weight: 700; color: #fff; border: 4px solid var(--ink); background: var(--orange); box-shadow: inset 0 -8px 0 rgba(0,0,0,.25); touch-action: none; }
.g-big.r { background: var(--purple); }
.g-big.on, .g-big:active { transform: translateY(3px); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); filter: brightness(1.15); }
.g-key { flex: 1; height: clamp(80px, 15vh, 120px); font-size: 30px; font-weight: 700; color: #fff; background: var(--kc); border: 4px solid var(--ink); box-shadow: inset 0 -8px 0 rgba(0,0,0,.25); touch-action: none; }
.g-key.on, .g-key:active { transform: translateY(3px); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.g-color { flex: 1; min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 17px; color: var(--ink); background: var(--cream); border: 4px solid var(--ink); cursor: pointer; touch-action: none; position: relative; }
.g-color i { width: 34px; height: 22px; background: var(--cc); box-shadow: 0 0 0 2px var(--ink); }
.g-color small { position: absolute; top: 3px; right: 6px; color: var(--dim); font-size: 11px; }
.g-color:active { background: #fff1c9; transform: translateY(2px); }

.overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; background: rgba(23,16,30,.72); padding: 16px; }
.tut { background: var(--cream); color: var(--ink); width: min(520px, 100%); padding: 22px; box-shadow: 0 0 0 4px var(--ink), 0 10px 0 4px rgba(0,0,0,.3); position: relative; animation: scIn .35s; }
.tut-step { font-size: 12px; color: var(--dim); }
.tut h2 { margin: 6px 0 12px; display: flex; align-items: center; gap: 10px; font-size: 26px; flex-wrap: wrap; }
.tut h2 small { font-size: 14px; color: var(--dim); font-weight: 400; }
.tut-ic canvas { width: 46px; height: 46px; display: block; }
.tut ul { margin: 0 0 18px; padding-left: 20px; line-height: 1.75; font-size: 16px; }
.tut-nurse { position: absolute; right: 10px; top: -60px; }
.tut-nurse canvas { width: 72px; height: 72px; animation: bob 1s steps(2) infinite; }
.tut .pbtn { width: 100%; }
.tut-wait { text-align: center; font-size: 17px; background: var(--ink); color: var(--cream); padding: 12px; }
.tut-wait b { color: var(--yellow); font-size: 24px; }
.cd b { font-size: clamp(80px, 22vw, 180px); color: var(--yellow); text-shadow: 0 6px 0 var(--ink), 6px 0 0 var(--ink), -6px 0 0 var(--ink), 0 -6px 0 var(--ink); display: inline-block; }
.cd b.pop { animation: cdPop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes cdPop { from { transform: scale(2.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bob { 50% { transform: translateY(-3px); } }

.sc-card { background: var(--cream); color: var(--ink); width: min(380px, 100%); padding: 22px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; box-shadow: 0 0 0 4px var(--ink), 0 10px 0 4px rgba(0,0,0,.3); animation: cdPop .45s cubic-bezier(.2,1.5,.4,1); }
.sc-grade { font-size: 58px; font-weight: 700; color: var(--gc); text-shadow: 0 4px 0 var(--ink); line-height: 1; }
.sc-num { font-size: 44px; }
.sc-num::after { content: attr(data-unit); font-size: 18px; margin-left: 4px; }   /* 단위는 언어별로 (영어는 pts) */
.sc-card em { font-style: normal; font-size: 14px; }
.sc-card .nb { color: #b8860b; font-weight: 700; animation: pulse 1s 3; }
.sc-card .pbtn { width: 100%; margin-top: 6px; }

/* ---------- 발급 ---------- */
.printer { width: min(420px, 90%); margin: 30px auto; }
.pr-body { background: #d6d0dc; color: var(--ink); padding: 18px; display: flex; align-items: center; gap: 12px; box-shadow: 0 0 0 4px var(--ink); font-size: 16px; }
.pr-led { width: 12px; height: 12px; background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink .4s steps(2) infinite; }
.pr-slot { height: 90px; margin: 0 26px; background: repeating-linear-gradient(0deg, var(--paper) 0 10px, #efe4cf 10px 12px); box-shadow: 0 0 0 4px var(--ink); transform-origin: top; animation: printOut 1.6s steps(8) forwards; }
@keyframes printOut { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes blink { 50% { opacity: .2; } }
.cert-box { margin: 10px auto 0; max-width: 820px; }
.loading, .empty { text-align: center; padding: 30px; color: var(--muted); list-style: none; }

/* 진단서 */
.cert { --pc: var(--paper); background: var(--pc); color: var(--ink); padding: clamp(16px, 4vw, 40px); position: relative; box-shadow: 0 0 0 5px var(--ink), 0 12px 0 5px rgba(0,0,0,.35); background-image: linear-gradient(transparent 31px, rgba(160,140,110,.08) 32px); background-size: 100% 32px; overflow: hidden; }
.cert-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; border-bottom: 4px double var(--ink); padding-bottom: 12px; flex-wrap: wrap; }
.cert-logo { display: flex; gap: 10px; align-items: center; }
.cert-logo .cross { width: 34px; height: 34px; position: relative; flex: 0 0 auto; }
.cert-logo .cross::before, .cert-logo .cross::after { content: ""; position: absolute; background: var(--red); }
.cert-logo .cross::before { left: 11px; top: 0; width: 12px; height: 34px; }
.cert-logo .cross::after { top: 11px; left: 0; height: 12px; width: 34px; }
.cert-logo b { font-size: 20px; display: block; } .cert-logo small { font-size: 10px; color: var(--dim); letter-spacing: .12em; }
.cert-no { text-align: right; display: flex; flex-direction: column; font-size: 12px; color: var(--dim); }
.cert-no b { color: var(--ink); font-size: 14px; }
.cert-title { text-align: center; font-size: clamp(30px, 6vw, 44px); letter-spacing: .35em; margin: 18px 0; }
.cert-patient { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.portrait { background: #d9eee9; padding: 6px; box-shadow: inset 0 0 0 3px var(--ink); }
.portrait canvas { width: clamp(84px, 16vw, 118px); height: auto; display: block; }
.pinfo { width: 100%; border-collapse: collapse; font-size: 14px; }
.pinfo th, .pinfo td { border: 2px solid var(--ink); padding: 7px 8px; text-align: left; }
.pinfo th { background: #efe4cf; white-space: nowrap; width: 1%; font-weight: 400; }
.cert-main { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; position: relative; }
.cert-main .big { background: #fff; box-shadow: inset 0 0 0 3px var(--ink); padding: 14px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.cert-main .big.age { background: #fff1c9; }
.cert-main .big small { font-size: 13px; color: var(--dim); } .cert-main .big small i { font-style: normal; font-size: 11px; }
.cert-main .num { font-size: clamp(46px, 10vw, 76px); line-height: 1.1; }
.cert-main .age .num { color: #c0392b; }
.cert-main em { font-style: normal; font-size: 15px; }
.diff.good { color: var(--green); } .diff.bad { color: #c0392b; }
.drum .num { animation: shake .1s infinite; }
.pop .num { animation: cdPop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes shake { 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
.stamp { position: absolute; right: -14px; bottom: -40px; width: 104px; height: 104px; z-index: 2; border-radius: 50%; border: 6px solid var(--sc); color: var(--sc); display: flex; flex-direction: column; align-items: center; justify-content: center; transform: rotate(-14deg); opacity: .9; background: rgba(255,255,255,.35); pointer-events: none; }
.stamp::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; border: 2px solid var(--sc); }
.stamp span { font-size: 32px; font-weight: 700; } .stamp small { font-size: 10px; }
.stamp.stamped { animation: stampIn .35s cubic-bezier(.3,1.7,.5,1); }
@keyframes stampIn { from { transform: rotate(-14deg) scale(2.4); opacity: 0; } to { transform: rotate(-14deg) scale(1); opacity: .9; } }
.cert-dx { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; margin-bottom: 18px; }
.dx-name, .dx-type { background: #fff; box-shadow: inset 0 0 0 3px var(--ink); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.dx-name small, .dx-type small { color: var(--dim); font-size: 12px; } .dx-name code { background: #efe4cf; padding: 1px 5px; }
.dx-name b { font-size: clamp(22px, 4.4vw, 30px); color: #c0392b; }
.dx-name em { font-style: normal; font-size: 13px; color: var(--purple); }
.dx-type b { font-size: 19px; color: #3c5a9a; } .dx-type p { margin: 0; font-size: 13px; line-height: 1.6; }
.cert h3 { font-size: 15px; margin: 0 0 8px; border-left: 6px solid var(--mint); padding-left: 8px; }
.cert-tests table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cert-tests td { padding: 6px 6px; border-bottom: 2px dashed var(--line); }
.cert-tests td:first-child { white-space: nowrap; }
.cert-tests .bar { width: 38%; position: relative; }
.cert-tests .bar i { display: block; height: 14px; width: var(--w); background: var(--blue); box-shadow: 0 0 0 2px var(--ink); }
.cert-tests tr[data-score] .bar i { background: linear-gradient(90deg, var(--blue), var(--mint)); }
.cert-tests .bar span { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-weight: 700; }
.cert-tests .ln { color: var(--dim); font-size: 12px; }
.tag { font-size: 10px; padding: 1px 4px; color: #fff; font-weight: 400; } .tag.best { background: var(--green); } .tag.worst { background: var(--red); }
.cert-tests tr.in .bar i { animation: grow .5s ease-out; }
@keyframes grow { from { width: 0; } }
.cert-ab { margin: 18px 0; }
.abs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 18px; }
.ab { display: grid; grid-template-columns: 54px 1fr 30px; align-items: center; gap: 6px; font-size: 13px; }
.ab i { height: 10px; background: #e3d8c4; position: relative; } .ab i::after { content: ""; position: absolute; inset: 0; width: var(--w); background: var(--purple); }
.ab.na em { grid-column: 2 / span 2; color: var(--muted); font-style: normal; font-size: 12px; }
.bw, .hl { font-size: 13px; margin: 10px 0 0; } .hl { color: #b8860b; }
.cert-op p { font-size: 15px; line-height: 1.85; margin: 0 0 8px; word-break: keep-all; }
.cert-op .genre, .cert-op .retest { font-size: 13px; color: var(--dim); }
.cert-foot { margin-top: 22px; padding-top: 14px; border-top: 4px double var(--ink); display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.doc { display: flex; align-items: center; gap: 10px; } .doc canvas { width: 64px; height: 64px; }
.doc div { display: flex; flex-direction: column; } .doc small { color: var(--dim); font-size: 11px; }
.sign { font-family: "Brush Script MT", cursive; font-size: 22px; color: #3c5a9a; }
.seal { width: 82px; height: 82px; border: 4px solid #d23a2f; color: #d23a2f; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 13px; font-weight: 700; line-height: 1.25; transform: rotate(6deg); opacity: .85; }
.disc { grid-column: 1 / -1; font-size: 11px; color: var(--dim); margin: 0; }
.cert .hide { opacity: 0; transform: translateY(8px); }
.cert .rv, .cert .rv-last, .cert tr.rv { transition: opacity .35s, transform .35s; }
.cert .stamp.hide { opacity: 0; transform: rotate(-14deg) scale(2); }

/* 공유 */
.share { background: var(--night2); padding: 18px; margin: 22px auto; max-width: 820px; box-shadow: 0 0 0 4px var(--ink); }
.share h3 { margin: 0 0 12px; font-size: 17px; }
.sh-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: center; }
.sh-row .pbtn { flex: 1 1 140px; font-size: 14px; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.sh-row.cta .pbtn { flex: 1 1 220px; }
.share .chk { color: var(--cream); margin: 0 6px; }
.vs-result { max-width: 820px; margin: 20px auto; background: var(--cream); color: var(--ink); padding: 18px; box-shadow: 0 0 0 4px var(--ink); text-align: center; animation: cdPop .5s; }
.vs-result.win { box-shadow: 0 0 0 4px var(--ink), 0 0 0 10px var(--yellow); }
.vs-result h3 { font-size: 26px; margin: 0 0 10px; }
.vs-cols { display: flex; justify-content: center; align-items: center; gap: 30px; font-size: 26px; }
.vs-result table { margin: 12px auto 0; border-collapse: collapse; font-size: 14px; }
.vs-result td, .vs-result th { padding: 4px 12px; border-bottom: 2px dashed var(--line); }
.vs-result td.w { color: var(--green); font-weight: 700; }
.av.jump { animation: jump .5s ease-in-out infinite alternate; } .av.shake { animation: shake .15s 6; }
@keyframes jump { to { transform: translateY(-10px); } }

/* 개별검사 · 랭킹 · 기록 */
.prac-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.prac { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; background: #fff; border: 3px solid var(--ink); cursor: pointer; color: var(--ink); }
.prac:hover { background: #fff1c9; transform: translateY(-2px); }
.prac b { font-size: 15px; } .prac small { font-size: 12px; color: var(--dim); } .prac em { font-style: normal; font-size: 12px; color: var(--green); }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.tabs button { flex: 1; padding: 9px 6px; border: 3px solid var(--ink); background: #fff; cursor: pointer; font-size: 14px; color: var(--ink); }
.tabs.sm button { padding: 6px; font-size: 13px; }
.tabs button.on { background: var(--ink); color: var(--yellow); }
.rk-sel { display: flex; gap: 8px; margin: 6px 0 12px; }
.rk-sel select { flex: 1; padding: 8px; border: 3px solid var(--ink); font-size: 14px; background: #fff; color: var(--ink); }
.rk-list, .hs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rk-list li { display: grid; grid-template-columns: 36px 40px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; background: #fff; border: 3px solid var(--line); }
.rk-list li.link { cursor: pointer; } .rk-list li.link:hover { border-color: var(--ink); }
.rk-list li.t1 { background: #fff1c9; border-color: var(--yellow); } .rk-list li.t2 { background: #f1f2f6; } .rk-list li.t3 { background: #f8e7d8; }
.rk-n { font-size: 18px; font-weight: 700; text-align: center; }
.rk-name { display: flex; flex-direction: column; min-width: 0; } .rk-name small { color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-v { text-align: right; display: flex; flex-direction: column; } .rk-v b { font-size: 17px; } .rk-v small { font-size: 11px; color: var(--dim); }
.hs-best h3 { font-size: 15px; margin: 0 0 6px; } .hb { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; } .hb span { background: #eef7f3; padding: 4px 8px; font-size: 13px; }
.hs-list a { display: grid; grid-template-columns: 90px 70px 1fr auto; grid-template-rows: auto auto; gap: 2px 8px; padding: 10px; background: #fff; border: 3px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px; align-items: center; }
.hs-list a:hover { border-color: var(--ink); }
.hs-list small { grid-column: 1 / -1; color: var(--dim); font-size: 12px; } .hs-list em { font-style: normal; }
.hs-list i { font-style: normal; font-weight: 700; } .hs-list i.up { color: var(--green); } .hs-list i.down { color: var(--red); }

/* ---------- 광고 (게임·버튼과 분리, 자리 고정으로 밀림 방지) ---------- */
.ad-slot { margin: 26px auto 8px; max-width: 728px; min-height: 0; text-align: center; clear: both; }
.ad-slot:not(:empty) { min-height: 100px; padding-top: 6px; border-top: 2px dashed rgba(255,247,232,.12); }
.ad-label { display: block; font-size: 10px; color: var(--muted); margin-bottom: 4px; }
body.in-test .ad-slot, .ad-slot.ad-empty { display: none; }
.side-ad { position: fixed; top: 76px; width: 160px; height: 600px; z-index: 1; }
/* 양옆 끝 쪽으로: 본문(1040px)에서 120px 띄우되 화면 끝에서 16px 안쪽까지만 → 1580px 화면에서도 본문과 94px 이상 떨어짐 (가리지 않음) */
.side-ad.l { left: max(16px, calc(50% - 520px - 120px - 160px)); } .side-ad.r { right: max(16px, calc(50% - 520px - 120px - 160px)); }
body.in-test .side-ad { visibility: hidden; }
@media (max-width: 1579px), (max-height: 759px) { .side-ad { display: none !important; } }

/* ---------- 토스트 ---------- */
.toasts, #toasts { position: fixed; left: 0; right: 0; margin: 0 auto; bottom: calc(18px + var(--safe-b)); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 520px); }
.toast { background: var(--cream); color: var(--ink); padding: 10px 16px; box-shadow: 0 0 0 3px var(--ink); font-size: 14px; animation: scIn .25s; text-align: center; }
.toast.error { background: #ffd9d4; } .toast.success { background: #d6f3e1; } .toast.warn { background: #fff1c9; }
.toast.out { opacity: 0; transition: opacity .3s; }

/* ---------- 로그인 창 (사이트 공통 login-modal.js용 최소 스타일) ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(10,6,16,.7); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.hidden { display: none; }
.modal-box { background: var(--cream); color: var(--ink); width: min(420px, 100%); box-shadow: 0 0 0 4px var(--ink); max-height: 90vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 3px solid var(--ink); }
.modal-head h3 { margin: 0; }
.icon-btn { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--ink); }
.auth-tabs { display: flex; } .auth-tab { flex: 1; padding: 10px; border: 0; border-bottom: 3px solid var(--line); background: none; cursor: pointer; font-size: 15px; }
.auth-tab.active { border-bottom-color: var(--ink); font-weight: 700; }
.modal-body { padding: 16px; } .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 14px; }
.field input { padding: 10px; border: 3px solid var(--ink); font-size: 16px; width: 100%; }
.password-wrap { display: flex; } .pw-toggle { border: 3px solid var(--ink); border-left: 0; background: #fff; cursor: pointer; }
.btn.primary { width: 100%; padding: 12px; border: 3px solid var(--ink); background: var(--green); color: #fff; font-size: 16px; cursor: pointer; }
.error-text { color: var(--red); } .success-text { color: var(--green); }

/* ---------- 반응형 ---------- */
@media (max-width: 760px) {
  .menu { grid-template-columns: 1fr; }
  .menu-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .menu-row .pbtn { padding: 4px 6px 8px; font-size: 14px; }
  .pf { grid-template-columns: 1fr; }
  .pf-char { flex-direction: row; justify-content: center; }
  .pf-cv { width: 140px; height: 140px; }
  .pf-parts { grid-template-columns: 1fr; }
  .fld { grid-template-columns: 76px 1fr; }
  .modes { grid-template-columns: 1fr; }
  .cert-main { grid-template-columns: 1fr; }
  .stamp { width: 84px; height: 84px; bottom: -30px; right: -8px; } .stamp span { font-size: 22px; }
  .cert-dx { grid-template-columns: 1fr; }
  .cert-tests .ln { display: none; }
  .abs { grid-template-columns: 1fr; }
  .cert-patient { grid-template-columns: 1fr; justify-items: center; }
  .pinfo { font-size: 13px; }
  .tb-title { font-size: 13px; }
  .hs-list a { grid-template-columns: 1fr auto; }
  .tut h2 { font-size: 22px; }
  .tut-nurse { top: -50px; } .tut-nurse canvas { width: 56px; height: 56px; }
}
@media (max-width: 380px) {
  .topbar .home { font-size: 13px; } .tb-title { display: none; }
  .g-color { font-size: 14px; min-height: 64px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; } }

/* ---------- 프로필 연동 (회원 사진·게스트 카드·공개 설정) ---------- */
.pf-card { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; background: #eef7f3; padding: 14px; box-shadow: inset 0 0 0 3px var(--mint); }
.pf-card-av canvas { width: 90px; height: 90px; display: block; }
.pf-card-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pf-card-info b { font-size: 22px; display: flex; align-items: center; gap: 8px; }
.pf-card-info small { color: var(--dim); font-size: 12px; }
.pf-card-btns { display: flex; flex-direction: column; gap: 6px; }
.pbtn.ghost-dark { border: 3px solid var(--ink); border-image: none; color: var(--ink); padding: 4px 10px; min-height: 34px; }
.pf-photo { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--ink); flex: 0 0 auto; }
.pf-locked { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pf-locked b { font-size: 18px; } .pf-locked small { color: var(--dim); font-size: 11px; }
.pf-privacy { display: flex; flex-direction: column; gap: 2px; background: #f6efe1; padding: 6px 10px; }
.pf-privacy .chk { margin: 2px 0; font-size: 13px; }
.guest-badge { display: inline-block; font-style: normal; font-size: 10px; background: var(--muted); color: #fff; padding: 0 5px; margin-left: 6px; vertical-align: middle; }
.rk-av { position: relative; display: flex; align-items: center; justify-content: center; }
.rk-photo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--ink); }
.vs-banner.merge { background: var(--mint); animation: none; }
@media (max-width: 760px) {
  .pf-card { grid-template-columns: auto 1fr; }
  .pf-card-btns { grid-column: 1 / -1; flex-direction: row; }
  .pf-card-btns .pbtn { flex: 1; }
  /* 진단서 환자 정보 표: 좁은 화면에서는 2열로 (일본어·영어 칸 이름이 길어도 안 깨짐) */
  .pinfo, .pinfo tbody, .pinfo tr { display: grid; grid-template-columns: auto 1fr; }
  .pinfo tr { display: contents; }
  .pinfo th, .pinfo td { display: block; }
  .pinfo th { width: auto; }   /* 넓은 화면용 width:1%가 남으면 영어 칸 이름이 칸 밖으로 넘침 */
  .pinfo td[colspan] { grid-column: auto; }
}

/* ---------- 방송 진단소 참여 (?bc=) ---------- */
.vs-banner.bc { background: #ffd9d4; animation: none; flex-wrap: wrap; }
.vs-banner.bc > div:first-child { font-size: 28px; }
.vs-banner.bc > div:nth-child(2) { min-width: 200px; }
.mode.locked { opacity: .4; }
.bc-opt { margin: 10px 0 4px; padding: 10px 12px; background: #ffd9d4; box-shadow: inset 0 0 0 3px var(--ink); display: flex; flex-direction: column; gap: 6px; }
.bc-opt small { color: var(--dim); font-size: 12px; }
#bcResult { margin: 14px 0; }

/* 방송 참여 결과: 비교 화면으로 가는 떠 있는 버튼 (진단서 화면에서만) */
.bc-float { position: fixed; z-index: 60; right: 14px; bottom: calc(14px + var(--ad-bottom, 0px) + var(--safe-b)); box-shadow: 0 6px 18px rgba(0,0,0,.4); }
body:not([data-screen="scIssue"]) .bc-float { display: none; }

/* 시청자 순위 더보기 */
.rk-more ol { margin-top: 6px; max-height: 480px; overflow-y: auto; }
.rk-more-btns { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
