/* Muted scenic accents: visible state without yellow frames. */
:root{--ui-accent:#466e80;--ui-outline:#7698a6;--ui-soft:#e1ebee;--ui-soft-ink:#2d4b5b;--ui-action:#466879;--ui-action-ink:#fff;--ui-focus:#5f91a4;--ui-card-edge:#4c7c91;--ui-card-wash:#e8f0f3}
html[data-environment="kanazawa"]{--ui-accent:#a8bfd1;--ui-outline:#6f8ba5;--ui-soft:#2c4158;--ui-soft-ink:#edf4fa;--ui-action:#405c78;--ui-focus:#a8c5da}
html[data-environment="amaharashi"]{--ui-accent:#b2c5cf;--ui-outline:#829ba9;--ui-soft:#304653;--ui-soft-ink:#edf4f5;--ui-action:#4a6575;--ui-focus:#b4cdd7}
html[data-environment="shiude"]{--ui-accent:#c0c6db;--ui-outline:#929bb7;--ui-soft:#3a435b;--ui-soft-ink:#f0f1f7;--ui-action:#58647f;--ui-focus:#bdc7df}
/* Clear information hierarchy on the scenic table. */
.viewport-game .topbar{padding-inline:18px;gap:12px}.viewport-game .top-actions .button,.viewport-game .pause-button{font-size:12px;min-height:36px}
.viewport-stage .table-bottom{left:14px;right:auto;bottom:6px;transform:none;width:max-content;max-width:calc(100% - 28px);z-index:3;text-align:left;pointer-events:none}
html body .viewport-stage #turn-status{display:block;padding:0;border-radius:0;background:transparent;color:#304d5e;font-size:13px!important;line-height:20px!important;max-height:20px;overflow:hidden;text-overflow:ellipsis;text-shadow:0 1px 3px #fffefa;box-shadow:none;border:0;white-space:nowrap;font-weight:500}
html body .viewport-stage #turn-status.your-turn{background:transparent;color:#29495b;font-weight:650;box-shadow:none}
html:is([data-environment="kanazawa"],[data-environment="amaharashi"],[data-environment="shiude"]) body .viewport-stage #turn-status{color:#dce5ee;text-shadow:0 1px 3px #102033,0 0 5px #102033}
html:is([data-environment="kanazawa"],[data-environment="amaharashi"],[data-environment="shiude"]) body .viewport-stage #turn-status.your-turn{color:#f1f5f8}
html body .viewport-stage #turn-status:before{display:none}
.viewport-stage .seat-play-0{bottom:32px}.viewport-stage .seat-play-name{display:none}.viewport-stage .seat-play-caption{gap:8px;flex-wrap:wrap;padding:5px 9px;border-radius:8px;background:#142638df;color:#fff;text-shadow:none;width:fit-content;margin:0 auto 5px}
html body .viewport-stage .seat-play-caption :is(.seat-play-name,.seat-play-badge){color:#fff;background:transparent;text-shadow:none;font-size:13px;line-height:18px}
.viewport-stage .seat-play.lead .seat-play-caption{background:var(--ui-action);color:var(--ui-action-ink)}html body .viewport-stage .seat-play.lead .seat-play-caption :is(.seat-play-name,.seat-play-badge){color:var(--ui-action-ink)}
html body .viewport-stage .seat-play.lead .seat-play-badge{font-weight:400;font-size:12px;border-bottom:0;letter-spacing:normal}
.viewport-stage .seat-play.held{opacity:.85}.viewport-stage .seat-play.held .seat-play-caption{border:1px dashed #fff9}
html body .viewport-stage .seat-play-detail{font-size:12px;line-height:18px;color:#fff;text-shadow:0 1px 4px #000;background:#142638dd;border-radius:6px;padding:2px 6px;width:fit-content;margin:4px auto}
html body .viewport-stage .empty-trick{padding:10px 18px;border-radius:10px;background:#142638de;color:#fff;font-size:16px;text-shadow:none}
html body .viewport-stage .table .seat.is-turn{outline:1px solid var(--ui-outline);outline-offset:2px;border-color:transparent;box-shadow:none;border-radius:10px}
.viewport-stage .table .seat .seat-count{font-size:12px!important;line-height:18px}
@media(min-width:1100px) and (min-height:740px){
 body.viewport-game{grid-template-rows:52px minmax(0,1fr)}
 .viewport-game>.layout{max-width:1480px;margin:0 auto;padding:0 18px 8px}
 .viewport-stage{grid-template-rows:max-content minmax(0,1fr) min(47dvh,490px)}
 .viewport-stage .hand-panel{grid-template-rows:40px 42px minmax(0,1fr) 36px auto 48px 22px;gap:4px;padding:3px 12px 8px}
 .viewport-stage .hand-header{height:40px}.viewport-stage .my-seat h2 span{font-size:14px}.viewport-stage .my-seat .avatar{--seat-avatar-size:36px}
 .viewport-stage .table .seat{width:190px;height:50px;--seat-card-width:190px;--seat-card-height:50px;--seat-avatar-size:40px}
 .viewport-stage .seat-left,.viewport-stage .seat-right{top:35%}
 .viewport-stage .seat-play-3{top:34%;left:210px;width:calc(50% - 350px)}.viewport-stage .seat-play-1{top:34%;right:210px;width:calc(50% - 350px)}
 .viewport-stage .seat-play-2{top:64px;max-width:400px}.viewport-stage .seat-play-0{max-width:400px;bottom:32px}
 .viewport-stage .controls .button{height:44px;min-height:44px;font-size:14px;padding-inline:22px}
 .viewport-stage .selection-row p{font-size:13px;line-height:20px}
 .viewport-stage .feedback{font-size:12px;line-height:20px}
}
/* Every public card gets a column. Long plays overlap slightly within their
   owner's area, keeping all ranks visible on one row. */
@media(min-width:901px) and (min-height:521px){
 .viewport-stage .seat-play-cards{grid-auto-flow:column;grid-template-columns:repeat(calc(var(--pile-total) - 1),minmax(0,47px)) 44px;width:calc(var(--pile-total)*47px - 3px);max-width:100%}
 .viewport-stage .seat-play-cards[data-count="1"]{width:44px}
 .viewport-stage .seat-play-cards .card{width:44px;min-width:44px;height:64px;min-height:64px;--face-rank:16px;--face-suit:12px}
 .viewport-stage .seat-play-cards .card .card-suit{top:20px}
 .viewport-stage .seat-play-cards .card .wild-tag{top:35px;font-size:6px}
}
/* Distinguish action availability in every theme, without relying on color alone. */
html body .viewport-stage .controls button:disabled,html body #join:disabled{opacity:1;background:#283442;color:#9ca9b8;border:1px dashed #85909c;box-shadow:none;cursor:not-allowed;filter:none}
.viewport-stage .controls button:disabled::after{content:' · 暂不可用';font-size:10px;font-weight:400}
html body .viewport-stage .controls .primary:not(:disabled){background:var(--ui-action);border-color:var(--ui-outline);color:var(--ui-action-ink);box-shadow:0 3px 8px #0003}
.viewport-stage .selection-row{height:auto;min-height:28px;align-self:center}.viewport-stage .selection-row .text-button{border:1px solid var(--line);border-radius:7px;padding:4px 10px;min-height:30px;font-size:12px;background:var(--surface);color:var(--ink)}
html body .viewport-stage .hand .card.selected{outline:2px solid var(--ui-card-edge)!important;outline-offset:-3px;background:linear-gradient(130deg,#f8fbfc,var(--ui-card-wash))!important;box-shadow:inset 0 0 0 1px #f8fbfc!important;translate:0 -4px}
.viewport-stage .hand .card.selected::after{content:'✓';position:absolute;right:2px;top:2px;width:14px;height:14px;line-height:14px;border-radius:50%;background:var(--ui-card-edge);color:#fff;font-size:11px;text-align:center;pointer-events:none}
html body :is(button,a,input,select,summary,[tabindex]):focus-visible{outline:2px solid var(--ui-focus)!important;outline-offset:3px!important;box-shadow:0 0 0 4px #12283d66!important}
.skip-link{z-index:1000}.skip-link:focus{position:fixed;top:8px;left:8px;width:auto;height:auto;clip:auto;padding:12px 18px;background:#152738;color:white}
html body button:not(.card):not(:disabled):hover,html body .mode-options a:hover{filter:brightness(1.16);box-shadow:0 2px 8px #0004}
html body button:not(.card):not(:disabled):active{translate:0 1px;filter:brightness(.94)}
@media(prefers-reduced-motion:reduce){html body button{transition:none}}
/* Every organizing action stays directly on the toolbar. */
.viewport-stage .inline-hand-tools{gap:8px;overflow-x:auto;overflow-y:hidden;position:relative;padding-block:2px}
.viewport-stage .inline-hand-tools button:focus-visible{outline-offset:-3px!important}
.viewport-stage .inline-hand-tools :is(.sort-button,.organize-button,.text-button){font-size:12px;padding-inline:12px;height:34px;min-height:34px}
/* Dialog height follows the active content; footer occupies its own layout space. */
.table-menu:has(.menu-pages)[open]{height:auto;max-height:calc(100dvh - 32px);width:min(720px,calc(100vw - 24px));gap:0;overflow:hidden}
.table-menu .menu-page-content{flex:0 1 auto;min-height:0;max-height:calc(100dvh - 260px);overflow-y:auto;overflow-x:hidden;padding:4px 16px 24px 4px;scrollbar-width:auto;scrollbar-gutter:stable}
.menu-page-content>section{min-height:0}.table-menu #menu-resume{position:static!important;inset:auto;transform:none;flex:0 0 auto;width:100%;margin:12px 0 0}
.table-menu .menu-version{font-size:12px;color:var(--muted);opacity:1}.menu-page-content .history{max-height:none;height:auto;overflow:visible}
.menu-page-content .history li{display:grid;grid-template-columns:88px minmax(0,1fr);gap:6px 12px;padding:12px 4px;font-size:13px;line-height:1.6}
.history-meta{grid-column:1/-1;font-size:11px;color:var(--muted)}.history-action small{display:block;line-height:1.7}
.menu-page-content .tools-disclosure{margin-bottom:12px}.keyboard-grid{display:grid;grid-template-columns:90px 1fr;gap:8px 12px;font-size:13px;line-height:1.5}.keyboard-grid dt{font-weight:700}.keyboard-grid dd{margin:0}.count-help{line-height:1.8;font-size:13px}
.table-menu .scene-options{grid-template-columns:repeat(2,minmax(0,1fr))}.table-menu .scene-preview{aspect-ratio:2/1}.table-menu .presentation-settings>label{margin-block:14px}
.audio-setting-row label{flex-wrap:wrap}.audio-setting-row output{min-width:3.5em;font-variant-numeric:tabular-nums;font-weight:650;color:var(--ink)}
.table-audio-settings>.audio-setting-actions:first-of-type{margin:8px 0 16px}.audio-setting-row input[type=range]{width:140px}.table-audio-settings p{font-size:12px}
/* Restore without a misleading running table behind the dialog. */
body:has(#resume-dialog[open])>.layout{visibility:hidden}body:has(#resume-dialog[open])>.topbar{visibility:hidden}
.resume-dialog{width:min(480px,calc(100vw - 28px));padding:30px}.resume-dialog #resume-continue{min-width:180px;font-size:16px;padding:14px 24px}.resume-dialog .dialog-actions{display:flex;flex-direction:column-reverse;align-items:stretch;gap:10px}
.resume-dialog #resume-new-game{border-color:var(--line);background:transparent;font-size:13px}.resume-dialog #resume-clear{margin-top:24px;width:100%;border:1px solid #bd7f78;color:#f3b7aa;background:#652b2922;font-size:12px;min-height:36px}.resume-dialog .input-note{font-size:12px;line-height:1.7}
/* A desktop welcome with clear next actions and an unobscured scenic area. */
.start-shell{max-width:1240px;width:100%;padding:36px 32px;margin:auto}
html .start-shell .start-hero{min-height:420px;padding:70px 44px 32px;background-position:center 42%;position:relative;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-end;isolation:isolate;overflow:hidden}
.start-hero::before{content:'';position:absolute;inset:0;background:linear-gradient(90deg,#101f32e6 0%,#101f3299 40%,#101f3200 75%);z-index:-1}
.start-hero h1{font-size:42px;line-height:1.25;margin:14px 0}.start-hero>p{font-size:16px;margin:0}.start-hero .mode-options{width:min(680px,100%);margin-top:26px;grid-template-columns:1.1fr 1fr;gap:12px}
.start-hero .mode-options a{padding:18px;border-radius:12px;background:#1b2e43f5;color:#fff}.start-hero .mode-options a strong{font-size:18px;color:inherit}
.start-hero .mode-options a.start-primary{background:var(--ui-action);color:var(--ui-action-ink);border-color:var(--ui-outline)}.start-hero .mode-options span{font-size:12px;line-height:1.5}
.start-shell .presentation-settings{padding:24px}.start-shell .presentation-settings h2{font-size:22px}.start-sound{padding:18px 24px;margin-top:20px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}.start-sound summary{cursor:pointer}
/* The friends lobby shares the selected scene; room access remains invitation-based. */
body:has(#welcome):not(.viewport-game){min-height:100dvh;background-image:linear-gradient(#101c2ea6,#101c2ed9),var(--shonan-scene);background-size:cover;background-attachment:fixed;background-position:center}
html[data-environment=kanazawa] body:has(#welcome):not(.viewport-game){background-image:linear-gradient(#101c2e80,#101c2ed9),var(--kanazawa-scene)}
html[data-environment=amaharashi] body:has(#welcome):not(.viewport-game){background-image:linear-gradient(#101c2e60,#101c2ed9),url('/assets/scenes/amaharashi-blue-hour-landscape-v2.webp')} 
html[data-environment=shiude] body:has(#welcome):not(.viewport-game){background-image:linear-gradient(#101c2e60,#101c2ed9),url('/assets/scenes/shiude-sakura-dawn-landscape.webp')} 
html body .online-lobby{max-width:960px;margin:48px auto 14px;padding:36px!important;border-radius:20px;background:var(--surface);border:1px solid var(--line);box-shadow:0 12px 40px #0005}
.online-lobby h2{font-size:30px}.online-lobby .lobby-help{padding:14px;border-radius:10px;background:var(--surface-deep);font-size:13px;line-height:1.8}.online-lobby .online-join{gap:12px;padding:18px 0}.online-lobby #code{letter-spacing:2px;text-transform:uppercase}
body:has(#welcome):not(.viewport-game)>.footer{max-width:960px;margin:0 auto;padding:12px 24px;text-align:left;background:transparent;border:0;color:#e6edf5}
@media(max-width:700px){.start-shell{padding:20px 14px}html .start-shell .start-hero{min-height:390px;padding:100px 20px 24px}.start-hero h1{font-size:30px}.start-hero .mode-options{grid-template-columns:1fr}.start-hero::before{background:linear-gradient(0deg,#101f32ed,#101f3244)}.start-shell .presentation-settings{padding:16px}.online-lobby{margin-inline:14px!important;padding:20px!important}.viewport-stage .inline-hand-tools{gap:5px}.viewport-stage .inline-hand-tools :is(.sort-button,.organize-button){padding-inline:7px;font-size:11px}.viewport-stage .controls button:disabled::after{content:''}.audio-setting-row{flex-wrap:wrap}.table-menu .menu-page-content{max-height:calc(100dvh - 225px)}html body .viewport-stage #turn-status{font-size:12px!important;line-height:18px!important;padding:0}}
@media(max-height:520px) and (orientation:landscape){html body .viewport-stage #turn-status{font-size:11px!important;line-height:14px!important;padding:0}.viewport-stage .table-bottom{bottom:0;left:8px;transform:none;max-width:29%;text-align:left}.viewport-stage .seat-play-0{bottom:0}.viewport-stage .seat-play-caption{padding:1px 4px;margin:0;gap:3px}.viewport-stage .seat-play-caption :is(.seat-play-name,.seat-play-badge){font-size:9px!important;line-height:12px!important}.viewport-stage .inline-hand-tools{gap:5px}.viewport-stage .inline-hand-tools :is(.sort-button,.organize-button,.text-button){height:25px;min-height:25px;padding:2px 6px;font-size:10px}.table-menu .menu-page-content{max-height:calc(100dvh - 210px)}}
@media(min-width:1100px) and (min-height:740px){.viewport-stage .seat-play-3,.viewport-stage .seat-play-1{width:calc(50% - 230px)}}
.menu-page-content .history li:not(:has(.history-player)){display:block;line-height:1.8}
@media(min-height:521px) and (max-width:1099px){.viewport-stage .hand-panel{grid-template-rows:40px 38px minmax(0,1fr) minmax(32px,auto) auto 44px minmax(18px,auto)}}
@media(min-width:1100px) and (min-height:740px){.viewport-stage .hand-panel{grid-template-rows:40px 42px minmax(0,1fr) minmax(36px,auto) auto 48px 22px}}

/* Share one toolbar row to give stacked desktop cards their own clear height. */
@media(min-width:901px) and (min-height:521px){
 .viewport-stage .hand-panel{grid-template-columns:116px minmax(0,1fr);grid-template-rows:40px minmax(0,1fr) minmax(32px,auto) auto 44px 18px;gap:4px 12px;padding:4px 12px}
 .viewport-stage .hand-header{grid-column:1;grid-row:1;height:40px}
 .viewport-stage .hand-panel:has(.organize-entry button:not([hidden])){grid-template-columns:220px minmax(0,1fr)}
 .viewport-stage .inline-hand-tools{grid-column:2;grid-row:1;margin:0}
 .viewport-stage .hand{grid-column:1/-1;grid-row:2}
 .viewport-stage .selection-row{grid-column:1/-1;grid-row:3}
 .viewport-stage .interpretations{grid-column:1/-1;grid-row:4}
 .viewport-stage .controls,.viewport-stage .online-exchange{grid-column:1/-1;grid-row:5}
 .viewport-stage .feedback{grid-column:1/-1;grid-row:6;line-height:18px}
}
@media(min-width:1100px) and (min-height:740px){
 .viewport-stage{grid-template-rows:max-content minmax(0,1fr) min(52dvh,calc(100dvh - 392px),560px)}
}

/* Menus and settings use the same quiet accent as the selected scene. */
html[data-environment] body :is(.dialog,.start-shell) .button.primary:not(:disabled){background:var(--ui-action);color:var(--ui-action-ink);border-color:var(--ui-outline);box-shadow:none}
html[data-environment] body .scene-options button[aria-pressed=true]{border-color:var(--ui-outline);box-shadow:none}
html[data-environment] body .menu-pages button[aria-pressed=true]{background:var(--ui-soft);color:var(--ui-soft-ink);border-color:var(--ui-outline)}
html[data-environment] body .avatar-options button[aria-pressed=true]{background:var(--ui-soft);color:var(--ui-soft-ink);border-color:var(--ui-outline);outline:1px solid var(--ui-outline);box-shadow:none}
html[data-environment] body :is(.sort-button.active,.pause-button[aria-pressed=true],.allocation-choice[aria-pressed=true]){background:var(--ui-soft);color:var(--ui-soft-ink);border-color:var(--ui-outline);box-shadow:none}
html[data-environment] body :is(.dialog,.start-shell) :is(input[type=range],input[type=checkbox]){accent-color:var(--ui-accent)}
.viewport-stage .inline-hand-tools>#group-cards:not(:disabled){background:var(--ui-soft);color:var(--ui-soft-ink);border:1px solid var(--ui-outline)}
.round-review-settings{padding:12px 0;font-size:13px;line-height:1.7}.round-review-settings>label{display:flex;align-items:center;gap:6px}.round-review-settings p{margin:6px 0;color:var(--muted)}
@media(max-width:700px){.viewport-stage .inline-hand-tools{gap:4px}.viewport-stage .inline-hand-tools>#reset-hand{font-size:10px;padding-inline:5px}}
