/* Freesentation (SIL OFL 1.1, 이주임) — 사이트에 쓰인 글자만 남긴 가변 폰트 서브셋 */
@font-face {
  font-family: "Freesentation";
  src: url("assets/fonts/freesentation.4669a602.woff2") format("woff2");
  font-weight: 100 800; font-style: normal; font-display: swap;
}
/* Caltype 공통 스타일. 이미지 없음, 글꼴은 Freesentation 서브셋. */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #faf9f6;
  --ink: #1d1c1a;
  --text: #3f3d39;
  --muted: #5e5b55;
  --faint: #75716a;
  --ghost: #8f8b83;
  --line: #e7e4dd;
  --line2: #d5d1c8;
  --accent: #2457c5;
  --accent-ink: #1d4aa8;
  --accent-soft: #edf2fc;
  --ok: var(--accent);
  --red: #c8352b;
  --fever: #c2560c; --fever-hi: #e07a2e; --fever-soft: rgba(224, 122, 46, .14);
  --red-soft: #fbecea;
  --bar: #ebe8e1;
  /* 키캡 (크림 알파 + 웜그레이 모디파이어 + 블루 엔터) */
  --case: #34343a;
  --case-hi: #3e3e45;
  --font: "Freesentation", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #161615;
  --surface: #1e1e1c;
  --surface2: #232321;
  --ink: #eceae5;
  --text: #cfccc6;
  --muted: #a6a39c;
  --faint: #8a877f;
  --ghost: #6f6c66;
  --line: #2c2b28;
  --line2: #3b3a36;
  --accent: #6f9df0;
  --accent-ink: #93b6f5;
  --accent-soft: rgba(111, 157, 240, .12);
  --red: #f0675d;
  --fever: #f0954a; --fever-hi: #ffb877; --fever-soft: rgba(240, 149, 74, .16);
  --red-soft: rgba(240, 103, 93, .13);
  --bar: #2f2e2b;
  --case: #0e0e0f;
  --case-hi: #18181a;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.6 var(--font); letter-spacing: -0.005em; word-spacing: .06em;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { color: var(--ink); letter-spacing: -0.02em; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
b, strong { color: var(--ink); font-weight: 650; }
kbd {
  font: 600 .78em/1 var(--font); padding: .22em .45em; border-radius: 4px;
  border: 1px solid var(--line2); border-bottom-width: 2px; background: var(--surface); color: var(--ink); white-space: nowrap;
}
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 24px; }   /* 본문 칸 1280px, 좌우 여백은 광고 자리 */

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.header-inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.logo { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; }
.logo-mark { color: var(--ink); display: block; }
.logo-text { font-weight: 750; font-size: 1.02rem; letter-spacing: -0.03em; }
.header-nav { display: flex; gap: 20px; margin-right: auto; height: 100%; }
.header-nav a { display: flex; align-items: center; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.header-nav a:hover { color: var(--ink); }
.header-nav a.active { color: var(--ink); border-bottom-color: var(--ink); }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line2); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; }
.icon-btn .i-sun, [data-theme="dark"] .icon-btn .i-moon { display: none; }
[data-theme="dark"] .icon-btn .i-sun { display: block; }

/* ---------- 광고: 1280px 본문 칸 바깥 좌우 여백(gutter) ----------
   .ad-rail 은 body 기준 absolute 라서 넣어도 본문이 밀리지 않습니다.
   160px 광고 + 안쪽·바깥 16px 간격: (화면 - 1280) / 2 >= 192 → 1664px 이상에서만 표시. */
body { position: relative; }
.ad-rail { display: none; }
@media (min-width: 1664px) {
  .ad-rail { display: block; position: absolute; top: 76px; bottom: 0; width: 160px; pointer-events: none; }
  .ad-rail-left { right: calc(50% + 640px + 16px); }
  .ad-rail-right { left: calc(50% + 640px + 16px); }
  .ad-rail-inner { position: sticky; top: 16px; width: 160px; min-height: 600px; pointer-events: auto; contain: layout paint; }
}

/* ---------- Layout ---------- */
.layout { margin-top: 20px; }
.game-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 24px 18px; }
.game-intro { margin-bottom: 12px; }
.game-title { margin: 0 0 2px; font-size: 1.45rem; font-weight: 750; line-height: 1.3; }
.game-sub { margin: 0; color: var(--muted); font-size: .9rem; }

/* ---------- Controls ---------- */
.btn-sm {
  height: 30px; padding: 0 11px; border: 1px solid var(--line2); border-radius: 6px; background: var(--surface);
  font-size: .82rem; font-weight: 600; color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn-sm:hover { border-color: var(--faint); color: var(--ink); }
.btn-sm.toggle[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.setup-label { display: block; font-size: .74rem; font-weight: 650; color: var(--muted); margin-bottom: 6px; letter-spacing: .02em; }
.mode-tiles { display: grid; gap: 5px; }
.tile {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; text-align: left; text-decoration: none;
  padding: 6px 12px; border: 1px solid var(--line2); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer;
}
.tile:hover { border-color: var(--faint); }
.tile-name { font-weight: 650; font-size: .88rem; color: var(--ink); }
.tile-sub { font-size: .74rem; color: var(--faint); }
.tile.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.seg { display: flex; border: 1px solid var(--line2); border-radius: 8px; padding: 3px; gap: 3px; background: var(--surface2); }
.seg button { flex: 1; border: 0; background: none; border-radius: 5px; padding: 6px 8px; font-size: .84rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--ink); color: var(--surface); }
.best-chip { margin-top: 8px; font-size: .78rem; color: var(--muted); }
.best-chip b { font-variant-numeric: tabular-nums; }
.link-btn { border: 0; background: none; padding: 2px 0; font-size: .84rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.link-btn:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.btn { display: block; width: 100%; text-align: center; text-decoration: none; border: 0; border-radius: 8px; padding: 12px 16px; font-size: .95rem; font-weight: 650; cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-primary kbd { margin-left: 6px; background: transparent; border-color: rgba(255,255,255,.45); color: #fff; font-size: .7rem; }

/* ---------- Game: play area ---------- */
.play { border-top: 1px solid var(--line); padding-top: 12px; }
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.progress { flex: 1; height: 4px; background: var(--bar); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--ok); transition: width .25s ease; }
.progress-text { min-width: 54px; text-align: right; font-size: .84rem; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.progress-text.warn { color: var(--red); }

.stage { position: relative; }
.stats-bar { display: flex; justify-content: center; gap: 22px; margin-bottom: 10px; font-size: .74rem; color: var(--muted); }
.stats-bar b { margin-right: 3px; font-size: 1rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stats-bar i { font-style: normal; margin-left: 3px; }
.stats-bar .hot b, .hud-stats .hot b { color: var(--ok); }
.target-card { position: relative; background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 18px 14px; }
.target-card.shake { animation: shake .28s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.target-card.flash-ok { animation: flashok .4s; }
@keyframes flashok { from { border-color: var(--ok); } }
.mode-badge { position: absolute; top: 10px; left: 12px; z-index: 2; font-size: .72rem; font-weight: 600; color: var(--faint); }

/* 세로 목록: 완료(위) · 현재 · 다음(아래로 흐려짐) */
.queue {
  height: 250px; display: flex; flex-direction: column; align-items: center; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 21%, #000 56%, rgba(0,0,0,.28) 80%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 21%, #000 56%, rgba(0,0,0,.28) 80%, transparent 100%);
}
.row { width: 100%; flex-shrink: 0; text-align: center; transition: transform .32s cubic-bezier(.2, .8, .2, 1); font-variant-numeric: tabular-nums; }
.row.ph, .row.done { height: 30px; line-height: 30px; font-size: .82rem; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 70px; }
.row.done .txt { font-size: 1.05rem; font-weight: 550; color: var(--ok); }
.row.done.was-bad .txt { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--red); }
.row.done.up2 { opacity: .55; }
.row .mark-ok { color: var(--ok); font-weight: 700; }
.row .mark-bad { color: var(--red); font-weight: 700; }
.row .res { color: var(--faint); }
.row.cur { min-height: 116px; padding: 4px 0 6px; display: flex; flex-direction: column; justify-content: center; }
.row.cur.promote { animation: promote .3s cubic-bezier(.2, .9, .3, 1); }
@keyframes promote { from { scale: .7; opacity: .5; } }
.row.next { color: var(--muted); font-weight: 550; line-height: 1.25; padding: 4px 20px; word-break: break-all; }
.row.n1 { font-size: 1.7rem; opacity: .8; }
.row.n2 { font-size: 1.4rem; opacity: .6; }
.row.n3 { font-size: 1.18rem; opacity: .45; }
.row.n4 { font-size: 1rem; opacity: .32; }
.row.enter { animation: rowin .32s ease both; }
@keyframes rowin { from { translate: 0 18px; opacity: 0; } }
.end-msg { font-size: 1.6rem; font-weight: 650; color: var(--ok); }

.target {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; padding-top: 16px;
  font-size: clamp(2rem, 4.4vw, 3rem); font-weight: 600; line-height: 1.05; letter-spacing: .005em; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.target.long { font-size: clamp(1.7rem, 3.3vw, 2.35rem); }
.target.xlong { font-size: clamp(1.4rem, 2.7vw, 1.9rem); }
.target .w { display: inline-flex; align-items: flex-end; white-space: nowrap; }
.target.xxlong { font-size: clamp(1.15rem, 2vw, 1.5rem); }
.target .c { position: relative; color: var(--ghost); padding: 0 .02em .16em; min-width: .5em; text-align: center; }
.target .c::after { content: ""; position: absolute; left: 10%; right: 10%; bottom: 0; height: 3px; border-radius: 2px; background: var(--bar); }
.target .c.ok { color: var(--ok); }
.target .c.ok::after { background: var(--ok); }
.target .c.bad { color: var(--red); }
.target .c.bad::after { background: var(--red); }
.target .c.bad::before { content: attr(data-orig); position: absolute; left: 0; right: 0; top: -1.05em; text-align: center; font-size: .36em; font-weight: 600; color: var(--red); }
.target .c.cur { color: var(--ink); }
.target .c.cur::after { background: var(--ink); animation: blink 1s steps(1) infinite; }
.target .sep { color: var(--ghost); padding-bottom: .16em; }
.target .sep.ok { color: var(--ok); }
@keyframes blink { 50% { opacity: .2; } }
.reading { margin-top: 6px; font-size: .78rem; color: var(--muted); min-height: 1.2em; }
.lcd-msg {
  position: absolute; left: 50%; bottom: -11px; transform: translateX(-50%); white-space: nowrap;
  font-size: .74rem; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--line2); border-radius: 4px; padding: 1px 10px;
}
.lcd-msg:empty { display: none; }
.lcd-msg.err { color: var(--red); border-color: var(--red); background: var(--surface); }

.pad-wrap { display: flex; justify-content: center; align-items: flex-start; gap: 22px; margin-top: 18px; }
.pad-side { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.play .pad-side.setup { flex: 1 1 auto; max-width: 480px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: stretch; }
.setup-col { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.play .pad-side .key-bs { height: 40px; margin-top: auto; }
.setup-block.opts { border-top: 1px solid var(--line); padding-top: 9px; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.opt-row + .opt-row { margin-top: 5px; }
.opt-row > span, .opt-row > label { font-size: .82rem; color: var(--text); }
.select-sm {
  height: 28px; padding: 0 26px 0 8px; border: 1px solid var(--line2); border-radius: 6px; background-color: var(--surface); color: var(--text);
  font: inherit; font-size: .8rem; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 12px top 12px, right 8px top 12px; background-size: 4px 4px; background-repeat: no-repeat;
}
.opt-row .select-sm { flex: 0 1 150px; min-width: 0; }
.select-sm:hover { border-color: var(--faint); }
.range-sm { flex: 0 1 150px; width: 150px; min-width: 0; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.range-sm:disabled { opacity: .4; cursor: default; }
.sound-ctl { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; font-size: .8rem; color: var(--muted); }
.sound-ctl label + .range-sm { margin-left: 0; }
.sound-ctl .select-sm { width: 140px; }
.sound-ctl .range-sm { flex: 0 0 110px; width: 110px; }
.seg-sm { flex: 0 1 150px; padding: 2px; gap: 2px; }
.seg-sm button { padding: 4px 6px; font-size: .78rem; }
.kbd-help { margin: 16px 0 0; font-size: .76rem; color: var(--faint); text-align: center; }
.kbd-help kbd { font-size: .72em; }

/* ---------- 기계식 키캡 ---------- */
.numpad {
  display: grid; gap: 6px;
  grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(5, 52px);
  grid-template-areas: "num div mul sub" "k7 k8 k9 add" "k4 k5 k6 add" "k1 k2 k3 ent" "k0 k0 dot ent";
  user-select: none; -webkit-user-select: none;
}
.calc-pad-wrap, .play .numpad {
  padding: 10px; border-radius: 10px; background: var(--case);
  box-shadow: inset 0 1px 0 var(--case-hi), inset 0 -2px 0 rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.12);
}
.key {
  --cap: #f2eee5; --cap-hi: #faf8f2; --wall: #ddd6c7; --wall-lo: #cbc3b1; --edge: #a89f8c; --legend: #34322d;
  position: relative; isolation: isolate; border: 0; padding: 0; cursor: pointer;
  border-radius: 6px; color: var(--legend);
  background: linear-gradient(180deg, var(--wall), var(--wall-lo));
  box-shadow: 0 2px 0 var(--edge), 0 3px 3px rgba(0,0,0,.28);
  transition: transform 40ms ease-out, box-shadow 40ms ease-out;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.key::before {          /* 윗면(살짝 오목한 표면) */
  content: ""; position: absolute; z-index: -1; top: 2px; left: 4px; right: 4px; bottom: 6px; border-radius: 4px;
  background: radial-gradient(130% 100% at 50% 15%, var(--cap-hi), var(--cap) 70%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 1px 1px rgba(0,0,0,.08);
}
.key .lg { position: absolute; top: 7px; left: 10px; font-size: 1rem; font-weight: 500; line-height: 1; letter-spacing: 0; }
.key small { position: absolute; left: 10px; bottom: 11px; font-size: .56rem; font-weight: 500; opacity: .6; line-height: 1; }
.key-mod { --cap: #d6d1c5; --cap-hi: #e2ded4; --wall: #c4beb0; --wall-lo: #b3ac9d; --edge: #918a7b; }
.key-mod .lg { font-size: .9rem; }
.key-accent { --cap: #2f5fbf; --cap-hi: #3b6cca; --wall: #2953a8; --wall-lo: #22478f; --edge: #183369; --legend: #f2eee5; }
.key-accent::before { box-shadow: inset 0 1px 0 rgba(255,255,255,.2); }
.key-clear { --legend: #a8322a; }
.key-home::after { content: ""; position: absolute; left: 50%; bottom: 13px; width: 10px; height: 2px; margin-left: -5px; border-radius: 1px; background: var(--legend); opacity: .28; }
.key.pressed, .key:active { transform: translateY(2px); box-shadow: 0 0 0 var(--edge), 0 1px 1px rgba(0,0,0,.3); }
.key.pressed::before, .key:active::before { background: var(--cap); }
.key.pressed-bad { --cap: #f0c9c3; --cap-hi: #f5d8d3; --legend: #9c2a22; }
.key.hint { outline: 2px solid var(--accent); outline-offset: 2px; }
.key-accent.hint { outline-color: #f2eee5; }
[data-theme="dark"] .key { --cap: #47464c; --cap-hi: #515057; --wall: #3b3a40; --wall-lo: #323137; --edge: #1c1b1f; --legend: #e8e5de; }
[data-theme="dark"] .key::before { box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 1px 1px rgba(0,0,0,.2); }
[data-theme="dark"] .key-mod { --cap: #34333a; --cap-hi: #3c3b42; --wall: #2c2b31; --wall-lo: #252429; --edge: #121114; --legend: #cfcbc3; }
[data-theme="dark"] .key-accent { --cap: #3463c4; --cap-hi: #3f6fd0; --wall: #2c56ac; --wall-lo: #254a94; --edge: #142c5c; --legend: #f2eee5; }
[data-theme="dark"] .key-clear { --legend: #f08a80; }
[data-theme="dark"] .key.pressed-bad { --cap: #6b2e2a; --cap-hi: #7a3530; --legend: #ffd9d4; }
.key-bs .lg { position: static; display: block; font-size: .84rem; padding-bottom: 4px; }

/* 게임에서는 키패드를 작게 (목록이 주인공) */
.play .numpad { flex: 0 0 236px; grid-template-rows: repeat(5, 38px); gap: 5px; padding: 8px; }
.play .numpad .key .lg { top: 5px; left: 8px; font-size: .84rem; }
.play .numpad .key-mod .lg { font-size: .74rem; }
.play .numpad .key small { display: none; }
.play .numpad .key-home::after { bottom: 9px; width: 8px; margin-left: -4px; }
@media (hover: hover) and (pointer: fine) { .pad-hidden .play .numpad { display: none; } }

/* ---------- 콤보 게이지 · 피버 ---------- */
.target-card { transition: border-color .3s, box-shadow .3s; }
.combo { position: absolute; z-index: 2; top: 12px; right: 14px; bottom: 14px; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.combo-label { display: flex; flex-direction: column; align-items: center; line-height: 1; min-height: 38px; justify-content: flex-end; }
.combo-label b { font-size: 1.5rem; font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums; }
.combo-label span { margin-top: 3px; font-size: .62rem; font-weight: 700; letter-spacing: .08em; color: var(--muted); white-space: nowrap; }
.combo-gauge { position: relative; flex: 1; width: 8px; border: 1px solid var(--line2); border-radius: 5px; background: var(--surface); overflow: hidden; }
.combo-gauge i { position: absolute; left: 0; right: 0; height: 1px; background: var(--line2); }
.combo-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--accent); border-radius: 4px; transition: height .35s cubic-bezier(.2, .8, .2, 1); }
.combo.idle .combo-label span { color: var(--faint); }
.combo.pop .combo-label b { animation: combopop .32s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes combopop { from { transform: scale(1.45); opacity: .4; } }
.combo.drain .combo-fill { transition: height .6s ease-in; }
.combo.drain .combo-gauge { animation: drainflash .6s ease; }
@keyframes drainflash { 30% { border-color: var(--red); } }
.combo.fever .combo-label b, .combo.fever .combo-label span { color: var(--fever); }
.combo.fever .combo-fill {
  background: repeating-linear-gradient(0deg, var(--fever) 0 10px, var(--fever-hi) 10px 20px); background-size: 100% 40px;
  animation: feverflow .8s linear infinite;
}
@keyframes feverflow { to { background-position: 0 -40px; } }
.target-card.fever { border-color: var(--fever); box-shadow: inset 0 0 0 1px var(--fever), 0 0 0 4px var(--fever-soft); }
.target-card.fever .target .c.ok, .target-card.fever .target .sep.ok { color: var(--fever); }
.target-card.fever .target .c.ok::after { background: var(--fever); }
.stat-score { position: relative; }
.score-float { position: absolute; left: 50%; top: -4px; transform: translateX(-50%); white-space: nowrap; font-size: .76rem; font-weight: 700; color: var(--accent); pointer-events: none; animation: scorefloat .9s ease-out forwards; }
.score-float.fever { color: var(--fever); }
@keyframes scorefloat { from { opacity: 0; translate: 0 6px; } 20% { opacity: 1; } to { opacity: 0; translate: 0 -18px; } }
.play .row.ph, .play .row.done { padding-left: 88px; padding-right: 88px; }
.play .row.cur, .play .row.next { padding-left: 80px; padding-right: 80px; }

/* ---------- Result ---------- */
.result-overlay {
  position: absolute; inset: 0; z-index: 10; border-radius: 12px; background: rgba(22, 22, 21, .32);
  display: flex; align-items: center; justify-content: center; padding: 18px; animation: fade .18s ease;
}
.result-overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.result-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line2); border-radius: 12px; padding: 22px 22px 16px; text-align: center; box-shadow: 0 16px 40px rgba(0,0,0,.18); }
.result-eyebrow { margin: 0; font-size: .76rem; font-weight: 650; color: var(--muted); }
.result-card h2 { margin: 2px 0 6px; font-size: 1.3rem; }
.result-record { display: inline-block; margin-bottom: 6px; padding: 2px 8px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-ink); font-size: .76rem; font-weight: 700; }
.result-record[hidden] { display: none; }
.result-main { display: grid; grid-template-columns: repeat(3, 1fr); margin: 10px 0 4px; }
.result-main b { display: block; font-size: 1.9rem; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
.result-main div:first-child b { color: var(--ok); }
.result-main span { font-size: .72rem; color: var(--muted); }
.result-rank { margin: 10px 0 12px; font-size: .86rem; color: var(--text); }
.receipt { margin: 0 0 16px; padding: 8px 0; border-top: 1px dashed var(--line2); border-bottom: 1px dashed var(--line2); text-align: left; }
.receipt-row { display: flex; justify-content: space-between; padding: 3px 2px; font-size: .84rem; }
.receipt-row dt { color: var(--muted); }
.receipt-row dd { margin: 0; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.receipt-row.total { margin-top: 4px; padding-top: 7px; border-top: 1px solid var(--line); }
.receipt-row.total dd { color: var(--ok); }
.result-actions { display: flex; justify-content: center; gap: 18px; margin-top: 10px; }

/* ---------- Calculator ---------- */
.calc-layout { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 28px; align-items: start; }
.calc-main { min-width: 0; }
.calc-display {
  position: relative; overflow: hidden; margin-bottom: 14px; padding: 10px 16px 12px; min-height: 156px;
  background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; text-align: right;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.calc-status { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: auto; font-size: .72rem; color: var(--muted); text-align: left; }
.level { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.level b { font-weight: 700; }
.xp-bar { display: inline-block; width: 64px; height: 3px; background: var(--bar); border-radius: 2px; overflow: hidden; }
.xp-fill { display: block; height: 100%; width: 0; background: var(--ink); transition: width .3s ease; }
.xp-text { font-variant-numeric: tabular-nums; color: var(--faint); }
.hud-stats { display: flex; gap: 12px; white-space: nowrap; }
.hud-stats b { margin-right: 2px; font-size: .86rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.calc-expr-prev { min-height: 1.4em; margin-top: 10px; font-size: .86rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.calc-expr-prev.slide-up { animation: slideup .3s ease; }
@keyframes slideup { from { transform: translateY(20px); opacity: 0; } }
.calc-expr { min-height: 1.15em; font-size: clamp(2.3rem, 5vw, 3rem); font-weight: 500; line-height: 1.15; color: var(--ink); letter-spacing: -0.01em; word-break: break-all; font-variant-numeric: tabular-nums; }
.calc-expr.md { font-size: clamp(1.9rem, 4vw, 2.4rem); }
.calc-expr.sm { font-size: clamp(1.55rem, 3.2vw, 1.9rem); }
.calc-expr.xs { font-size: clamp(1.25rem, 2.6vw, 1.55rem); }
.calc-expr.result { color: var(--ok); font-weight: 600; }
.calc-display .calc-expr.result.res-pop { animation: respop .12s ease-out; transform-origin: right center; }
@keyframes respop { from { transform: scale(1.06); } }
.calc-expr .op, .calc-expr-prev .op, .h-expr .op { color: var(--muted); }
.calc-expr .sep { color: var(--faint); }
.calc-expr .pop { display: inline-block; animation: popin .16s ease-out; }
@keyframes popin { from { transform: translateY(35%); opacity: 0; } }
.calc-zero { color: var(--faint); }
.calc-expr .caret { display: inline-block; width: 2px; height: .85em; margin-left: 3px; vertical-align: -0.06em; background: var(--ink); animation: blink 1s steps(1) infinite; }
.calc-preview { min-height: 1.5em; font-size: 1.05rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.calc-display.result-pop { animation: rpop .3s ease; }
@keyframes rpop { from { border-color: var(--ok); } }
.calc-display.shake { animation: shake .28s; }
.calc-display.clear-wipe .calc-expr { animation: wipe .2s ease; }
@keyframes wipe { from { opacity: 0; transform: translateX(-16px); } }
.calc-toast {
  position: absolute; left: 16px; top: 34px; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .74rem; font-weight: 650; color: var(--accent-ink); background: var(--accent-soft); border-radius: 4px; padding: 2px 8px;
  opacity: 0; transition: opacity .15s; pointer-events: none;
}
.calc-toast.show { opacity: 1; }
.calc-toast.err { color: var(--red); background: var(--red-soft); }
.float-xp { position: absolute; right: 16px; top: 46%; font-size: .78rem; font-weight: 700; color: var(--muted); pointer-events: none; animation: floatup .8s ease forwards; }
@keyframes floatup { to { transform: translateY(-30px); opacity: 0; } }
.calc-util { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 6px; }
.calc-util .key { height: 40px; }
.calc-util .key .lg { top: 6px; }
.calc-pad .key .lg { font-size: 1.08rem; }
.calc-pad .key-accent .lg { font-size: 1.3rem; }

.calc-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.cta-card { display: flex; flex-direction: column; gap: 3px; padding: 16px; border: 1px solid var(--line2); border-radius: 10px; color: var(--text); text-decoration: none; background: var(--surface); transition: border-color .15s; }
.cta-card:hover, .cta-card.pulse { border-color: var(--ink); }
.cta-eyebrow { font-size: .74rem; font-weight: 650; color: var(--muted); }
.cta-title { font-size: 1.08rem; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.cta-desc { font-size: .82rem; color: var(--muted); line-height: 1.55; }
.cta-btn { margin-top: 10px; align-self: flex-start; padding: 7px 14px; border-radius: 6px; background: var(--accent); color: #fff; font-size: .84rem; font-weight: 650; }
.cta-card:hover .cta-btn { background: var(--accent-ink); }
.history-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; font-size: .84rem; font-weight: 650; color: var(--ink); }
.history-head .link-btn { font-size: .76rem; }
.history-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; border-top: 1px solid var(--line); }
.history-list li { border-bottom: 1px solid var(--line); }
.history-list button { width: 100%; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; padding: 7px 4px; border: 0; background: none; cursor: pointer; text-align: right; }
.history-list button:hover { background: var(--surface2); }
.h-expr { font-size: .74rem; color: var(--muted); word-break: break-all; font-variant-numeric: tabular-nums; }
.h-res { font-size: 1rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.history-empty { margin: 10px 0 0; font-size: .8rem; color: var(--faint); }
.history-empty[hidden] { display: none; }
.mini-modes { display: grid; gap: 6px; }

.levelup { position: absolute; right: 20px; bottom: 20px; z-index: 12; }
.levelup[hidden] { display: none; }
.levelup.show { animation: fade .2s ease; }
.levelup-card { width: 250px; display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--surface); border: 1px solid var(--line2); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.16); }
.levelup-card h2 { margin: 0; font-size: 1.15rem; }
.levelup-desc { margin: 0 0 6px; font-size: .8rem; color: var(--muted); }
.levelup-card .btn { padding: 9px; font-size: .86rem; }
.levelup-card .link-btn { align-self: center; font-size: .78rem; }

/* ---------- Content ---------- */
.content { max-width: 800px; padding-top: 12px; padding-bottom: 40px; }
.content section { padding: 26px 0; border-top: 1px solid var(--line); }
.content section:first-child { border-top: 0; }
.content h2 { margin: 0 0 10px; font-size: 1.15rem; font-weight: 700; }
.content h3 { margin: 18px 0 6px; font-size: 1rem; font-weight: 700; color: var(--ink); }
.content p, .content li { font-size: .95rem; line-height: 1.75; }
.content ul, .content ol { padding-left: 1.2em; }
.content li { margin-bottom: 4px; }
.content em { font-style: normal; font-weight: 650; color: var(--ink); }
.content details { padding: 10px 0; border-bottom: 1px solid var(--line); }
.content summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.content details p { margin: 8px 0 0; }
.promo-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.table-wrap { overflow-x: auto; }
.shortcut-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.shortcut-table th, .shortcut-table td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); text-align: left; }
.shortcut-table th { font-size: .78rem; color: var(--muted); font-weight: 600; }

.site-footer { color: var(--muted); font-size: .8rem; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding-top: 22px; padding-bottom: 32px; border-top: 1px solid var(--line); }
.footer-inner p { margin: 0 0 3px; }
.footer-brand { font-weight: 700; color: var(--ink); }
.site-footer nav { display: flex; gap: 16px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* privacy */
.doc { max-width: 800px; margin: 28px auto 56px; padding: 0 20px; }
.doc h1 { font-size: 1.5rem; margin-top: 0; }
.doc h2 { font-size: 1.05rem; margin-top: 28px; }
.doc p, .doc li { line-height: 1.75; }
.doc .notice { padding: 10px 12px; border: 1px solid var(--line2); border-left: 3px solid var(--accent); border-radius: 4px; background: var(--surface); font-size: .88rem; color: var(--text); }

/* ---------- 넓은 화면 (1280 칸을 꽉 채우는 배치) ---------- */
@media (min-width: 1100px) {
  /* 계산기: [계산기] [계산 기록] [1분 테스트 · 바로가기] */
  .calc-layout {
    grid-template-columns: minmax(0, 480px) minmax(0, 1fr) 300px; gap: 32px;
    grid-template-areas: "main hist cta" "main hist modes"; grid-template-rows: auto 1fr;
  }
  .calc-main { grid-area: main; }
  .calc-side { display: contents; }
  .cta-card { grid-area: cta; }
  .history-card { grid-area: hist; min-width: 0; padding-left: 32px; border-left: 1px solid var(--line); align-self: stretch; display: flex; flex-direction: column; }
  .history-list { max-height: 470px; }
  .mini-modes { grid-area: modes; align-content: start; }
  .numpad.calc-pad { grid-template-rows: repeat(5, 56px); }
  .calc-util .key { height: 42px; }

  /* 게임: [목록] [키패드 + 설정] */
  .play-grid { display: grid; grid-template-columns: minmax(0, 1fr) 470px; gap: 28px; align-items: stretch; }
  .play-grid .stage { display: flex; flex-direction: column; }
  .play-grid .target-card { flex: 1; display: flex; flex-direction: column; justify-content: center; }
  .play-grid .queue {
    height: 400px;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 52%, rgba(0,0,0,.28) 80%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 52%, rgba(0,0,0,.28) 80%, transparent 100%);
    padding-top: 36px;
  }
  .play-grid .pad-wrap { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 16px; margin-top: 0; }
  .play-grid .numpad { flex: none; width: 100%; grid-template-rows: repeat(5, 44px); gap: 6px; padding: 10px; }
  .play-grid .numpad .key .lg { top: 6px; left: 10px; font-size: .92rem; }
  .play-grid .numpad .key-mod .lg { font-size: .8rem; }
  .play-grid .pad-side.setup { max-width: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .calc-layout { grid-template-columns: 1fr; }
  .calc-side { display: grid; grid-template-columns: 1fr 1fr; }
  .mini-modes { display: none; }
  .pad-wrap { flex-direction: column; align-items: center; gap: 14px; }
  .play .numpad { flex: none; width: 100%; max-width: 420px; grid-template-rows: repeat(5, 46px); }
  .play .numpad .key .lg { font-size: .95rem; }
  .play .pad-side.setup { width: 100%; max-width: 420px; grid-template-columns: 1fr; }
  .setup-col { display: contents; }
  .setup .opts, .setup-col > .best-chip { order: 5; }
  .setup .key-bs { order: 6; }
  .mode-tiles { grid-template-columns: repeat(3, 1fr); }
  .tile { flex-direction: column; align-items: center; text-align: center; gap: 0; padding: 7px 4px; }
  .kbd-help { display: none; }
  .queue { height: 240px; }
  .row.cur { min-height: 98px; }
  .row.ph, .row.done { padding: 0 10px; }
  .mode-badge { position: static; display: block; text-align: center; }
  .combo { top: 8px; right: 6px; bottom: 10px; width: 36px; gap: 6px; }
  .combo-label { min-height: 28px; }
  .combo-label b { font-size: 1.1rem; }
  .combo-label span { font-size: .5rem; letter-spacing: .04em; }
  .combo-gauge { width: 6px; }
  .play .row.ph, .play .row.done { padding-left: 42px; padding-right: 42px; }
  .play .row.cur, .play .row.next { padding-left: 40px; padding-right: 40px; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 12px; }
  .layout { margin-top: 12px; }
  .header-inner { gap: 16px; }
  .header-nav { gap: 14px; }
  .game-card { padding: 16px 12px; border-radius: 10px; }
  .game-title { font-size: 1.3rem; }
  .topbar { flex-wrap: wrap; }
  .topbar .progress { order: 5; flex-basis: 100%; }
  .topbar .progress-text { margin-left: auto; }
  .stats-bar { gap: 12px; font-size: .68rem; }
  .stats-bar b { font-size: .9rem; }
  .calc-side { grid-template-columns: 1fr; }
  .calc-status { flex-direction: column; align-items: flex-start; gap: 3px; }
  .promo-tiles { grid-template-columns: 1fr; }
  .levelup { left: 12px; right: 12px; bottom: 12px; }
  .levelup-card { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* 자릿수: 버튼 5개라 조금 촘촘하게 */
.seg-dense button { padding: 6px 2px; font-size: .8rem; white-space: nowrap; }
.setup-col > .best-chip { margin-top: auto; }
/* 결과 화면: 점수 계산 방법 (접이식) */
.score-rule { margin: 8px 0 0; text-align: left; font-size: .78rem; color: var(--muted); }
.score-rule summary { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; list-style: none; color: var(--muted); font-weight: 600; }
.score-rule summary::-webkit-details-marker { display: none; }
.score-rule summary:hover { color: var(--ink); }
.score-rule[open] { background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.score-rule p { margin: 6px 0 4px; line-height: 1.5; color: var(--text); }
.score-rule ul { margin: 0 0 6px; padding-left: 16px; line-height: 1.55; }
.score-rule a { color: var(--accent, inherit); font-weight: 600; }
.result-card .score-rule:not([open]) { text-align: center; }
/* 문제 수: 1분 테스트일 때는 흐리게 */
#countBlock.off { opacity: .45; }
#countBlock.off button { cursor: default; }
#countBlock.off button.active { background: none; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line2); }
/* 문서(개인정보처리방침 · 이용약관) */
.doc h3 { font-size: .95rem; margin: 18px 0 4px; color: var(--ink); }
.doc .doc-meta { font-size: .86rem; color: var(--muted); }
.doc code { font-size: .86em; padding: 1px 5px; border-radius: 4px; background: var(--surface2); border: 1px solid var(--line); }
.doc .toc { margin: 18px 0 8px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.doc .toc ol { margin: 0; padding-left: 1.4em; columns: 2; column-gap: 28px; font-size: .9rem; }
.doc .toc li { line-height: 1.9; break-inside: avoid; }
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: .88rem; }
.doc-table th, .doc-table td { border: 1px solid var(--line2); padding: 7px 9px; text-align: left; vertical-align: top; line-height: 1.6; }
.doc-table th { background: var(--surface2); font-weight: 650; color: var(--ink); }
.doc-en { margin-top: 36px; padding-top: 8px; border-top: 1px solid var(--line2); }
.doc a { overflow-wrap: anywhere; }
@media (max-width: 640px) { .doc .toc ol { columns: 1; } .doc-table { font-size: .82rem; } .doc-table th, .doc-table td { padding: 6px; } }
.doc-table td, .doc-table th { word-break: keep-all; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .doc-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .doc-table, .doc-table tbody, .doc-table tr, .doc-table td { display: block; width: 100%; }
  .doc-table tr { margin-bottom: 10px; border: 1px solid var(--line2); border-radius: 6px; overflow: hidden; }
  .doc-table td { border: 0; border-top: 1px solid var(--line); }
  .doc-table td:first-child { border-top: 0; background: var(--surface2); font-weight: 600; color: var(--ink); }
  .doc-table td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; font-size: .74rem; font-weight: 650; color: var(--muted); }
}
