/* TAECHORA WEB v2 · 나인 스도쿠(NINE) — 화면 모양. 손으로 쓴 원본(생성물 아님).
   한 화면 앱: 판이 무대이고, 레벨·스페셜 룰마다 자기 색으로 판을 물들인다.
   글꼴: Black Han Sans는 영문 제목·숫자·등급(.en)에만, 한글·일본어·스페인어와 모든 UI 문구는 IBM Plex Sans KR(ja·es는 사이트 번역이 Plex JP·Plex Sans를 앞에 끼운다). */
:root {
  --void: #05060b;
  --deep: #0a0d17;
  --panel: #111525;
  --panel2: #181d31;
  --line: rgba(214, 222, 255, .12);
  --line2: rgba(214, 222, 255, .24);
  --ivory: #f4efe3;
  --text: #e8e6ef;
  --mute: #9aa0b8;
  --dim: #626883;
  --ink: #07080e;
  --gold: #f5b93f;
  --gold2: #ffdc8f;
  --red: #ff4f7b;
  --acc: #8fd3ff;
  --f-disp: "Black Han Sans", "IBM Plex Sans KR", "Apple SD Gothic Neo", sans-serif;
  --f-ui: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --skew: -12deg;
  color-scheme: dark;
}

html { box-sizing: border-box; height: 100%; }
body { height: 100%; }
body {
  margin: 0;
  background: var(--void);
  color: var(--text);
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
html { touch-action: manipulation; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; }
svg { display: block; }

#app {
  position: relative;
  height: 100%;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  max-width: 520px;
  margin: 0 auto;
  padding-inline: 16px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
}
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
html:not(.nine-ready) #app { opacity: 0; animation: nine-reveal 0s 6s forwards; }
@keyframes nine-reveal { to { opacity: 1; } }
html:lang(ja) body { word-break: normal; line-break: strict; }
.screen[hidden] { display: none !important; }

/* ---------- title ---------- */
.title-screen { padding-block: 12px 10px; gap: 10px; overflow-y: auto; }
.title-top { display: flex; align-items: center; gap: 8px; flex: none; }
.title-top .back-link { margin-right: auto; }
.lang-pick { position: relative; display: inline-flex; align-items: center; height: 40px; border-radius: 12px; color: var(--mute); }
.lang-pick svg { position: absolute; left: 10px; width: 16px; height: 16px; pointer-events: none; }
.lang-pick select {
  appearance: none; -webkit-appearance: none; height: 36px; padding: 0 12px 0 32px; border-radius: 10px;
  border: 1px solid var(--line2); background: rgba(10, 13, 23, .7); color: var(--text);
  font: 600 13px var(--f-ui); cursor: pointer;
}
.lang-pick select:focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; }
.lang-pick select option { background: #151822; color: #fff; }
.back-link {
  align-self: flex-start;
  font-family: var(--f-disp);
  font-size: 15px;
  letter-spacing: .06em;
  color: var(--mute);
  text-decoration: none;
  padding: 6px 2px;
}
.title-card {
  position: relative;
  flex: 1 0 auto;
  min-height: 560px;
  border-radius: 26px;
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 70% at 85% 105%, rgba(176, 140, 255, .16), transparent 60%),
    radial-gradient(90% 60% at 0% 0%, rgba(143, 211, 255, .10), transparent 60%),
    linear-gradient(180deg, #0c0f1d, #07080f);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 20px 22px;
  box-sizing: border-box;
}
#title-disc {
  position: absolute;
  width: 128%;
  aspect-ratio: 1;
  left: 50%;
  bottom: -52%;
  transform: translateX(-50%);
  opacity: .42;
  pointer-events: none;
}
@media (max-height: 760px) { #title-disc { bottom: -66%; opacity: .32; } }
.title-card > *:not(canvas), .tc-brand > *, .tc-menu > * { position: relative; }
.tc-brand, .tc-menu { display: contents; }
.tag-strip {
  margin-top: 0;
  background: var(--gold);
  color: var(--ink);
  font-family: var(--f-disp);
  font-size: 13px;
  letter-spacing: .08em;
  padding: 7px 18px 6px;
  transform: skewX(var(--skew));
  white-space: nowrap;
}
.tag-strip span { display: inline-block; transform: skewX(calc(var(--skew) * -1)); }
.logo {
  margin: 26px 0 0;
  font-family: var(--f-disp);
  font-weight: 400;
  font-size: clamp(84px, 30vw, 128px);
  line-height: .9;
  letter-spacing: .02em;
  transform: skewX(var(--skew));
  background: linear-gradient(100deg, #ffffff 0%, #ffe7b0 32%, #8fd3ff 66%, #b08cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 24px rgba(143, 211, 255, .18));
}
.subtitle { margin: 12px 0 0; font-weight: 700; font-size: 19px; color: var(--ivory); letter-spacing: .02em; }
.desc { margin: 8px 0 0; max-width: 30ch; color: var(--mute); font-size: 15px; line-height: 1.6; text-wrap: balance; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 340px; margin-top: 22px; }
.stat {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 8px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(10, 13, 23, .72);
  backdrop-filter: blur(6px);
}
.stat-label { font-family: var(--f-disp); font-size: 12px; letter-spacing: .14em; color: var(--mute); }
.stat-value { font-family: var(--f-disp); font-size: 26px; color: var(--ivory); font-variant-numeric: tabular-nums; }
.cta-row { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; width: 100%; max-width: 340px; margin-top: 18px; }
.btn-primary, .btn-ghost {
  height: 58px;
  transform: skewX(var(--skew));
  border-radius: 8px;
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0;
  display: grid; place-items: center;
  padding: 0 10px;
}
.btn-primary .en, .btn-ghost .en { font-family: var(--f-disp); font-weight: 400; font-size: 22px; letter-spacing: .04em; }
.btn-primary { background: var(--gold); color: var(--ink); box-shadow: 0 10px 30px rgba(245, 185, 63, .25); }
.btn-ghost { border: 1.5px solid var(--line2); background: rgba(10, 13, 23, .6); color: var(--ivory); }
.btn-primary > span, .btn-ghost > span { transform: skewX(calc(var(--skew) * -1)); }
.btn-primary:active, .btn-ghost:active { filter: brightness(1.12); transform: skewX(var(--skew)) scale(.97); }
.daily {
  width: 100%; max-width: 340px; margin-top: 14px;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(10, 13, 23, .72);
  backdrop-filter: blur(6px);
  text-align: left;
}
.daily-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 12px rgba(245, 185, 63, .8); }
.daily-label { font-weight: 700; color: var(--ivory); }
.daily-label small { margin-left: 6px; font-weight: 500; color: var(--mute); font-size: 13px; }
.daily-state { font-size: 13px; font-weight: 600; color: var(--gold2); }
.text-link {
  margin-top: 12px; padding: 7px 14px; border-radius: 999px;
  background: rgba(10, 13, 23, .78); border: 1px solid var(--line);
  color: var(--text); font-size: 14px; font-weight: 600;
}
.foot { margin: 0; text-align: center; color: var(--dim); font-size: 12.5px; text-wrap: balance; }
.foot a, .set-note a { color: var(--gold2); font-weight: 700; text-decoration: none; margin-left: 4px; }
.set-note { display: block; font-weight: 500; font-size: 12.5px; color: var(--mute); }
.set-row select {
  appearance: none; -webkit-appearance: none; min-width: 120px; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line2); background: var(--panel); color: var(--text); font: 600 14px var(--f-ui); cursor: pointer;
}
.set-row select:focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; }
.set-row[hidden] { display: none; }

/* ---------- bars ---------- */
.bar { display: flex; align-items: center; gap: 6px; height: 54px; flex: none; }
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--text);
}
.icon-btn:active { background: var(--panel2); }
.icon-btn svg { width: 22px; height: 22px; }
.bar-title { margin: 0; flex: 1; font-family: var(--f-disp); font-weight: 400; font-size: 21px; letter-spacing: .06em; color: var(--ivory); }
.bar-meta { font-family: var(--f-disp); font-size: 14px; color: var(--mute); letter-spacing: .06em; }
.bar-title small { margin-left: 8px; font-family: var(--f-ui); font-weight: 700; font-size: 14px; letter-spacing: 0; color: var(--mute); }

/* ---------- chapters ---------- */
.chapter-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-block: 4px 20px; }
.chapter {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, color-mix(in srgb, var(--acc) 9%, var(--panel)), var(--deep) 70%);
  padding: 14px 14px 14px;
}
.ch-head { display: flex; align-items: center; gap: 12px; }
.ch-glyph { width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--deep); border: 1px solid var(--line); display: grid; place-items: center; color: var(--acc); }
.ch-glyph svg { width: 22px; height: 22px; }
.ch-names { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.ch-en { font-family: var(--f-disp); font-size: 19px; letter-spacing: .06em; color: var(--acc); }
.ch-ko { font-size: 14px; font-weight: 600; color: var(--ivory); }
.ch-count { font-family: var(--f-disp); font-size: 15px; color: var(--mute); font-variant-numeric: tabular-nums; }
.ch-rule { margin: 10px 0 12px; color: var(--mute); font-size: 13.5px; line-height: 1.55; }
.ch-stages { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.stage {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 6px 0 4px;
  border-radius: 12px;
}
.stage:active { background: rgba(255, 255, 255, .04); }
.stage-num {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--f-disp); font-size: 17px;
  border: 1.5px solid var(--line2);
  color: var(--mute);
}
.stage.play .stage-num { border-color: var(--acc); color: var(--acc); }
.stage.done .stage-num { background: var(--acc); border-color: var(--acc); color: var(--ink); }
.dots { display: flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--line2); }
.dots i.on { background: var(--gold); }

/* ---------- game ---------- */
.game-bar { gap: 2px; }
.g-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding-left: 2px; }
.g-chip {
  font-family: var(--f-disp); font-size: 12.5px; letter-spacing: .1em;
  color: var(--ink); background: var(--acc);
  padding: 3px 9px 2px; transform: skewX(var(--skew)); border-radius: 3px;
}
.g-chip > span { display: inline-block; transform: skewX(calc(var(--skew) * -1)); }
.g-name { font-weight: 700; font-size: 15px; color: var(--ivory); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-timer { font-family: var(--f-disp); font-size: 16px; color: var(--mute); font-variant-numeric: tabular-nums; letter-spacing: .04em; margin: 0 2px 0 8px; }
.g-name { flex: none; }
.g-chip { flex: 0 1 auto; min-width: 0; overflow: hidden; }
@media (max-width: 420px) {
  .game-bar .icon-btn { width: 36px; }
  .g-title { gap: 6px; }
  .g-chip { font-size: 11.5px; padding: 3px 7px 2px; letter-spacing: .06em; }
  .g-name { font-size: 14px; }
  .g-timer { font-size: 15px; margin-left: 4px; }
}
@media (max-width: 370px) {
  .game-bar .icon-btn { width: 32px; }
  .g-chip { font-size: 10.5px; padding: 3px 6px 2px; }
  .g-timer { font-size: 14px; margin-left: 2px; }
}
.g-timer[hidden] { display: none; }
.icon-btn.off { color: var(--dim); }

.board-wrap { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
#board { display: block; touch-action: none; border-radius: 16px; }
.skip {
  position: absolute; right: 6px; bottom: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: rgba(17, 21, 37, .85); border: 1px solid var(--line2);
  font-size: 13px; font-weight: 600; color: var(--mute);
}
.toast {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%);
  padding: 7px 14px; border-radius: 999px;
  background: rgba(17, 21, 37, .94); border: 1px solid var(--line2);
  font-size: 13.5px; font-weight: 600; color: var(--ivory);
  white-space: nowrap; pointer-events: none;
  transition: opacity .25s;
}

.g-info { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 30px; padding: 0 2px; }
.g-rulebar { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; font-weight: 600; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-rulebar svg { width: 14px; height: 14px; flex: none; color: var(--acc); }
.g-rulebar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.g-miss { flex: none; font-size: 13px; font-weight: 600; color: var(--mute); font-variant-numeric: tabular-nums; }
.g-miss b { color: var(--ivory); font-weight: 700; }
.g-miss[hidden] { display: none; }
.now-playing {
  position: absolute; left: 0; right: 0; top: 2px;
  display: flex; justify-content: center; gap: 8px; align-items: baseline;
  font-family: var(--f-disp); font-size: 13px; letter-spacing: .14em; color: var(--gold);
  pointer-events: none;
}
.now-playing span { color: var(--mute); }
.now-playing[hidden] { display: none; }
#scr-game .controls { transition: opacity .5s; }
#scr-game.finale .controls { opacity: .18; pointer-events: none; }
#scr-game.finale .g-info { visibility: hidden; }
.controls { position: relative; flex: none; }
.hint {
  position: absolute; left: 0; right: 0; bottom: 12px; min-height: calc(100% - 20px); box-sizing: border-box; z-index: 7;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid rgba(245, 185, 63, .5);
  background: linear-gradient(180deg, rgba(245, 185, 63, .12), rgba(245, 185, 63, .04)), var(--deep);
  animation: fade .18s ease-out;
}
.hint[hidden] { display: none; }
.hint-tag { font-family: var(--f-disp); font-size: 12px; letter-spacing: .14em; color: var(--gold); }
.hint-tag small { margin-left: 8px; font-family: var(--f-ui); font-size: 12px; font-weight: 600; letter-spacing: 0; color: var(--mute); }
.hint p { margin: 4px 0 12px; font-size: 15px; line-height: 1.55; color: var(--ivory); text-wrap: pretty; }
.icon-btn .mute-x { display: none; }
.icon-btn.off .mute-x { display: inline; }
.icon-btn.off .snd-on { display: none; }
.hint-actions { display: flex; gap: 8px; }
.hint-actions button { height: 38px; padding: 0 16px; border-radius: 10px; font-weight: 700; font-size: 14px; }
#hint-fill { background: var(--gold); color: var(--ink); }
#hint-close { border: 1px solid var(--line2); color: var(--text); }

.tools { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding-top: 8px; }
.tool {
  height: 54px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--mute); font-size: 12.5px; font-weight: 600;
}
.tool svg { width: 22px; height: 22px; color: var(--text); }
.tool:active { background: var(--panel); }
.tool b { font-weight: 700; color: var(--dim); }
.tool.on { color: var(--acc); }
.tool.on svg { color: var(--acc); }
.tool.on b { color: var(--acc); }
.tool:disabled { opacity: .35; }
#hint-count { color: var(--gold2); }
.tool.empty { opacity: .45; }
.tool.empty #hint-count { color: var(--dim); }

.pad { flex: none; display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; padding-block: 6px 12px; }
.key {
  height: 62px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line);
  transition: transform .08s, background .2s;
}
.key:active { transform: scale(.93); background: var(--panel2); }
.k-d { font-family: var(--f-ui); font-weight: 500; font-size: 27px; line-height: 1; color: var(--ivory); }
.k-n { margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--dim); font-variant-numeric: tabular-nums; }
.pad.memo .key { border-color: color-mix(in srgb, var(--acc) 45%, transparent); }
.pad.memo .k-d { font-size: 20px; color: var(--acc); }
.key.done { opacity: .28; }
.key:disabled { opacity: .18; cursor: default; }
.key:disabled:active { transform: none; background: var(--panel); }
.key.ping { background: color-mix(in srgb, var(--ping, #fff) 30%, var(--panel)); }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.nudge { animation: nudge .22s ease-in-out; }

/* ---------- sheets ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(3, 4, 8, .6);
  animation: fade .14s ease-out;
}
.sheet-wrap.clear { background: linear-gradient(180deg, transparent 40%, rgba(3, 4, 8, .7)); }
.sheet {
  width: 100%; max-width: 520px; box-sizing: border-box;
  max-height: 92%; overflow-y: auto;
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: linear-gradient(180deg, var(--panel2), var(--deep));
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: rise .2s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-eyebrow { display: flex; align-items: center; gap: 10px; }
.sheet-eyebrow .ch-glyph { width: 36px; height: 36px; }
.sheet h3 { margin: 0; font-family: var(--f-disp); font-weight: 400; font-size: 26px; letter-spacing: .05em; color: var(--acc); transform: skewX(var(--skew)); }
.sheet .sheet-sub { margin: 0; font-size: 14px; font-weight: 600; color: var(--ivory); }
.rule-figure { margin: 16px 0 6px; padding: 16px 8px; border-radius: 16px; background: var(--deep); border: 1px solid var(--line); display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; }
.rule-figure figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rule-figure figcaption { font-size: 12.5px; color: var(--mute); }
.rule-list { margin: 12px 0 18px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.rule-list li { position: relative; padding-left: 16px; font-size: 15px; line-height: 1.55; color: var(--text); }
.rule-list li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--acc); }
.rule-list b { color: var(--ivory); }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.sheet .btn-primary { height: 54px; font-size: 16px; }
.sheet .btn-ghost { height: 50px; font-size: 15px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.result-title { display: flex; align-items: baseline; justify-content: space-between; }
.result-title h3 { font-size: 40px; color: var(--ivory); }
.result-stars { display: flex; gap: 8px; }
.result-stars i { width: 14px; height: 14px; border-radius: 50%; background: var(--line2); }
.result-stars i.on { background: var(--gold); box-shadow: 0 0 14px rgba(245, 185, 63, .7); }
.result-stats { margin: 14px 0 6px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-stats div { padding: 10px 6px; border-radius: 12px; background: var(--deep); border: 1px solid var(--line); text-align: center; }
.result-stats span { display: block; font-size: 12px; color: var(--mute); font-weight: 600; }
.result-stats strong { font-family: var(--f-disp); font-weight: 400; font-size: 22px; color: var(--ivory); font-variant-numeric: tabular-nums; }
.result-note { margin: 10px 0 16px; font-size: 14px; color: var(--mute); line-height: 1.55; }

.set-list { margin: 14px 0 18px; display: flex; flex-direction: column; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row label, .set-row .set-label { flex: 1; font-size: 15px; font-weight: 600; color: var(--ivory); }
.set-row small { display: block; font-weight: 500; font-size: 12.5px; color: var(--mute); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--panel); border: 1px solid var(--line2); transition: background .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--mute); transition: transform .2s, background .2s; }
.switch input:checked + span { background: color-mix(in srgb, var(--gold) 35%, var(--panel)); border-color: var(--gold); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--gold); }
.switch input:focus-visible + span { outline: 2px solid var(--gold2); outline-offset: 2px; }

/* ---------- title: records card + mini cards ---------- */
.records-card {
  width: 100%; max-width: 340px; margin-top: 20px;
  display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 14px;
  padding: 10px 14px 10px 10px;
  border-radius: 18px; border: 1px solid var(--line2);
  background: linear-gradient(120deg, rgba(245, 185, 63, .12), rgba(10, 13, 23, .78) 55%);
  backdrop-filter: blur(6px);
  text-align: left;
}
.records-card:active { filter: brightness(1.1); }
#title-pile { width: 64px; height: 74px; display: block; }
.rc-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.rc-label { font-family: var(--f-disp); font-size: 12px; letter-spacing: .14em; color: var(--gold); }
.rc-count { font-size: 14px; font-weight: 700; color: var(--mute); }
.rc-count b { font-family: var(--f-disp); font-weight: 400; font-size: 34px; color: var(--ivory); margin-right: 3px; font-variant-numeric: tabular-nums; }
.rc-next { font-size: 12.5px; color: var(--mute); font-weight: 600; }
.rc-go { width: 20px; height: 20px; color: var(--mute); }
.btn-primary small { display: block; margin-top: 2px; font-family: var(--f-ui); font-size: 12px; font-weight: 700; letter-spacing: 0; opacity: .75; }
.btn-primary > span { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.sub-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 340px; margin-top: 12px; }
.mini-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 11px 12px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(10, 13, 23, .78); backdrop-filter: blur(6px);
  text-align: left;
}
.mc-label { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 14px; color: var(--ivory); line-height: 1.25; }
.mc-state { font-size: 12.5px; font-weight: 600; color: var(--gold2); }
.mc-glyphs { display: inline-flex; gap: 3px; align-items: center; }
.mc-glyphs i { display: block; width: 7px; height: 7px; }
.g-dot { border-radius: 50%; background: #ffd36e; width: 6px !important; height: 6px !important; }
.g-line { height: 2.5px !important; width: 9px !important; background: #6ff0b8; transform: rotate(-45deg); border-radius: 2px; }
.g-plane { background: #b08cff; border-radius: 1.5px; }
.g-circle { border: 2px solid #ff8fb0; border-radius: 50%; box-sizing: border-box; width: 8px !important; height: 8px !important; }

/* ---------- lists ---------- */
.scroll-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-block: 4px 24px; }
.list-intro { margin: 0 2px; color: var(--mute); font-size: 14px; }
.level-card {
  border-radius: 20px; border: 1px solid var(--line);
  background: linear-gradient(150deg, color-mix(in srgb, var(--acc) 13%, var(--panel)), var(--deep) 72%);
  padding: 16px 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.lv-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.lv-en { font-family: var(--f-disp); font-size: 30px; line-height: 1; letter-spacing: .04em; color: var(--acc); transform: skewX(var(--skew)); }
.lv-ko { font-weight: 700; font-size: 16px; color: var(--ivory); }
.lv-prog { display: flex; align-items: center; gap: 12px; }
.lv-prog .lv-bar { flex: 1; min-width: 0; }
.lv-count { flex: none; white-space: nowrap; font-family: var(--f-disp); font-size: 15px; line-height: 1; color: var(--mute); font-variant-numeric: tabular-nums; }
.lv-count b { font-weight: 400; color: var(--ivory); }
.lv-desc { margin: 0; color: var(--mute); font-size: 14px; line-height: 1.5; }
.lv-bar { height: 8px; border-radius: 99px; background: rgba(214, 222, 255, .08); overflow: hidden; }
.lv-bar i { display: block; height: 100%; border-radius: 99px; background: var(--acc); min-width: 0; transition: width .4s; }
.lv-actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; margin-top: 2px; }
.lv-go, .lv-all { height: 46px; border-radius: 12px; font-weight: 700; font-size: 15px; }
.lv-go { background: var(--acc); color: var(--ink); }
.lv-all { border: 1px solid var(--line2); color: var(--text); }
.num-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.num {
  aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-family: var(--f-disp); font-size: 19px; color: var(--mute);
}
.num.done { background: color-mix(in srgb, var(--acc) 22%, var(--panel)); border-color: color-mix(in srgb, var(--acc) 55%, transparent); color: var(--ivory); }
.num.play { border-color: var(--acc); color: var(--acc); }
.num.next { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.num .dots i { width: 4px; height: 4px; }

/* ---------- records ---------- */
.rec-hero {
  display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: end;
  padding: 16px; border-radius: 20px; border: 1px solid var(--line);
  background: radial-gradient(120% 90% at 20% 100%, rgba(245, 185, 63, .14), transparent 60%), var(--deep);
}
#rec-pile { width: 150px; height: 210px; display: block; }
.rec-side { display: flex; flex-direction: column; gap: 6px; padding-bottom: 6px; min-width: 0; }
.rec-label { font-size: 13px; font-weight: 700; color: var(--mute); }
.rec-num { font-size: 18px; font-weight: 700; color: var(--mute); line-height: 1; }
.rec-num b { font-family: var(--f-disp); font-weight: 400; font-size: 64px; color: var(--ivory); margin-right: 4px; font-variant-numeric: tabular-nums; }
.rec-next { font-size: 13.5px; font-weight: 600; color: var(--gold2); }
.rec-bar { height: 6px; border-radius: 99px; background: rgba(214, 222, 255, .08); overflow: hidden; }
.rec-bar i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.milestones { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ms { display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; }
.ms-disc {
  width: 46px; height: 46px; border-radius: 50%;
  border: 2px dashed var(--line2); display: grid; place-items: center;
  font-family: var(--f-disp); font-size: 13px; color: var(--dim);
}
.ms.on .ms-disc { border: 0; color: var(--ink); background: radial-gradient(circle at 50% 50%, var(--ms) 0 28%, #0b0c13 29% 31%, var(--ms) 32% 100%); box-shadow: 0 0 18px color-mix(in srgb, var(--ms) 55%, transparent); }
.ms-name { font-family: var(--f-disp); font-size: 10.5px; letter-spacing: .06em; color: var(--mute); line-height: 1.15; }
.ms.on .ms-name { color: var(--ivory); }
.rec-levels { display: flex; flex-direction: column; gap: 2px; padding: 6px 14px; border-radius: 18px; background: var(--deep); border: 1px solid var(--line); }
.rl { display: grid; grid-template-columns: 112px 1fr 76px; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rl:last-child { border-bottom: 0; }
.rl-name { display: flex; flex-direction: column; font-family: var(--f-disp); font-size: 14px; letter-spacing: .06em; color: var(--acc); line-height: 1.15; }
.rl-name small { font-family: var(--f-ui); font-size: 11.5px; font-weight: 600; letter-spacing: 0; color: var(--mute); }
.rl-bar { height: 6px; border-radius: 99px; background: rgba(214, 222, 255, .07); overflow: hidden; }
.rl-bar i { display: block; height: 100%; border-radius: 99px; background: var(--acc); }
.rl-bar:empty { visibility: hidden; }
.rl strong { text-align: right; font-family: var(--f-disp); font-weight: 400; font-size: 18px; color: var(--ivory); font-variant-numeric: tabular-nums; }
.rl strong small { font-family: var(--f-ui); font-size: 11.5px; font-weight: 600; color: var(--dim); }
.lv-tempo { margin: -4px 0 0; font-size: 12.5px; font-weight: 600; color: var(--acc); opacity: .85; }
.rec-h { margin: 6px 2px 0; font-size: 15px; font-weight: 700; color: var(--ivory); }
.rec-h small { display: block; font-size: 12.5px; font-weight: 500; color: var(--mute); }
.rec-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rec-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px; border-radius: 14px; background: var(--deep); border: 1px solid var(--line); }
.rec-tile canvas { width: 84px; height: 84px; display: block; }
.rec-tile span { font-family: var(--f-disp); font-size: 12px; letter-spacing: .05em; color: var(--acc); }
.rec-tile small { font-size: 11px; color: var(--dim); font-weight: 600; margin-top: -4px; }
.rec-empty { margin: 4px 2px; color: var(--mute); font-size: 14px; }
.rec-empty[hidden] { display: none; }

/* ---------- result record row ---------- */
.res-record {
  display: flex; align-items: flex-end; gap: 14px;
  margin: 12px 0 2px; padding: 10px 14px 10px 10px;
  border-radius: 16px; border: 1px solid rgba(245, 185, 63, .35);
  background: linear-gradient(120deg, rgba(245, 185, 63, .14), rgba(10, 13, 23, .6));
}
#res-pile { width: 66px; height: 86px; display: block; flex: none; }
.rr-text { display: flex; flex-direction: column; gap: 3px; padding-bottom: 4px; }
.rr-plus { font-size: 14px; font-weight: 700; color: var(--gold); }
.rr-plus .en { font-family: var(--f-disp); font-weight: 400; font-size: 15px; letter-spacing: .1em; }
.rr-total { font-size: 15px; font-weight: 600; color: var(--text); }
.rr-total b { font-family: var(--f-disp); font-weight: 400; font-size: 26px; color: var(--ivory); margin: 0 2px; }
.rr-level { font-size: 13px; font-weight: 600; color: var(--mute); }
.rr-plus.milestone { color: var(--ivory); background: var(--gold); color: var(--ink); padding: 2px 8px; border-radius: 4px; align-self: flex-start; transform: skewX(var(--skew)); }

/* ---------- player ---------- */
.player-sheet { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
#player-disc { width: min(78vw, 300px); aspect-ratio: 1; display: block; margin-bottom: 8px; }
.player-sheet h3 { color: var(--ivory); }
.pl-meta { margin: 0 0 12px; font-size: 13.5px; color: var(--mute); }
.player-sheet .btn-row { width: 100%; }

/* ---------- fx overlay ---------- */
#scr-game { position: relative; }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

@media (min-height: 780px) {
  .key { height: 70px; }
  .k-d { font-size: 30px; }
  .tool { height: 60px; }
  .pad { padding-block: 8px 16px; }
}
@media (max-height: 700px) {
  .key { height: 54px; }
  .k-d { font-size: 24px; }
  .tool { height: 48px; }
  .bar { height: 48px; }
  .title-card { min-height: 500px; }
  .logo { margin-top: 18px; }
}
@media (max-height: 600px) {
  .g-info { height: 24px; }
  .key { height: 48px; }
  .k-d { font-size: 22px; }
  .k-n { margin-top: 2px; }
  .tool { height: 42px; font-size: 12px; }
  .tool svg { width: 19px; height: 19px; }
  .pad { padding-block: 4px 8px; }
}

/* ---------- tablets & foldables (Galaxy Z Fold inner screens, iPad) ---------- */
@media (min-width: 600px) {
  #app { max-width: 760px; padding-inline: 24px; }
  .title-card { width: 100%; max-width: 560px; margin-inline: auto; }
  .sheet { max-width: 560px; }
  #level-list { display: grid; grid-template-columns: 1fr 1fr; align-content: start; }
  .num-grid { grid-template-columns: repeat(8, 1fr); }
  .rec-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 900px) {
  body:not([data-screen="game"]) #app { max-width: 920px; }
  .num-grid { grid-template-columns: repeat(10, 1fr); }
  .rec-grid { grid-template-columns: repeat(6, 1fr); }
}
/* tall tablet / unfolded portrait: same stack, bigger keys */
@media (min-width: 600px) and (max-aspect-ratio: 11/10) and (min-height: 760px) {
  .key { height: 78px; }
  .k-d { font-size: 32px; }
  .tool { height: 64px; font-size: 13.5px; }
  .tools { gap: 10px; }
  .pad { gap: 8px; padding-block: 10px 18px; }
}
/* wide: unfolded landscape, tablets in landscape, desktop — board on the left, keys on the right */
@media (min-width: 640px) and (min-aspect-ratio: 11/10) {
  body[data-screen="game"] #app { max-width: 1180px; }
  #scr-game {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(220px, 30vw, 340px);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "bar bar" "info controls" "board controls";
    column-gap: 28px;
    padding-bottom: 14px;
  }
  #scr-game > .bar { grid-area: bar; }
  #scr-game > .g-info { grid-area: info; }
  #scr-game > .board-wrap { grid-area: board; }
  #scr-game > .controls { grid-area: controls; align-self: center; display: flex; flex-direction: column; gap: 10px; }
  .tools { grid-template-columns: repeat(2, 1fr); gap: 8px; padding-top: 0; }
  .tool { height: clamp(42px, calc((100vh - 300px) / 6), 56px); flex-direction: row; gap: 8px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
  .pad { grid-template-columns: repeat(3, 1fr); gap: 8px; padding-block: 0; }
  .key { height: clamp(46px, calc((100vh - 230px) / 3), 88px); }
  .k-d { font-size: clamp(22px, calc((100vh - 230px) / 9), 34px); }
  .hint { top: 0; bottom: auto; min-height: 100%; justify-content: flex-start; }
}
/* wide title: brand on the left, menu on the right */
@media (min-width: 760px) and (min-aspect-ratio: 11/10) {
  .title-card {
    max-width: 920px; min-height: 0; flex: 1 1 auto;
    display: grid; grid-template-columns: 1.05fr 1fr; align-items: center; justify-items: center;
    column-gap: 28px; padding: 24px 32px;
  }
  .tc-brand, .tc-menu { display: flex; flex-direction: column; align-items: center; width: 100%; }
  .tc-brand .logo { margin-top: 18px; }
  .tc-menu .records-card { margin-top: 0; }
  #title-disc { width: 78%; left: 50%; bottom: -80%; opacity: .26; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-wrap { animation: none; }
  .nudge { animation: none; }
}
