#home .online-section { grid-column:2; padding:28px; }
.home-mode-nav { grid-column:2; display:flex; gap:4px; padding:5px; background:#dce9f5; border:1px solid var(--color-border); border-radius:16px; align-self:start; }
.home-mode-nav button { flex:1; border-radius:11px; font-size:15px; padding:13px 7px; color:var(--color-text-muted); }
.home-mode-nav button[aria-pressed="true"] { background:var(--color-action); color:#fff; box-shadow:3px 3px 0 #174f7c; }
#home .home-intro { grid-row:1 / 3; }
#home .home-card { align-items:start; }
.online-heading { display:flex; justify-content:space-between; align-items:center; gap:16px; }
.room-fields { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin:20px 0; }
.room-fields label:first-child { grid-column:1 / -1; }
.room-fields label, .join-fields label { display:flex; flex-direction:column; gap:8px; font-size:14px; }
.room-fields input,.room-fields select,.join-fields input { font:inherit; font-size:16px; color:var(--color-action); background:var(--color-surface); border:1px solid var(--color-shadow); padding:12px; border-radius:10px; width:100%; min-width:0; }
.room-primary,.room-secondary,.public-room button { padding:12px 20px; border:2px solid var(--color-action); border-radius:14px; font-size:15px; }
.room-primary { background:var(--color-action); color:white; box-shadow:3px 3px 0 var(--color-shadow); }
.room-secondary,.public-room button { background:var(--color-surface); color:var(--color-action); }
.room-primary:disabled,.public-room button:disabled { opacity:.5; cursor:default; }
.join-fields { display:flex; gap:12px; align-items:end; margin-top:24px; padding-top:24px; border-top:1px solid var(--color-border); }
.join-fields label { flex:1; }
#room-message { color:var(--color-danger); font-size:14px; min-height:1.5em; margin:16px 0; }
.public-heading { display:flex; justify-content:space-between; align-items:center; margin:24px 0 12px; }
.public-heading h3 { font-size:18px; margin:0; }
#refresh-rooms { color:#205f95; text-decoration:underline; font-size:14px; }
#public-rooms { font-size:14px; color:var(--color-text-muted); line-height:1.8; }
.public-room { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 0; border-top:1px solid #e3ded5; }
.public-room span { overflow-wrap:anywhere; }
#room-wait { max-width:600px; margin:24px auto; background:var(--color-surface); border:2px solid var(--color-action); border-radius:28px; padding:32px; box-shadow:6px 6px 0 var(--color-shadow); }
#room-wait h2 { margin-top:0; }
#wait-code { font-size:clamp(22px,4vw,32px); letter-spacing:2px; display:block; margin:16px 0; user-select:all; }
#wait-members { list-style:none; padding:0; margin:24px 0; }
#wait-members li { padding:16px; background:var(--color-surface-muted); margin:8px 0; border-radius:12px; overflow-wrap:anywhere; }
#wait-message { font-size:15px; line-height:1.7; }
.wait-actions { display:flex; flex-wrap:wrap; gap:12px; }
#network-status { font-size:13px; color:var(--color-text-muted); line-height:1.6; overflow-wrap:anywhere; }
@media(max-width:760px){ .room-fields{grid-template-columns:1fr 1fr;} .room-fields label:first-child{grid-column:1 / -1;} .join-fields{flex-wrap:wrap;} .join-fields label{flex-basis:100%;} #home .online-section{padding:22px;} #room-wait{padding:22px;} }

@media(max-width:760px){ .home-mode-nav { width:100%; } .home-mode-nav button { font-size:14px; } }

/* 精簡列表與操作彈窗。 */
.lobby-symbol { font-size:42px; color:var(--color-action); }
.lobby-actions { display:flex; gap:12px; margin:0 0 26px; }
.lobby-actions button { flex:1; padding:13px 12px; }
.lobby-aside-copy,.lobby-aside-note { display:none; }
.room-browser { min-width:0; }
.public-heading { margin:0 0 14px; }
#room-count { display:inline-block; font-size:12px; color:var(--color-action); background:var(--color-surface-muted); border-radius:20px; padding:3px 8px; vertical-align:middle; margin-left:4px; }
#public-rooms { margin-top:16px; max-height:370px; overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; padding-right:6px; }
.public-room { display:grid; grid-template-columns:38px minmax(0,1fr) auto auto; gap:12px; padding:16px 0; border-top:1px solid #e3ded5; }
.room-emblem { width:38px; height:38px; display:grid; place-items:center; background:var(--color-surface-muted); color:var(--color-action); border-radius:10px; font-size:10px; white-space:nowrap; }
.public-room:nth-child(even) .room-emblem { color:#b73835; background:#fbe9e7; }
.room-info { min-width:0; }
.room-info strong { display:block; font-size:15px; color:var(--color-action); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.room-info small { display:block; font-size:12px; color:var(--color-text-muted); font-weight:500; }
.room-occupancy { font-size:13px; font-variant-numeric:tabular-nums; }
.public-room button { padding:7px 12px; font-size:13px; border:1px solid var(--color-shadow); border-radius:8px; }
.public-room button:disabled { opacity:1; background:#edf2f7; color:#61778b; border-color:#d2dde8; }
.room-full { opacity:.65; }
#public-rooms.room-empty { display:block; padding:40px 20px; text-align:center; border:1px dashed var(--color-shadow); border-radius:14px; line-height:1.8; }
#room-message:empty { display:none; }
#refresh-rooms:disabled { opacity:.45; cursor:default; }
/* 原生 dialog 提供焦點管理及 Escape 關閉。 */
#room-dialog { width:calc(100% - 32px); max-width:480px; max-height:90dvh; overflow-y:auto; border:2px solid var(--color-action); border-radius:26px; padding:28px; color:var(--color-action); background:var(--color-surface); box-shadow:7px 7px 0 var(--color-shadow); }
#room-dialog::backdrop { background:#152b41a8; }
.room-dialog-header { display:flex; align-items:start; justify-content:space-between; gap:12px; }
.room-dialog-header h2 { margin:0; font-size:25px; overflow-wrap:anywhere; }
#close-room-dialog { font-size:28px; width:36px; height:36px; border-radius:50%; background:var(--color-surface-muted); flex:none; }
#room-dialog-description { font-size:14px; color:var(--color-text-muted); line-height:1.7; }
#room-dialog .join-fields { margin:0; padding:0; border:0; }
#room-dialog .room-primary { width:100%; }
#room-dialog-error { font-size:14px; color:var(--color-danger); line-height:1.7; }
#room-dialog button:focus-visible,#room-dialog input:focus-visible,#room-dialog select:focus-visible { outline:3px solid var(--color-action); outline-offset:3px; }
@media(max-width:760px) {
  .lobby-symbol { display:none; }
  .lobby-actions { gap:10px; }
  .lobby-actions button { font-size:14px; }
  .public-room { grid-template-columns:32px minmax(0,1fr) auto; gap:10px; }
  .room-emblem { width:32px; height:32px; }
  .room-occupancy { grid-column:2; grid-row:2; font-size:12px; }
  .public-room button { grid-column:3; grid-row:1 / 3; }
}

.room-sort-note { font-size:12px; color:var(--color-text-muted); font-weight:500; margin:0 0 12px; }

#home .ranked-section { grid-column:2; }
#rank-auth { display:flex; flex-direction:column; gap:14px; }
#rank-auth label { display:flex; flex-direction:column; gap:7px; font-size:14px; }
#rank-auth input { font:inherit; font-size:16px; padding:12px; border:1px solid var(--color-shadow); border-radius:10px; background:var(--color-surface); color:var(--color-action); width:100%; }
.rank-buttons { display:flex; gap:12px; margin-top:8px; }
.rank-buttons button { flex:1; }
.rank-identity { display:flex; justify-content:space-between; align-items:center; }
#rank-logout,#rank-refresh { font-size:13px; text-decoration:underline; color:var(--color-text-muted); }
.rank-rating { margin:22px 0 14px; padding:22px; background:var(--color-surface-muted); border:1px solid var(--color-shadow); border-radius:18px; display:grid; grid-template-columns:1fr auto; align-items:center; }
#rank-tier { font-size:24px; color:#205f95; }
#rank-score { font-size:46px; color:var(--color-action); font-variant-numeric:tabular-nums; }
.rank-rating small { grid-column:2; font-size:12px; color:var(--color-text-muted); text-align:right; }
#rank-record { font-size:18px; text-align:center; }
#rank-progress { font-size:14px; color:var(--color-text-muted); text-align:center; margin-bottom:24px; }
#rank-queue,#rank-cancel { width:100%; }
#rank-message { color:var(--color-danger); font-size:14px; line-height:1.7; }
#rank-message:empty { display:none; }
.rank-rules { margin:24px 0; font-size:13px; font-weight:500; color:var(--color-text-muted); line-height:1.8; border-block:1px solid #e3ded5; padding:14px 0; }
.rank-rules summary { cursor:pointer; font-size:14px; font-weight:700; }
#rank-leaderboard { padding:0; list-style:none; margin:0; max-height:260px; overflow:auto; font-size:14px; color:var(--color-text-muted); }
#rank-leaderboard li { display:flex; justify-content:space-between; gap:12px; border-top:1px solid #e3ded5; padding:12px 0; }
#rank-leaderboard li span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#rank-leaderboard li strong { white-space:nowrap; }
#rank-match-result { background:var(--color-surface); color:var(--color-action); border:2px solid var(--color-action); border-radius:14px; padding:16px; font-size:15px; width:100%; }
@media(max-width:760px){.home-mode-nav button{font-size:12px;padding:13px 4px;}}

.rank-result-note { margin-top:18px !important; padding:14px; background:var(--color-surface-muted); border-radius:12px; font-weight:700; text-align:center; }

/* Independent ranked ladders */
.rank-mode-nav {display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:24px 0 12px;}
.rank-mode-nav button {padding:16px;border:2px solid var(--ink,#203c55);border-radius:18px;background:var(--color-surface);color:#203c55;font:inherit;font-weight:800;cursor:pointer;}
.rank-mode-nav button small {display:block;font-size:12px;margin-top:4px;font-weight:600;}
.rank-mode-nav button[aria-pressed="true"] {background:var(--color-action);color:white;box-shadow:3px 3px 0 #203c55;}
.rank-mode-nav button:disabled {cursor:default;opacity:.75;}
.rank-mode-note {font-size:14px;color:#526f88;}

/* Home stays within a viewport; longer secondary content lives in dialogs. */
#home[data-style="coral"] {padding:24px 28px;height:100dvh;overflow:hidden;}
#home[data-style="coral"] .home-card {height:100%;min-height:0;grid-template-rows:auto minmax(0,1fr) auto;gap:18px 40px;}
#home[data-style="coral"] .home-intro {align-self:start;grid-row:1 / 3;padding-top:48px;}
#home[data-style="coral"] h1 {font-size:clamp(32px,4vw,54px);}
#home[data-style="coral"] .home-art {max-width:min(290px,32vh);margin:24px auto;}
#home[data-style="coral"] .home-section {grid-row:2;max-height:100%;min-height:0;overflow:auto;padding:24px;}
#home .home-footer {grid-row:3;margin:0;padding-top:12px;}
#home .section-description {margin:12px 0 18px;}
#home .rank-mode-nav {margin:16px 0 10px;}
#home .rank-rating {margin:14px 0 10px;padding:14px;}
#home #rank-progress {margin-bottom:16px;}
#home #rank-record {font-size:15px;}
.rank-more {display:flex;gap:12px;margin-top:18px;}
.rank-more button {flex:1;padding:10px;font-size:14px;}
#open-rank-auth {width:100%;margin:16px 0 0;}
.rank-login-note {font-size:14px;color:var(--color-text-muted);line-height:1.7;}
.home-modal {width:min(560px,calc(100% - 32px));max-height:calc(100dvh - 40px);padding:24px;border:2px solid var(--color-action);border-radius:24px;background:var(--color-surface);color:var(--color-action);overflow:auto;box-shadow:6px 6px var(--color-shadow);}
.home-modal::backdrop {background:#152b41a8;}
.home-modal>header {display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:20px;}
.home-modal h2 {margin:0;font-size:23px;}
.home-modal>header button {width:38px;height:38px;flex:none;border-radius:50%;background:var(--color-surface-muted);font-size:28px;color:var(--color-action);}
.home-modal button:focus-visible {outline:3px solid var(--color-action);outline-offset:3px;}
.home-modal #rank-leaderboard {max-height:none;overflow:visible;}
.home-modal .rank-rules {margin:0;border:0;padding:0;}
.guide-content h3 {margin:0 0 12px;font-size:21px;}
.guide-content svg {display:block;width:100%;max-height:32dvh;}
.guide-content p {line-height:1.8;font-size:15px;min-height:108px;}
.guide-nav {display:flex;align-items:center;justify-content:space-between;gap:12px;}
.guide-nav button {padding:12px;border-radius:12px;background:var(--color-surface-muted);color:#205f95;}
.guide-nav button:disabled {opacity:.35;}
#visitor-country {font-size:12px;}
@media(max-width:760px){
 #home[data-style="coral"] {padding:16px;}
 #home[data-style="coral"] .home-card {display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr) auto;gap:12px;}
 #home[data-style="coral"] .home-intro {grid-column:1;grid-row:1;padding:0;}
 #home[data-style="coral"] h1 {font-size:30px;}
 #home .tagline {display:none;}
 #home .home-mode-nav {grid-column:1;grid-row:2;}
 #home[data-style="coral"] .home-section {grid-column:1;grid-row:3;padding:18px;}
 #home .home-footer {grid-row:4;grid-column:1;}
 #home .section-kicker {display:none;}
 #home .home-section h2 {font-size:22px;}
 #home .section-description {font-size:13px;margin:10px 0;}
 #home .rank-mode-nav button {padding:10px;}
 #home .rank-mode-note {font-size:12px;}
 .home-modal {padding:20px;}
}

/* Ranked card is a fixed panel, not a nested scroll area. */
#home[data-style="coral"] .ranked-section {overflow:visible;max-height:none;}
@media(max-height:800px){
 #home[data-style="coral"] .ranked-section {padding:18px;}
 #home .ranked-section .section-kicker {display:none;}
 #home .ranked-section .section-description {margin:8px 0 12px;font-size:13px;}
 #home .ranked-section .rank-mode-nav {margin:12px 0 8px;}
 #home .ranked-section .rank-mode-nav button {padding:10px;}
 #home .ranked-section .rank-mode-note,#home .rank-login-note {font-size:12px;margin:8px 0;}
 #home .ranked-section .rank-rating {padding:10px 14px;margin:10px 0;}
 #home .ranked-section #rank-score {font-size:34px;}
 #home .ranked-section #rank-record {margin:8px 0;font-size:14px;}
 #home .ranked-section #rank-progress {margin:8px 0 12px;font-size:12px;}
 #home .ranked-section .rank-more {margin-top:12px;}
 #home .ranked-section #open-rank-auth {margin-top:12px;}
 #home .ranked-section #rank-message {margin:8px 0;font-size:12px;}
}
@media(max-width:760px) and (max-height:740px), (min-width:761px) and (max-height:650px){
 #home .ranked-section .section-description,#home .ranked-section .rank-mode-note {display:none;}
 #home .ranked-section h2 {font-size:20px;}
 #home .ranked-section .rank-mode-nav button small {display:none;}
 #home .ranked-section .rank-rating {display:flex;justify-content:space-between;gap:8px;padding:8px 12px;margin:8px 0;}
 #home .ranked-section .rank-rating small {display:none;}
 #home .ranked-section #rank-score {font-size:28px;}
 #home .ranked-section #rank-tier {font-size:20px;}
 #home .ranked-section #rank-progress {display:none;}
 #home .ranked-section .rank-more button {padding:8px;}
 #home .ranked-section .rank-identity {font-size:13px;gap:8px;}
 #home .ranked-section #rank-name {overflow-wrap:anywhere;}
}
@media(max-width:760px) and (max-height:600px){
 #home[data-style="coral"] {padding:10px 12px;}
 #home[data-style="coral"] .home-card {gap:8px;}
 #home[data-style="coral"] h1 {font-size:25px;}
 #home .home-mode-nav button {padding:9px 3px;}
 #home[data-style="coral"] .ranked-section {padding:12px;}
 #home .ranked-section h2 {font-size:17px;}
 #home .ranked-section .rank-mode-nav {margin:8px 0;}
 #home .ranked-section .rank-more {margin-top:8px;}
 #home .ranked-section #rank-queue,#home .ranked-section #rank-cancel {padding:9px;}
 #home .ranked-section #rank-record {font-size:12px;margin:6px 0;}
 #home .home-footer {padding-top:8px;}
}

/* Native selects keep a consistent inset arrow across browsers. */
#room-dialog select {
 appearance:none;-webkit-appearance:none;
 padding-right:36px;
 background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23203952' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
 background-repeat:no-repeat;background-size:16px 16px;background-position:right 12px center;
}
#home #public-rooms {max-height:none;overflow:visible;scrollbar-gutter:auto;padding-right:0;}
#open-all-rooms {width:100%;margin-top:12px;}
#all-rooms-dialog {max-width:640px;}
#refresh-all-rooms {font-size:14px;color:#205f95;text-decoration:underline;white-space:nowrap;}
#all-public-rooms {font-size:14px;color:var(--color-text-muted);}
@media(max-width:420px){
 #room-dialog .room-fields {grid-template-columns:1fr;}
 #room-dialog .room-fields label {grid-column:1;}
}

.rank-title-row {display:flex;align-items:center;justify-content:space-between;gap:12px;}
.rank-title-row h2 {min-width:0;}
.rank-title-row .rank-help {flex:none;width:30px;height:30px;padding:0;border:1.5px solid var(--color-shadow);border-radius:50%;background:var(--color-surface-muted);color:#205f95;font-size:18px;font-weight:800;}
#home .rank-more {display:block;border-top:1px solid #e3ded5;padding-top:12px;}
.rank-preview-heading {display:flex;justify-content:space-between;align-items:center;gap:10px;font-size:14px;}
#home .rank-more .rank-view-more {border:0;padding:4px 0;background:none;color:#205f95;text-decoration:underline;font-size:13px;}
#rank-preview {list-style:none;padding:0;margin:6px 0 0;font-size:13px;color:var(--color-text-muted);line-height:1.6;}
#rank-preview li {display:flex;justify-content:space-between;gap:10px;padding:6px 0;}
#rank-preview li span {min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
#rank-preview li strong {flex:none;color:var(--color-action);font-variant-numeric:tabular-nums;}
@media(max-height:740px){
 #home .rank-more {padding-top:8px;}
 #rank-preview li {padding:2px 0;}
}
@media(max-width:760px) and (max-height:740px){
 #home .ranked-section:has(#rank-profile:not(.hidden)) .rank-title-row h2 {font-size:16px;}
 #home .ranked-section:has(#rank-profile:not(.hidden)) .rank-rating {margin:4px 0;padding:4px 10px;}
 #home .ranked-section:has(#rank-profile:not(.hidden)) #rank-record {font-size:11px;margin:4px 0;}
 #home .ranked-section #rank-message {font-size:11px;margin:4px 0;}
}

/* Fit the board into the space remaining after controls and status. */
#play {position:fixed;inset:0;height:100dvh;min-height:0;overflow:hidden;box-sizing:border-box;}
#play .board-wrap {min-width:0;min-height:0;position:relative;top:auto;left:auto;transform:none;width:100%;height:100%;container-type:size;}
#play #board {position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:min(100cqw,100cqh);height:min(100cqw,100cqh);}
@media(min-width:1001px){
 #play {grid-template-rows:48px minmax(0,1fr) auto;gap:16px 28px;padding:20px 28px;}
 #play .side-r {min-height:0;gap:12px;}
 #play .score-card {height:74px;padding:12px 18px;flex-shrink:0;}
 #play .turn-timer {padding:12px 16px;}
 #play .panel {padding:16px 18px;}
 #play .panel .msg,#play .panel .note {margin-top:6px;}
 #play .board-wrap {align-self:stretch;justify-self:stretch;}
}
@media(min-width:1001px) and (max-height:760px){
 #play {padding:12px 20px;gap:12px 24px;grid-template-columns:minmax(0,1fr) 260px;}
 #play .side-r {gap:10px;}
 #play .score-card {height:58px;padding:8px 14px;border-radius:16px;}
 #play .score-card .label {font-size:14px;}
 #play .score-card .clock {font-size:11px;margin-top:3px;}
 #play .score-card .num {font-size:28px;}
 #play .turn-timer {padding:8px 12px;gap:5px;}
 #play #timer-value {font-size:30px;}
 #play .total-clock {padding:0;font-size:12px;}
 #play .panel {padding:12px 16px;}
 #play .steps {font-size:20px;}
 #play .panel .msg {font-size:14px;}
 #play .panel .note {font-size:12px;}
}
@media(max-width:1000px){
 #play {display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:40px auto minmax(0,1fr) auto;gap:10px;padding:10px 14px 16px;align-items:stretch;}
 #play .topbar,#play .bottom-row {display:contents;}
 #play .corner {position:static;transform:none;}
 #play .corner.tl {grid-row:1;grid-column:1;gap:8px;}
 #play .corner.bl {grid-row:1;grid-column:2;justify-content:flex-end;}
 #play .round-btn {width:36px;height:36px;font-size:20px;border-radius:12px;}
 #play .pill-btn {height:36px;padding:0 12px;font-size:14px;}
 #play .side-r {position:static;transform:none;grid-row:2;grid-column:1 / -1;display:flex;flex-direction:row;flex-wrap:wrap;gap:8px;width:100%;align-items:stretch;}
 #play .turn-timer {padding:7px 10px;gap:5px;border-radius:14px;}
 #play #timer-player {font-size:13px;}
 #play #timer-caption {font-size:11px;margin-top:2px;}
 #play #timer-value,#play .turn-timer.idle #timer-value {font-size:24px;}
 #play .timer-track {height:3px;}
 #play .score-card,#play .score-card.active {height:54px;padding:7px 10px;border-radius:14px;flex:1;min-width:0;}
 #play .score-card.active {outline-width:2px;outline-offset:2px;}
 #play .score-card .label {font-size:12px;}
 #play .score-card .clock {font-size:10px;margin-top:3px;}
 #play .score-card .num {font-size:23px;}
 #play .total-clock {flex-basis:100%;font-size:11px;padding:0;margin:0;}
 #play .board-wrap {grid-row:3;grid-column:1 / -1;align-self:stretch;justify-self:stretch;}
 #play .panel {position:static;transform:none;grid-row:4;grid-column:1 / -1;width:100%;max-width:none;padding:10px 14px;border-radius:18px;}
 #play .steps {font-size:19px;}
 #play .panel .msg {font-size:13px;line-height:1.4;margin-top:4px;}
 #play .panel .note {font-size:11px;line-height:1.4;margin-top:4px;}
 #play .panel-actions {margin-top:6px;gap:6px;}
 #play .chip {padding:5px 10px;font-size:12px;}
 #play #network-status {font-size:10px;line-height:1.3;}
 #play #rank-match-result {padding:7px;font-size:12px;}
}

/* Keep the ranking link intrinsic-width and flush with the right edge. */
#home .rank-more .rank-view-more {flex:0 0 auto;margin-left:auto;text-align:right;}

/* Draw dialog close icons independently of font baselines and button padding. */
#close-room-dialog,.home-modal > header > button {
 position:relative;display:grid;place-items:center;padding:0;
 font-size:0;line-height:1;
}
#close-room-dialog::before,#close-room-dialog::after,
.home-modal > header > button::before,.home-modal > header > button::after {
 content:"";position:absolute;left:50%;top:50%;
 width:17px;height:3px;border-radius:2px;background:var(--color-action);
 transform:translate(-50%,-50%) rotate(45deg);
}
#close-room-dialog::after,.home-modal > header > button::after {
 transform:translate(-50%,-50%) rotate(-45deg);
}

/* Practice and local play use the same bold controls as ranked/friend rooms. */
#home[data-style="coral"] .computer-section,
#home[data-style="coral"] .local-section {overflow:visible;max-height:none;}
#home[data-style="coral"] .local-section {box-shadow:6px 6px 0 var(--color-shadow);}
#home .computer-section .seg {display:flex;gap:8px;background:none;padding:0;border-radius:0;}
#home .computer-section .seg button {
 flex:1;min-width:0;min-height:44px;padding:10px 6px;
 border:2px solid var(--color-action);border-radius:14px;background:var(--color-surface);color:var(--color-action);
 font-weight:800;box-shadow:none;
}
#home .computer-section .seg button[aria-pressed="true"] {
 background:var(--color-action);color:white;box-shadow:3px 3px 0 var(--color-action);
}
#home[data-style="coral"] .computer-section #ai-seat button[data-seat][aria-pressed="true"] {
 background:var(--seat);color:white;box-shadow:3px 3px 0 var(--color-action);
}
#home .computer-section .seg button:disabled {opacity:.45;box-shadow:none;cursor:default;}
#home .computer-section .opt-row>span {color:var(--color-action);font-weight:800;}
#home[data-style="coral"] .computer-section .ai-start {
 border:2px solid var(--color-action);border-radius:14px;box-shadow:3px 3px 0 var(--color-shadow);
 min-height:48px;margin-top:4px;
}
#home[data-style="coral"] .local-section .mode {
 border:2px solid var(--color-action);border-radius:18px;padding:20px;
 background:var(--color-surface) !important;color:var(--color-action);box-shadow:none;font-weight:800;
}
#home[data-style="coral"] .local-section .mode:focus-visible {background:var(--color-action) !important;color:white;}
#home[data-style="coral"] .local-section .mode small {color:inherit;opacity:.85;}
@media(max-height:800px){
 #home[data-style="coral"] .computer-section,#home[data-style="coral"] .local-section {padding:18px;}
 #home .computer-section .section-kicker,#home .local-section .section-kicker {display:none;}
 #home .computer-section .section-description,#home .local-section .section-description {font-size:13px;margin:10px 0 14px;}
 #home .computer-section .ai-card {gap:14px;}
 #home .computer-section .opt-row>span {font-size:13px;margin-bottom:6px;}
 #home .computer-section .seg button {min-height:40px;padding:8px 4px;font-size:13px;}
}
@media(max-width:760px) and (max-height:740px), (min-width:761px) and (max-height:650px){
 #home .computer-section .section-description,#home .computer-section .section-icon {display:none;}
 #home .computer-section .ai-card {gap:12px;margin-top:14px;}
 #home .computer-section .seg {gap:6px;}
}
@media(max-width:760px) and (max-height:600px){
 #home[data-style="coral"] .computer-section {padding:14px;}
 #home .computer-section .ai-card {gap:10px;margin-top:10px;}
 #home .computer-section .seg button {min-height:36px;font-size:12px;padding:7px 2px;border-radius:10px;}
 #home .computer-section .opt-row>span {font-size:12px;margin-bottom:4px;}
 #home[data-style="coral"] .computer-section .ai-start {min-height:42px;}
}
/* Give the game board and action card breathing room above the screen edge. */
@media(min-width:1001px){
 #play {padding-bottom:clamp(28px,5dvh,56px);}
}
@media(max-width:1000px){
 #play {padding-bottom:clamp(20px,3dvh,32px);}
}

/* Every mode occupies the same right-hand grid row. */
#home[data-style="coral"] .home-section {
 height:100%;max-height:none;align-self:stretch;box-sizing:border-box;
}
#home[data-style="coral"] .home-section:not(.hidden) {display:flex;flex-direction:column;}
#home .home-section > * {flex-shrink:0;}
#home .ranked-section .rank-more {margin-top:auto;}
#home .computer-section .ai-card {flex:1;}
#home[data-style="coral"] .computer-section .ai-start {margin-top:auto;}
#home .local-section .modes {margin-top:16px;}
#home .ranked-section #rank-preview {min-height:84px;}
@media(max-height:740px){
 #home .ranked-section #rank-preview {min-height:72px;}
}

/* Let the ranking preview use the spare height instead of leaving a blank gap. */
#home .ranked-section .rank-more {
 margin-top:18px;flex:1 1 auto;min-height:0;
 display:flex;flex-direction:column;
}
#home .ranked-section #rank-preview {
 flex:1;display:flex;flex-direction:column;justify-content:space-evenly;
 margin-top:10px;
}
#home .ranked-section #rank-preview li {
 flex:1;align-items:center;padding:8px 0;border-bottom:1px solid var(--color-surface-muted);
}
#home .ranked-section #rank-preview li:last-child {border-bottom:0;}
@media(max-height:740px){
 #home .ranked-section .rank-more {margin-top:10px;}
 #home .ranked-section #rank-preview {margin-top:6px;}
 #home .ranked-section #rank-preview li {padding:2px 0;}
}

#rank-preview li > .rank-medal,#rank-leaderboard li > .rank-medal {flex:0 0 28px;width:28px;overflow:visible;text-align:center;font-size:23px;line-height:1.2;}
#rank-preview li > .rank-player-name,#rank-leaderboard li > .rank-player-name {flex:1;min-width:0;}
#rank-leaderboard li {align-items:center;}
#home .local-section .local-explainer {flex:1 1 auto;min-height:0;margin-top:20px;border-top:1px solid #e3ded5;padding-top:14px;display:flex;flex-direction:column;gap:12px;}
.local-explainer svg {width:100%;flex:1;min-height:0;display:block;}
.local-howto {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;list-style:none;margin:0;padding:0;flex:none;}
.local-howto li {font-size:12px;line-height:1.6;}
.local-howto b {display:block;color:var(--color-action);margin-bottom:4px;font-size:13px;}
.local-howto span {color:var(--color-text-muted);}
@media(max-width:760px){
 #home .local-section .local-explainer {margin-top:14px;padding-top:10px;gap:8px;}
 .local-howto {gap:8px;}
 .local-howto li {font-size:11px;}
 .local-howto b {font-size:12px;}
}
@media(max-height:600px){
 #home[data-style="coral"] .local-section .mode {padding:12px;font-size:19px;}
 #home .local-section .local-explainer {margin-top:10px;padding-top:8px;gap:6px;}
 .local-howto b {font-size:11px;}
 .local-howto li {font-size:10px;}
}

#home .computer-section #ai-players button {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;}
#ai-players svg {display:block;width:100%;height:clamp(48px,12dvh,140px);pointer-events:none;}
@media(max-height:650px){
 #ai-players svg {height:48px;}
 #home .computer-section #ai-players button {gap:3px;padding-block:6px;}
}

#rank-refresh.rank-refresh-icon,#refresh-rooms.rank-refresh-icon,#refresh-all-rooms.rank-refresh-icon {width:36px;height:36px;flex:none;display:grid;place-items:center;padding:8px;border:1px solid var(--color-border);border-radius:50%;background:var(--color-surface-muted);color:#205f95;text-decoration:none;}
.rank-refresh-icon svg {width:20px;height:20px;display:block;}
#leaderboard-dialog[open] {display:flex;flex-direction:column;overflow:hidden;}
#leaderboard-dialog>header,#leaderboard-dialog>.public-heading {flex-shrink:0;}
#leaderboard-dialog #rank-leaderboard {min-height:0;overflow-y:auto;overscroll-behavior:contain;}

@media(min-width:761px){
 #home[data-style="coral"] .home-card {max-width:1240px;grid-template-columns:1fr 1.1fr;}
 #home[data-style="coral"] .home-intro {padding-top:32px;}
 #home[data-style="coral"] h1 {font-size:clamp(40px,4.6vw,68px);}
 #home[data-style="coral"] .home-art {max-width:min(400px,40dvh);margin:24px auto;}
 #home[data-style="coral"] .tagline {font-size:20px;}
}
@media(min-width:761px) and (max-height:700px){
 #home[data-style="coral"] .home-intro {padding-top:16px;}
 #home[data-style="coral"] h1 {font-size:48px;}
 #home[data-style="coral"] .home-art {max-width:34dvh;margin:16px auto;}
 #home[data-style="coral"] .tagline {font-size:17px;margin:18px 0;}
}

/* Shared header tokens across all four home modes. */
#home[data-style="coral"] .home-section {padding:24px;}
#home .home-section .section-kicker {display:none;}
#home .home-section .section-heading,
#home .home-section .online-heading,
#home .home-section .rank-title-row {display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:38px;margin:0;flex-shrink:0;}
#home[data-style="coral"] .home-section h2,
#home .ranked-section:has(#rank-profile:not(.hidden)) .rank-title-row h2 {font-size:24px;line-height:1.35;font-weight:900;letter-spacing:-.5px;margin:0;}
#home .home-section .section-icon,#home .home-section .lobby-symbol {display:grid;place-items:center;width:38px;height:38px;font-size:30px;line-height:1;flex:none;color:var(--color-action);}
#home .home-section .rank-help {width:32px;height:32px;margin:3px;}
#home .home-section .section-description {display:block;font-size:14px;line-height:1.6;margin:10px 0 18px;color:var(--color-text-muted);}
#home .home-section .rank-mode-nav,#home .local-section .modes {margin-top:0;}
#home .computer-section .ai-card {margin-top:0;}
@media(max-width:760px), (max-height:700px){
 #home[data-style="coral"] .home-section {padding:18px;}
 #home[data-style="coral"] .home-section h2,
 #home .ranked-section:has(#rank-profile:not(.hidden)) .rank-title-row h2 {font-size:21px;}
 #home .home-section .section-heading,#home .home-section .online-heading,#home .home-section .rank-title-row {min-height:34px;}
 #home .home-section .section-description {font-size:12px;margin:8px 0 14px;}
 #home .home-section .section-icon,#home .home-section .lobby-symbol {width:32px;height:32px;font-size:26px;}
 #home .home-section .rank-help {width:30px;height:30px;margin:1px;}
}
@media(max-width:760px) and (max-height:650px){
 #home[data-style="coral"] .home-section {padding:12px;}
 #home[data-style="coral"] .home-section h2,
 #home .ranked-section:has(#rank-profile:not(.hidden)) .rank-title-row h2 {font-size:18px;}
 #home .home-section .section-description {display:none;}
 #home .home-section .section-heading,#home .home-section .online-heading,#home .home-section .rank-title-row {margin-bottom:8px;min-height:30px;}
 #home .computer-section .ai-card {gap:9px;}
 #home .home-section .section-icon,#home .home-section .lobby-symbol {width:30px;height:30px;font-size:24px;}
}

/* Local game choices are whole clickable illustrated cards. */
#home .local-section .local-game-cards {
 flex:1;min-height:0;display:grid;grid-template-columns:1fr;
 grid-template-rows:repeat(2,minmax(0,1fr));gap:16px;margin-top:4px;
}
#home[data-style="coral"] .local-game-cards .mode {
 display:flex;align-items:center;justify-content:flex-start;gap:24px;
 min-height:0;padding:14px 20px;overflow:hidden;
}
.local-game-cards .mode svg {height:100%;max-height:190px;width:auto;max-width:48%;flex:0 1 auto;pointer-events:none;}
.local-game-label {display:flex;flex-direction:column;justify-content:center;gap:8px;min-width:0;}
.local-game-label strong {font-size:30px;}
#home .local-section .local-text-only {flex:none;margin-top:18px;padding-top:12px;}
@media(max-width:760px), (max-height:700px){
 #home .local-section .local-game-cards {gap:12px;}
 #home[data-style="coral"] .local-game-cards .mode {padding:10px 14px;gap:18px;}
 .local-game-label strong {font-size:24px;}
 #home .local-section .local-text-only {margin-top:12px;padding-top:10px;}
}
@media(max-height:600px){
 #home .local-section .local-game-cards {gap:10px;}
 #home[data-style="coral"] .local-game-cards .mode {padding:8px 12px;gap:14px;}
 .local-game-label strong {font-size:22px;}
 #home .local-section .local-text-only {margin-top:10px;padding-top:8px;}
}

/* Keep country flags distinct from names and retain scrolling without a visible track. */
#rank-preview li > .rank-country-flag,#rank-leaderboard li > .rank-country-flag {flex:0 0 34px;width:34px;overflow:visible;font-size:28px;line-height:1.2;text-align:center;}
#leaderboard-dialog #rank-leaderboard {scrollbar-width:none;}
#leaderboard-dialog #rank-leaderboard::-webkit-scrollbar {display:none;}

/* Player count cards: board on the left, large label on the right. */
#home .computer-section #ai-players button {flex-direction:row;gap:12px;padding:12px;}
#ai-players svg {flex:0 1 48%;width:48%;height:clamp(64px,14dvh,140px);min-width:0;}
#ai-players button > span {flex:1;font-size:clamp(23px,2.4vw,34px);font-weight:900;white-space:nowrap;}
@media(max-width:760px), (max-height:650px){
 #home .computer-section #ai-players button {gap:6px;padding:8px;}
 #ai-players svg {height:clamp(48px,10dvh,90px);}
 #ai-players button > span {font-size:24px;}
}
@media(max-width:380px){
 #home .computer-section #ai-players button {gap:3px;padding:6px;}
 #ai-players button > span {font-size:21px;}
}

/* Compact ranked facts replace the two explanatory paragraphs. */
#home .rank-quick-facts {display:flex;flex-wrap:wrap;gap:8px 18px;list-style:none;padding:0;margin:16px 0;color:var(--color-text-muted);font-size:13px;line-height:1.4;flex-shrink:0;}
.rank-quick-facts li {display:flex;align-items:center;gap:6px;}
.rank-quick-facts li[hidden] {display:none;}
.rank-quick-facts svg {width:18px;height:18px;fill:none;stroke:var(--color-action);stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:none;}
@media(max-height:700px), (max-width:760px){
 #home .rank-quick-facts {font-size:11px;gap:6px 12px;margin:10px 0;}
 .rank-quick-facts svg {width:16px;height:16px;}
}

.local-bot-seat {display:flex;gap:10px;border:0;padding:0;margin:20px 0 12px;min-width:0;}
.local-bot-seat legend {font-weight:800;margin-bottom:10px;}
.local-bot-seat label {flex:1;min-width:0;position:relative;cursor:pointer;}
.local-bot-seat input {position:absolute;opacity:0;width:1px;height:1px;}
.local-bot-seat span {display:block;text-align:center;border:2px solid var(--color-action);border-radius:14px;padding:12px 6px;font-weight:800;background:var(--color-surface);}
.local-bot-seat small {display:block;font-size:12px;margin-top:4px;}
.local-bot-seat input:checked + span {background:var(--color-action);color:var(--color-surface);box-shadow:3px 3px 0 var(--color-shadow);}
.local-bot-seat input:focus-visible + span {outline:3px solid var(--color-action);outline-offset:3px;}
#dlg-body .local-bot-note {font-size:13px;color:var(--color-text-muted);}

/* Neutral game-room palette: team colors remain exclusive to the players. */
#home[data-style="coral"] {--paper:#f5f1e9;--well:var(--color-surface-muted);--edge:var(--color-border);--accent:var(--color-action);background-image:radial-gradient(#d1cbc1 1px,transparent 1px);}
#home[data-style="coral"] h1 {color:var(--color-action);}
#home .home-mode-nav {background:#e9e4dc;border-color:var(--color-border);}
#home .home-mode-nav button[aria-pressed="true"] {background:var(--color-action);box-shadow:3px 3px 0 #122637;}
#home[data-style="coral"] .home-section {box-shadow:6px 6px 0 var(--color-shadow);}
#play,.overlay {--bg:#f5f1e9;--line:#d7d2ca;--neutral:var(--color-surface-muted);}
#play {background-image:radial-gradient(#d1cbc1 1px,transparent 1px);}
#play .round-btn {box-shadow:3px 3px 0 var(--color-shadow);}
#play #board {filter:drop-shadow(6px 8px 0 var(--color-shadow));}
.overlay .dialog {box-shadow:6px 6px 0 var(--color-shadow);}
.overlay .dialog .foot button.primary {background:var(--color-action);color:var(--color-surface);box-shadow:3px 3px 0 var(--color-shadow);}

/* The lobby preview stays in the home viewport; the full list lives in its dialog. */
#home[data-style="coral"] .online-section {overflow:hidden;display:flex;flex-direction:column;min-height:0;}
#home .online-section .lobby-body {flex:1;min-height:0;display:flex;flex-direction:column;}
#home .online-section .room-browser {flex:1;min-height:0;display:flex;flex-direction:column;}
#home .online-section #public-rooms {flex:1;min-height:0;overflow:hidden;}
#home .online-section #open-all-rooms {flex:none;}
@media(max-width:760px), (max-height:700px){
 #home .online-section .lobby-actions {margin-bottom:14px;}
 #home .online-section .public-heading {margin-bottom:6px;}
 #home .online-section .room-sort-note {font-size:11px;margin-bottom:4px;}
 #home .online-section #public-rooms {margin-top:6px;}
 #home .online-section .public-room {grid-template-columns:minmax(0,1fr) auto auto;gap:8px;padding:10px 0;}
 #home .online-section .room-emblem {display:none;}
 #home .online-section .room-occupancy {grid-column:auto;grid-row:auto;}
 #home .online-section .public-room button {grid-column:auto;grid-row:auto;padding:6px 8px;}
 #home .online-section .room-info strong {font-size:13px;}
 #home .online-section .room-info small {font-size:11px;}
 #home .online-section #open-all-rooms {margin-top:8px;padding:10px;}
}
@media(max-height:600px){
 #home .online-section .section-description {display:none;}
 #home .online-section .lobby-actions {margin:10px 0;}
 #home .online-section .lobby-actions button {padding:9px 6px;font-size:12px;}
 #home .online-section .public-room {padding:7px 0;}
}

/* Crisp paper selections: dark ink is an accent, not a large muted fill. */
#home[data-style="coral"] {--accent:var(--color-action);}
#home .home-mode-nav button[aria-pressed="true"] {background:var(--color-action);color:var(--color-surface);box-shadow:3px 3px 0 #122637;}
.rank-mode-nav button[aria-pressed="true"],
#home .computer-section .seg:not(#ai-seat) button[aria-pressed="true"] {background:var(--color-surface);color:var(--color-action);box-shadow:3px 3px 0 var(--color-action);}
.room-primary,.overlay .dialog .foot button.primary {background:var(--color-action);color:var(--color-surface);}
.local-bot-seat input:checked + span {background:var(--color-surface);color:var(--color-action);box-shadow:3px 3px 0 var(--color-action);}
#home[data-style="coral"] .local-section .mode:focus-visible {background:var(--color-surface-muted) !important;color:var(--color-action);}
.room-occupancy {display:flex;align-items:center;gap:5px;white-space:nowrap;}
.room-seat {display:block;width:14px;height:14px;border:1.5px solid #b5b0a7;border-radius:3px;background:var(--color-surface);}
.room-seat.occupied {background:var(--color-action);border-color:var(--color-action);}
#all-rooms-dialog>.public-heading {justify-content:flex-end;}
.public-room button:disabled {background:var(--color-surface-muted);border-color:var(--color-border);color:#77756f;}

#home .rank-entry-hint {font-size:12px;color:var(--color-text-muted);margin:4px 0 10px;line-height:1.5;}
#account-dialog .rank-entry-hint {font-size:14px;color:var(--color-text-muted);line-height:1.6;margin:0 0 18px;}
.rank-entry-hint[hidden] {display:none;}

#home[data-style="coral"] .local-section .mode:hover {filter:none;}

/* Separate entering ranked play from browsing the rankings. */
#home .ranked-section .rank-more > .rank-mode-nav {flex:none;margin:0 0 12px;}
#home .ranked-section .rank-more > .rank-mode-nav button {padding:12px;font-size:16px;}
#home .ranked-section .rank-more > .rank-mode-nav small {display:none;}
#home .ranked-section .rank-more > .rank-preview-heading {flex:none;}
@media(max-height:700px), (max-width:760px){
 #home .ranked-section .rank-more > .rank-mode-nav {margin-bottom:8px;}
 #home .ranked-section .rank-more > .rank-mode-nav button {padding:9px;font-size:14px;}
}

#home .ranked-section .rank-more.rank-columns {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px;}
.rank-column {min-width:0;min-height:0;display:flex;flex-direction:column;}
.rank-column + .rank-column {border-left:1px solid #e3ded5;padding-left:20px;}
.rank-preview-list {list-style:none;padding:0;margin:10px 0 0;flex:1;min-height:0;display:flex;flex-direction:column;}
.rank-preview-list li {display:grid;grid-template-columns:22px 26px minmax(0,1fr) auto;gap:6px;align-items:center;flex:1;min-height:30px;padding:6px 0;border-bottom:1px solid #e3ded5;font-size:12px;}
.rank-preview-list li:last-child {border:0;}
.rank-preview-list .rank-player-name {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.rank-preview-list .rank-medal {text-align:center;font-size:19px;}
.rank-preview-list .rank-country-flag {font-size:21px;}
.rank-preview-list strong {font-size:12px;white-space:nowrap;}
#home .rank-more .rank-more-icon {flex:none;width:30px;height:30px;padding:5px;border:1px solid var(--color-border);border-radius:50%;background:var(--color-surface);color:var(--color-action);}
.rank-more-icon svg {display:block;width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.rank-column .rank-preview-heading strong {font-size:15px;}
#leaderboard-dialog .rank-mode-nav {flex:none;margin:0 0 16px;}
.rank-change-label {flex:none;margin:0 0 8px;color:var(--color-text-muted);font-size:12px;text-align:right;}
#rank-leaderboard li .rank-change {flex:0 0 52px;text-align:right;font-size:12px;}
.rank-change.up {color:#29744c;}.rank-change.down {color:#b33934;}.rank-change.steady {color:#77756f;}
@media(max-width:760px){
 #home .ranked-section .rank-more.rank-columns {gap:10px;}
 .rank-column + .rank-column {padding-left:10px;}
 .rank-preview-list li {grid-template-columns:20px minmax(0,1fr);gap:2px 4px;position:relative;padding:5px 0;}
 .rank-preview-list .rank-country-flag {display:none;}
 .rank-preview-list strong {grid-column:2;font-size:11px;}
 .rank-column .rank-preview-heading strong {font-size:12px;}
 #home .rank-more .rank-more-icon {width:24px;height:24px;padding:4px;}
 #rank-leaderboard li {gap:6px;}
 #rank-leaderboard li .rank-change {flex-basis:36px;font-size:11px;}
}

.rank-demo-tag {display:block;font-size:10px;color:#77756f;font-weight:500;margin-top:3px;}
.rank-column .rank-preview-heading {min-height:38px;}
#home #rank-profile .rank-match-modes {margin:0 0 10px;}
#home #rank-profile .rank-match-modes button {padding:8px;font-size:13px;}

#home .ranked-section #open-rank-auth {margin-top:0;margin-bottom:8px;}
#home .ranked-section .section-description {margin-bottom:12px;}

/* Keep account details out of the fixed-height matchmaking panel. */
.home-topbar {grid-column:2;grid-row:1;display:flex;align-items:center;gap:12px;min-width:0;}
#home .home-topbar .home-mode-nav {flex:1;min-width:0;margin:0;}
.account-menu-button {display:flex;align-items:center;gap:8px;flex:none;padding:4px;border:0;background:transparent;color:var(--color-action);max-width:160px;}
.account-avatar {display:grid;place-items:center;flex:none;width:40px;height:40px;border:2px solid var(--color-action);border-radius:50%;background:var(--color-surface-muted);color:var(--color-action);font-size:20px;font-weight:800;overflow:hidden;}
.account-avatar img {width:100%;height:100%;object-fit:cover;}
.account-menu-name {max-width:78px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:700;}
.account-menu-arrow {font-size:18px;}
#home .ranked-section {overflow:hidden;}
#home #rank-profile {flex:none;}
#home #rank-profile:not(.hidden) {display:flex;gap:12px;align-items:center;}
#home #rank-profile .rank-match-modes {flex:1;margin:0;gap:8px;}
#home #rank-profile .rank-match-modes button {padding:12px 8px;white-space:nowrap;font-size:13px;}
#home #rank-profile #rank-queue,#home #rank-profile #rank-cancel {width:auto;flex:0 0 30%;padding:14px 8px;font-size:14px;}
#home .ranked-section .rank-more.rank-columns {overflow:hidden;}
#home .rank-column {overflow:hidden;}
#home .rank-preview-list li {min-height:0;}
#home .ranked-section #rank-message {flex:none;max-height:40px;overflow:auto;margin:6px 0 0;}
#profile-dialog {width:min(480px,calc(100% - 32px));}
.account-overview {display:flex;align-items:center;gap:20px;margin:20px 0;}
.account-avatar-large {width:80px;height:80px;font-size:36px;}
.account-overview h3 {margin:0 0 4px;font-size:22px;overflow-wrap:anywhere;}
.account-overview p {margin:0 0 10px;color:var(--color-text-muted);font-size:13px;}
.account-text-button {padding:0;background:none;color:var(--color-action);font-weight:700;text-decoration:underline;font-size:14px;}
.account-stats-tabs {display:flex;gap:10px;margin:20px 0 16px;}
.account-stats-tabs button {flex:1;border:2px solid var(--color-action);border-radius:12px;padding:10px;background:var(--color-surface);color:var(--color-action);font-weight:700;}
.account-stats-tabs button[aria-pressed="true"] {box-shadow:3px 3px 0 var(--color-action);}
.account-rating {display:flex;justify-content:space-between;align-items:center;padding:16px 0;border-bottom:1px solid #e3ded5;}
.account-rating strong {font-size:22px;}.account-rating b {font-size:32px;}
.account-stats {display:grid;grid-template-columns:repeat(5,1fr);gap:8px;text-align:center;margin:20px 0;}
.account-stats dt {font-size:13px;color:var(--color-text-muted);}.account-stats dd {margin:8px 0 0;font-size:24px;font-weight:800;}
#account-progress,#account-trio {color:var(--color-text-muted);font-size:13px;text-align:center;}
#account-trio:empty,#account-message:empty {display:none;}
#account-message {font-size:13px;color:#29744c;}#account-message.is-error {color:var(--color-danger);}
.account-footer {border-top:1px solid #e3ded5;padding-top:16px;margin-top:20px;text-align:right;}
#profile-dialog #rank-logout {font-size:14px;padding:8px 16px;border:1px solid var(--color-shadow);border-radius:10px;text-decoration:none;color:var(--color-action);}
@media(max-width:1100px){.account-menu-name,.account-menu-arrow {display:none;}.home-topbar {gap:8px;}}
@media(max-width:760px){
 .home-topbar {display:contents;}
 #home .account-menu-button {position:absolute;top:12px;right:16px;z-index:2;padding:0;}
 #home .account-avatar {width:34px;height:34px;font-size:17px;}
 #home #rank-profile:not(.hidden) {gap:8px;}
 #home #rank-profile .rank-match-modes button {padding:9px 4px;font-size:11px;}
 #home #rank-profile #rank-queue,#home #rank-profile #rank-cancel {padding:12px 5px;font-size:12px;}
 .account-stats {grid-template-columns:repeat(3,1fr);row-gap:16px;}
 .account-overview {gap:12px;}.account-overview h3 {font-size:20px;}
}

.wait-invite {display:flex;align-items:center;justify-content:space-between;gap:16px;margin:12px 0 24px;}
#room-wait #wait-code {font-size:38px;letter-spacing:6px;margin:0;}
#room-wait #room-copy {flex:none;padding:12px 16px;font-size:14px;}
#wait-members li {display:flex;align-items:center;gap:14px;}
.wait-country {font-size:28px;flex:none;}
.wait-player-name {min-width:0;flex:1;font-size:17px;font-weight:700;}
.wait-player-name small {display:block;font-size:12px;color:var(--color-text-muted);margin-top:4px;font-weight:500;}
.wait-player-score {flex:none;font-size:17px;white-space:nowrap;}
#wait-members .wait-empty {border:1px dashed var(--color-shadow);background:transparent;justify-content:center;color:#77756f;font-size:15px;min-height:64px;}
#room-wait .wait-actions {display:grid;grid-template-columns:1fr 1fr;gap:12px;}
#room-wait .wait-actions button {width:100%;}
@media(max-width:480px){
 #room-wait {margin:12px auto;padding:20px;width:100%;box-sizing:border-box;}
 #room-wait #wait-code {font-size:30px;letter-spacing:3px;}
 #room-wait #room-copy {padding:10px;font-size:12px;}
 #wait-members li {padding:12px;gap:8px;}
 .wait-player-name,.wait-player-score {font-size:14px;}
 .wait-country {font-size:24px;}
}

/* Player identity first; country is the trailing detail. */
.rank-avatar {display:grid;place-items:center;width:32px;height:32px;flex:none;border-radius:50%;overflow:hidden;background:var(--color-surface-muted);color:var(--color-text-muted);}
.rank-avatar img {width:100%;height:100%;object-fit:cover;}
.rank-avatar svg,.account-avatar svg {display:block;width:80%;height:80%;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.rank-preview-list li {grid-template-columns:22px 28px minmax(0,1fr) auto 24px;}
.rank-preview-list .rank-avatar {width:28px;height:28px;}
.rank-preview-list .rank-country-flag {display:block;text-align:right;font-size:21px;}
#rank-leaderboard li {display:grid;grid-template-columns:28px 36px minmax(0,1fr) auto 52px 34px;}
#rank-leaderboard li .rank-avatar {width:36px;height:36px;}
#rank-leaderboard li .rank-change {width:auto;}
@media(max-width:760px){
 .rank-preview-list li {grid-template-columns:18px 24px minmax(0,1fr) 20px;gap:3px;}
 .rank-preview-list .rank-avatar {width:24px;height:24px;}
 .rank-preview-list .rank-medal {grid-column:1;grid-row:1;font-size:17px;}
 .rank-preview-list .rank-avatar {grid-column:2;grid-row:1;}
 .rank-preview-list .rank-player-name {grid-column:3 / 5;grid-row:1;}
 .rank-preview-list strong {grid-column:2 / 4;grid-row:2;}
 .rank-preview-list .rank-country-flag {grid-column:4;grid-row:2;font-size:18px;}
 #rank-leaderboard li {grid-template-columns:22px 28px minmax(0,1fr) auto 30px 24px;gap:5px;font-size:12px;}
 #rank-leaderboard li .rank-avatar {width:28px;height:28px;}
 #rank-leaderboard li > .rank-country-flag {width:24px;font-size:22px;}
 #rank-leaderboard li > .rank-medal {width:22px;font-size:20px;}
 #rank-leaderboard li .rank-change {font-size:11px;}
}

/* A compact home preview; both modes remain available in the full dialog. */
@media(max-width:760px){
 #home .ranked-section .rank-more.rank-columns {grid-template-columns:minmax(0,1fr);gap:0;}
 #home .rank-column + .rank-column {display:none;}
 #home .rank-preview-list li {grid-template-columns:22px 28px minmax(0,1fr) auto 24px;gap:8px;flex:0 0 auto;min-height:44px;}
 #home .rank-preview-list li > * {grid-column:auto;grid-row:auto;}
 #home .rank-preview-list .rank-avatar {width:28px;height:28px;}
 #home .rank-preview-list .rank-player-name {font-size:13px;}
 #home .rank-preview-list strong {font-size:12px;}
}

/* Give the board priority on phones; keep contextual controls within reach. */
@media(max-width:1000px){
 #play {gap:8px;padding:8px 12px max(12px,env(safe-area-inset-bottom));grid-template-rows:36px auto minmax(0,1fr) auto;}
 #play .side-r {gap:6px;}
 #play .score-card,#play .score-card.active {height:46px;padding:5px 10px;}
 #play .panel {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:3px 10px;padding:8px 12px;border-radius:16px;text-align:left;}
 #play .steps {display:none;}
 #play .panel .msg {grid-column:1;grid-row:1;font-size:13px;line-height:1.35;margin:0;font-weight:700;}
 #play .panel .note {grid-column:1;grid-row:2;font-size:11px;line-height:1.35;margin:0;}
 #play .panel-actions {grid-column:2;grid-row:1 / 3;align-self:center;display:flex;flex-wrap:wrap;max-width:120px;gap:5px;margin:0;}
 #play .chip {min-height:40px;padding:6px 10px;font-size:12px;}
 #play .panel-actions:empty {display:none;}
}

/* Landscape uses the desktop arrangement even on phones and tablets. */
@media(max-width:1000px) and (orientation:landscape){
 #play {grid-template-columns:minmax(0,1fr) clamp(210px,32vw,280px);grid-template-rows:36px minmax(0,1fr) auto 36px;gap:8px 16px;padding:10px 16px;}
 #play .board-wrap {grid-column:1;grid-row:1 / 5;}
 #play .corner.tl {grid-column:2;grid-row:1;}
 #play .corner.bl {grid-column:2;grid-row:4;justify-content:flex-end;}
 #play .side-r {grid-column:2;grid-row:2;align-self:start;gap:6px;}
 #play .turn-timer {padding:6px 8px;}
 #play .score-card,#play .score-card.active {height:44px;padding:5px 7px;}
 #play .score-card .label {font-size:10px;}
 #play .score-card .clock {font-size:9px;}
 #play .score-card .num {font-size:20px;}
 #play .panel {grid-column:2;grid-row:3;gap:4px;padding:8px 10px;}
 #play .panel-actions {grid-column:1 / -1;grid-row:3;max-width:none;}
 #play .chip {min-height:36px;}
}

.language-toggle {border:0;background:transparent;color:var(--ink);font:inherit;padding:6px 8px;white-space:nowrap;}
.home-footer #home-rules {margin-left:auto;}
.home-footer {gap:12px;}
.language-dialog {width:min(380px,calc(100% - 32px));}
.language-options {display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:20px;}
.language-options button {padding:14px 8px;background:var(--surface);color:var(--ink);border:2px solid var(--ink);border-radius:12px;font-size:15px;}
.language-options button[aria-pressed="true"] {background:var(--ink);color:var(--surface);}
#play .language-game {font-size:20px;}
html:lang(en) .home-mode-nav button {font-size:clamp(11px,1.2vw,16px);}
@media(max-width:760px){
 .home-footer {gap:4px;flex-wrap:wrap;}
 #visitor-country {font-size:10px;}
 .language-toggle {font-size:11px;padding:4px;}
 html:lang(en) #home .home-mode-nav button {font-size:10px;padding-left:3px;padding-right:3px;}
 html:lang(en) #home #rank-profile .rank-match-modes button {font-size:10px;}
 html:lang(en) #home #rank-profile #rank-queue {font-size:11px;}
}

html:lang(en) .guide-content svg text {font-size:9px;}
html:lang(ko) .guide-content svg text {font-size:10px;}
@media(max-width:760px){
 html:lang(ko) #play .score-card .label {font-size:10px;}
 #home #rank-profile #rank-queue {overflow-wrap:normal;}
}

/* Eight alternating turns: each piece moves one cell, then places one wall. */
.home-art .demo-blue-piece {animation:demo-blue-piece 20s ease-in-out infinite;}
@keyframes demo-blue-piece {0%{transform:translate(0,0);opacity:1}2%{transform:translate(0px,0px)}5%{transform:translate(-36px,0px)}22%{transform:translate(-36px,0px)}25%{transform:translate(-36px,-36px)}94%{transform:translate(-36px,-36px);opacity:1}97%{transform:translate(-36px,-36px);opacity:0}98%{transform:translate(0,0);opacity:0}100%{transform:translate(0,0);opacity:1}}
.home-art .demo-red-piece {animation:demo-red-piece 20s ease-in-out infinite;}
@keyframes demo-red-piece {0%{transform:translate(0,0);opacity:1}12%{transform:translate(0px,0px)}15%{transform:translate(36px,0px)}32%{transform:translate(36px,0px)}35%{transform:translate(36px,36px)}94%{transform:translate(36px,36px);opacity:1}97%{transform:translate(36px,36px);opacity:0}98%{transform:translate(0,0);opacity:0}100%{transform:translate(0,0);opacity:1}}
.home-art .demo-blue-circle {animation:demo-blue-circle 20s ease-in-out infinite;}
@keyframes demo-blue-circle {0%{transform:translate(0,0);opacity:1}42%{transform:translate(0px,0px)}45%{transform:translate(0px,36px)}62%{transform:translate(0px,36px)}65%{transform:translate(36px,36px)}94%{transform:translate(36px,36px);opacity:1}97%{transform:translate(36px,36px);opacity:0}98%{transform:translate(0,0);opacity:0}100%{transform:translate(0,0);opacity:1}}
.home-art .demo-red-circle {animation:demo-red-circle 20s ease-in-out infinite;}
@keyframes demo-red-circle {0%{transform:translate(0,0);opacity:1}52%{transform:translate(0px,0px)}55%{transform:translate(0px,-36px)}72%{transform:translate(0px,-36px)}75%{transform:translate(-36px,-36px)}94%{transform:translate(-36px,-36px);opacity:1}97%{transform:translate(-36px,-36px);opacity:0}98%{transform:translate(0,0);opacity:0}100%{transform:translate(0,0);opacity:1}}
.home-art .demo-wall-0 {animation:demo-wall-0 20s ease-out infinite;}
@keyframes demo-wall-0 {0%,6%{stroke-dashoffset:36;opacity:0}6.1%{opacity:1}8%,94%{stroke-dashoffset:0;opacity:1}97%,100%{stroke-dashoffset:0;opacity:0}}
.home-art .demo-wall-1 {animation:demo-wall-1 20s ease-out infinite;}
@keyframes demo-wall-1 {0%,16%{stroke-dashoffset:36;opacity:0}16.1%{opacity:1}18%,94%{stroke-dashoffset:0;opacity:1}97%,100%{stroke-dashoffset:0;opacity:0}}
.home-art .demo-wall-2 {animation:demo-wall-2 20s ease-out infinite;}
@keyframes demo-wall-2 {0%,26%{stroke-dashoffset:36;opacity:0}26.1%{opacity:1}28%,94%{stroke-dashoffset:0;opacity:1}97%,100%{stroke-dashoffset:0;opacity:0}}
.home-art .demo-wall-3 {animation:demo-wall-3 20s ease-out infinite;}
@keyframes demo-wall-3 {0%,36%{stroke-dashoffset:36;opacity:0}36.1%{opacity:1}38%,94%{stroke-dashoffset:0;opacity:1}97%,100%{stroke-dashoffset:0;opacity:0}}
.home-art .demo-wall-4 {animation:demo-wall-4 20s ease-out infinite;}
@keyframes demo-wall-4 {0%,46%{stroke-dashoffset:36;opacity:0}46.1%{opacity:1}48%,94%{stroke-dashoffset:0;opacity:1}97%,100%{stroke-dashoffset:0;opacity:0}}
.home-art .demo-wall-5 {animation:demo-wall-5 20s ease-out infinite;}
@keyframes demo-wall-5 {0%,56%{stroke-dashoffset:36;opacity:0}56.1%{opacity:1}58%,94%{stroke-dashoffset:0;opacity:1}97%,100%{stroke-dashoffset:0;opacity:0}}
.home-art .demo-wall-6 {animation:demo-wall-6 20s ease-out infinite;}
@keyframes demo-wall-6 {0%,66%{stroke-dashoffset:36;opacity:0}66.1%{opacity:1}68%,94%{stroke-dashoffset:0;opacity:1}97%,100%{stroke-dashoffset:0;opacity:0}}
.home-art .demo-wall-7 {animation:demo-wall-7 20s ease-out infinite;}
@keyframes demo-wall-7 {0%,76%{stroke-dashoffset:36;opacity:0}76.1%{opacity:1}78%,94%{stroke-dashoffset:0;opacity:1}97%,100%{stroke-dashoffset:0;opacity:0}}
.home-art .demo-wall {stroke-dasharray:36;stroke-dashoffset:36;}
.home-art .demo-blue-territory {animation:demo-blue-claim 20s ease-in-out infinite;}
.home-art .demo-red-territory {animation:demo-red-claim 20s ease-in-out infinite;}
.home-art .demo-territory {opacity:0;}
.home-art[data-paused="true"] svg * {animation-play-state:paused;}
@keyframes demo-blue-claim {0%,68%,100%{opacity:0}71%,94%{opacity:.24}97%{opacity:0}}
@keyframes demo-red-claim {0%,78%,100%{opacity:0}81%,94%{opacity:.24}97%{opacity:0}}
@media(prefers-reduced-motion:reduce){
 .home-art svg * {animation:none!important;}
 .home-art .demo-blue-piece {transform:translate(-36px,-36px);}
 .home-art .demo-red-piece {transform:translate(36px,36px);}
 .home-art .demo-blue-circle {transform:translate(36px,36px);}
 .home-art .demo-red-circle {transform:translate(-36px,-36px);}
 .home-art .demo-wall {stroke-dashoffset:0;}
 .home-art .demo-territory {opacity:.24;}
}
/* Footer and practice options must fit inside their allocated grid rows. */
#home .home-footer {display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:8px;min-width:0;align-items:center;}
#home .home-footer #visitor-country {min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
#home .home-footer #home-rules {margin:0;white-space:nowrap;}
#home .computer-section .ai-card {min-height:0;display:grid;grid-template-rows:minmax(80px,1.4fr) minmax(65px,1fr) minmax(65px,1fr) auto;gap:20px;}
#home .computer-section .opt-row {min-height:0;display:flex;flex-direction:column;align-items:stretch;gap:0;}
#home .computer-section .opt-row > span {flex:none;margin-bottom:6px;}
#home .computer-section .seg {min-height:0;flex:1;gap:12px;}
#home .computer-section #ai-players svg {height:100%;max-height:76px;min-height:0;max-width:40%;}
#home[data-style="coral"] .computer-section .ai-start {margin:8px 0 0;padding:10px;min-height:46px;}
@media(max-height:700px){
 #home .computer-section .ai-card {grid-template-rows:minmax(60px,1.2fr) minmax(52px,1fr) minmax(52px,1fr) auto;gap:14px;}
 #home .computer-section #ai-players button {padding:6px;min-height:0;}
 #home .computer-section .opt-row > span {font-size:12px;margin-bottom:4px;}
 #home .computer-section .seg button {min-height:32px;padding:5px;}
 #home[data-style="coral"] .computer-section .ai-start {min-height:42px;margin-top:6px;padding:8px;}
}
@media(max-width:400px){#home .home-footer {gap:4px;}#home .home-footer #home-rules {font-size:11px;}.language-toggle {font-size:10px;}}

#wait-members .wait-avatar {width:44px;height:44px;background:var(--color-surface);border:1px solid #d7d2ca;}
@media(max-width:480px){#wait-members .wait-avatar {width:36px;height:36px;}}

#wait-members .wait-tier {flex:none;display:inline-flex;width:44px;height:48px;}
#wait-members .wait-tier svg {width:100%;height:100%;}
@media(max-width:480px){#wait-members .wait-tier {width:36px;height:40px;}}

/* Waiting room: players left, shared conversation right. */
#room-wait {max-width:1040px;display:grid;grid-template-columns:minmax(0,1.65fr) minmax(250px,1fr);gap:28px;}
#room-wait.hidden {display:none;}
.wait-main {min-width:0;}
.wait-chat {min-width:0;min-height:0;contain:size;display:flex;flex-direction:column;border-left:1px solid #d7d2ca;padding-left:24px;}
.wait-chat h3 {flex:none;font-size:20px;margin:0 0 16px;}
#wait-chat-log {height:0;min-height:0;flex:1;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-width:none;}
#wait-chat-log::-webkit-scrollbar {display:none;width:0;height:0;}
.chat-message {display:flex;align-items:flex-start;gap:8px;margin:0 0 18px;padding:0 2px;overflow-wrap:anywhere;}
.chat-message-own {flex-direction:row-reverse;}
.chat-avatar.rank-avatar {width:32px;height:32px;flex:none;}
.chat-content {min-width:0;max-width:calc(100% - 52px);display:flex;flex-direction:column;align-items:flex-start;gap:5px;}
.chat-message-own .chat-content {align-items:flex-end;}
.chat-message strong {font-size:12px;color:#526b7c;line-height:1.4;}
.chat-message p {margin:0;padding:10px 14px;border-radius:0 14px 14px 14px;background:#eeebe5;color:var(--color-action);font-size:15px;line-height:1.5;white-space:pre-wrap;max-width:100%;box-sizing:border-box;}
.chat-message-own p {background:var(--color-action);color:var(--color-surface);border-radius:14px 0 14px 14px;}
#wait-chat-form {display:flex;gap:8px;margin-top:16px;flex:none;}
#wait-chat-input {min-width:0;width:100%;flex:1;box-sizing:border-box;min-height:48px;border:1px solid var(--color-shadow);border-radius:12px;padding:10px;font:inherit;background:var(--color-surface);}
#wait-chat-form button {flex:none;padding:12px 14px;font-size:15px;min-height:48px;}
#wait-chat-error {font-size:13px;color:#b52c2c;margin:10px 0 0;}
#wait-chat-error:empty {display:none;}
.chat-input-label {position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden;}
@media(max-width:760px){
 #room-wait {grid-template-columns:1fr;}
 .wait-chat {contain:none;height:clamp(300px,50dvh,440px);border-left:0;border-top:1px solid #d7d2ca;padding:20px 0 0;}
 #wait-chat-log {height:0;flex:1;}
}

.wait-heading {display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:20px;}
#room-wait .wait-heading h2 {margin:0;}
#wait-visibility-control {display:flex;align-items:center;gap:8px;font-size:13px;cursor:pointer;white-space:nowrap;position:relative;}
#wait-visibility-control.hidden {display:none;}
#wait-visibility {position:absolute;opacity:0;width:100%;height:100%;cursor:pointer;}
.wait-switch {width:40px;height:24px;border-radius:20px;background:#b8b3aa;display:block;position:relative;flex:none;}
.wait-switch::after {content:'';position:absolute;left:3px;top:3px;width:18px;height:18px;border-radius:50%;background:var(--color-surface);}
#wait-visibility:checked+.wait-switch {background:var(--color-action);}
#wait-visibility:checked+.wait-switch::after {left:19px;}
#wait-visibility:focus-visible+.wait-switch {outline:2px solid var(--color-action);outline-offset:3px;}

.tier-legend {padding-bottom:18px;margin-bottom:24px;border-bottom:1px solid #e3ded5;}
#rank-rules-dialog h3 {font-size:18px;margin:0 0 12px;}
.tier-legend-hint {font-size:14px;color:#526b7c;line-height:1.6;margin:10px 0;}
.tier-legend-grid {list-style:none;padding:0;margin:20px 0;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;}
.tier-legend-grid li {display:flex;flex-direction:column;align-items:center;gap:8px;padding:18px 8px;background:#f4f1eb;border:1px solid #e3ded5;border-radius:16px;}
.tier-legend-badge {display:block;width:54px;height:58px;}
.tier-legend-badge svg {width:100%;height:100%;}
.tier-legend-grid strong {font-size:17px;}
.tier-legend-range {font-size:13px;color:#526b7c;white-space:nowrap;}
@media(max-width:480px){.tier-legend-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}.tier-legend-grid li{padding:14px 6px;}}

/* Keep native scrolling while hiding its visual rails on every surface. */
*,*::before,*::after {scrollbar-width:none;}
*::-webkit-scrollbar {display:none;width:0;height:0;}

.queue-placement {display:block;font-size:10px;line-height:1.4;font-weight:500;margin-top:3px;}
.placement-dots {display:flex;gap:8px;margin:18px 0 8px;flex-wrap:wrap;}
.placement-dots[hidden] {display:none;}
.placement-dots span {width:12px;height:12px;border-radius:50%;border:1px solid #b8b3aa;}
.placement-dots span.complete {background:var(--color-action);border-color:var(--color-action);}
.tier-unranked {display:flex;align-items:center;gap:14px;padding:14px 18px;margin-top:18px;border:1px dashed var(--color-shadow);border-radius:16px;}

/* Waiting rooms can exceed one viewport when chat stacks below the seats. */
#home[data-style="coral"]:has(#room-wait:not(.hidden)) {overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;}

#room-wait .wait-heading h2 {min-width:0;overflow-wrap:anywhere;}
#wait-visibility-status {flex:none;font-size:13px;color:#526b7c;white-space:nowrap;}
#wait-visibility-control {flex:none;}

/* Readiness is a toggle; transient notices do not occupy action-row space. */
#wait-message:empty {display:none;}
#wait-message {position:fixed;right:24px;bottom:24px;z-index:100;margin:0;padding:12px 18px;max-width:min(360px,calc(100vw - 48px));box-sizing:border-box;border:1px solid #d7d2ca;border-radius:12px;background:var(--color-surface);color:var(--color-action);box-shadow:4px 4px 0 var(--color-shadow);font-size:14px;}
#room-start.ready-toggle {display:flex;align-items:center;justify-content:center;gap:10px;}
.ready-mark {width:20px;height:20px;box-sizing:border-box;border:2px dashed currentColor;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;flex:none;font-size:15px;line-height:1;}
#room-start.ready-toggle.is-ready {background:var(--color-success-soft);color:var(--color-success);border:2px solid var(--color-success);box-shadow:none;}
.is-ready .ready-mark {border-style:solid;background:var(--color-success);color:white;border-color:var(--color-success);}

/* Center the waiting room when it fits; auto margins collapse for scrolling. */
#home[data-style="coral"]:has(#room-wait:not(.hidden)) {display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;padding-block:24px;}
#home[data-style="coral"] #room-wait:not(.hidden) {flex:none;width:100%;max-width:1108px;box-sizing:border-box;margin:auto;}

#wait-visibility-label svg,#wait-visibility-status svg {display:block;width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;}

/* Keep undo's footprint stable before and after selecting a piece. */
#play .chip.undo-action {width:auto;height:40px;min-height:40px;flex:none;padding:8px 10px;gap:6px;align-items:center;justify-content:center;white-space:nowrap;line-height:1;box-sizing:border-box;}
#play .undo-action svg {width:20px;height:20px;}
#play .undo-action:disabled {opacity:.4;cursor:default;}

/* The current action already names the phase; avoid duplicate instructions. */
#play .steps {display:none;}
#timer-caption,#play .panel .note:empty {display:none;}
@media(max-width:1000px){#play .panel {min-height:60px;box-sizing:border-box;align-content:center;}}

@media(max-width:1000px){#play .panel:has(.note:empty) .msg {grid-row:1 / 3;align-self:center;}#play .panel-actions:has(.undo-action) {max-width:none;}}

/* The turn countdown follows the board edge instead of taking a separate row. */
#play .turn-timer {display:none;}

/* Keep the timer and hourglass flat; only the physical board casts a shadow. */
#play #board {filter:none;}
#play #board .board-frame {filter:drop-shadow(6px 8px 0 var(--color-shadow));}

/* Conversation stays beside the board on desktop and opens as a sheet on phones. */
.chat-heading {display:flex;align-items:center;justify-content:space-between;gap:12px;flex:none;margin-bottom:16px;}
.chat-heading h3 {margin:0;}
#close-game-chat {display:none;background:none;border:0;color:var(--color-action);font-size:28px;width:36px;height:36px;}
#btn-chat {position:relative;}
#btn-chat.hidden,#game-chat-slot.hidden {display:none;}
.chat-unread {position:absolute;right:-4px;top:-5px;background:#c63e37;color:white;border:2px solid var(--color-surface);border-radius:50%;width:18px;height:18px;display:grid;place-items:center;font-size:12px;font-weight:900;line-height:1;}
.chat-unread[hidden] {display:none;}
#game-chat-slot {flex:1;min-height:0;display:flex;}
#game-chat-slot .wait-chat {height:100%;width:100%;padding:16px;border:2px solid var(--color-action);border-radius:20px;background:var(--color-surface);box-sizing:border-box;}
#game-chat-slot .chat-heading h3 {font-size:15px;}
#game-chat-slot #wait-chat-input {font-size:13px;min-height:40px;}
#game-chat-slot #wait-chat-form button {min-height:40px;padding:8px 10px;font-size:13px;}
#game-chat-dialog {width:min(460px,calc(100vw - 24px));max-width:none;height:min(560px,80dvh);max-height:calc(100dvh - 24px);padding:20px;border:1px solid #c5cdc8;border-radius:20px;background:var(--color-surface);color:var(--color-action);box-sizing:border-box;}
#game-chat-dialog::backdrop {background:#20395266;}
#game-chat-dialog .wait-chat {height:100%;contain:size;padding:0;border:0;}
#game-chat-dialog #close-game-chat {display:block;}
@media(min-width:1001px){#play.has-game-chat .side-r {height:100%;min-height:0;}}
@media(max-width:480px){#play .corner.tl {gap:5px;}#play .round-btn {width:32px;height:32px;border-radius:10px;}#play .pill-btn {padding:0 9px;}}

@media(max-width:1000px){#play #network-status {flex-basis:100%;}}

/* End-of-game actions share a row and a consistent touch target. */
#play .panel.game-finished {display:flex;flex-direction:column;align-items:stretch;gap:12px;}
#play .panel.game-finished .msg {margin:0;text-align:left;}
#play .panel.game-finished .panel-actions {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));max-width:none;width:100%;gap:10px;margin:0;}
#play .panel.game-finished .chip {display:flex;align-items:center;justify-content:center;gap:7px;min-width:0;min-height:44px;margin:0;padding:10px 6px;box-sizing:border-box;line-height:1.3;font-size:13px;}
#play .panel.game-finished .chip svg {width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}

#play .rematch-prompt {padding:0;}
#play .rematch-prompt p {margin:0;font-size:13px;line-height:1.5;}
#play .rematch-responses {display:grid;grid-template-columns:1fr 1fr;gap:10px;}
#play .panel.game-finished .panel-actions > button:only-child {grid-column:1 / -1;}
#play .player-room-status {display:block;font-size:12px;margin-top:4px;font-weight:500;}

/* Tablet landscape follows the same board/sidebar arrangement as desktop. */
@media(min-width:761px) and (max-width:1000px) and (orientation:landscape){
 #play {grid-template-columns:minmax(0,1fr) 260px;grid-template-rows:36px minmax(0,1fr) auto;gap:12px 20px;padding:12px 16px;}
 #play .corner.tl {grid-column:1;grid-row:1;}
 #play .corner.bl {grid-column:2;grid-row:1;}
 #play .board-wrap {grid-column:1;grid-row:2 / 4;}
 #play .side-r {grid-column:2;grid-row:2;flex-direction:column;flex-wrap:nowrap;height:100%;min-height:0;gap:10px;}
 #play .score-card,#play .score-card.active {flex:none;height:52px;padding:8px 12px;}
 #play .score-card .label {font-size:13px;}
 #play .score-card .num {font-size:26px;}
 #play .panel {grid-column:2;grid-row:3;}
 #game-chat-slot .wait-chat {padding:12px;}
 #game-chat-slot .chat-heading {margin-bottom:8px;}
}

#play .panel.game-finished {max-height:60dvh;overflow-y:auto;}

#wait-members li.can-remove {position:relative;overflow:visible;}
#room-wait .room-kick {position:absolute;top:0;right:0;transform:translate(35%,-35%);z-index:1;display:grid;place-items:center;width:28px;height:28px;padding:0;border:0;border-radius:50%;background:#f7d9d6;color:var(--color-danger);cursor:pointer;}
#room-wait .room-kick svg {width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;}
#room-wait .room-kick:hover {background:#f7d9d6;color:var(--color-danger);}
#room-wait .room-kick:focus-visible {outline:2px solid var(--color-danger);outline-offset:2px;}
#overlay[data-rematch] #dlg-foot {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}
#overlay[data-rematch] #dlg-foot button {white-space:nowrap;min-width:0;padding:12px 10px;}
#overlay[data-rematch] #dlg-foot button:last-child {grid-column:1 / -1;background:transparent;box-shadow:none;min-height:40px;}

/* A single notification surface across the lobby, waiting room and game. */
#app-notifications {position:fixed;inset:auto;top:max(16px,env(safe-area-inset-top));left:50%;transform:translateX(-50%);margin:0;padding:0;border:0;background:transparent;color:var(--color-surface);width:min(420px,calc(100vw - 32px));max-height:40dvh;overflow-y:auto;pointer-events:none;z-index:200;}
#app-notifications:popover-open {display:grid;gap:8px;}
.app-notification {display:flex;align-items:center;gap:12px;padding:12px 14px;background:var(--color-action);border:1px solid #fffdf944;border-radius:14px;box-shadow:0 4px 16px #20395222;pointer-events:auto;font-size:14px;line-height:1.5;overflow-wrap:anywhere;}
.app-notification span {flex:1;min-width:0;}
.app-notification button {flex:none;align-self:center;display:grid;place-items:center;line-height:1;box-sizing:border-box;width:28px;height:28px;padding:0;border:0;border-radius:50%;background:transparent;color:inherit;font-size:22px;cursor:pointer;}
.app-notification button:focus-visible {outline:2px solid white;}
#room-message,#wait-message,#rank-message {display:none;}

.app-notification button svg {display:block;width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2.5;stroke-linecap:round;}

/* A status-only action panel has no hidden step spacing or top text margin. */
#play .panel:not(.game-finished):has(.note:empty):has(.panel-actions:empty) {display:flex;align-items:center;min-height:60px;box-sizing:border-box;}
#play .panel:not(.game-finished):has(.note:empty):has(.panel-actions:empty) .msg {margin:0;align-self:center;}
