/* on-Chess. 글꼴은 on-RTS 와 같다 — 본문은 시스템 스택, 큰 제목만 Kenney Future. 패널·버튼은 Kenney Fantasy UI Borders(ui/borders, 색 입힘)를 border-image 로, 아이콘은 Kenney Game Icons. 색은 on-Play 다크 표면. */
:root {
  --fg: #f5f5f7; --muted: #a8a49c; --team: #3aa0ff; --accent: #ff3131; --gold: #e9c46a;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Apple SD Gothic Neo', system-ui, sans-serif;
}
* { box-sizing: border-box; }
@font-face { font-family: 'Kenney Future'; src: url('fonts/KenneyFuture.ttf') format('truetype'); font-display: swap; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0e12; color: var(--fg); font: 400 14px/18px var(--font); letter-spacing: -0.224px; user-select: none; }
/* dvh: 모바일 브라우저 바가 떠 있는 동안의 '보이는 높이'. 100vh 는 바가 숨겨진 큰 높이라 아래가 바 뒤로 들어갔다 (2026-09-20 사용자) */
canvas#game { position: fixed; inset: 0; display: block; width: 100vw !important; height: 100vh !important; height: 100dvh !important; }
button { font: 600 14px/18px var(--font); color: var(--fg); cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.w { color: var(--team); } .b { color: var(--accent); }

/* Kenney 틀: 48px 원본, 16px 슬라이스 */
.card { padding: 14px 18px; border: 16px solid transparent; border-image: url('ui/borders/card-ivory.png') 16 fill / 16px round; image-rendering: pixelated; }
.card.gold { border-image-source: url('ui/borders/card-gold.png'); }
.card > * { image-rendering: auto; }
.divider { height: 14px; margin: 2px auto 8px; width: 100%; background: url('ui/borders/divider-gold.png') center / auto 14px no-repeat; image-rendering: pixelated; opacity: 0.9; }
#tools button, .page button, #result button, #lesson-done button, #promo button, #tutor button, #rooms button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 4px 14px; /* 틀(panel-transparent-center-013)은 상하좌우 대칭 — 실측 — 이라 보정 없이 정가운데 (2026-09-19 사용자) */
  background: none; border: 12px solid transparent; border-image: url('ui/borders/btn-ivory.png') 16 fill / 12px round; image-rendering: pixelated; transition: filter .12s;
}
#tools button:hover, .page button:hover, #result button:hover, #lesson-done button:hover, #promo button:hover, #tutor button:hover, #rooms button:hover { filter: brightness(1.3); }
#tools button:disabled { opacity: 0.4; filter: none; cursor: default; }
button img { width: 20px; height: 20px; image-rendering: auto; opacity: 0.9; flex: none; }
button svg.ico { width: 20px; height: 20px; opacity: 0.9; flex: none; color: var(--fg); } /* 시점 전환은 돋보기 대신 카메라 (2026-09-20 사용자) */
button span { image-rendering: auto; white-space: nowrap; } /* 버튼 글자는 줄바꿈하지 않는다 (2026-09-19 사용자) */
#result .row { flex-wrap: wrap; justify-content: center; }
#result .row button { flex: 0 1 auto; }

#hud { position: fixed; inset: 0; height: 100dvh; pointer-events: none; }
#hud > * { pointer-events: auto; }
/* 상태 패널 (2026-09-19 디자이너의 손 2차): 진영은 킹 초상으로, 차례는 그 카드가 금색으로 밝아지고 가운데 모래시계가 그쪽으로 기운다. 글자는 진영 이름·차례 한 줄뿐 */
/* 상태 패널 = 진영 둘 + 가운데 시계 + 기보 한 줄, 한 박스. 너비는 채팅줄과 같은 판 너비 (2026-09-19 사용자) */
#status { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; padding: 10px 12px;
  width: var(--tutor-w, min(560px, calc(100vw - 20px))); cursor: pointer; }
#status .sides { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: center; } /* 두 진영 같은 너비 (2026-09-19 사용자) */
#status .side { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; border: 1px solid rgba(216, 207, 187, 0.14); background: rgba(255, 255, 255, 0.03); opacity: 0.6; transition: opacity .2s, border-color .2s, background .2s; }
#status .side.active { opacity: 1; border-color: var(--gold); background: rgba(233, 196, 106, 0.1); box-shadow: inset 0 0 0 1px rgba(233, 196, 106, 0.25); }
#status .side .face { width: 40px; height: 40px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); flex: none; }
#status .side.w .face { box-shadow: 0 0 0 2px var(--team); } #status .side.b .face { box-shadow: 0 0 0 2px var(--accent); }
#status .side > div { display: grid; gap: 2px; min-width: 0; }
#status .side b { font-size: 14px; font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status .cap { display: inline-flex; align-items: center; gap: 2px; min-height: 18px; min-width: 0; overflow: hidden; } /* 패널 밖으로 나가지 않는다 (2026-09-20 사용자) */
#status .cap:empty::after { content: '–'; color: var(--muted); opacity: 0.6; font-size: 12px; }
#status .cap img { width: 18px; height: 18px; border-radius: 3px; background: rgba(255, 255, 255, 0.05); flex: none; }
#status .cap .more { font-size: 11px; font-weight: 700; color: var(--muted); }
/* 가운데는 체스 시계 — 쓴 시간을 위(백)·아래(흑)로, 두는 쪽이 밝다 (2026-09-19 사용자) */
#status .clock { display: grid; gap: 2px; justify-items: center; white-space: nowrap; padding: 4px 10px; border-radius: 6px; background: rgba(0, 0, 0, 0.28); }
#status .clock b { font: 600 13px/16px ui-monospace, Menlo, monospace; letter-spacing: -0.02em; color: var(--muted); font-variant-numeric: tabular-nums; }
#status.turn-w .clock #clock-w, #status.turn-b .clock #clock-b { color: var(--gold); }
#status.check .side.active .face { box-shadow: 0 0 0 2px var(--accent), 0 0 12px var(--accent); }
#turn { color: var(--muted); font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; }
/* 기보: 상태 패널과 한 박스. 최신 한 줄만 보이고, 누르면 그 자리에서 아래로 펼쳐진다 (2026-09-19 사용자) */
#moves { padding-top: 7px; border-top: 1px solid rgba(216, 207, 187, 0.16); }
#status:not(.open) #movelist li:not(:last-child) { display: none; }
#status.open #movelist { max-height: var(--moves-max, 200px); overflow-y: auto; }
#movelist { margin: 0; padding: 0; list-style: none; overflow: hidden; scrollbar-width: none; } /* 투명 스크롤 */
#movelist::-webkit-scrollbar { width: 0; height: 0; }
#movelist li { display: grid; grid-template-columns: 18px 1fr 1fr; align-items: center; gap: 2px; padding: 1px 0; }
#movelist em { font-style: normal; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
#movelist .mv { display: inline-flex; align-items: center; gap: 3px; min-width: 0; padding: 1px 3px; border-radius: 5px; }
#movelist .mv img { width: 20px; height: 20px; border-radius: 4px; background: rgba(255, 255, 255, 0.05); flex: none; }
#movelist .mv b { margin: 0; font: 600 12px/16px ui-monospace, Menlo, monospace; letter-spacing: -0.02em; }
#movelist .mv.w b { color: #9ccbff; } #movelist .mv.b b { color: #ffb3a7; }
#movelist .mv.cap img { box-shadow: 0 0 0 1.5px var(--accent); } /* 잡은 수 */
#movelist .mv.last { background: rgba(233, 196, 106, 0.16); } /* 마지막 수 */
#movelist .chk { font-style: normal; font-size: 11px; font-weight: 700; color: var(--gold); }

/* 고른 기물 이름표: 판 위 머리 위에 떠 있다. 자리는 render.js 가 월드 좌표를 투영해 잡는다 (2026-10-03 사용자) */
#name-tag { position: fixed; left: 0; top: 0; display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 9px;
  background: rgba(14, 15, 19, 0.86); border: 1px solid var(--gold); border-radius: 7px; backdrop-filter: blur(4px);
  white-space: nowrap; pointer-events: none; z-index: 3; animation: tag-in .12s ease-out; }
#name-tag b { font-size: 13px; font-weight: 700; color: var(--fg); }
#tutor-msg b { color: var(--gold); font-weight: 700; } /* 튜터 줄 맨 앞의 기물 이름 */
#name-tag i { font-style: normal; font-size: 11px; color: var(--muted); }
#name-tag i:empty { display: none; }
#name-tag.faint { opacity: 0.6; border-color: rgba(216, 207, 187, 0.3); } /* 데스크톱에서 올려만 놨을 때 */
@keyframes tag-in { from { opacity: 0; transform-origin: bottom center; } }

/* 버튼이 늘어도 화면 밖으로 나가지 않게 — 좁으면 줄바꿈하고 여백을 줄인다 (2026-09-20 사용자) */
/* left:50% + 자동 너비면 쓸 수 있는 폭이 화면의 절반뿐이라 버튼 5개도 접혔다 — 가로 전체를 쓰고 가운데 정렬 (2026-09-20 사용자) */
#tools { position: absolute; bottom: calc(12px + env(safe-area-inset-bottom)); left: 8px; right: 8px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
#tools button span { display: none; } /* 아이콘만 (2026-09-19 사용자). 이름은 title·aria-label 로 남는다 */
#tools button { padding: 4px 8px; }
#tools button[aria-pressed="true"] { border-image-source: url('ui/borders/btn-gold.png'); }

/* 튜터: 진짜 채팅 한 줄 (2026-09-19 사용자: 과한 틀·라벨 빼고 간소하게). 말하는 기물 얼굴이 프사, 오른쪽 1:1 아이콘 둘 */
#tutor { position: absolute; bottom: var(--tutor-bottom, 70px); left: 50%; transform: translateX(-50%); width: var(--tutor-w, min(560px, calc(100vw - 20px)));
  display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 7px;
  background: rgba(14, 15, 19, 0.82); border: 1px solid rgba(216, 207, 187, 0.16); border-radius: 10px; backdrop-filter: blur(6px); }
#tutor-portrait { width: 34px; height: 34px; border-radius: 8px; background: rgba(255, 255, 255, 0.06); flex: none; }
#tutor-msg { flex: 1; min-width: 0; margin: 0; font-size: 13px; line-height: 18px; color: var(--fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#tutor-msg.hint { color: var(--gold); }
#tutor button.sq { flex: none; width: 30px; height: 30px; min-height: 0; padding: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(216, 207, 187, 0.16); border-image: none; border-radius: 8px; image-rendering: auto; }
#tutor button.sq img { width: 15px; height: 15px; opacity: 0.75; }
#tutor button.sq:hover { background: rgba(255, 255, 255, 0.12); filter: none; }
#tutor button.sq:hover img { opacity: 1; }
#tutor button.sq:disabled { opacity: 0.4; cursor: default; }
#tutor button.mini img { width: 14px; height: 14px; }
#tutor p { margin: 0; font-size: 13px; line-height: 19px; color: var(--fg); }
#tutor p.hint { color: var(--gold); }
#tutor-guide { display: flex; gap: 10px; align-items: center; padding-top: 8px; border-top: 1px solid rgba(216, 207, 187, 0.18); }
#tutor-guide img { width: 44px; height: 44px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); flex: none; }
#tutor-guide div { display: grid; gap: 2px; font-size: 12px; line-height: 17px; color: var(--muted); }
#tutor-guide b { font-size: 13px; color: var(--fg); }
#tutor button { justify-self: start; min-height: 36px; font-size: 13px; }
#tutor button:disabled { opacity: 0.5; cursor: default; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(6, 8, 12, 0.45); }
.overlay .card { display: grid; gap: 12px; justify-items: center; text-align: center; min-width: 300px; padding: 22px 30px; }
.overlay h1 { margin: 0; font: 400 30px/36px 'Kenney Future', var(--font); letter-spacing: 3px; color: var(--gold); }
.overlay b { font-size: 16px; }
.page { display: grid; gap: 10px; justify-items: stretch; width: 100%; }
.page .big { min-height: 64px; font-size: 16px; }
.page .big img { width: 28px; height: 28px; }
.row { display: flex; gap: 6px; justify-content: center; }
.row button { flex: 1; }
.page .back { justify-self: center; min-height: 36px; font-size: 13px; color: var(--muted); }
.lv { width: 34px; height: 22px; display: block; margin: 0 auto; }
.lv rect { fill: var(--gold); }
.lv rect.off { fill: none; stroke: var(--muted); stroke-width: 1.5; opacity: 0.55; }
#net-login { display: grid; gap: 8px; }
#net-login p { margin: 0; }
#rooms { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 220px; overflow-y: auto; text-align: left; }
#rooms li.muted { padding: 8px 4px; text-align: center; }
#rooms button { width: 100%; justify-content: flex-start; min-height: 40px; }
#rooms button small { margin-left: auto; color: var(--muted); font-weight: 400; }
#net-msg:empty { display: none; }

#promo img { width: 56px; height: 56px; }
#promo button { flex-direction: column; gap: 2px; min-width: 84px; }

#result-icon { width: 48px; height: 48px; }
#result-text { font: 400 34px/40px 'Kenney Future', var(--font); letter-spacing: 4px; }

#loading { position: fixed; inset: 0; display: grid; place-content: center; gap: 10px; background: #0b0e12; color: var(--muted); font-size: 13px; text-align: center; }
#loading i { display: block; width: 180px; height: 4px; background: #2a2a2e; border-radius: 2px; overflow: hidden; }
#loading i::after { content: ''; display: block; height: 100%; width: var(--p, 0%); background: var(--gold); transition: width .2s; }

@media (max-width: 720px) {
  #status { min-width: 0; padding: 8px 10px; }
  /* 좁은 화면: 이름이 잘리지 않게 얼굴·글자를 줄인다 */
  #status .side { padding: 4px 6px; gap: 6px; }
  #status .side .face { width: 30px; height: 30px; }
  #status .side b { font-size: 12px; }
  #status .clock { padding: 3px 6px; }
  #status .clock b { font-size: 12px; }
  #tools { gap: 4px; }
  #tools button { padding: 4px 5px; border-width: 10px; }
}
/* 버튼이 여덟 개가 되면서 390px 에서 두 줄이 됐다 — 좁은 화면에선 더 작게 (2026-10-03 사용자) */
@media (max-width: 430px) {
  #tools { gap: 3px; }
  #tools button { padding: 4px 3px; border-width: 8px; min-height: 40px; }
  button img, button svg.ico { width: 18px; height: 18px; }
  .lv { width: 18px; height: 12px; }
}

/* ── 난이도 6단계 · 오프닝 배우기 (2026-10-20 사용자) ── */
.overlay .card { max-width: min(480px, calc(100vw - 16px)); }
/* 난이도: 2열 3줄. 막대 여섯 개 중 채운 개수가 단계, 그 아래 이름과 한 줄 설명. 글자는 가운데 정렬 */
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.page .levels button.lvl { flex-direction: column; gap: 3px; min-height: 76px; padding: 6px 8px; text-align: center; }
.lvl b { font-size: 15px; line-height: 18px; }
.lvl small { font-size: 11px; line-height: 14px; color: var(--muted); font-weight: 400; white-space: normal; word-break: keep-all; }
.lvl.on { border-image-source: url('ui/borders/btn-gold.png') !important; }
.meter { width: 46px; height: 16px; display: block; }
.meter rect { fill: var(--gold); }
.meter rect.off { fill: none; stroke: var(--muted); stroke-width: 1; opacity: 0.55; }
/* 오프닝 목록 */
.lesson-list { width: min(380px, calc(100vw - 80px)); display: grid; gap: 4px; max-height: min(52dvh, 420px); overflow-y: auto; padding-right: 2px; text-align: left; scrollbar-width: thin; }
.lesson-group { display: block; margin: 6px 0 2px; font-size: 12px; font-weight: 700; color: var(--muted); }
.lesson-group.w { color: #9ccbff; } .lesson-group.b { color: #ffb3a7; }
.page .lesson-list button.lesson-row { width: 100%; justify-content: flex-start; min-height: 44px; gap: 8px; }
.lesson-row img { width: 26px; height: 26px; border-radius: 5px; background: rgba(255, 255, 255, 0.06); opacity: 1; }
.lesson-row span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.lesson-row small { font-size: 11px; font-weight: 400; color: var(--muted); }
/* 진행 표시: 네모 배지, 글자 가운데 (알약 모양 쓰지 않음) */
.mark { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 20px; padding: 0 6px; border-radius: 4px;
  font-style: normal; font-size: 11px; font-weight: 700; line-height: 1; color: var(--fg); border: 1px solid rgba(216, 207, 187, 0.35); background: rgba(255, 255, 255, 0.05); }
.mark.gold { color: #14100c; background: var(--gold); border-color: var(--gold); }
/* 오프닝 소개 */
.lesson-head { display: grid; gap: 2px; justify-items: center; }
.lesson-head b { font-size: 18px; }
.lesson-line { margin: 0; padding: 8px 10px; border-radius: 6px; background: rgba(0, 0, 0, 0.28); font: 600 12px/18px ui-monospace, Menlo, monospace; color: var(--fg); text-align: left; user-select: text; }
.lesson-plan { display: grid; gap: 3px; text-align: left; width: 100%; max-width: 380px; justify-self: center; }
.lesson-plan p { margin: 0; font-size: 13px; line-height: 19px; color: var(--fg); }
#lesson-done .row { flex-wrap: wrap; justify-content: center; }
#ld-icon { width: 48px; height: 48px; }
#ld-icon.dim { opacity: 0.55; filter: grayscale(0.6); }
#ld-title { font-size: 18px; }
/* 수업 줄은 세 줄까지 */
#tutor.lesson #tutor-msg { -webkit-line-clamp: 3; }
#tutor-msg.warn { color: #ffb3a7; }
@media (max-width: 430px) {
  .overlay .card { min-width: 0; padding: 16px 14px; }
  .page .levels button.lvl { min-height: 70px; padding: 4px 4px; }
  .lvl small { font-size: 10px; }
}

/* 백·흑 탭: 네모 버튼 둘, 글자 가운데. 고른 쪽은 금색 틀 */
.lesson-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: min(380px, calc(100vw - 80px)); justify-self: center; }
.page .lesson-tabs button.lesson-tab { min-height: 40px; padding: 2px 6px; font-size: 13px; justify-content: center; text-align: center; }
.lesson-tab[aria-pressed="false"] { opacity: 0.6; }
.lesson-tab[aria-pressed="true"] { border-image-source: url('ui/borders/btn-gold.png') !important; }
.lesson-tab.w[aria-pressed="true"] { color: #9ccbff; } .lesson-tab.b[aria-pressed="true"] { color: #ffb3a7; }

/* ── ECO 사전 (2026-10-20) ── */
.lesson-tabs:has(> :nth-child(3)) { grid-template-columns: 1fr 1fr 1fr; }
.eco-tools { display: grid; gap: 6px; width: min(380px, calc(100vw - 80px)); justify-self: center; }
#eco-search { width: 100%; height: 38px; padding: 0 12px; border-radius: 6px; border: 1px solid rgba(216, 207, 187, 0.35); background: rgba(0, 0, 0, 0.35); color: var(--fg); font: 400 13px/18px var(--font); user-select: text; }
#eco-search:focus { outline: none; border-color: var(--gold); }
.eco-letters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.eco-letters button.eco-letter { min-height: 34px !important; padding: 0 !important; border: 1px solid rgba(216, 207, 187, 0.3) !important; border-image: none !important; border-radius: 5px; background: rgba(255, 255, 255, 0.04) !important; font-weight: 700; justify-content: center; }
.eco-letters button.eco-letter[aria-pressed="true"] { border-color: var(--gold) !important; color: var(--gold); background: rgba(233, 196, 106, 0.12) !important; }
#eco-group { font-size: 11px; text-align: left; }
.page .lesson-list button.eco-row { width: 100%; justify-content: flex-start; min-height: 50px; gap: 8px; padding: 4px 8px; text-align: left; }
.eco-row .code { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 22px; border-radius: 4px; background: rgba(0, 0, 0, 0.4); font: 700 11px/1 ui-monospace, Menlo, monospace; font-style: normal; color: var(--gold); }
.eco-row .nm { flex: 1; min-width: 0; display: grid; gap: 1px; }
.eco-row .nm b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eco-row .nm small { font-size: 11px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eco-row .wr { flex: none; width: 92px; display: grid; gap: 2px; justify-items: stretch; }
.wr-bar { display: flex; height: 6px; border-radius: 2px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
.wr-bar i { display: block; height: 100%; }
.wr-bar .w { background: #9ccbff; } .wr-bar .d { background: #8a857b; } .wr-bar .b { background: #ffb3a7; } /* 백=모험가 파랑, 흑=스켈레톤 빨강 */
.wr-mini { font: 600 10px/12px ui-monospace, Menlo, monospace; color: var(--muted); text-align: center; white-space: nowrap; }
.wr-box { display: grid; gap: 4px; width: 100%; max-width: 380px; justify-self: center; text-align: left; }
.wr-box .wr-bar { height: 10px; }
.wr-txt { font-size: 13px; font-weight: 600; }
.eco-note { font-size: 11px; }
@media (max-width: 430px) { .eco-row .wr { width: 70px; } }

.wr-none { font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; }
/* ECO 탭은 도구 줄이 있어 목록을 더 짧게 — 카드가 화면 밖으로 나가지 않게 */
.eco-tools:not([hidden]) + .lesson-list { max-height: max(180px, calc(100dvh - 400px)); }

/* 메뉴 카드는 어떤 창 높이에서도 화면 안에 들어온다. 넘치는 만큼 오프닝 목록만 줄어들고 그 안에서 스크롤 (2026-10-20 사용자: 박스가 화면 밖으로 밀림) */
#menu .card { max-height: calc(100dvh - 96px); box-sizing: border-box; display: flex; flex-direction: column; align-items: center; overflow: hidden; }
#menu .card > h1, #menu .card > .divider { flex: none; }
#menu .page[data-page="lessons"]:not([hidden]) { display: flex; flex-direction: column; align-items: stretch; min-height: 0; flex: 1 1 auto; }
#menu .page[data-page="lessons"] > * { flex: none; }
#menu .page[data-page="lessons"] > .lesson-tabs, #menu .page[data-page="lessons"] > .eco-tools, #menu .page[data-page="lessons"] > .lesson-list { align-self: center; }
#menu .page[data-page="lessons"] > .back { align-self: center; }
#menu .page[data-page="lessons"] > .lesson-list { flex: 0 1 auto; min-height: 120px; max-height: none !important; }
@media (max-height: 640px) { #menu .card { padding-top: 12px; padding-bottom: 12px; gap: 8px; } #menu .card > h1 { font-size: 24px; line-height: 28px; } }
/* 위아래 여유 48px씩. 낮은 창에서는 24px씩 (2026-10-20 사용자: 화면 끝에 붙이지 말고 여유 있게) */
@media (max-height: 640px) { #menu .card { max-height: calc(100dvh - 48px); } }

/* ── 라운지판: 점수와 랭킹 (2026-11-12 Gilbert) ── */
.rules-box { width: 100%; text-align: left; }
.rules-box summary { display: flex; align-items: center; justify-content: center; min-height: 32px; color: var(--gold); font-weight: 600; font-size: 13px; cursor: pointer; list-style: none; }
.rules-box summary::-webkit-details-marker { display: none; }
.rules { margin: 4px 0 0; padding: 0 0 0 18px; display: grid; gap: 3px; text-align: left; color: var(--muted); font-size: 12px; line-height: 17px; word-break: keep-all; }
.score-total { font: 600 26px/32px var(--font) !important; color: var(--gold); font-variant-numeric: tabular-nums; }
#score-box { display: grid; gap: 8px; justify-items: center; width: 100%; }
#score-box .rules { justify-self: stretch; }
.rank { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 4px; max-height: 236px; overflow-y: auto; overscroll-behavior: contain; text-align: left; }
.rank:empty { display: none; }
.rank li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; min-height: 40px; padding: 4px 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(216, 207, 187, 0.12); }
.rank li.me { border-color: var(--gold); background: rgba(233, 196, 106, 0.12); }
.rank li i { grid-row: 1 / 3; display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; background: rgba(0, 0, 0, 0.3); font-style: normal; font-weight: 700; font-size: 13px; color: var(--muted); }
.rank li:nth-child(1) i { color: #1b1408; background: var(--gold); }
.rank li:nth-child(2) i { color: #14161a; background: #c9ced6; }
.rank li:nth-child(3) i { color: #1b1008; background: #c98a4a; }
.rank li b { font-size: 14px !important; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank li small { grid-column: 2; font-size: 11px; line-height: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank li span { grid-row: 1 / 3; grid-column: 3; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--gold); }
.name-row { display: flex; gap: 6px; width: 100%; align-items: center; }
.name-row input { flex: 1 1 auto; min-width: 0; height: 44px; padding: 0 12px; border-radius: 6px; border: 1px solid rgba(216, 207, 187, 0.35); background: rgba(0, 0, 0, 0.35); color: var(--fg); font: 400 14px/18px var(--font); user-select: text; }
.name-row input:focus { outline: none; border-color: var(--gold); }
#result .card { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
#menu .page[data-page="ranking"]:not([hidden]) { display: grid; gap: 10px; justify-items: center; width: min(420px, calc(100vw - 64px)); }
html, body { overscroll-behavior: none; }

/* ── 1:1 대결 (라운지 LetscodingMatch, 2026-11-13 Gilbert) ── */
.match-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-row .big { min-width: 0; padding-left: 8px; padding-right: 8px; }
.match-row button:disabled { opacity: 0.45; filter: none; cursor: default; }
.match-off { margin: 0; text-align: center; line-height: 17px; word-break: keep-all; }
.match-err { margin: 0; padding: 8px 10px; border-radius: 6px; background: rgba(255, 49, 49, 0.12); color: #ffb3b3; font-size: 13px; line-height: 18px; text-align: center; word-break: keep-all; }
.room-code { display: block; font: 700 44px/52px ui-monospace, Menlo, monospace; letter-spacing: 8px; color: var(--gold); text-align: center; user-select: text; }
.waiting { display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--fg); }
.waiting .dots { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--gold); border-right-color: transparent; animation: mspin .9s linear infinite; }
@keyframes mspin { to { transform: rotate(360deg); } }
.join-code { height: 56px; padding: 0 12px; border-radius: 6px; border: 1px solid rgba(216, 207, 187, 0.35); background: rgba(0, 0, 0, 0.35); color: var(--gold);
  font: 700 28px/56px ui-monospace, Menlo, monospace; letter-spacing: 6px; text-align: center; text-transform: uppercase; user-select: text; }
.join-code:focus { outline: none; border-color: var(--gold); }
.join-code::placeholder { color: rgba(168, 164, 156, 0.35); }
#match-bar { display: grid; gap: 4px; padding: 6px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.28); }
#match-bar .mb-names { display: flex; justify-content: space-between; gap: 10px; min-width: 0; font-size: 13px; }
#match-bar .mb-names > span { display: inline-flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; }
#match-bar i { font-style: normal; color: var(--muted); }
#match-bar b { max-width: 9em; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
#match-bar em { font-style: normal; color: var(--muted); }
#match-bar .online { width: 8px; height: 8px; border-radius: 50%; background: #6b6b6b; flex: none; }
#match-bar .online.on { background: #3ddc84; box-shadow: 0 0 6px #3ddc84; }
#match-bar .mb-turn { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }
#match-bar .mb-turn b { color: var(--muted); font-weight: 700; }
#match-bar .mb-turn b.mine { color: var(--gold); }
#match-bar #mb-time { font: 600 13px/16px ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; color: var(--fg); }
#match-bar #mb-time.low { color: var(--accent); }
#status.match .clock { display: none; }
#status.match .sides { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
#match-note { position: absolute; bottom: var(--tutor-bottom, 70px); left: 50%; transform: translateX(-50%); width: var(--tutor-w, min(560px, calc(100vw - 20px)));
  display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 12px;
  background: rgba(14, 15, 19, 0.88); border: 1px solid rgba(233, 196, 106, 0.35); border-radius: 10px; backdrop-filter: blur(6px); }
#match-note p { flex: 1 1 auto; margin: 0; min-width: 0; font-size: 14px; line-height: 19px; word-break: keep-all; }
#match-note.err { border-color: rgba(255, 49, 49, 0.5); }
#match-note button { flex: none; display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 4px 12px; background: none;
  border: 12px solid transparent; border-image: url('ui/borders/btn-ivory.png') 16 fill / 12px round; image-rendering: pixelated; }
/* 360 폭: 코드 입력칸·참가 버튼이 카드 밖으로 나가지 않게 */
.page .join-code { width: 100%; min-width: 0; box-sizing: border-box; letter-spacing: 4px; }
.page[data-page="join"] .big { min-width: 0; }
