/* Enclave — 백자. 밝은 바탕, 흰 판. 벽은 세운 사람 말 색(검은 벽, 흰 벽). 장식 없이 여백과 그림자로 짠다. */
:root {
  --bg: #efede8;
  --ink: #17171b;
  --soft: #4f4f59;
  --muted: #63636d;
  --card: #ffffff;
  --accent: #e5482d;
  --shadow-card: 0 1px 2px rgba(23, 23, 27, 0.05), 0 24px 60px rgba(23, 23, 27, 0.1);
  --shadow-pill: 0 1px 2px rgba(23, 23, 27, 0.06), 0 8px 24px rgba(23, 23, 27, 0.06);
  --sans: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --latin: 'Manrope', 'Noto Sans KR', sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* 판 그림이 함께 쓰는 색과 그림자를 담아 둔 보이지 않는 그림 */
.shared-defs { position: absolute; }

.wordmark { font-family: var(--latin); font-size: 15px; font-weight: 800; letter-spacing: 0.38em; }

/* ---------- 단추 ---------- */

.btn {
  min-height: 44px;
  padding: 0 20px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s, box-shadow 0.15s, color 0.15s, opacity 0.15s;
}
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.primary { background: var(--ink); color: #ffffff; }
.btn.primary:hover:not(:disabled) { background: #2d2d34; }
.btn.outline { border-color: rgba(23, 23, 27, 0.22); }
.btn.outline:hover:not(:disabled) { background: rgba(23, 23, 27, 0.05); }
.btn.outline[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.btn.ghost { padding: 0 14px; color: var(--soft); font-weight: 400; }
.btn.ghost:hover { background: rgba(23, 23, 27, 0.05); color: var(--ink); }
.btn.card { min-height: 56px; background: var(--card); border-radius: 28px; box-shadow: var(--shadow-pill); font-size: 16px; }
.btn.card:hover { box-shadow: 0 1px 2px rgba(23, 23, 27, 0.08), 0 12px 30px rgba(23, 23, 27, 0.11); }
.btn.wide { width: 100%; }

/* ---------- 첫 화면 ---------- */

.title-screen { position: relative; min-height: 100dvh; overflow: hidden; }
.title-main {
  position: relative;
  width: min(600px, 100%);
  min-height: 100dvh;
  padding: 64px 0 52px 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
}
.title-body { display: flex; flex-direction: column; gap: 40px; }
.title-copy h1 { margin: 0; font-size: 60px; font-weight: 700; line-height: 1.18; letter-spacing: -0.03em; }
.title-copy p { margin: 18px 0 0; max-width: 400px; font-size: 16px; line-height: 1.7; color: var(--soft); }
.menu { width: min(440px, 100%); display: flex; flex-direction: column; gap: 12px; }
#menu-continue {
  min-height: 68px;
  padding: 0 26px;
  border-radius: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
}
#menu-continue .cap { font-size: 13px; font-weight: 400; color: #b9b9c2; }
.menu-row { display: flex; gap: 12px; }
.menu-row .btn { flex: 1; }
.menu-row .btn.primary { min-height: 56px; border-radius: 28px; font-size: 16px; }
.menu-links { display: flex; gap: 4px; }
.records { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 13px; color: var(--muted); }
.records i { width: 18px; height: 1px; background: rgba(23, 23, 27, 0.3); }
.records b { font-weight: 500; color: var(--ink); }

/* 오른쪽에 비스듬히 잘려 보이는 판 그림 */
.title-art {
  position: absolute;
  left: 54%;
  top: 70px;
  transform: rotate(-8deg) scale(1.2);
  transform-origin: 0 0;
  pointer-events: none;
}
.art-card { width: 616px; padding: 28px; background: var(--card); border-radius: 32px; box-shadow: 0 1px 2px rgba(23, 23, 27, 0.05), 0 30px 80px rgba(23, 23, 27, 0.14); }
.art-card svg { display: block; width: 560px; height: 560px; overflow: visible; }

/* ---------- 판 화면 ---------- */

.app {
  min-height: 100dvh;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 48px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.top { height: 84px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.top-actions { justify-self: end; display: flex; gap: 4px; }
.turn-pill {
  height: 40px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-pill);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.turn-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.table {
  display: grid;
  grid-template-columns: 216px minmax(0, 616px) 216px;
  grid-template-areas: 'p0 board p1';
  align-items: center;
  justify-content: center;
  gap: 64px;
  padding: 8px 0;
}
#plaque-0 { grid-area: p0; }
#plaque-1 { grid-area: p1; }

.board-card {
  grid-area: board;
  justify-self: center;
  width: min(616px, 100%, calc(100dvh - 200px));
  min-width: 280px;
  aspect-ratio: 1;
  padding: 4.5%;
  background: var(--card);
  border-radius: 32px;
  box-shadow: var(--shadow-card);
}
#board { display: block; width: 100%; height: 100%; overflow: visible; user-select: none; -webkit-user-select: none; touch-action: manipulation; }

.plaque { display: flex; flex-direction: column; gap: 20px; }
.plaque.right { align-items: flex-end; text-align: right; }
.plaque .who { display: flex; align-items: center; gap: 12px; }
.plaque.right .who { flex-direction: row-reverse; }
.plaque .stone-icon { flex: none; width: 40px; height: 42px; }
.plaque .who-text { display: flex; flex-direction: column; gap: 2px; }
.plaque.right .who-text { align-items: flex-end; }
.plaque .name { font-size: 20px; font-weight: 700; line-height: 1.2; }
.plaque .role { font-size: 13px; color: var(--muted); }
.plaque .points {
  font-family: var(--latin);
  font-size: 136px;
  font-weight: 300;
  line-height: 0.9;
  letter-spacing: -0.05em;
  color: #8e8e97;
  transition: color 0.2s;
}
.plaque.active .points { color: var(--ink); }
.plaque .label { font-size: 13px; letter-spacing: 0.08em; color: var(--muted); }
.plaque .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.plaque.right .chips { justify-content: flex-end; }
.chip {
  height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(23, 23, 27, 0.18);
  border-radius: 15px;
  font-size: 13px;
  white-space: nowrap;
}
.chip.on, .chip.done { background: var(--ink); border-color: var(--ink); color: #ffffff; font-weight: 500; }
.chip.on i, .chip.done i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.chip.off { border-color: rgba(23, 23, 27, 0.12); color: var(--muted); }
.wall-swatch { flex: none; width: 28px; height: 11px; margin-left: -3px; }

.bottom { min-height: 100px; padding-bottom: 24px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.land { font-size: 13px; color: var(--muted); }
.guide { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.steps { min-height: 20px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.steps .on { font-weight: 700; color: var(--ink); }
.steps i { width: 18px; height: 1px; background: rgba(23, 23, 27, 0.3); }
.status { min-height: 22px; font-size: 15px; }
.tools { justify-self: end; display: flex; gap: 10px; }

/* 말을 놓는 동안 나오는 놓을 말 고르기 */
.kind-picker { display: flex; gap: 6px; }
.kind-picker .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; }
.kind-picker .btn[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: #ffffff; }
.kind-icon { flex: none; width: 15px; height: 15px; fill: currentColor; }

/* ---------- 판 위에서 누르는 것들 ---------- */

#board [data-act] { cursor: pointer; outline: none; }
#board .clear { cursor: default; }
#board .hit { fill: transparent; }
#board .spot .mark { opacity: 0.24; transition: opacity 0.12s; }
#board .spot:hover .mark,
#board .spot:focus-visible .mark { opacity: 0.75; }
#board .focus { opacity: 0; fill: none; stroke: var(--ink); stroke-width: 2; }
#board .stone:focus-visible .focus,
#board .spot:focus-visible .focus { opacity: 0.5; }
#board .wall-opt .bar { stroke: var(--ink); stroke-opacity: 0.22; animation: breathe 1s ease-in-out infinite alternate; }
#board .wall-opt:hover .bar,
#board .wall-opt:focus-visible .bar { stroke-opacity: 1; animation: none; }
#board .wall-break .bar { stroke: var(--accent); animation: flare 0.8s ease-in-out infinite alternate; }
#board .wall-break:hover .bar,
#board .wall-break:focus-visible .bar { stroke-opacity: 1; animation: none; }
#board .wall-opt .hit,
#board .wall-break .hit { stroke: transparent; fill: none; pointer-events: stroke; }

@keyframes breathe {
  from { stroke-opacity: 0.14; }
  to { stroke-opacity: 0.42; }
}
@keyframes flare {
  from { stroke-opacity: 0.45; }
  to { stroke-opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #board .wall-opt .bar { animation: none; stroke-opacity: 0.32; }
  #board .wall-break .bar { animation: none; stroke-opacity: 0.85; }
  .btn, .plaque .points { transition: none; }
}

/* ---------- 창 ---------- */

dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 28px;
  background: var(--card);
  border: 0;
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(23, 23, 27, 0.25);
  color: var(--ink);
  font-family: var(--sans);
}
dialog::backdrop { background: rgba(23, 23, 27, 0.35); }
dialog h2 { margin: 0 0 18px; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
dialog fieldset { margin: 0 0 16px; padding: 0; border: 0; display: flex; flex-direction: column; gap: 2px; }
dialog fieldset[disabled] { opacity: 0.35; }
dialog legend { padding: 0; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
dialog label { min-height: 44px; display: flex; align-items: center; gap: 12px; font-size: 16px; cursor: pointer; }
dialog input[type='radio'] { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
/* 짧은 선택지 둘은 한 줄에 나란히 둔다 */
dialog fieldset.pair { flex-direction: row; flex-wrap: wrap; gap: 0 26px; }
dialog fieldset.pair legend { width: 100%; }
dialog label small { display: block; font-size: 13px; line-height: 1.4; color: var(--muted); }
#form-online-new fieldset { margin-bottom: 12px; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dlg-note { margin: 16px 0 0; font-size: 14px; line-height: 1.6; color: #c2371f; }
.join { margin-top: 20px; padding-top: 18px; border-top: 1px solid rgba(23, 23, 27, 0.12); }
dialog .join-label { display: block; min-height: 0; margin-bottom: 10px; font-size: 13px; color: var(--muted); cursor: default; }
.join-row { display: flex; gap: 10px; }
.join-row input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 22px;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}
.join-row input::placeholder { color: var(--muted); letter-spacing: 0.04em; font-size: 14px; }
.join-row input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.rules { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 1.7; }
.over-score { margin: 0; font-family: var(--latin); font-size: 72px; font-weight: 300; line-height: 1.1; letter-spacing: -0.04em; }
.over-note { margin: 12px 0 0; font-size: 15px; line-height: 1.7; color: var(--soft); }

/* 게임 방법 창 */
.guide-dlg { width: min(460px, calc(100vw - 32px)); }
.guide-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.guide-tabs .btn { min-height: 36px; padding: 0 16px; border-radius: 18px; font-size: 13px; }
.guide-tabs .btn[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: #ffffff; }
.guide-art { display: flex; justify-content: center; margin-bottom: 20px; }
.guide-art svg { display: block; width: min(100%, 40dvh); aspect-ratio: 1; overflow: visible; }
.guide-art .order { font-family: var(--latin); font-size: 22px; font-weight: 800; }
.guide-count { margin: 0 0 6px; font-size: 13px; letter-spacing: 0.06em; color: var(--muted); }
.guide-dlg h2 { margin-bottom: 10px; }
.guide-text { margin: 0; min-height: 6.8em; font-size: 15px; line-height: 1.7; color: var(--soft); }
.guide-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.guide-dots { display: flex; align-items: center; gap: 5px; }
.guide-dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(23, 23, 27, 0.18); transition: width 0.15s, background-color 0.15s; }
.guide-dots i.on { width: 18px; background: var(--ink); }
.guide-actions { display: flex; gap: 8px; }

/* ---------- 좁은 화면 ---------- */

@media (max-width: 1180px) {
  .app { padding: 0 24px; }
  .table { grid-template-columns: 160px minmax(0, 616px) 160px; gap: 28px; }
  .plaque .points { font-size: 104px; }
  .title-art { left: 58%; }
}

@media (max-width: 900px) {
  .app { padding: 0 16px; }
  .top { height: 64px; grid-template-columns: auto 1fr; }
  .turn-pill { display: none; }
  .btn.ghost { padding: 0 10px; }
  .table {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: 'board board' 'p0 p1';
    gap: 12px;
    align-content: start;
  }
  .table { align-items: stretch; }
  .board-card { width: min(100%, calc(100dvh - 360px)); border-radius: 24px; align-self: center; }

  /* 명패는 두 장을 나란히, 같은 짜임으로. 차례인 쪽은 테두리로 알린다. */
  .plaque,
  .plaque.right {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: 'who who' 'points chips';
    align-items: center;
    gap: 8px 10px;
    padding: 14px 16px;
    background: var(--card);
    border-radius: 20px;
    box-shadow: var(--shadow-pill);
    text-align: left;
  }
  .plaque.turn { box-shadow: 0 0 0 2px var(--ink), var(--shadow-pill); }
  .plaque .who,
  .plaque.right .who { grid-area: who; flex-direction: row; gap: 10px; min-width: 0; }
  .plaque.right .who-text { align-items: flex-start; }
  .plaque .stone-icon { width: 30px; height: 32px; }
  .plaque .name { font-size: 16px; }
  .plaque .role { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .plaque .who-text { min-width: 0; }
  .plaque .points { grid-area: points; font-size: 44px; line-height: 1; }
  .plaque .label { display: none; }
  .plaque .chips,
  .plaque.right .chips { grid-area: chips; justify-content: flex-end; }
  .plaque .chip.on { display: none; }
  .chip { height: 26px; padding: 0 10px; font-size: 12px; }

  .bottom { min-height: 0; grid-template-columns: 1fr; gap: 10px; padding: 14px 0 16px; }
  .land { order: 2; text-align: center; }
  .tools { order: 3; justify-self: stretch; }
  .tools .btn { flex: 1; min-height: 48px; border-radius: 24px; }
  .kind-picker { flex: 2; }
  .kind-picker .btn { padding: 0 10px; }

  .guide-foot { flex-direction: column; align-items: stretch; gap: 14px; }
  .guide-dots { justify-content: center; }
  .guide-actions .btn { flex: 1; }
  .guide-text { min-height: 8.5em; }

  /* 첫 화면: 판 그림을 위쪽에 잘라 걸고 그 아래에 글과 단추를 둔다. */
  .title-screen { display: flex; flex-direction: column; }
  .title-art { position: relative; left: auto; top: auto; transform: none; flex: none; height: 250px; overflow: hidden; }
  .title-art .art-card { position: absolute; left: 34%; top: 22px; transform: rotate(-8deg) scale(0.6); transform-origin: 0 0; }
  .title-main { position: static; flex: 1; width: 100%; min-height: 0; padding: 18px 24px 28px; gap: 28px; }
  .title-main > .wordmark { position: absolute; left: 24px; top: 30px; }
  .title-body { gap: 28px; }
  .title-copy h1 { font-size: 44px; }
  .title-copy p { margin-top: 14px; }
  .menu { width: 100%; }
}

/* ---------- 대전과 이야기 ---------- */

#menu-battle {
  min-height: 68px;
  padding: 0 26px;
  border-radius: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 18px;
  font-weight: 700;
}
#menu-battle .cap { font-size: 13px; font-weight: 400; color: #b9b9c2; white-space: normal; text-align: right; }

/* 명패: 남은 시간과 인사말 */
.chip.clock { font-family: var(--latin); font-weight: 800; font-variant-numeric: tabular-nums; }
.chip.clock.hot { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.plaque .bubble {
  align-self: flex-start;
  padding: 8px 14px;
  background: var(--ink);
  color: #ffffff;
  border-radius: 16px 16px 16px 4px;
  font-size: 14px;
}
.plaque.right .bubble { align-self: flex-end; border-radius: 16px 16px 4px 16px; }

.emotes { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 6px; }
.emotes .btn { min-height: 32px; padding: 0 12px; border-radius: 16px; font-size: 13px; }

/* 이야기 */
.story-dlg { width: min(520px, calc(100vw - 32px)); }
.story-lead { margin: -6px 0 18px; font-size: 14px; line-height: 1.7; color: var(--soft); }
.story-list { display: flex; flex-direction: column; gap: 18px; max-height: 56dvh; overflow-y: auto; padding: 2px; }
.story-list h3 { margin: 0; font-size: 15px; font-weight: 700; }
.story-list h3 small { margin-left: 8px; font-size: 13px; font-weight: 400; color: var(--muted); }
.stage-row { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.btn.stage {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-color: rgba(23, 23, 27, 0.14);
  border-radius: 14px;
  font-size: 15px;
  text-align: left;
}
.btn.stage:hover:not(:disabled) { background: rgba(23, 23, 27, 0.05); }
.btn.stage .no { font-family: var(--latin); font-weight: 800; font-size: 13px; color: var(--muted); }
.btn.stage .what { flex: 1; }
.btn.stage .stars, .over-stars { font-size: 16px; letter-spacing: 0.12em; color: var(--accent); }
.over-stars { margin: -8px 0 6px; font-size: 22px; }
.over-extra { margin: 10px 0 0; font-size: 15px; font-weight: 700; }
.cut-text { margin: 0; font-size: 16px; line-height: 1.8; }
.cut-goal { margin: 16px 0 0; font-size: 13px; color: var(--muted); }
.join-row input.plain { letter-spacing: 0; text-transform: none; text-align: left; }
#match-clock { font-variant-numeric: tabular-nums; }
#menu-continue.card .cap { color: var(--muted); }
.account { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(23, 23, 27, 0.12); }
.account-state { margin: 0 0 10px; font-size: 14px; line-height: 1.6; color: var(--soft); }
.account-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 여러 크기의 화면 ---------- */

/* 화면 확대와 축소를 막는다: 두 손가락 벌리기와 두 번 두드리기를 받지 않고, 밀어 넘기기만 받는다. */
html { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* 끝까지 민 뒤 더 당겨도 화면이 딸려 오거나 새로 읽히지 않게 한다. */
body { overscroll-behavior: none; }

/* 화면 모서리가 둥글거나 카메라 구멍이 있는 기기에서 가려지지 않게 한다. */
.app {
  padding-left: max(48px, env(safe-area-inset-left, 0px));
  padding-right: max(48px, env(safe-area-inset-right, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
dialog { max-width: calc(100vw - 20px); }
/* 넓은 화면에서도 판과 아래 단추가 한 화면에 들어오게 한다. 인사말 줄이 생겨 아래가 높아졌다. */
.board-card { width: min(616px, 100%, calc(100dvh - 260px)); }

@media (max-width: 1180px) {
  .app { padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
}

/* 좁은 화면(전화기 세로, 작은 태블릿) */
@media (max-width: 900px) {
  .app { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .table > *, .bottom > * { min-width: 0; }
  .title-main { padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
  /* 인사말은 한 줄에 두고 옆으로 밀어 본다. 여러 줄로 접히면 아래 단추를 밀어낸다. */
  .guide { overflow: hidden; }
  .emotes { align-self: stretch; flex-wrap: nowrap; justify-content: flex-start; max-width: 100%; overflow-x: auto; padding: 2px; scrollbar-width: none; }
  .emotes::-webkit-scrollbar { display: none; }
  .emotes .btn { flex: none; }
  .tools { flex-wrap: wrap; }
  /* 이름이 길면 줄여서 보인다. 명패가 화면 밖으로 밀려 나가지 않게 한다. */
  .plaque .who-text { flex: 1; }
  .plaque .role { display: block; max-width: 100%; }
  /* 태블릿 세로: 판이 너무 커져 아래가 밀려나지 않게 한다. */
  .board-card { width: min(616px, 100%, calc(100dvh - 430px)); }
  .btn.stage { min-height: 48px; height: auto; padding: 8px 16px; white-space: normal; }
  #menu-battle .cap, #menu-continue .cap { min-width: 0; white-space: normal; text-align: right; }
}

/* 전화기 세로. 판과 단추가 한 화면에 들어오게 줄인다. */
@media (max-width: 520px) {
  .app { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .top { height: 52px; gap: 6px; }
  .wordmark { font-size: 13px; letter-spacing: 0.3em; }
  .top-actions { gap: 0; }
  .top-actions .btn.ghost { min-height: 40px; padding: 0 8px; font-size: 13px; }
  .table { gap: 8px; padding: 0; }
  .board-card { min-width: 0; width: min(100%, calc(100dvh - 318px)); padding: 3.5%; border-radius: 20px; }
  .plaque,
  .plaque.right { grid-template-areas: 'who points' 'chips chips'; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; padding: 10px 12px; border-radius: 16px; }
  .plaque .points { font-size: 30px; }
  .plaque .stone-icon { width: 24px; height: 26px; }
  .plaque .name { font-size: 14px; }
  .plaque .role { font-size: 11px; }
  .plaque .chips,
  .plaque.right .chips { flex-wrap: nowrap; justify-content: flex-start; gap: 4px; min-height: 22px; overflow: hidden; }
  .plaque .chip { flex: none; }
  .plaque .chip.walls { display: none; }
  .plaque .bubble { grid-column: 1 / -1; padding: 5px 10px; font-size: 12px; }
  .chip { height: 22px; padding: 0 7px; font-size: 11px; white-space: nowrap; }
  .steps { display: none; }
  .status { min-height: 40px; display: flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1.4; }
  .bottom { gap: 6px; padding: 8px 0 12px; }
  .land { font-size: 12px; }
  .tools { flex-wrap: nowrap; gap: 6px; }
  .tools .btn { min-width: 0; min-height: 44px; padding: 0 8px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
  .kind-picker { gap: 6px; }
  .tools #btn-undo, .tools #btn-break { flex: 1 0 auto; overflow: visible; }
  .emotes { margin-top: 0; }
  .emotes .btn { min-height: 30px; padding: 0 10px; font-size: 12px; }

  dialog { width: calc(100vw - 20px); padding: 20px; border-radius: 22px; }
  dialog h2 { margin-bottom: 14px; font-size: 20px; }
  .dlg-actions { margin-top: 16px; }
  .dlg-actions .btn { flex: 1 1 auto; padding: 0 14px; }
  .over-score { font-size: 56px; }
  .join-row { flex-wrap: wrap; }
  .join-row .btn { flex: 1; }

  .title-art { height: 190px; }
  .title-art .art-card { left: 30%; top: 10px; transform: rotate(-8deg) scale(0.5); }
  .title-main { padding-top: 14px; padding-bottom: 20px; gap: 20px; }
  .title-main > .wordmark { top: 22px; }
  .title-body { gap: 20px; }
  .title-copy h1 { font-size: 36px; }
  .title-copy p { margin-top: 10px; font-size: 15px; }
  .menu { gap: 10px; }
  .menu-row { gap: 10px; }
  .btn.card { min-height: 52px; font-size: 15px; padding: 0 10px; white-space: normal; }
  #menu-battle, #menu-continue { min-height: 60px; padding: 0 20px; font-size: 17px; }
  .menu-links { flex-wrap: wrap; }
}

/* 키가 작은 전화기 세로: 첫 화면의 판 그림을 줄인다. */
@media (max-width: 520px) and (max-height: 700px) {
  .title-art { height: 110px; }
  .title-art .art-card { top: -40px; }
  .title-main > .wordmark { top: 16px; }
}

/* 아주 좁은 전화기 */
@media (max-width: 350px) {
  .title-copy h1 { font-size: 30px; }
  .top-actions .btn.ghost { padding: 0 6px; font-size: 12px; }
  .plaque .points { font-size: 26px; }
  #menu-battle .cap { font-size: 12px; }
}

/* 전화기 가로. 높이가 모자라므로 판을 가운데 두고 명패를 양옆에 세운다. */
@media (max-height: 520px) and (orientation: landscape) {
  .app { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .top { height: 40px; grid-template-columns: auto 1fr; }
  .turn-pill { display: none; }
  .top-actions .btn.ghost { min-height: 36px; padding: 0 10px; font-size: 13px; }
  .table {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas: 'p0 board p1';
    align-items: center;
    align-content: center;
    gap: 12px;
    padding: 0;
  }
  .table > *, .bottom > * { min-width: 0; }
  .board-card { width: calc(100dvh - 144px); min-width: 0; padding: 3%; border-radius: 16px; align-self: center; }
  .guide { overflow: hidden; }
  .plaque .who-text { flex: 1; }
  .plaque,
  .plaque.right {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px 12px;
    background: var(--card);
    border-radius: 16px;
    box-shadow: var(--shadow-pill);
    text-align: left;
  }
  .plaque.turn { box-shadow: 0 0 0 2px var(--ink), var(--shadow-pill); }
  .plaque .who,
  .plaque.right .who { flex-direction: row; gap: 8px; min-width: 0; }
  .plaque .who-text,
  .plaque.right .who-text { align-items: flex-start; min-width: 0; }
  .plaque .stone-icon { width: 24px; height: 26px; }
  .plaque .name { font-size: 14px; }
  .plaque .role { max-width: 100%; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .plaque .points { font-size: 34px; line-height: 1; }
  .plaque .label { display: none; }
  .plaque .chips,
  .plaque.right .chips { justify-content: flex-start; gap: 4px; }
  .plaque .chip.on { display: none; }
  .plaque .bubble,
  .plaque.right .bubble { align-self: flex-start; padding: 5px 10px; font-size: 12px; }
  .chip { height: 22px; padding: 0 8px; font-size: 11px; }
  /* 왼쪽 글과 오른쪽 단추는 제 너비만큼, 가운데 안내가 남은 자리를 쓴다. 그래야 단추가 안내를 덮지 않는다. */
  .bottom { min-height: 0; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 4px 0 8px; }
  .land { order: 0; text-align: left; font-size: 12px; }
  .guide { gap: 4px; }
  .steps { display: none; }
  .status { min-height: 20px; font-size: 13px; line-height: 1.35; }
  .emotes { align-self: stretch; flex-wrap: nowrap; justify-content: flex-start; max-width: 100%; margin-top: 0; overflow-x: auto; scrollbar-width: none; }
  .emotes::-webkit-scrollbar { display: none; }
  .emotes .btn { flex: none; min-height: 28px; padding: 0 10px; font-size: 12px; }
  .tools { order: 0; justify-self: end; flex-wrap: nowrap; gap: 6px; }
  .tools .btn { flex: none; min-height: 40px; padding: 0 10px; border-radius: 20px; font-size: 13px; }
  .kind-picker .btn { gap: 6px; padding: 0 10px; }
  .plaque .chip.walls { display: none; }
  .kind-picker { flex: none; }

  dialog { padding: 18px 20px; border-radius: 20px; }
  dialog h2 { margin-bottom: 10px; font-size: 19px; }
  .guide-art svg { width: min(100%, 34dvh); }
  .guide-text { min-height: 0; }

  /* 첫 화면: 판 그림을 빼고 글과 단추를 두 단으로 놓는다. */
  .title-art { display: none; }
  .title-main { position: static; width: 100%; min-height: 100dvh; padding: 44px max(24px, env(safe-area-inset-right, 0px)) 16px max(24px, env(safe-area-inset-left, 0px)); gap: 12px; }
  .title-main > .wordmark { position: absolute; left: max(24px, env(safe-area-inset-left, 0px)); top: 16px; }
  .title-body { flex-direction: row; align-items: center; gap: 24px; }
  .title-copy { flex: 1; min-width: 0; }
  .title-copy h1 { font-size: 32px; }
  .title-copy p { margin-top: 8px; font-size: 14px; }
  .menu { flex: 1; min-width: 0; width: auto; gap: 8px; }
  .menu-row { gap: 8px; }
  .btn.card { min-height: 44px; font-size: 14px; }
  #menu-battle, #menu-continue { min-height: 50px; padding: 0 18px; font-size: 16px; }
}

/* ---------- 이용약관과 개인정보처리방침 ---------- */

.foot { display: flex; flex-direction: column; gap: 8px; }
.legal-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.btn.link { min-height: 28px; padding: 0; border-radius: 4px; font-size: 13px; font-weight: 400; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; white-space: normal; }
.btn.link:hover { color: var(--ink); }
.account-legal { margin: 0 0 12px; font-size: 13px; line-height: 1.7; color: var(--muted); }
.account-legal .btn.link { display: inline; min-height: 0; font-size: inherit; }
.legal-dlg { width: min(560px, calc(100vw - 32px)); }
.legal-dlg h2 { margin-bottom: 4px; }
.legal-body { max-height: 52dvh; margin-top: 12px; padding-right: 8px; overflow-y: auto; font-size: 14px; line-height: 1.75; color: var(--soft); }
.legal-body:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.legal-body h3 { margin: 18px 0 6px; font-size: 15px; font-weight: 700; color: var(--ink); }
.legal-body h3:first-child { margin-top: 0; }
.legal-body p { margin: 0 0 8px; }
.legal-body ul { margin: 0 0 8px; padding-left: 18px; }
.legal-body li { margin-bottom: 4px; }
@media (max-height: 520px) and (orientation: landscape) {
  .legal-body { max-height: 38dvh; }
}

/* ---------- 게임 방법을 밀어 넘기기 ---------- */

/* 옆으로 미는 손짓을 화면 밀기로 받지 않고 창이 받는다. 위아래로 미는 것은 그대로 둔다. */
.guide-dlg { touch-action: pan-y; overscroll-behavior: contain; }
.guide-dlg.slide-next .guide-art svg,
.guide-dlg.slide-next h2,
.guide-dlg.slide-next .guide-text { animation: guide-from-right 0.2s ease-out; }
.guide-dlg.slide-prev .guide-art svg,
.guide-dlg.slide-prev h2,
.guide-dlg.slide-prev .guide-text { animation: guide-from-left 0.2s ease-out; }
@keyframes guide-from-right { from { opacity: 0; transform: translateX(28px); } }
@keyframes guide-from-left { from { opacity: 0; transform: translateX(-28px); } }
@media (prefers-reduced-motion: reduce) {
  .guide-dlg.slide-next .guide-art svg, .guide-dlg.slide-next h2, .guide-dlg.slide-next .guide-text,
  .guide-dlg.slide-prev .guide-art svg, .guide-dlg.slide-prev h2, .guide-dlg.slide-prev .guide-text { animation: none; }
}

/* ---------- 지금 접속한 사람 수 ---------- */

.presence { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: -2px 0 2px; padding: 0 6px; font-size: 13px; color: var(--soft); font-variant-numeric: tabular-nums; }
.presence::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: #2f9e5b; }
.presence.alone::before { background: rgba(23, 23, 27, 0.3); }
.presence b { font-weight: 700; color: var(--ink); }
#match-presence { margin: 8px 0 0; padding: 0; }

/* ---------- 지니보드 첫 화면과 게임의 첫 화면 ---------- */

.hub {
  max-width: 1180px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 28px max(5%, env(safe-area-inset-right, 0px)) 28px max(5%, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 44px;
}
.hub-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.hub-top a.wordmark { color: inherit; text-decoration: none; }
.hub-top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; }
.hub-me { min-height: 44px; padding: 0 16px; gap: 8px; border-radius: 22px; font-size: 14px; }
.hub-me i { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); }
.hub-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 28px 40px; }
.hub-copy { flex: 1 1 420px; min-width: 0; }
.hub-copy h1 { margin: 0; font-size: clamp(34px, 6vw, 56px); font-weight: 700; line-height: 1.16; letter-spacing: -0.03em; }
.hub-copy p { margin: 14px 0 0; max-width: 30rem; font-size: 16px; line-height: 1.7; color: var(--soft); }
.hub-quick, .hub .menu { flex: 0 1 400px; min-width: 0; width: auto; display: flex; flex-direction: column; gap: 10px; }
.hub-battle { min-height: 68px; padding: 8px 26px; border-radius: 34px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 12px; font-size: 18px; font-weight: 700; }
a.hub-battle { color: #ffffff; }
.hub-battle .cap { font-size: 13px; font-weight: 400; color: #c9c9d1; white-space: normal; text-align: right; }
.hub-games { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.hub-card { display: flex; flex-direction: column; background: var(--card); border-radius: 28px; overflow: hidden; color: inherit; text-decoration: none; box-shadow: var(--shadow-card); transition: transform 0.15s, box-shadow 0.15s; }
a.hub-card:hover { transform: translateY(-2px); }
a.hub-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.hub-card.soon { background: #f7f5f1; box-shadow: none; }
.hub-card svg { display: block; width: 100%; height: 200px; }
.hub-card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 8px; }
.hub-card h2 { margin: 0; font-size: 20px; font-weight: 700; }
.hub-card p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--soft); }
.hub-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hub > .legal-links { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(23, 23, 27, 0.1); }
.hub .presence { margin: 0; padding: 0 4px; }
/* 판 위의 누를 수 있는 점(나인 멘스 모리스) */
#board .spot .focus { fill: none; stroke: none; }
#board .spot:focus-visible .focus { stroke: var(--ink); stroke-width: 2; }
#board .spot { cursor: pointer; outline: none; }
@media (max-width: 520px) {
  .hub { padding-top: 18px; gap: 26px; }
  .hub-copy p { font-size: 15px; }
  .hub-battle { min-height: 60px; padding: 8px 20px; font-size: 17px; }
  .hub-card svg { height: 150px; }
  .hub-games { gap: 14px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .hub { gap: 18px; padding-top: 12px; }
  .hub-copy h1 { font-size: 30px; }
  .hub-card svg { height: 110px; }
}

/* 게임의 첫 화면(나인 멘스 모리스, 숨긴 수) 제목 위의 판 그림. 벽 가르기의 .art-card 를 작게 줄여 비스듬히 놓는다. */
.game-art { position: relative; width: 290px; height: 300px; margin-bottom: 8px; pointer-events: none; }
.game-art .art-card { position: absolute; left: 4px; top: 30px; transform: rotate(-6deg) scale(0.42); transform-origin: 0 0; }
@media (max-width: 520px) {
  .game-art { width: 220px; height: 222px; margin-bottom: 4px; }
  .game-art .art-card { top: 22px; transform: rotate(-6deg) scale(0.31); }
}
@media (max-width: 520px) and (max-height: 720px) {
  .game-art { width: 170px; height: 172px; }
  .game-art .art-card { top: 18px; transform: rotate(-6deg) scale(0.24); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .game-art { display: none; }
}

/* ---------- 지니보드 첫 화면: 게임 하나를 띄워 넘기는 무대 ----------
   색과 카드 모양은 위의 .hub-card 를 그대로 쓰고, 놓는 자리만 정한다. 게임의 첫 화면(.game-home)은 건드리지 않는다. */
.hub.lobby { max-width: 600px; gap: 18px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.hub-intro { margin: 4px 0 -2px; font-size: 15px; line-height: 1.6; color: var(--soft); }
.lobby .hub-stage { position: relative; margin-top: 6px; }
/* 카드의 그림자가 잘리지 않게 트랙을 양옆과 아래로 조금 넓힌다. */
.lobby .hub-track {
  display: flex;
  gap: 24px;
  margin: -12px -20px -84px;
  padding: 12px 20px 84px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 20px;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.lobby .hub-track::-webkit-scrollbar { display: none; }
.lobby .hub-track > .hub-card { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; }
.lobby .hub-track > a.hub-card:hover { transform: none; }
.lobby .hub-card svg { height: 220px; }
.hub-arrow {
  position: absolute;
  top: 110px;
  z-index: 1;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-pill);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}
.hub-arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hub-arrow.prev { left: -10px; }
.hub-arrow.next { right: -10px; }
.hub-arrow:disabled { opacity: 0; pointer-events: none; }
.hub-arrow:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.hub-dots { position: relative; display: flex; justify-content: center; gap: 2px; margin-top: -4px; }
.lobby .hub-quick { position: relative; }
/* 넓은 화면에서는 양옆 그림자도 잘리지 않게 더 넓힌다. */
@media (min-width: 680px) {
  .lobby .hub-track { gap: 64px; margin-left: -48px; margin-right: -48px; padding-left: 48px; padding-right: 48px; scroll-padding: 0 48px; }
}
.hub-dots button { width: 28px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.hub-dots button::before { content: ''; width: 8px; height: 8px; border-radius: 4px; background: rgba(23, 23, 27, 0.22); transition: width 0.15s, background 0.15s; }
.hub-dots button[aria-current='true']::before { width: 22px; background: var(--ink); }
.hub-dots button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; border-radius: 12px; }
.lobby .hub-quick { flex: none; width: 100%; display: flex; flex-direction: column; gap: 10px; }
.lobby .presence { justify-content: center; text-align: center; }
.lobby .hub-battle { min-height: 72px; flex-direction: column; flex-wrap: nowrap; justify-content: center; gap: 2px; font-size: 20px; }
.lobby .hub-battle .cap { text-align: center; }
.hub-modes { display: flex; gap: 8px; }
.hub-modes[hidden] { display: none; }
.hub-modes .btn { flex: 1 1 0; min-width: 0; min-height: 48px; padding: 0 10px; font-size: 15px; }
@media (prefers-reduced-motion: reduce) {
  .hub-dots button::before, .hub-arrow { transition: none; }
}
@media (max-width: 520px) {
  .lobby .hub-card svg { height: 180px; }
  .lobby .hub-battle { min-height: 64px; font-size: 18px; }
  .hub-arrow { top: 90px; }
  .hub-arrow.prev { left: -6px; }
  .hub-arrow.next { right: -6px; }
}
/* 키가 작은 휴대폰에서도 대전 단추까지 한 화면에 들어오게 그림을 줄인다. */
@media (max-height: 720px) {
  .lobby .hub-card svg { height: 130px; }
  .lobby .hub-card-body { padding: 14px 18px 16px; gap: 6px; }
  .hub-arrow { top: 65px; }
}

/* ---------- 숨긴 수 ---------- */
.last-round { min-height: 20px; font-size: 13px; color: var(--muted); }
#board .spot .focus { fill: none; }
#board .spot[data-tile] { transition: transform 0.12s; }
#board .spot[data-tile]:hover { transform: translateY(-6px); }
@media (prefers-reduced-motion: reduce) {
  #board .spot[data-tile] { transition: none; }
  #board .spot[data-tile]:hover { transform: none; }
}

/* 주소 옮기기(move.html) */
.move { min-height: 100dvh; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px 16px; }
.move-wait { margin: 0; color: var(--muted); }
.move-card { width: min(440px, 100%); box-sizing: border-box; padding: 28px; background: var(--card); border-radius: 28px; box-shadow: var(--shadow-card); }
.move-card h1 { margin: 0 0 10px; font-size: 24px; letter-spacing: -0.02em; }
.move-card p { margin: 0; line-height: 1.7; color: var(--soft); }
.move-card .move-name { margin-top: 14px; padding: 12px 16px; background: #f7f5f1; border-radius: 14px; font-weight: 700; color: var(--ink); }
.move-card .move-note { margin-top: 18px; font-size: 13px; color: var(--muted); }

/* 지니보드 글자 앞의 로고. 그림은 src/icons/icon.svg(원본은 docs/brand/logo-original.png). */
.wordmark.brand { display: inline-flex; align-items: center; gap: 10px; }
.wordmark.brand::before {
  content: '';
  flex: none;
  width: 1.7em;
  height: 1.7em;
  background: url('icons/icon.svg') center / contain no-repeat;
}
