/* Lobby uses the available width; only detail dialogs scroll. */
body { --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px); --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); }
body.touch-table { --safe-side: max(var(--safe-left), var(--safe-right)); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.touch-table input, body.touch-table textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
/* Small editable text triggers Safari's focus zoom even without a zoom gesture. */
body.touch-table .online-room input, body.touch-table #settings select { font-size: 16px; }
body.touch-table, body.touch-table * { touch-action: pan-x pan-y !important; }
body.touch-table #game { touch-action: none !important; }
body.portrait-blocked > :not(#orientation-tip):not(script) { visibility: hidden !important; }
#orientation-tip { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; background: #170f12; }
#orientation-tip::backdrop { background: #170f12; }
#start-screen { padding: 16px; overflow-y: auto; align-items: safe center; }
#start-screen .start-card { width: min(980px, 100%); padding: 24px; max-height: none; overflow: visible; display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px 24px; }
.start-card::before, .start-card::after { display: none; }
.start-heading, .start-footer { grid-column: 1 / -1; }
.start-heading { position: relative; display: grid; grid-template-columns: 1fr auto; text-align: left; gap: 5px 24px; align-items: center; }
.start-heading .ceremony-mon { display: none; }
.start-heading .eyebrow, .start-heading h1, .start-heading .start-copy { grid-column: 1; margin: 0; }
.start-heading h1 { font-size: 38px; }
.start-heading .eyebrow { font-size: 11px; }
.start-heading .start-copy { font-size: 13px; }
.start-heading #lobby-audio { grid-column: 2; grid-row: 3; margin: 0; min-height: 36px; font-size: 13px; }
.lobby-guide-cards { grid-column: 2; grid-row: 1 / 3; display: flex; gap: 12px; justify-content: center; }
.lobby-guide-cards button { width: 64px; min-height: 86px; padding: 7px 4px; border: 3px double #c5a36a; border-radius: 7px; background: linear-gradient(145deg, #713345, #30171f); box-shadow: 0 3px 6px #0005; }
.lobby-guide-cards #moon-guide { background: linear-gradient(145deg, #36584e, #142d2a); }
.lobby-guide-cards button > span { display: block; font: 34px HanamiText, serif; line-height: 1.2; }
.lobby-guide-cards small { display: block; font-size: 10px; letter-spacing: .05em; margin-top: 5px; }
.lobby-guide-cards button:focus-visible { outline: 2px solid #fff0b3; outline-offset: 3px; }
.start-heading #lobby-seating { grid-column: 1 / -1; margin: 10px 0 0; padding: 12px 0 0; border-top: 1px solid #b492563d; color: #c9b18a; font-size: 16px; letter-spacing: .08em; }
.start-card .online-room { margin: 0; padding: 14px; display: flex; flex-direction: column; }
.lobby-intro { margin-top: auto; padding: 20px 4px 4px; text-align: left; }
.ceremony .lobby-intro h2 { margin: 0 0 9px; color: #e7c891; font-size: 20px; letter-spacing: .08em; text-shadow: none; }
.lobby-intro p { margin: 0; color: #c5b092; font-size: 14px; line-height: 1.9; }
.lobby-version { margin-top: 18px; padding-top: 14px; border-top: 1px solid #ad8d5045; }
.lobby-version > span { display: inline-block; margin-bottom: 8px; color: #ecd298; font: 600 12px HanamiText, serif; letter-spacing: .1em; }
.lobby-version p { font-size: 12px; color: #ab987f; line-height: 1.8; }
.start-card .room-actions button, .start-card .join-room button { min-height: 42px; padding: 6px; font-size: 17px; }
.start-card #room-status { min-height: 32px; line-height: 1.5; font-size: 12px; overflow-wrap: anywhere; }
.start-card #match-rules { margin: 0; min-width: 0; display: grid; grid-template-columns: 1fr 1fr; align-content: center; gap: 8px 10px; padding: 12px 16px; }
.start-card #match-rules label { min-height: 32px; font-size: 15px; letter-spacing: 0; }
.start-card #match-rules input { flex: none; margin: 0 3px 0 0; width: 18px; height: 18px; }
.start-card #match-rules small { grid-column: 1 / -1; margin-top: 6px; font-size: 12px; }
#lobby-rule-help { padding: 4px 0; min-height: 32px; background: none; border: 0; box-shadow: none; color: #efd598; font-size: 13px; text-decoration: underline; }
#self-collection-toggle { display: none; }
/* Major declarations cover the table controls; settings remain a reachable escape route. */
body.ceremonial-effect #game { position: relative; z-index: 8; }
body.ceremonial-effect #actions { visibility: hidden; }
/* Equal desktop rails frame the central play area; seat controls sit inside each nameplate. */
body.desktop-table #status { top: 12px; width: min(220px, var(--desktop-center-width)); max-width: none; min-height: 48px; padding: 8px 18px; display: flex; align-items: center; justify-content: center; font-size: clamp(20px, 1.6vw, 24px); font-weight: 600; line-height: 1.25; letter-spacing: .12em; color: #fff2d0; background: #973e46; border: 3px double #e6c58a; border-radius: 8px; box-shadow: 0 3px 10px #64232b35; }
body.desktop-table #status.status-error { width: min(720px, var(--desktop-center-width)); font-size: 16px; letter-spacing: .035em; border-color: #cb8582; }
#status.status-own-turn, body.desktop-table #status.status-own-turn { background: #356451; box-shadow: 0 3px 10px #153d3035; }
body.desktop-table #round-counter { left: var(--desktop-margin); top: 12px; width: var(--desktop-rail-width); height: 48px; display: grid; place-items: center; padding: 0 12px; font-size: 24px; }
body.desktop-table #settings:not([open]) { right: var(--desktop-margin); top: 12px; }
body.desktop-table #settings:not([open]) > summary { width: calc((var(--desktop-rail-width) - 12px) * .4); height: 48px; font-size: clamp(16px, 1.3vw, 20px); }
body.desktop-table #rules-toggle { top: 12px; right: calc(var(--desktop-margin) + (var(--desktop-rail-width) - 12px) * .4 + 12px); width: calc((var(--desktop-rail-width) - 12px) * .6); height: 48px; font-size: clamp(16px, 1.3vw, 20px); }
body.desktop-table:not(.pre-game) #actions.decision-stage:not(.counter-stage), body.desktop-table:not(.pre-game) #actions.flower-stage { top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(660px, var(--desktop-center-width)); }
body.desktop-table:not(.pre-game) #actions.flower-stage { width: min(440px, var(--desktop-center-width)); }
body.desktop-table .seat-voice-toggle { width: calc(24px * var(--desktop-seat-scale)); min-width: 24px; height: calc(64px * var(--desktop-seat-scale)); padding: 4px 2px; font-size: calc(14px * var(--desktop-seat-scale)); background: transparent; border: 0; border-radius: 3px; box-shadow: none; }
body.desktop-table .seat-voice-toggle[aria-pressed="true"] { color: #ffe6b1; background: #873044; box-shadow: inset 0 0 0 1px #b58d5688; }
body.desktop-table .seat-voice-toggle:focus-visible { outline: 2px solid #f3cb7f; outline-offset: 2px; }
body.desktop-table #seat-mute-self { right: var(--desktop-seat-toggle-x); top: calc(var(--desktop-self-y) - 32px * var(--desktop-seat-scale)); }
body.desktop-table #seat-mute-opponent { left: var(--desktop-seat-toggle-x); top: calc(var(--desktop-opponent-y) - 32px * var(--desktop-seat-scale)); }
body.desktop-table #table-picker { display: none; }
/* The canvas uses the same 1440 × 768 table on landscape phones; HUD coordinates follow its scale. */
body.phone-landscape #round-counter, body.phone-landscape #status, body.phone-landscape #rules-toggle, body.phone-landscape #settings:not([open]) { top: calc(var(--table-top) + 12px * var(--table-scale)); }
body.phone-landscape #round-counter { height: calc(48px * var(--table-scale)); font-size: calc(24px * var(--table-scale)); padding: 0 4px; border-width: 2px; }
body.phone-landscape #status { width: calc(220px * var(--table-scale)); min-height: calc(48px * var(--table-scale)); padding: calc(8px * var(--table-scale)) 6px; font-size: calc(24px * var(--table-scale)); border-width: 2px; }
body.phone-landscape #status.status-error { width: var(--desktop-center-width); font-size: 12px; }
body.phone-landscape #settings:not([open]) > summary, body.phone-landscape #rules-toggle { height: calc(48px * var(--table-scale)); font-size: calc(20px * var(--table-scale)); padding: 0 3px; }
/* Invisible padding reaches down into the table; neighbouring hit areas do not overlap. */
body.touch-table #settings:not([open]) > summary { position: relative; overflow: visible; }
body.touch-table #rules-toggle { overflow: visible; }
body.touch-table #rules-toggle::after { display: none; }
body.touch-table #settings:not([open]) > summary::before, body.touch-table #rules-toggle::before { content: ''; position: absolute; inset: -4px -2px -16px; pointer-events: auto; }
body.phone-landscape:not(.pre-game) #actions.counter-stage { top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(400px, calc(100vw - 40px)); }
body.phone-landscape:not(.pre-game) #actions.decision-stage:not(.counter-stage) { width: min(420px, calc(100vw - 40px)); }
body.phone-landscape:not(.pre-game) #actions.flower-stage { width: min(300px, calc(100vw - 40px)); }
body.phone-landscape #actions button.current { min-height: 48px; }
body.touch-table .seat-voice-toggle { min-width: 0; width: calc(18px * var(--desktop-seat-scale)); padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; writing-mode: horizontal-tb; line-height: 1.15; letter-spacing: 0; gap: .12em; }
body.touch-table .seat-voice-toggle span { display: block; width: 100%; text-align: center; writing-mode: horizontal-tb; line-height: 1; }
body.touch-table #deck-atlas { width: min(960px, calc(100vw - 2 * var(--safe-side) - 40px)); max-width: calc(100vw - 2 * var(--safe-side) - 40px); max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 32px); margin: auto; }
#result-captured { display: none; }
#result-summary { display: contents; }
#result-summary > * { flex-shrink: 0; }
@media (orientation: landscape) {
  body.touch-table #result-screen { padding: calc(var(--safe-top) + 12px) calc(var(--safe-side) + 16px) calc(var(--safe-bottom) + 12px); }
  body.touch-table .ceremony-card.result-card { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto; gap: 6px 22px; width: min(1060px, 100%); height: min(720px, calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px)); max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px); padding: 18px 22px; overflow: hidden; }
  body.touch-table #result-kicker { grid-column: 2; grid-row: 1; margin: 0; font-size: 12px; }
  body.touch-table #result-title { grid-column: 2; grid-row: 2; margin: 0; padding: 5px 0; font-size: clamp(30px, 5vw, 54px); }
  body.touch-table #result-reason { grid-column: 2; grid-row: 3; margin: 0; font-size: 12px; line-height: 1.4; }
  body.touch-table #result-yaku { grid-column: 1; grid-row: 1 / -1; min-height: 0; margin: 0; padding: 0 4px 8px; overflow-y: auto; }
  body.touch-table #result-summary { display: flex; flex-direction: column; grid-column: 2; grid-row: 4; min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #b6975c #24171b; padding: 0 6px 8px 0; gap: 10px; }
  body.touch-table #result-summary > * { flex-shrink: 0; }
  body.touch-table .result-total { min-width: 0; margin: 0; padding: 26px 4px 4px; gap: 6px; }
  body.touch-table #result-captured:not([hidden]) { display: block; min-width: 0; }
  body.touch-table #result-captured > p { margin: 0 0 8px; font-size: 12px; line-height: 1.2; color: #d7bf8c; }
  body.touch-table #result-captured .recap-card-row { grid-template-columns: 28px minmax(0, 1fr); gap: 6px; padding: 6px 0; }
  body.touch-table #result-captured .recap-card-label strong { font-size: 18px; }
  body.touch-table #result-captured .recap-card-label small { font-size: 10px; white-space: nowrap; }
  body.touch-table #result-captured .recap-card-strip { flex-wrap: wrap; overflow: visible; min-height: 55px; padding: 0; gap: 4px; }
  body.touch-table #result-captured .guide-card { width: 37px; height: 53px; flex: 0 0 37px; }
  body.touch-table .match-finale #result-captured { display: none; }
  body.touch-table .result-total-label { top: 4px; font-size: 13px; }
  body.touch-table .result-number-window { font-size: calc(clamp(28px, 7dvh, 52px) * var(--score-growth, 1) * var(--score-fit, 1)); }
  body.touch-table #result-scores { margin: 0; gap: 6px; }
  body.touch-table .result-score { padding: 7px; }
  body.touch-table .result-score strong { font-size: 13px; margin: 0 0 3px; }
  body.touch-table .result-score b { font-size: 20px; }
  body.touch-table .result-score small { float: none; display: block; margin: 2px 0 0; font-size: 11px; }
  body.touch-table .result-actions { grid-column: 2; grid-row: 5; gap: 6px; padding-top: 5px; border-top: 1px solid #b6975c66; }
  body.touch-table .result-actions button { min-width: 0; min-height: 40px; flex: 1; padding: 5px; font-size: 16px; }
  body.touch-table .result-yaku-row { padding: 7px 9px; }
  body.touch-table .result-yaku-row strong { font-size: 21px; }
  body.touch-table .result-multiplier { padding: 8px 10px; gap: 4px; }
  body.touch-table .result-multiplier span { font-size: 18px; }
  body.touch-table .result-multiplier b { font-size: 27px; }
  body.touch-table .result-subtotal { padding: 7px 9px; font-size: 16px; }
  body.touch-table .streak-stamp { position: static; display: block; width: fit-content; margin-top: 4px; padding: 2px 5px; font-size: 12px; line-height: 1.2; border-width: 1px; transform: none; animation: none; box-shadow: none; }
  body.touch-table .match-finale .result-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto; }
  body.touch-table .match-finale #result-kicker, body.touch-table .match-finale #result-title, body.touch-table .match-finale #result-reason { grid-column: 1 / -1; }
  body.touch-table .match-finale #result-yaku { grid-column: 1 / -1; grid-row: 4; }
  body.touch-table .match-finale #result-summary { grid-column: 1; grid-row: 5; overflow-y: auto; padding: 0; display: block; max-height: 80px; }
  body.touch-table #match-recap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
  body.touch-table .recap-player { margin: 0; padding: 10px; min-width: 0; }
  body.touch-table .recap-player h3 { font-size: 22px; }
  body.touch-table .recap-player p { font-size: 12px; }
  body.touch-table .recap-facts b { font-size: 20px; }
  body.touch-table .recap-facts span { font-size: 10px; }
  body.touch-table .recap-card-strip { flex-wrap: wrap; overflow: visible; }
  body.touch-table #dealer-intro { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); align-content: center; gap: 16px; padding: calc(var(--safe-top) + 16px) calc(var(--safe-side) + 18px) calc(var(--safe-bottom) + 24px); overflow-y: auto; }
  body.touch-table .dealer-banner { padding: 12px; }
  body.touch-table .dealer-banner h2 { font-size: clamp(22px, 3vw, 32px); }
  body.touch-table .dealer-banner p { font-size: 13px; }
  body.touch-table .dealer-cards { width: 100%; gap: 12px; }
  body.touch-table .dealer-entry { padding: 8px; min-width: 0; }
  body.touch-table .dealer-entry h3 { margin: 0 0 8px; font-size: 16px; }
  body.touch-table .dealer-flip { width: min(12vw, 34dvh, 112px); margin-inline: auto; }
  body.touch-table .dealer-month { font-size: 12px; margin: 8px 0 0; }
  body.touch-table .dealer-stamp { font-size: 24px; padding: 4px 8px; border-width: 3px; }
}
#asset-retry { margin-top: 10px; min-height: 44px; padding: 6px 18px; font-size: 16px; }
@media (orientation: landscape) and (max-height: 600px) {
  #start-screen { padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  #start-screen .start-card { padding: 14px; gap: 10px 14px; }
  .start-heading h1 { font-size: 28px; }
  .start-card .lobby-intro { padding-top: 10px; }
  .start-card #match-rules label { font-size: 13px; }
  #settings[open], body:not(.pre-game) #settings[open] { top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); width: min(420px, calc(100vw - 36px)); max-height: calc(100dvh - 24px - env(safe-area-inset-bottom)); }
  #settings .settings-content { max-height: calc(100dvh - 90px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; }
  .ceremony-card.result-card { height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); }
  #pair-choice { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 12px 18px; }
  #pair-choice .pair-choice-heading h2 { font-size: 22px; }
  #pair-choice-options .guide-card { max-height: 36dvh; width: auto; }
  #dealer-intro { padding: 10px; }
  .dealer-banner { padding: 12px; }
  .dealer-banner h2 { font-size: 28px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.touch-table .ceremony-card.result-card { padding: 10px 14px; gap: 4px 16px; }
  body.touch-table #result-title { font-size: 28px; padding: 0; }
  body.touch-table #result-reason { font-size: 11px; }
  body.touch-table .result-total { padding-top: 20px; }
  body.touch-table .result-total-label { font-size: 11px; }
  body.touch-table .result-number-window { font-size: calc(28px * var(--score-growth, 1) * var(--score-fit, 1)); }
  body.touch-table .result-score { padding: 4px 6px; }
  body.touch-table .result-score strong { font-size: 12px; display: inline; margin-right: 5px; }
  body.touch-table .result-score b { font-size: 18px; }
  body.touch-table .result-score small { font-size: 10px; }
  body.touch-table .result-actions button { min-height: 36px; }
}
@media (orientation: landscape) and (max-height: 400px) {
  body.touch-table #result-title { font-size: 24px; }
  body.touch-table #result-reason { display: none; }
  body.touch-table .result-number-window { font-size: calc(22px * var(--score-growth, 1) * var(--score-fit, 1)); }
  body.touch-table .result-total { padding-top: 18px; }
  body.touch-table .result-score small { display: none; }
  body.touch-table .result-score b { font-size: 16px; }
  body.touch-table .result-actions button { min-height: 32px; font-size: 14px; }
  body.touch-table #result-captured p { font-size: 10px; }
}
#round-counter { position: fixed; z-index: 5; top: 20px; left: 30px; padding: 8px 16px; background: #29191af2; color: #ffe7b0; border: 3px double #bd995f; border-radius: 5px; font: 700 20px HanamiText, serif; white-space: nowrap; pointer-events: none; }
body.touch-table #settings[open], body.touch-table #settings.start-settings-open[open] { top: calc(var(--safe-top) + 12px); right: calc(var(--safe-side) + 12px); transform: none; width: min(420px, calc(100vw - 2 * var(--safe-side) - 24px)); max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px); padding: 12px; overflow: hidden; }
body.touch-table #settings[open] .settings-content { max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 96px); overflow-y: auto; overflow-x: hidden; }
body.touch-table #settings[open] #settings-close { top: 12px; right: 12px; }
#table-exit-setting { display: flex; align-items: center; gap: 12px; padding: 0 0 14px; margin-bottom: 14px; border-bottom: 1px solid #b4965f55; }
/* Keep the recovery route reachable during dealing and other table animations. */
body:not(.pre-game) #settings, body:not(.pre-game) #mobile-menu-toggle { z-index: 34; }
body:not(.pre-game) #panel-backdrop, body.settings-open:not(.pre-game)::before { z-index: 33; }
#table-exit-setting strong { font-size: 16px; color: #eed4a1; }
#table-exit-setting small { display: block; margin-top: 5px; line-height: 1.5; font-size: 11px; color: #bba487; }
#escape-table { flex: none; margin-left: auto; min-width: 66px; min-height: 42px; padding: 6px 12px; font-size: 16px; }
body.pre-game #table-exit-setting, body.pre-game #round-counter { display: none; }
#escape-dialog { width: min(430px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 28px; border: 3px double #c4a168; border-radius: 10px; color: #e6d1ac; background: radial-gradient(ellipse at top, #632a3455, transparent 65%), #1d1215; box-shadow: 0 20px 70px #000a; text-align: center; }
#escape-dialog::backdrop { background: #10090d99; }
.escape-seal { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-bottom: 18px; border: 3px double #c18f69; color: #f0cfaa; background: #6c2937; font: 600 19px HanamiText, serif; border-radius: 4px; }
#escape-title { margin: 8px 0 12px; font-size: 29px; font-weight: 600; letter-spacing: .1em; color: #f5dba9; }
#escape-note, #escape-error { font-size: 14px; line-height: 1.8; }
.escape-score-rule { display: grid; grid-template-columns: 1fr 1fr; margin: 22px 0; padding: 15px 0; border-block: 1px solid #ab875145; }
.escape-score-rule > div + div { border-left: 1px solid #ab875145; }
.escape-score-rule small { display: block; font-size: 12px; color: #b69f7d; }
.escape-score-rule strong { display: block; margin-top: 8px; color: #edb4a4; font: 600 32px/1.2 HanamiText, serif; }
.escape-score-rule > div + div strong { font-size: 25px; line-height: 1.54; color: #d1c49d; }
.escape-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.escape-actions button, #escape-local { min-height: 44px; font-size: 16px; padding: 9px; }
#escape-local { margin-top: 12px; width: 100%; }
#escape-error { color: #e9b2a0; }
.round-count-setting { grid-column: 1 / -1; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid #ad8d5038; }
#round-count-title { display: block; margin-bottom: 10px; color: #dfc596; font-size: 14px; }
.round-count-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.start-card #match-rules .round-count-options label { position: relative; min-height: 40px; padding: 6px; justify-content: center; gap: 5px; cursor: pointer; border: 1px solid #a185555c; border-radius: 6px; color: #bba584; background: #170e10; }
.start-card #match-rules .round-count-options input { appearance: none; width: 15px; height: 15px; margin: 0; border: 1px solid #9d8054; border-radius: 3px; display: grid; place-items: center; flex-shrink: 0; }
.round-count-options input:checked { background: #bb4356; border-color: #e4b388 !important; }
.round-count-options input:checked::after { content: ''; width: 7px; height: 4px; border-left: 2px solid #fff1c9; border-bottom: 2px solid #fff1c9; transform: translateY(-1px) rotate(-45deg); }
.start-card #match-rules .round-count-options label:has(input:checked) { color: #ffe4b0; border-color: #caa36d; background: #582330; box-shadow: inset 0 0 0 1px #c99a5938; }
.round-count-options label:has(input:focus-visible) { outline: 2px solid #ffe0a0; outline-offset: 3px; }
.round-count-options label:has(input:disabled) { cursor: default; opacity: .7; }
.capture-counts { display: none; }
#mobile-menu-toggle, #mobile-menu { display: none; }
#collection-dialog, #collection-zoom { box-sizing: border-box; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); border: 1px solid #bb995e; border-radius: 12px; padding: 12px; background: #160f11fa; color: #efdbb3; }
#collection-dialog::backdrop, #collection-zoom::backdrop { background: #08050899; }
#collection-dialog header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#collection-dialog h2 { font-size: 20px; margin: 0; }
#collection-dialog small { font-size: 11px; color: #b9a582; }
#collection-close, #collection-zoom-close { width: 40px; height: 40px; padding: 0; flex: none; font-size: 24px; }
#collection-strips h3 { font-size: 13px; margin: 6px 0 0; }
.collection-row { display: flex; flex-wrap: nowrap; align-items: flex-start; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #a47d4c #ffffff0a; padding: 5px 5px 6px; min-height: 35px; }
.collection-row .collection-card { display: block; padding: 0; flex: 0 0 clamp(56px, 17vw, 74px); width: clamp(56px, 17vw, 74px); height: clamp(79.52px, 24.14vw, 105.08px); min-width: 0; border: 0; border-radius: 5px; background: none; box-shadow: -3px 1px 6px #0008; }
.collection-card + .collection-card { margin-left: -13px; }
.collection-card .guide-card { display: block; width: 100%; height: 100%; box-sizing: border-box; border: 1px solid #cfa971; }
.collection-card:focus-visible { position: relative; z-index: 1; outline: 2px solid #ffe3a0; }
.collection-row .collection-card:not(:disabled):hover, .collection-row .collection-card:not(:disabled):active { transform: none; }
.collection-empty { font-size: 13px; color: #8f7e65; padding: 4px; }
#collection-yaku { margin: 9px 0 4px; font-size: 13px; }
#collection-zoom { width: min(270px, calc(100vw - 36px)); text-align: center; }
#collection-zoom-close { display: block; margin: 0 0 8px auto; }
#collection-zoom .guide-card { width: min(170px, 55vw); max-height: 50dvh; }
#collection-zoom p { margin: 8px 0 0; }
.start-footer .start-rules { margin: 0 0 8px; }
.start-footer button { min-height: 46px; padding: 8px; font-size: 19px; }

@media (max-width: 700px) and (orientation: portrait) {
  #round-counter { top: max(12px, env(safe-area-inset-top)); left: 12px; font-size: 15px; padding: 7px 10px; }
  body { --phone-bottom: env(safe-area-inset-bottom, 0px); }
  #game { height: calc(100% - var(--phone-bottom)); }
  #start-screen { padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom)); }
  #start-screen .start-card { grid-template-columns: 1fr; gap: 10px; padding: 14px; border-radius: 12px; }
  .start-heading { gap: 3px 8px; }
  .start-heading h1 { font-size: 29px; letter-spacing: .06em; }
  .start-heading .eyebrow { font-size: 9px; }
  .start-heading .start-copy { grid-column: 1 / -1; font-size: 11px; }
  .start-heading #lobby-audio { grid-row: 4; grid-column: 1 / -1; min-height: 32px; padding: 3px 10px; justify-self: center; }
  .start-heading #lobby-seating { font-size: 13px; padding-top: 9px; }
  .start-card .online-room { padding: 10px; }
  .lobby-intro { padding: 10px 0 0; }
  .ceremony .lobby-intro h2 { font-size: 16px; margin-bottom: 5px; }
  .lobby-intro p { font-size: 12px; line-height: 1.7; }
  .lobby-version { margin-top: 10px; padding-top: 8px; }
  .lobby-version > span { margin-bottom: 4px; font-size: 11px; }
  .lobby-version p { font-size: 11px; line-height: 1.65; }
  .round-count-setting { padding-bottom: 8px; }
  #round-count-title { font-size: 12px; margin-bottom: 7px; }
  .start-card .room-actions, .start-card .join-room { gap: 6px; margin-top: 6px; }
  .start-card .join-room { grid-template-columns: 1.35fr 1fr; }
  .start-card .room-actions button, .start-card .join-room button { min-height: 38px; font-size: 16px; padding: 5px; }
  .start-card #invite-code { font-size: 16px; padding: 5px 8px; }
  .start-card #room-status { margin-top: 6px; min-height: 30px; font-size: 11px; }
  .start-card #match-rules { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 4px 7px 6px; }
  .start-card #match-rules legend { font-size: 12px; }
  .start-card #match-rules label { font-size: 12px; gap: 2px; min-height: 32px; white-space: normal; }
  .start-card #match-rules input { width: 16px; height: 16px; margin-right: 2px; }
  .start-card #match-rules small { grid-column: 1 / -1; font-size: 10px; margin: 0; }
  #lobby-rule-help { min-height: 28px; font-size: 11px; padding: 2px; }
  .start-footer .start-rules { margin-bottom: 6px; font-size: 10px; }
  .start-footer .start-buttons { gap: 6px; grid-template-columns: .65fr 1fr 1.3fr; }
  .start-footer button, .start-footer #start-match { min-height: 42px; font-size: 16px; padding: 6px 3px; letter-spacing: .03em; }
  body:not(.pre-game) #rules-toggle, body:not(.pre-game) #settings:not([open]) summary { width: 60px; min-width: 0; height: 38px; font-size: 13px; padding: 0; letter-spacing: 0; }
  body:not(.pre-game) #settings { right: 12px; top: max(12px, env(safe-area-inset-top)); }
  body:not(.pre-game) #rules-toggle { right: 144px; top: max(12px, env(safe-area-inset-top)); }
  body:not(.pre-game) #settings[open] { top: 54px; right: 12px; width: min(330px, calc(100vw - 24px)); }
  body:not(.pre-game) #settings:not([open]), body:not(.pre-game) #rules-toggle{ display: none; }
  #mobile-menu-toggle { display: block; position: fixed; z-index: 7; top: max(10px, env(safe-area-inset-top)); right: 12px; min-height: 40px; min-width: 74px; padding: 6px 10px; font-size: 14px; letter-spacing: 0; }
  #mobile-menu:popover-open { display: grid; position: fixed; inset: max(56px, calc(env(safe-area-inset-top) + 46px)) 12px auto auto; margin: 0; padding: 6px; width: 154px; gap: 5px; border: 1px solid #ba945d; border-radius: 9px; background: #201416f5; box-shadow: 0 8px 24px #0007; }
  #mobile-menu button { min-height: 44px; font-size: 16px; padding: 6px 10px; }
  #mobile-menu::backdrop { background: #0002; }
  body.pre-game #mobile-menu-toggle, body.settings-open #mobile-menu-toggle, body.inspector-open #mobile-menu-toggle { display: none; }
  #settings .settings-content { max-height: calc(100dvh - 135px); }
  #table-picker { display: none; }
  #seat-mute-opponent { top: 62px; left: 8px; }
  #seat-mute-self { top: 62px; right: 8px; bottom: auto; }
  .seat-voice-toggle { width: 32px; height: 44px; font-size: 13px; }
  #status { top: 151px; max-width: calc(100vw - 24px); white-space: normal; text-align: center; min-height: 28px; font-size: 11px; padding: 5px 10px; letter-spacing: 0; }
  body #actions:not(.counter-stage) { top: auto; bottom: calc(var(--phone-hand-zone, 194px) + var(--phone-bottom) + 4px); left: 16px; transform: none; width: calc(100vw - 32px); display: flex; gap: 8px; }
  body #actions:not(.counter-stage) button { flex: 1; height: 44px; min-height: 44px; font-size: 20px; padding: 4px; transform: none; animation: none; }
  body #actions:not(.counter-stage) button:not(.current), body #actions .action-gap { display: none; }
  body #actions.flower-stage:not(.counter-stage) { bottom: calc(var(--phone-hand-zone, 194px) + var(--phone-bottom) + 104px); }
  body #actions.flower-stage:not(.counter-stage) button.flower-action { height: 86px; min-height: 86px; font-size: 34px; flex: none; padding: 7px 24px; }
  body #actions.flower-stage button.flower-action::before { font-size: 86px; left: 12px; }
  body #actions.decision-stage:not(.counter-stage) { display: grid; gap: 10px; bottom: calc(var(--phone-hand-zone, 194px) + var(--phone-bottom) + 104px); }
  body #actions.decision-stage button.current, body #actions.decision-stage button.current:not(:disabled) { height: 88px; min-height: 88px; font-size: 28px; padding: 7px 5px; gap: 6px; border-radius: 23px 7px 23px 7px; }
  body #actions.decision-stage button.current::before { font-size: 90px; top: -15px; }
  body #actions.decision-stage button.current::after { font-size: 11px; letter-spacing: 0; } #self-collection-toggle { bottom: calc(var(--phone-hand-zone, 194px) + var(--phone-bottom) + 56px); height: 40px; padding: 6px; font-size: 13px; width: 86px; letter-spacing: 0; }
  .capture-counts b { font: 700 14px HanamiText, sans-serif; }
  #self-collection-toggle { display: block; position: fixed; z-index: 6; left: auto; right: 12px; top: 110px; bottom: auto; width: calc(50% - 18px); height: 40px; padding: 3px 6px; background: #24151dea; color: #f3dfae; border-color: #c5a56490; }
  #self-collection-toggle > span:first-child { display: block; font-size: 10px; line-height: 13px; text-align: left; }
  #self-collection-toggle .capture-counts { display: block; font: 700 12px/19px HanamiText, serif; white-space: nowrap; }
  body.pre-game #self-collection-toggle, body.settings-open #self-collection-toggle, body.inspector-open #self-collection-toggle, body.dealing #self-collection-toggle { visibility: hidden; }
  .dealer-banner { padding: 12px 8px; }
  .dealer-banner h2 { font-size: 25px; }
  #dealer-intro { padding: 12px; }
}
@media (max-width: 700px) and (orientation: portrait) and (max-height: 680px) {
  #seat-mute-self, #seat-mute-opponent { top: 54px; }
  #status { top: 131px; }
  #self-collection-toggle { top: 102px; height: 28px; }
  #self-collection-toggle > span:first-child { display: none; }
  #start-screen .start-card { padding: 8px; gap: 5px; }
  .start-heading .eyebrow, .start-heading .start-copy { display: none; }
  .start-heading h1 { font-size: 27px; }
  .start-heading #lobby-audio { grid-row: 2; }
  .start-card .online-room { padding: 7px; }
  .start-card #room-status { min-height: 28px; }
  .start-card #match-rules { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .start-card #match-rules label { font-size: 11px; }
}
