:root {
  --paper: #fcf8ef;
  --paper-deep: #ede7da;
  --ink: #293b34;
  --muted: #687168;
  --line: rgba(56, 47, 34, 0.16);
  --green: #4f7d6e;
  --green-soft: #e7eee7;
  --red: #ad5d4a;
  --wood: #dab884;
  --wood-dark: #765c36;
  --white-stone: #f7f4eb;
  --shadow: 0 10px 32px rgba(66, 48, 24, 0.05);
  --radius-lg: 18px;
  --radius-md: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { min-width: 320px; min-height: 100vh; margin: 0; background: radial-gradient(circle at 8% 0%, rgba(255, 255, 255, 0.78), transparent 34%), radial-gradient(circle at 92% 95%, rgba(201, 169, 115, 0.18), transparent 30%), var(--paper); }
button, input { font: inherit; }
button { color: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.18em; }

.topbar { width: min(1460px, calc(100% - 40px)); height: 82px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.brand > span:last-child { display: grid; }
.brand strong { font-family: Georgia, "Songti SC", serif; font-size: 1.36rem; line-height: 1; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 0.58rem; font-weight: 800; letter-spacing: 0.16em; }
.brand-mark { position: relative; width: 42px; height: 42px; border-radius: 12px; background: var(--wood); box-shadow: inset 0 0 0 1px rgba(93, 62, 25, 0.24), 0 8px 18px rgba(111, 76, 32, 0.16); }
.brand-mark i { position: absolute; background: rgba(89, 61, 27, 0.44); }
.brand-mark i:nth-child(1), .brand-mark i:nth-child(2) { top: 5px; bottom: 5px; width: 1px; }
.brand-mark i:nth-child(1) { left: 14px; }
.brand-mark i:nth-child(2) { right: 14px; }
.brand-mark i:nth-child(3), .brand-mark i:nth-child(4) { left: 5px; right: 5px; height: 1px; }
.brand-mark i:nth-child(3) { top: 14px; }
.brand-mark i:nth-child(4) { bottom: 14px; }
.brand-mark b { position: absolute; width: 12px; height: 12px; top: 15px; left: 15px; border-radius: 50%; background: #161817; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); }
.header-status { display: flex; align-items: center; gap: 10px; }
.room-chip, .quiet-button { min-height: 42px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, 0.44); padding: 0 16px; cursor: pointer; }
.room-chip { display: flex; align-items: center; gap: 8px; }
.room-chip span:not(.connection-dot) { color: var(--muted); font-size: 0.8rem; }
.room-chip b { font-size: 0.86rem; letter-spacing: 0.12em; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: #c48f37; box-shadow: 0 0 0 4px rgba(196, 143, 55, 0.12); }
.connection-dot.online { background: #3a8567; box-shadow: 0 0 0 4px rgba(58, 133, 103, 0.12); }
.quiet-button { transition: background 160ms ease, border-color 160ms ease, transform 160ms ease; }
.quiet-button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.8); border-color: rgba(56, 47, 34, 0.26); }
.quiet-button:active:not(:disabled) { transform: scale(0.98); }
.quiet-button:disabled { cursor: not-allowed; opacity: 0.48; }
.quiet-button kbd { margin-left: 7px; color: var(--muted); font-family: inherit; }

main { width: min(1460px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 60px; }
body[data-screen="game"] .topbar { height: 66px; }
body[data-screen="game"] main { padding-top: 10px; }
.lobby { min-height: calc(100vh - 176px); display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(430px, 0.82fr); align-items: center; gap: clamp(44px, 7vw, 120px); }
.lobby-copy { max-width: 680px; padding-left: clamp(0px, 4vw, 68px); }
.lobby-copy h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(3.2rem, 6vw, 6.8rem); font-weight: 500; line-height: 0.96; letter-spacing: -0.045em; }
.lobby-copy h1 em { color: var(--green); font-style: normal; }
.lobby-copy > p:not(.eyebrow) { max-width: 600px; margin: 28px 0; color: var(--muted); font-size: 1.04rem; line-height: 1.9; }
.feature-row { display: flex; flex-wrap: wrap; gap: 10px; }
.feature-row span { padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.82rem; background: rgba(255, 255, 255, 0.32); }
.feature-row b { color: var(--ink); }
.lobby-card, .waiting-card { border: 1px solid rgba(74, 59, 37, 0.14); border-radius: var(--radius-lg); background: rgba(255, 252, 246, 0.78); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.lobby-card { padding: clamp(24px, 3.2vw, 38px); }
.mode-heading, .panel-heading, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.mode-heading h2, .panel-heading h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 1.7rem; font-weight: 500; }
.mode-badge, .online-state { padding: 7px 11px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 0.74rem; font-weight: 800; }
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 24px; }
.mode-picker label { position: relative; cursor: pointer; }
.mode-picker input { position: absolute; opacity: 0; pointer-events: none; }
.mode-picker span { min-height: 86px; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255, 255, 255, 0.4); transition: border 160ms ease, background 160ms ease, transform 160ms ease; }
.mode-picker label:active span { transform: scale(0.985); }
.mode-picker input:checked + span { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.mode-picker strong { font-size: 0.92rem; }
.mode-picker small { color: var(--muted); line-height: 1.35; }
.online-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 14px; background: rgba(93, 75, 49, 0.08); }
.online-tab { min-height: 40px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; }
.online-tab.active { background: #fffdf8; color: var(--ink); font-weight: 700; box-shadow: 0 3px 10px rgba(62, 48, 28, 0.08); }
.online-form { display: grid; gap: 14px; margin-top: 18px; }
.online-form label { display: grid; gap: 7px; }
.online-form label > span { color: var(--muted); font-size: 0.76rem; font-weight: 700; }
.online-form input { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, 0.68); padding: 0 14px; outline: none; }
.online-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(36, 77, 63, 0.09); }
.code-input { text-transform: uppercase; letter-spacing: 0.18em; font-weight: 800; }
.primary-button { min-height: 48px; border: 0; border-radius: 14px; background: var(--green); color: #fff; padding: 0 20px; font-weight: 750; cursor: pointer; box-shadow: 0 9px 20px rgba(36, 77, 63, 0.17); transition: transform 160ms ease, filter 160ms ease; }
.primary-button:hover { filter: brightness(1.08); }
.primary-button:active { transform: scale(0.985); }
.primary-button:disabled { cursor: not-allowed; opacity: 0.48; box-shadow: none; }
.form-message { min-height: 20px; margin: 9px 0 0; color: var(--red); font-size: 0.78rem; line-height: 1.4; }
.offline-entry { width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; margin-top: 12px; padding: 18px 4px 2px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.offline-entry:hover { color: var(--green); }
.offline-entry:focus-visible { outline: 3px solid rgba(36, 77, 63, 0.2); outline-offset: 4px; }
.offline-entry > span:nth-child(2) { display: grid; gap: 3px; }
.offline-entry strong { color: var(--ink); font-weight: 650; }
.offline-entry small { color: var(--muted); line-height: 1.35; }
.offline-entry > span:last-child { opacity: 0.45; }
.offline-icon { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-weight: 800; }

.waiting { min-height: calc(100vh - 176px); display: grid; place-items: center; }
.waiting-card { width: min(560px, 100%); padding: clamp(28px, 4vw, 46px); text-align: center; }
.waiting-card h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(2.3rem, 5vw, 3.8rem); font-weight: 500; }
.waiting-card > p:not(.eyebrow, .form-message) { color: var(--muted); line-height: 1.7; }
.large-code { width: 100%; display: grid; gap: 4px; margin: 24px 0; padding: 19px; border: 1px dashed rgba(56, 47, 34, 0.26); border-radius: 18px; background: var(--paper); cursor: pointer; }
.large-code span, .large-code small { color: var(--muted); font-size: 0.72rem; }
.large-code b { font-size: clamp(2rem, 7vw, 3.2rem); letter-spacing: 0.18em; }
.seat-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 15px; text-align: left; }
.seat.empty { border-style: dashed; color: var(--muted); }
.seat-stone, .turn-stone { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; }
.seat-stone.black, .turn-stone.black { background: radial-gradient(circle at 36% 30%, #4a4d4a, #111312 62%); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.32); }
.seat-stone.white, .turn-stone.white { background: radial-gradient(circle at 35% 30%, #fff, #e5e0d4 70%); box-shadow: inset 0 0 0 1px rgba(32, 31, 28, 0.16), 0 3px 8px rgba(32, 31, 28, 0.14); }
.seat > span:last-child { display: grid; }
.seat small { color: var(--muted); }
.waiting-actions { display: grid; grid-template-columns: 1.4fr 1fr 0.8fr; gap: 10px; margin-top: 20px; }

.game-shell { display: grid; grid-template-columns: minmax(560px, 1fr) minmax(300px, 380px); align-items: start; gap: clamp(20px, 3vw, 42px); }
.board-column { width: min(100%, 920px); margin: 0 auto; }
.turn-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 252, 246, 0.64); }
.turn-player { display: flex; align-items: center; gap: 13px; min-width: 0; }
.turn-player h1 { margin: 0; overflow: hidden; font-family: Georgia, "Songti SC", serif; font-size: clamp(1.2rem, 2.4vw, 1.8rem); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.turn-number { display: grid; text-align: right; }
.turn-number strong { font-size: 1.35rem; line-height: 1; }
.turn-number span { margin-top: 4px; color: var(--muted); font-size: 0.56rem; letter-spacing: 0.15em; }
.player-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.player-card { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.32); }
.player-card.active { border-color: rgba(36, 77, 63, 0.45); background: var(--green-soft); }
.player-card .seat-stone { width: 21px; height: 21px; }
.player-card > span:last-child { min-width: 0; display: grid; }
.player-card strong { overflow: hidden; font-size: 0.82rem; text-overflow: ellipsis; white-space: nowrap; }
.player-card small { color: var(--muted); font-size: 0.67rem; }
.board-wrap { position: relative; width: min(100%, calc(100svh - 178px)); min-width: 480px; aspect-ratio: 1; margin: 0 auto; padding: clamp(22px, 3.5vw, 38px); border-radius: 22px; background: linear-gradient(135deg, #e0b66f, #c89148); box-shadow: inset 0 0 0 1px rgba(93, 61, 24, 0.32), inset 0 0 36px rgba(125, 77, 21, 0.11), 0 20px 50px rgba(78, 52, 21, 0.16); }
.board { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(15, 1fr); position: relative; }
.intersection { position: relative; min-width: 0; min-height: 0; border: 0; background: transparent; padding: 0; cursor: pointer; touch-action: manipulation; }
.intersection::before, .intersection::after { content: ""; position: absolute; background: rgba(71, 49, 23, 0.64); pointer-events: none; }
.intersection::before { top: calc(50% - 0.5px); left: 0; width: 100%; height: 1px; }
.intersection::after { left: calc(50% - 0.5px); top: 0; width: 1px; height: 100%; }
.intersection[data-col="0"]::before { left: 50%; width: 50%; }
.intersection[data-col="14"]::before { width: 50%; }
.intersection[data-row="0"]::after { top: 50%; height: 50%; }
.intersection[data-row="14"]::after { height: 50%; }
.intersection:focus-visible { z-index: 4; outline: 3px solid rgba(36, 77, 63, 0.62); outline-offset: -2px; border-radius: 50%; }
.intersection.star::marker { display: none; }
.star-dot { position: absolute; z-index: 1; top: 50%; left: 50%; width: 5px; height: 5px; border-radius: 50%; background: rgba(64, 43, 19, 0.78); transform: translate(-50%, -50%); pointer-events: none; }
.stone { position: absolute; z-index: 3; top: 50%; left: 50%; width: clamp(16px, 80%, 42px); aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.stone.black, .result-symbol[data-color="black"]::before { background: radial-gradient(circle at 34% 27%, #535753 0%, #171918 55%, #070807 100%); box-shadow: inset -3px -4px 7px rgba(0, 0, 0, 0.42), 0 3px 5px rgba(55, 36, 13, 0.34); }
.stone.white, .result-symbol[data-color="white"]::before { background: radial-gradient(circle at 33% 24%, #fff 0%, #f3efe5 56%, #d7d0c1 100%); box-shadow: inset -3px -4px 7px rgba(120, 108, 87, 0.18), 0 3px 5px rgba(55, 36, 13, 0.23); }
.stone.ghost { opacity: 0.48; }
.stone.ghost::after { content: ""; position: absolute; inset: -5px; border: 2px solid var(--green); border-radius: 50%; animation: ghost-ring 1.2s ease-in-out infinite; }
.stone.ghost.illegal { background: rgba(168, 77, 61, 0.78); box-shadow: none; }
.stone.ghost.illegal::before { content: "×"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.35rem; font-weight: 900; }
.stone.ghost.illegal::after { border-color: var(--red); }
.stone.last::after { content: ""; position: absolute; top: 50%; left: 50%; width: 6px; height: 6px; border-radius: 50%; background: #b55341; transform: translate(-50%, -50%); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.56); }
@keyframes ghost-ring { 0%, 100% { opacity: 0.42; transform: scale(0.92); } 50% { opacity: 0.9; transform: scale(1); } }
.coordinate { position: absolute; display: flex; color: rgba(72, 49, 23, 0.64); font-size: clamp(0.48rem, 1vw, 0.68rem); font-weight: 700; pointer-events: none; }
.coordinate.top { top: 6px; left: clamp(22px, 3.5vw, 38px); right: clamp(22px, 3.5vw, 38px); justify-content: space-around; }
.coordinate.left { top: clamp(22px, 3.5vw, 38px); bottom: clamp(22px, 3.5vw, 38px); left: 7px; flex-direction: column; justify-content: space-around; }
.coordinate span { flex: 1; display: grid; place-items: center; }
.status-line { min-height: 48px; display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.34); }
.status-line > span { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); }
.status-line p { margin: 0; color: var(--muted); font-size: 0.8rem; }
.status-line.error { border-color: rgba(168, 77, 61, 0.3); background: rgba(168, 77, 61, 0.06); }
.status-line.error > span { background: rgba(168, 77, 61, 0.12); color: var(--red); }

.game-panel { position: sticky; top: 18px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255, 252, 246, 0.76); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.rule-summary { display: grid; gap: 8px; margin: 20px 0; }
.rule-summary p { display: flex; align-items: flex-start; gap: 9px; margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.rule-summary b { flex: 0 0 auto; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--paper-deep); color: var(--green); font-size: 0.65rem; }
.preview-card { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 15px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, 0.38); }
.preview-card.illegal { border-color: rgba(168, 77, 61, 0.34); background: rgba(168, 77, 61, 0.06); }
.preview-stone { width: 48px; height: 48px; border-radius: 50%; }
.preview-stone.black { background: radial-gradient(circle at 34% 27%, #535753, #111312 62%); }
.preview-stone.white { background: radial-gradient(circle at 33% 24%, #fff, #ded8cb 72%); box-shadow: inset 0 0 0 1px rgba(45, 42, 36, 0.14); }
.preview-card > div:last-child { display: grid; gap: 2px; min-width: 0; }
.preview-card span { color: var(--muted); font-size: 0.68rem; }
.preview-card strong { font-family: Georgia, serif; font-size: 1.35rem; }
.preview-card small { overflow: hidden; color: var(--muted); font-size: 0.69rem; text-overflow: ellipsis; white-space: nowrap; }
.confirm-button { width: 100%; margin-top: 12px; }
.match-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.match-actions .quiet-button { border-radius: 13px; }
.quiet-button.danger { color: var(--red); }
.move-log { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.move-log-heading { display: flex; align-items: center; justify-content: space-between; }
.move-log h3 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 1.08rem; font-weight: 500; }
.move-log-heading span { color: var(--muted); font-size: 0.7rem; }
.move-log ol { max-height: 230px; margin: 12px 0 0; padding: 0; overflow: auto; list-style: none; }
.move-log li { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 9px; padding: 9px 2px; border-bottom: 1px solid rgba(56, 47, 34, 0.08); font-size: 0.76rem; }
.move-log li i { width: 18px; height: 18px; border-radius: 50%; }
.move-log li i.black { background: #151716; }
.move-log li i.white { background: #f6f2e8; box-shadow: inset 0 0 0 1px rgba(45, 42, 36, 0.2); }
.move-log li time { color: var(--muted); font-variant-numeric: tabular-nums; }
.move-log .empty-log { display: block; color: var(--muted); text-align: center; }

dialog { border: 0; padding: 0; background: transparent; color: var(--ink); }
dialog::backdrop { background: rgba(24, 25, 23, 0.5); backdrop-filter: blur(6px); }
.rules-dialog form, .result-card, .confirm-dialog form { border: 1px solid rgba(255, 255, 255, 0.55); border-radius: 26px; background: #f7f1e6; box-shadow: 0 30px 100px rgba(0, 0, 0, 0.24); }
.rules-dialog { width: min(780px, calc(100% - 24px)); }
.rules-dialog form { padding: clamp(22px, 4vw, 36px); }
.dialog-heading h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 2rem; font-weight: 500; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255, 255, 255, 0.46); font-size: 1.35rem; cursor: pointer; }
.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.rule-grid section { padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255, 255, 255, 0.35); }
.rule-grid b { color: var(--green); font-size: 0.68rem; letter-spacing: 0.12em; }
.rule-grid h3 { margin: 8px 0 5px; font-family: Georgia, "Songti SC", serif; font-weight: 500; }
.rule-grid p, .dialog-note { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.6; }
.dialog-note { margin-top: 16px; padding: 13px 15px; border-radius: 14px; background: var(--paper-deep); }
.result-dialog { width: min(440px, calc(100% - 24px)); }
.result-card { padding: 36px; text-align: center; }
.result-symbol { width: 74px; height: 74px; display: grid; place-items: center; margin: 18px auto; border-radius: 50%; background: var(--wood); color: #151716; font-size: 2.5rem; }
.result-symbol[data-color="black"]::before, .result-symbol[data-color="white"]::before { content: ""; width: 36px; height: 36px; border-radius: 50%; }
.result-card h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 2.1rem; font-weight: 500; }
.result-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 24px; }
.result-actions #resultLobbyButton { grid-column: 1 / -1; }
.confirm-dialog { width: min(420px, calc(100% - 24px)); }
.confirm-dialog form { padding: 28px; }
.confirm-dialog h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-weight: 500; }
.confirm-dialog p { color: var(--muted); }
.confirm-dialog form > div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.danger-fill { background: var(--red); box-shadow: 0 9px 20px rgba(168, 77, 61, 0.16); }

@media (max-width: 1050px) {
  .lobby { grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1fr); gap: 42px; }
  .lobby-copy { padding-left: 0; }
  .game-shell { grid-template-columns: minmax(480px, 1fr) minmax(280px, 330px); }
  .board-wrap { min-width: 440px; }
}

@media (min-width: 851px) {
  .board-column { width: 100%; display: grid; grid-template-columns: minmax(210px, 0.82fr) minmax(0, 1.18fr); grid-template-areas: "turn players" "board board" "status status"; gap: 10px; }
  .turn-card { grid-area: turn; min-height: 70px; margin: 0; padding: 10px 14px; }
  .turn-player h1 { font-size: clamp(1rem, 1.55vw, 1.42rem); }
  .turn-number strong { font-size: 1.05rem; }
  .player-strip { grid-area: players; min-height: 70px; margin: 0; }
  .player-card { padding: 8px 11px; }
  .board-wrap { grid-area: board; }
  .status-line { grid-area: status; }
}

@media (max-width: 850px) {
  .topbar { width: min(100% - 28px, 760px); }
  main { width: min(100% - 28px, 760px); padding-top: 18px; }
  .lobby { min-height: auto; grid-template-columns: 1fr; gap: 28px; padding: 28px 0 48px; }
  .lobby-copy { max-width: 620px; }
  .lobby-copy h1 { font-size: clamp(3.2rem, 11vw, 5.3rem); }
  .lobby-copy > p:not(.eyebrow) { margin: 20px 0; }
  .game-shell { grid-template-columns: 1fr; }
  .board-column { width: 100%; }
  .board-wrap { width: 100%; min-width: 0; }
  .game-panel { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; padding: 20px; }
  .game-panel .panel-heading, .game-panel .rule-summary, .game-panel .move-log { grid-column: 1 / -1; }
  .preview-card { grid-column: 1 / 2; grid-row: 3 / span 2; }
  .confirm-button { grid-column: 2; margin: 0; }
  .match-actions { grid-column: 2; margin: 0; }
  .move-log ol { max-height: 150px; }
}

@media (max-width: 560px) {
  .topbar { width: calc(100% - 24px); height: 68px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
  .brand-mark b { width: 10px; height: 10px; top: 13px; left: 13px; }
  .brand-mark i:nth-child(1) { left: 12px; }
  .brand-mark i:nth-child(2) { right: 12px; }
  .brand-mark i:nth-child(3) { top: 12px; }
  .brand-mark i:nth-child(4) { bottom: 12px; }
  .brand small, .rules-button kbd, .quiet-button kbd { display: none; }
  .header-status .quiet-button { min-height: 38px; padding: 0 13px; font-size: 0.76rem; }
  .room-chip { min-height: 38px; padding: 0 11px; }
  .room-chip span:not(.connection-dot) { display: none; }
  main { width: calc(100% - 20px); padding: 12px 0 40px; }
  .lobby { padding-top: 18px; }
  .lobby-copy h1 { font-size: clamp(2.8rem, 15vw, 4rem); }
  .lobby-copy > p:not(.eyebrow) { font-size: 0.92rem; line-height: 1.7; }
  .feature-row { gap: 6px; }
  .feature-row span { padding: 8px 10px; font-size: 0.72rem; }
  .lobby-card { padding: 19px; border-radius: 22px; }
  .mode-picker { grid-template-columns: 1fr; }
  .mode-picker span { min-height: 66px; }
  .seat-list { grid-template-columns: 1fr; }
  .waiting-actions { grid-template-columns: 1fr; }
  .turn-card { padding: 11px 12px; border-radius: 14px; }
  .turn-stone { width: 24px; height: 24px; }
  .turn-player { gap: 9px; }
  .turn-player h1 { font-size: 1rem; }
  .turn-number strong { font-size: 1rem; }
  .player-card { padding: 8px 9px; }
  .board-wrap { padding: 18px; border-radius: 14px; }
  .coordinate.top { left: 18px; right: 18px; top: 3px; }
  .coordinate.left { top: 18px; bottom: 18px; left: 3px; }
  .stone { width: 88%; }
  .status-line { min-height: 42px; padding: 8px 10px; }
  .status-line p { font-size: 0.72rem; }
  .game-panel { grid-template-columns: 1fr; padding: 18px; border-radius: 22px; }
  .game-panel .panel-heading, .game-panel .rule-summary, .game-panel .move-log, .preview-card, .confirm-button, .match-actions { grid-column: 1; grid-row: auto; }
  .preview-card { min-height: 82px; }
  .rule-grid { grid-template-columns: 1fr; }
  .rules-dialog form, .result-card { border-radius: 20px; }
  .result-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Approved UI: cream surfaces, natural maple, contemporary Chinese typography. */
body { background: var(--paper); }
.topbar, main { width: min(1240px, calc(100% - 64px)); }
.topbar { height: 84px; border-bottom: 1px solid var(--line); }
.brand strong { font-size: 27px; font-weight: 500; letter-spacing: .05em; }
.brand small { font-size: 9px; letter-spacing: .14em; }
.brand-mark { background: var(--wood) url("assets/design/maple-board.jpg") center / cover; box-shadow: inset 0 0 0 1px #b99d7166; }
button:focus-visible, summary:focus-visible { outline: 3px solid var(--green); outline-offset: 4px; }
.mode-picker input:focus-visible + span { outline: 3px solid var(--green); outline-offset: 3px; }
.room-chip, .quiet-button, .icon-button { min-height: 44px; border-radius: 12px; }
.icon-button { width: 44px; height: 44px; flex-shrink: 0; }
.lobby { min-height: calc(100svh - 180px); grid-template-columns: minmax(0, 1.12fr) minmax(350px, .88fr); gap: clamp(44px, 6vw, 90px); padding: 12px 0 32px; }
.lobby-copy { padding: 0; max-width: 560px; }
.lobby-art { display: block; width: 100%; height: auto; aspect-ratio: 2.5; object-fit: contain; margin: 0 0 24px; border-radius: 16px; }
.lobby-copy h1 { font-size: clamp(38px, 4vw, 58px); line-height: 1.4; letter-spacing: .015em; }
.lobby-copy > p:not(.eyebrow) { margin: 20px 0; font-size: 15px; line-height: 1.8; max-width: 430px; }
.feature-row { gap: 14px; }
.feature-row span { padding: 0; border: 0; background: none; font-size: 12px; }
.lobby-card { padding: 28px; background: #fffdf780; backdrop-filter: none; box-shadow: none; }
.online-tabs { padding: 0; margin-bottom: 24px; background: none; border-radius: 0; border-bottom: 1px solid var(--line); }
.online-tab { min-height: 48px; border-radius: 0; font-size: 14px; border-bottom: 2px solid transparent; }
.online-tab.active { background: none; border-bottom-color: var(--green); box-shadow: none; }
.mode-heading h2 { font-family: inherit; font-size: 14px; font-weight: 600; }
.mode-heading .eyebrow { display: none; }
.mode-badge { padding: 4px 8px; font-size: 12px; }
.mode-picker { margin: 12px 0 20px; gap: 8px; }
.mode-picker span { min-height: 80px; border-radius: 12px; padding: 12px; }
.mode-picker input:checked + span { box-shadow: none; }
.mode-picker small { font-size: 12px; line-height: 1.5; }
.lobby-card:has(.online-tab[data-tab="join"].active) .mode-heading,
.lobby-card:has(.online-tab[data-tab="join"].active) .mode-picker { display: none; }
.online-form input { border-radius: 12px; background: #fffdf8; min-height: 48px; }
.online-form label > span, .form-message { font-size: 13px; }
.primary-button { min-height: 50px; border-radius: 12px; box-shadow: none; }
.join-rule-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.offline-entry { margin-top: 16px; padding-top: 20px; }
.offline-entry small { font-size: 12px; }
.waiting-card { width: min(540px, 100%); padding: 30px; background: #fffdf780; backdrop-filter: none; box-shadow: none; }
.waiting-card h1 { font-size: clamp(30px, 4vw, 42px); line-height: 1.4; }
.waiting-art { display: block; width: 100%; height: auto; aspect-ratio: 2.5; object-fit: contain; margin: 20px 0; border-radius: 12px; }
.large-code { border-style: solid; border-radius: 12px; background: transparent; margin: 18px 0; }
.large-code b { color: var(--green); font-size: 30px; }
.large-code span, .large-code small { font-size: 12px; }
.seat-list { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: 14px; padding: 0 16px; }
.seat { border: 0; border-radius: 0; border-bottom: 1px solid var(--line); padding: 15px 0; }
.seat:last-child { border-bottom: 0; }
.waiting-actions { grid-template-columns: 1fr; }
#leaveWaitingButton { color: var(--red); }
.game-shell { grid-template-columns: minmax(0, 1fr) 300px; gap: 30px; }
body[data-screen="game"] main { padding-top: 20px; }
.board-column { max-width: 840px; }
.turn-card { border: 0; border-radius: 0; padding: 10px 0; background: none; }
.player-card { border: 0; border-radius: 10px; border-bottom: 2px solid transparent; background: none; }
.player-card.active { background: var(--green-soft); border-bottom-color: var(--green); }
.player-card strong { font-size: 14px; }
.player-card small { font-size: 12px; }
.board-wrap { width: 100%; min-width: 0; max-width: 800px; padding: clamp(18px, 2.7vw, 32px); border-radius: 16px; background: var(--wood) url("assets/design/maple-board.jpg") center / cover; box-shadow: inset 0 0 0 1px #ab8d5866, 0 6px 12px #5b3f231a; }
.coordinate.top { left: clamp(18px, 2.7vw, 32px); right: clamp(18px, 2.7vw, 32px); }
.coordinate.left { top: clamp(18px, 2.7vw, 32px); bottom: clamp(18px, 2.7vw, 32px); }
.coordinate { color: #705b3d; }
.game-panel { padding: 24px 0 0 24px; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: none; box-shadow: none; backdrop-filter: none; }
.panel-heading h2 { font-size: 25px; }
.panel-heading .eyebrow { display: none; }
.rule-disclosure { margin: 18px 0; color: var(--muted); }
.rule-disclosure summary { font-size: 14px; cursor: pointer; min-height: 30px; }
.rule-summary { margin: 10px 0 0; }
.rule-summary p { font-size: 13px; }
.preview-card { border-radius: 12px; padding: 14px; background: #fffdf780; }
.preview-stone { width: 36px; height: 36px; }
.preview-card span, .preview-card small { font-size: 12px; }
.preview-card small { white-space: normal; overflow: visible; }
.preview-card strong { color: var(--green); font-size: 24px; }
.match-actions { grid-template-columns: 1fr; }
.match-actions .quiet-button { font-size: 14px; min-height: 44px; }
.status-line { border: 0; background: none; padding: 10px 0; }
.status-line p { font-size: 13px; }
.move-log-heading { cursor: pointer; min-height: 36px; }
.move-log-heading > span:first-child { color: var(--ink); font-size: 16px; font-family: Georgia, "Songti SC", serif; }
.move-log li { font-size: 13px; }
dialog { max-height: calc(100svh - 32px); overflow-y: auto; }
dialog::backdrop { background: #273b344d; backdrop-filter: blur(3px); }
.rules-dialog form, .result-card, .confirm-dialog form { border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 20px 70px #23342826; }
.rule-grid section { background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 0; }
.rule-grid { gap: 16px 24px; }
.rule-grid p, .dialog-note { font-size: 14px; line-height: 1.7; }
.result-symbol { background: var(--wood) url("assets/design/maple-board.jpg") center / cover; }
.result-actions { grid-template-columns: 1fr; }
.result-card .text-button:focus { outline: none; }
.result-card .text-button:focus-visible { text-decoration-thickness: 3px; }
.text-button { min-height: 44px; padding: 0 12px; border: 0; background: none; color: var(--green); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.finished-actions { display: grid; gap: 12px; margin: 18px 0; grid-column: 1 / -1; grid-row: 2; }
.finished-actions p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.game-shell.finished .move-log, .game-shell.finished .rule-disclosure { grid-row: auto; }
.confirm-dialog p { font-size: 14px; line-height: 1.7; }
@media (max-width: 900px) {
  .topbar, main { width: min(720px, calc(100% - 40px)); }
  .lobby { grid-template-columns: 1fr; gap: 24px; min-height: auto; max-width: 540px; margin: auto; }
  .lobby-copy { max-width: none; }
  .lobby-copy h1 { font-size: 40px; }
  .lobby-art { max-height: 195px; margin-bottom: 18px; }
  .game-shell { grid-template-columns: 1fr; gap: 14px; }
  .board-column { display: block; }
  .turn-card { margin: 0 0 8px; }
  .player-strip { margin: 0 0 12px; }
  .game-panel { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .game-panel .panel-heading { grid-column: 1 / -1; }
  .rule-disclosure { grid-column: 1 / -1; grid-row: 5; margin: 0; }
  .preview-card { grid-column: 1; grid-row: 2 / span 2; }
  .confirm-button { grid-column: 2; grid-row: 2; margin: 0; }
  .match-actions { grid-column: 2; grid-row: 3; grid-template-columns: 1fr 1fr; margin: 0; }
  .move-log { grid-column: 1 / -1; grid-row: 4; margin-top: 4px; padding-top: 8px; }
}
@media (max-width: 560px) {
  .topbar, main { width: calc(100% - 32px); }
  .topbar { height: 70px; gap: 10px; }
  .header-status { gap: 6px; }
  .header-status .quiet-button, .room-chip { min-height: 44px; padding: 0 10px; }
  .lobby { padding-top: 4px; gap: 20px; }
  .lobby-copy h1 { font-size: 32px; }
  .lobby-art { margin: 0 0 16px; }
  .lobby-copy > p:not(.eyebrow) { font-size: 14px; margin: 12px 0; }
  .lobby-copy .eyebrow, .feature-row { display: none; }
  .lobby-card { padding: 0; border: 0; border-radius: 0; background: none; }
  .online-tabs { margin-bottom: 18px; }
  .mode-picker { grid-template-columns: 1fr 1fr; }
  .mode-picker span { min-height: 84px; padding: 10px; }
  .waiting-card { padding: 22px 16px; }
  .waiting-art { margin: 14px 0; }
  .board-wrap { padding: 18px; }
  .coordinate.top { left: 18px; right: 18px; }
  .coordinate.left { top: 18px; bottom: 18px; }
  .game-panel { grid-template-columns: 1fr; }
  .game-panel .panel-heading { grid-row: 1; }
  .preview-card { grid-column: 1; grid-row: 2; min-height: 70px; }
  .confirm-button { grid-column: 1; grid-row: 3; }
  .match-actions { grid-column: 1; grid-row: 4; }
  .game-panel .move-log { grid-row: 5; }
  .rule-disclosure { grid-row: 6; }
  .rule-grid { grid-template-columns: 1fr; }
  .rules-dialog { width: calc(100% - 20px); }
  .dialog-heading h2 { font-size: 25px; }
}

@media (max-width: 560px) {
  .lobby-copy > p:not(.eyebrow) { display: none; }
  .lobby-art { max-height: 145px; }
  .lobby-copy h1 { font-size: 30px; line-height: 1.35; }
  .lobby { gap: 12px; }
  .offline-entry { margin-top: 8px; }
}

@media (min-width: 901px) {
  .board-wrap { width: min(100%, max(360px, calc(100svh - 210px))); }
}

/* Avatar emotes stay outside board input and survive room rerenders. */
.player-avatar { position: relative; flex: 0 0 44px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); }
button.player-avatar { cursor: pointer; transition: background 150ms, transform 150ms; }
button.player-avatar:hover, button.player-avatar[aria-expanded="true"] { background: var(--green-soft); border-color: var(--green); }
button.player-avatar:active { transform: scale(.93); }
.player-avatar .seat-stone { width: 25px; height: 25px; }
.avatar-emote-hint { position: absolute; right: -3px; bottom: -2px; display: grid; place-items: center; width: 19px; height: 19px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--green); pointer-events: none; }
.avatar-emote-hint svg { display: block; width: 15px; height: 15px; }
.emote-picker { position: fixed; z-index: 40; width: min(300px, calc(100vw - 24px)); padding: 14px 10px 10px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 12px 40px #293b3426; }
.emote-picker p { margin: 0 6px 8px; font-size: 13px; font-weight: 600; }
.emote-picker > small { display: block; margin-top: 9px; color: var(--muted); font-size: 11px; text-align: center; }
.emote-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.emote-options button { display: grid; justify-items: center; gap: 4px; min-width: 44px; min-height: 76px; padding: 5px 0; border: 0; border-radius: 12px; background: transparent; cursor: pointer; font-size: 12px; }
.emote-options button:hover { background: var(--green-soft); }
.emote-options img { width: 56px; height: 56px; object-fit: contain; }
.player-avatar:focus-visible, .emote-options button:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
.emote-layer { position: fixed; inset: 0; z-index: 35; pointer-events: none; }
.emote-burst { position: absolute; width: 104px; height: 104px; margin-left: -52px; margin-top: -72px; animation: emote-pop 2400ms both; transform-origin: 50% 90%; }
.emote-burst img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 3px #293b3420); }
.emote-feedback { position: fixed; z-index: 41; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 32px); margin: 0; padding: 9px 16px; border-radius: 14px; background: var(--ink); color: var(--paper); font-size: 13px; pointer-events: none; }
.emote-feedback:empty { display: none; }
@keyframes emote-pop {
  0% { opacity: 0; transform: translateY(15px) scale(.35) rotate(-12deg); }
  14% { opacity: 1; transform: translateY(-7px) scale(1.12) rotate(6deg); }
  25%, 65% { opacity: 1; transform: translateY(-3px) scale(1) rotate(-3deg); }
  80% { opacity: 1; transform: translateY(-15px) scale(1.03) rotate(3deg); }
  100% { opacity: 0; transform: translateY(-42px) scale(.85); }
}
@keyframes emote-notice { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .emote-burst { animation: emote-notice 2400ms both; }
  button.player-avatar { transition: none; }
}
