:root {
  color-scheme: light;
  --felt: #0d4a32;
  --felt-dark: #073724;
  --cream: #fffaf0;
  --ink: #17251d;
  --muted: #647168;
  --gold: #e7b94d;
  --red: #a52c2c;
  --line: #d8d2c4;
  --card-width: 72px;
  --card-height: 100px;
  --radius: 18px;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--felt-dark);
  color: var(--ink);
}

* { box-sizing: border-box; min-width: 0; }
html, body { min-height: 100%; max-width: 100%; margin: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(circle at 50% 15%, #1a6749, var(--felt) 55%, var(--felt-dark));
}
button, input { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, dialog:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .48; }
[hidden] { display: none !important; }
body:not(.demo-mode) .demo-only { display: none !important; }
body.demo-mode .real-only { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.screen {
  width: min(100%, 680px);
  min-height: 100dvh;
  margin: auto;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.welcome-screen, .form-screen { display: grid; place-items: center; }
.panel { width: 100%; padding: 24px; border: 1px solid rgb(0 0 0 / 12%); border-radius: var(--radius); background: var(--cream); box-shadow: 0 12px 28px rgb(0 0 0 / 18%); }
.welcome-screen { width: min(100%, 960px); }
.home-shell { width: 100%; max-width: 760px; margin-inline: auto; }
.hero-panel { max-width: none; text-align: center; }
.home-actions, .rules-choices { display: grid; gap: 10px; }
.home-rules-button { margin-top: 8px; }
.setup-panel { max-width: 760px; }
.room-form-panel { max-width: 560px; }
.game-selector { margin: 14px 0 0; padding: 0; border: 0; }
.game-selector legend { margin-bottom: 10px; font-size: .9rem; font-weight: 750; }
.game-options { display: grid; gap: 10px; }
.game-option { position: relative; display: block; margin: 0; cursor: pointer; }
.game-option input { position: absolute; width: 1px; min-height: 1px; margin: 0; opacity: 0; }
.game-option-copy { display: grid; min-height: 154px; gap: 7px; padding: 15px; border: 2px solid var(--line); border-radius: 14px; background: white; text-align: left; }
.game-choice-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-choice-heading > strong { color: #173e2b; font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; }
.game-option:has(input:checked) .game-option-copy { border-color: #1d6745; box-shadow: 0 0 0 2px #c4e1d0; }
.game-option:focus-within .game-option-copy { outline: 3px solid var(--gold); outline-offset: 3px; }
.game-description { color: var(--muted); font-size: .86rem; font-weight: 400; line-height: 1.4; }
.game-option-selection { align-self: end; color: #1d6745; font-size: .78rem; font-weight: 900; visibility: hidden; }
.game-option:has(input:checked) .game-option-selection { visibility: visible; }
.game-player-count { font-size: .82rem; font-weight: 800; }
.game-status { flex: none; padding: 5px 8px; border-radius: 999px; font-size: .68rem; font-weight: 900; text-transform: uppercase; }
.game-status.is-available { background: #def1e5; color: #175b38; }
.game-status.is-development { background: #f4ead1; color: #6f5314; }
.form-rules-button { justify-self: start; width: auto; padding-inline: 4px; }
.eyebrow { margin: 0 0 6px; color: #657168; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { margin-bottom: 12px; font-family: Georgia, "Times New Roman", serif; color: #173e2b; }
h1 { font-size: clamp(3.25rem, 17vw, 5rem); line-height: .95; }
h2 { font-size: clamp(2rem, 9vw, 3rem); }
h3 { margin-bottom: 10px; font-size: 1rem; }
.lead { margin: 0 auto 24px; max-width: 24rem; color: #4d5d53; line-height: 1.5; }
.muted, .fine-print { color: var(--muted); line-height: 1.45; }
.fine-print { margin: 16px auto 0; max-width: 26rem; font-size: .82rem; }
.home-message { min-height: 20px; margin: 10px 0 0; color: #8a2c24; font-size: .84rem; font-weight: 700; }
.stack { display: grid; gap: 10px; }

.button, .icon-button, .back-button, .remove-button {
  min-height: 44px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 750;
}
.button { width: 100%; padding: 11px 18px; }
.button-primary { background: #1d6745; color: white; }
.button-primary:not(:disabled):active { background: #155438; transform: translateY(1px); }
.button-secondary { border: 1px solid #9ba79f; background: white; color: #234332; }
.button-quiet { background: transparent; color: #4c5b52; text-decoration: underline; }
.button-compact { width: auto; min-width: 104px; }
.back-button { margin: -8px 0 20px -8px; padding: 8px; background: transparent; color: #315541; }
.icon-button { padding: 8px 12px; background: rgb(255 255 255 / 12%); color: white; }

form { display: grid; gap: 8px; margin-top: 22px; }
label { margin-top: 8px; font-size: .9rem; font-weight: 750; }
input { width: 100%; min-height: 50px; padding: 10px 13px; border: 2px solid #aab1ab; border-radius: 10px; background: white; color: var(--ink); font-size: 1rem; }
.code-input { text-align: center; font-size: 1.5rem; font-weight: 800; letter-spacing: .35em; text-transform: uppercase; }
.form-message { min-height: 21px; margin: 2px 0; color: #9b2020; font-size: .88rem; font-weight: 700; }

.connection-status { display: inline-flex; align-items: center; gap: 7px; margin: 20px 0 0; color: #4d5d53; font-size: .88rem; font-weight: 700; }
.connection-status::before { width: 9px; height: 9px; border-radius: 50%; background: #a44d37; content: ""; }
.connection-status[data-state="connected"]::before { background: #23935b; }
.connection-status[data-state="reconnecting"]::before { background: #e0a52a; }
.connection-status[data-state="resuming"]::before { background: #e0a52a; }
.connection-status[data-state="offline"]::before { background: #c85a45; }
.connection-status.compact { margin: 0; color: #eaf5ee; font-size: .7rem; }

.screen-header, .game-header, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.screen-header { color: white; }
.screen-header h2, .screen-header .eyebrow { margin: 0; color: white; }
.screen-header h2 { font-size: 2rem; letter-spacing: .12em; }
.toast-space { min-height: 26px; margin: 8px 0; color: #fff7d5; text-align: center; font-size: .85rem; }
.lobby-panel { padding: 18px; }
.section-heading h3, .section-heading span { margin: 0; }
.section-heading span { color: var(--muted); font-size: .82rem; font-weight: 700; }
.player-list { display: grid; gap: 8px; margin: 14px 0; padding: 0; list-style: none; }
.player-row { display: flex; min-height: 57px; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px 9px 13px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.player-row.is-you { border: 2px solid #256744; }
.player-row.is-you strong::after { content: " (you)"; font-size: .75rem; }
.player-row strong, .player-row span { display: block; }
.player-row > div { min-width: 0; overflow-wrap: anywhere; }
.player-row span { margin-top: 3px; color: var(--muted); font-size: .76rem; }
.remove-button { min-width: 76px; padding: 7px; background: #f6e5e1; color: #81291f; font-size: .72rem; }
.callout { padding: 12px; border-radius: 10px; background: #edf4ef; color: #365044; font-size: .85rem; line-height: 1.4; }
.callout.is-ready { border: 2px solid #2b7650; background: #def1e5; font-weight: 700; }

.game-screen {
  height: 100dvh; min-height: 560px; display: grid;
  grid-template-rows: auto auto minmax(122px, 1fr) auto auto auto minmax(128px, 1.15fr) auto;
  gap: 7px; overflow: hidden; color: white;
}
.game-header { min-height: 42px; }
.game-header > div, .header-actions { display: flex; align-items: center; gap: 9px; }
.room-chip { font-size: .78rem; }
.round-label { color: #c7ded0; font-size: .72rem; }
.opponents { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: thin; padding: 1px 0 4px; }
.opponent { flex: 1 0 92px; max-width: 130px; min-height: 57px; padding: 7px 8px; border: 1px solid rgb(255 255 255 / 16%); border-radius: 10px; background: rgb(1 35 22 / 45%); }
.opponent strong, .opponent span, .opponent small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opponent strong { font-size: .8rem; }
.opponent span, .opponent small { margin-top: 3px; color: #c6ded0; font-size: .67rem; }
.opponent.is-turn { border: 2px solid var(--gold); background: #275d43; }
.opponent.is-offline { opacity: .58; }
.opponent-remove { min-height: 30px; margin-top: 5px; border: 0; border-radius: 7px; background: #f4dfd8; color: #78271f; font-size: .65rem; font-weight: 800; }

.pile-area { display: grid; place-items: center; align-content: center; min-height: 0; padding: 4px; text-align: center; }
.pile-area .eyebrow { color: #b8d4c3; }
.pile-cards { display: flex; justify-content: center; min-height: 78px; }
.pile-cards .playing-card { width: 57px; height: 78px; margin-left: -19px; }
.pile-cards .playing-card:first-child { margin-left: 0; transform: rotate(-3deg); }
.pile-cards .playing-card:last-child { transform: rotate(3deg); }
.pile-summary { margin: 3px 0 0; font-size: .78rem; font-weight: 700; }
.turn-panel { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 47px; padding: 8px 11px; border: 1px solid rgb(255 255 255 / 18%); border-radius: 11px; background: rgb(0 30 18 / 40%); }
.turn-panel.is-your-turn { border: 2px solid var(--gold); background: #f7e5ac; color: #263c2e; }
.turn-panel.is-urgent { border-color: #e66b57; }
.prototype-label { display: block; margin-top: 2px; font-size: .62rem; opacity: .72; }
.timer { width: 72px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; }
.timer-track { height: 4px; margin-top: 4px; overflow: hidden; border-radius: 3px; background: rgb(0 0 0 / 22%); }
.timer-track span { display: block; width: 100%; height: 100%; background: currentcolor; transition: width .2s linear; }
.game-notice { min-height: 17px; margin: 0; color: #ffe89c; font-size: .7rem; text-align: center; }
.special-rule-controls { display: grid; gap: 5px; color: white; font-size: .75rem; text-align: center; }
.special-rule-controls p { margin: 0; }
.choice-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-buttons .button, #call-consecutive { min-height: 40px; padding: 7px 12px; }
.choice-buttons [aria-pressed="true"], #call-consecutive[aria-pressed="true"] { outline: 3px solid var(--gold); background: #173e2b; color: white; }
.active-rule-status { min-height: 1em; color: #ffe89c; font-weight: 800; }
.game-screen.ce-game-screen {
  height: auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: visible;
}
.ce-game-screen > * { flex: none; min-width: 0; }
.ce-game-screen .game-header > div { min-width: 0; }
.ce-game-screen .room-chip, .ce-game-screen .round-label { white-space: nowrap; }
.ce-game-screen .header-actions { justify-content: flex-end; }
.ce-game-screen .opponents { width: 100%; }
.ce-table { display: grid; grid-template-columns: minmax(100px, .8fr) minmax(145px, 1.2fr); align-items: center; gap: 12px; color: white; text-align: center; }
.ce-table > div { min-width: 0; }
.ce-suit-panel { display: grid; gap: 7px; padding: 16px 10px; border: 2px solid var(--gold); border-radius: 14px; background: rgb(0 30 18 / 45%); }
.ce-suit-panel span, .ce-suit-panel small { font-size: .74rem; }
.ce-suit-panel strong { font-size: 1.25rem; }
.ce-status-region { display: grid; gap: 4px; }
.ce-status-region .turn-panel { min-height: 44px; }
.ce-status-region .turn-panel strong { overflow-wrap: anywhere; }
.ce-status-region .game-notice { min-height: 0; line-height: 1.35; overflow-wrap: anywhere; }
.ce-status-region .game-notice:empty { display: none; }
.ce-decision-panel { display: grid; gap: 8px; padding: 10px; border: 1px solid rgb(255 255 255 / 20%); border-radius: 12px; background: rgb(0 30 18 / 45%); }
.ce-decision-panel .callout { margin: 0; }
.ce-suit-chooser { color: white; text-align: center; }
.ce-suit-chooser p { margin: 0 0 6px; font-weight: 800; }
.ce-suit-chooser > div { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ce-suit-chooser button { min-height: 44px; padding: 7px; border: 1px solid white; border-radius: 10px; background: white; color: var(--ink); font-weight: 800; }
.ce-suit-chooser button[aria-pressed="true"] { outline: 3px solid var(--gold); background: #173e2b; color: white; }
.ce-primary-actions, .ce-secondary-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.ce-primary-actions .button, .ce-secondary-actions .button { min-height: 44px; padding-inline: 9px; }
.ce-secondary-actions { padding-bottom: 2px; }
.playing-card.is-unplayable { filter: grayscale(.65); opacity: .58; }
.playing-card.is-newly-drawn { box-shadow: 0 0 0 3px var(--gold), 0 5px 10px rgb(0 0 0 / 30%); }

.mahjong-game-screen {
  width: min(100%, 1120px); min-height: 100dvh; margin-inline: auto; display: flex; flex-direction: column;
  gap: 12px; overflow: visible; color: white;
}
.mahjong-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mahjong-header h2, .mahjong-header .eyebrow { margin: 0; color: white; }
.mahjong-header h2 { font-size: clamp(1.6rem, 7vw, 2.5rem); }
.mahjong-status { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.mahjong-status span, .mahjong-opponents article {
  padding: 9px 10px; border: 1px solid rgb(255 255 255 / 18%); border-radius: 10px; background: rgb(0 30 18 / 45%);
}
.mahjong-status strong, .mahjong-opponents strong, .mahjong-opponents span { display: block; }
.mahjong-status strong { color: #bad5c5; font-size: .65rem; text-transform: uppercase; }
.mahjong-opponents { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.mahjong-opponents article { min-width: 0; }
.mahjong-opponents strong, .mahjong-opponents span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mahjong-opponents strong { font-size: .76rem; }
.mahjong-opponents span { margin-top: 4px; color: #bad5c5; font-size: .65rem; }
.mahjong-centre { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; padding: 12px; border-radius: 14px; background: rgb(0 30 18 / 40%); }
.mahjong-centre .eyebrow { color: #bad5c5; }
.mahjong-centre aside { display: grid; gap: 3px; align-content: center; padding: 10px; border: 2px solid var(--gold); border-radius: 10px; text-align: center; }
.mahjong-centre aside span, .mahjong-centre aside small { color: #d7e8dd; }
.mahjong-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.mahjong-actions .button { padding-inline: 7px; }
.mahjong-collections { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.mahjong-collections > div { flex: 0 0 auto; padding: 9px; border-radius: 10px; background: rgb(0 30 18 / 42%); }
.mahjong-collections h3 { margin-bottom: 6px; color: white; font-size: .72rem; }
.mahjong-tile-row { display: flex; gap: 3px; min-width: 0; }
.mahjong-tile-row.wrap { flex-wrap: wrap; }
.mahjong-tile {
  position: relative; flex: 0 0 auto; width: 42px; height: 58px; padding: 0; overflow: hidden;
  border: 2px solid #d8d2c4; border-radius: 6px; background: #fffdf7; color: #173e2b;
  box-shadow: 0 2px 5px rgb(0 0 0 / 28%); font: inherit;
}
.mahjong-tile__image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; }
.mahjong-tile.has-tile-image .mahjong-tile__image { opacity: 1; }
.mahjong-tile.has-tile-image .mahjong-tile__fallback { visibility: hidden; }
.mahjong-tile__fallback { display: grid; height: 100%; place-items: center; padding: 3px; font-size: .52rem; font-weight: 800; line-height: 1.1; text-align: center; }
.mahjong-tile.is-selected { transform: translateY(-8px); border-color: var(--gold); box-shadow: 0 0 0 2px #173e2b; }
.mahjong-tile.is-newly-drawn { margin-left: 7px; box-shadow: 0 0 0 3px var(--gold); }
.mahjong-tile.is-disabled { filter: grayscale(.7); opacity: .5; }
.mahjong-tile.is-discarded { transform: rotate(90deg); margin: 7px; }
.mahjong-tile.is-bonus { border-color: var(--gold); }
.mahjong-tile.is-face-down { background: repeating-linear-gradient(45deg, #17623f, #17623f 5px, #e8c467 5px, #e8c467 7px); }
.mahjong-hand-area { min-width: 0; padding: 10px 8px 7px; border-radius: 13px; background: rgb(0 29 18 / 50%); }
.mahjong-hand-area h3, .mahjong-hand-area .section-heading span { color: white; }
.mahjong-hand {
  display: flex; align-items: flex-end; width: 100%; min-height: 86px; padding: 12px 3px 5px; overflow-x: auto; overflow-y: hidden;
  overscroll-behavior-x: contain; touch-action: pan-x; scrollbar-width: thin;
}
.mahjong-hand .mahjong-tile { width: clamp(43px, 13.5vw, 64px); height: clamp(60px, 18.8vw, 88px); margin-right: -8px; z-index: calc(var(--tile-stack-index) + 1); }
.mahjong-hand .mahjong-tile:last-child { margin-right: 3px; }
.mahjong-hand .mahjong-tile.is-selected { z-index: calc(var(--tile-stack-index) + 1); }
.mahjong-primary-actions { display: grid; padding-bottom: env(safe-area-inset-bottom); }
.mahjong-scoring-panel { padding: 14px; border: 1px solid rgb(255 255 255 / 18%); border-radius: 13px; background: rgb(0 29 18 / 62%); }
.mahjong-scoring-panel .section-heading { align-items: end; gap: 12px; }
.mahjong-scoring-panel h3, .mahjong-scoring-panel .eyebrow, .mahjong-scoring-panel label { color: white; }
.mahjong-scoring-panel label { display: grid; gap: 4px; min-width: min(100%, 260px); font-size: .72rem; font-weight: 800; }
.mahjong-scoring-panel select { width: 100%; min-height: 40px; padding: 7px; border-radius: 7px; background: white; color: var(--ink); }
.mahjong-score-summary { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 12px 0; }
.mahjong-score-summary dt { color: #bad5c5; font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.mahjong-score-summary dd { margin: 0; color: white; overflow-wrap: anywhere; }
.mahjong-score-list, .mahjong-payment-list { margin: 8px 0 0; padding-left: 20px; color: #e9f4ed; line-height: 1.45; }

.hand-area { min-height: 0; padding: 8px 9px 2px; border-radius: 13px 13px 0 0; background: rgb(0 29 18 / 35%); }
.hand-area .section-heading { padding: 0 3px 5px; }
.hand-area h3, .hand-area .section-heading span { color: white; }
.hand { --card-selection-lift: .75rem; --card-step: 46px; --hand-width: 100%; --card-width: 72px; height: calc(var(--card-height) + var(--card-selection-lift) + .4rem); overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; touch-action: pan-x; scrollbar-width: thin; }
.hand::after { display: block; width: var(--hand-width); height: 1px; content: ""; }
.hand .playing-card { position: absolute; z-index: calc(var(--card-stack-index, 0) + 1); top: calc(var(--card-selection-lift) + .2rem); left: calc(var(--card-stack-index, 0) * var(--card-step)); }
.hand .playing-card { touch-action: pan-x; }
.hand { position: relative; }
.ce-game-screen .hand {
  width: 100%;
  height: calc(var(--card-height) + var(--card-selection-lift) + .75rem);
  min-height: calc(var(--card-height) + var(--card-selection-lift) + .75rem);
}
.playing-card {
  position: relative;
  width: var(--card-width); height: var(--card-height); padding: 0; overflow: hidden; border: 2px solid #d7d3c8; border-radius: 9px;
  background: #fffdf8; color: #151b17; box-shadow: 0 3px 8px rgb(0 0 0 / 22%); text-align: left;
}
button.playing-card { cursor: pointer; }
.playing-card__image {
  position: absolute; inset: 0; z-index: 1; display: block; width: 100%; height: 100%;
  border-radius: inherit; object-fit: contain; opacity: 0; pointer-events: none;
}
.playing-card.has-card-image .playing-card__image { opacity: 1; }
.playing-card.has-card-image .playing-card__fallback { visibility: hidden; }
.playing-card__fallback { position: absolute; inset: 0; display: block; padding: 6px; }
.playing-card[data-suit="hearts"], .playing-card[data-suit="diamonds"] { color: var(--red); }
.card-rank, .card-suit, .card-name { display: block; }
.card-rank { font-size: 1.15rem; font-weight: 900; line-height: 1; }
.card-suit { margin-top: 3px; font-size: 1rem; }
.card-name { position: absolute; right: 4px; bottom: 6px; font-size: .48rem; font-weight: 700; writing-mode: vertical-rl; text-transform: uppercase; }
.playing-card.is-selected, .playing-card[aria-pressed="true"] { transform: translateY(calc(-1 * var(--card-selection-lift, .75rem))); border: 3px solid var(--gold); box-shadow: 0 0 0 2px #173e2b, 0 5px 8px rgb(0 0 0 / 28%); }
.playing-card:focus-visible { outline: none; }
.playing-card:focus-visible::after { position: absolute; inset: 2px; z-index: 3; border: 3px solid #fff6bf; border-radius: 5px; content: ""; pointer-events: none; }
.playing-card:disabled { opacity: .72; }
.game-controls { display: grid; grid-template-columns: 1fr 1.45fr; gap: 9px; padding-bottom: env(safe-area-inset-bottom); }
.game-controls .button { min-height: 49px; }

.menu-dialog { width: min(calc(100% - 28px), 390px); padding: 22px; border: 0; border-radius: 17px; background: var(--cream); color: var(--ink); }
.menu-dialog::backdrop { background: rgb(0 20 12 / 70%); }
.menu-dialog .button { margin-top: 9px; }
.instructions-dialog { width: min(calc(100% - 20px), 620px); max-height: calc(100dvh - 20px); padding: 0; overflow: hidden; border: 0; border-radius: 17px; background: var(--cream); color: var(--ink); }
.instructions-dialog::backdrop { background: rgb(0 20 12 / 78%); }
.instructions-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 8px; }
.instructions-header h2, .instructions-header p { margin-bottom: 0; }
.instructions-dialog > .callout { margin: 8px 18px; }
.instructions-content { max-height: calc(100dvh - 190px); padding: 8px 18px 22px; overflow-y: auto; overscroll-behavior: contain; }
.instructions-content section { padding-block: 10px; border-bottom: 1px solid var(--line); }
.instructions-content h3 { color: #173e2b; }
.instructions-content ul { margin: 0; padding-left: 1.25rem; }
.instructions-content li { margin: 6px 0; line-height: 1.45; }
.result-hero { padding: 28px 6px 18px; color: white; text-align: center; }
.result-hero h2, .result-hero .eyebrow { color: white; }
.result-hero h2 { margin-bottom: 5px; }
.results-list { margin: 0 0 18px; padding: 0; list-style: none; }
.results-list li { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; min-height: 43px; border-bottom: 1px solid var(--line); }
.results-list li > span { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; background: #e9e2d2; font-size: .75rem; }
.results-list em { color: #315942; font-size: .76rem; font-style: normal; font-weight: 800; }
.exchange-summary { margin: 0 0 18px; padding: 13px; border-radius: 11px; background: #edf4ef; }
.exchange-summary p { margin: 6px 0 0; color: #42564a; font-size: .78rem; line-height: 1.4; }

@media (max-height: 650px) {
  :root { --card-height: 86px; --card-width: 64px; }
  .game-screen { gap: 4px; grid-template-rows: auto auto minmax(88px, 1fr) auto auto auto minmax(104px, 1fr) auto; }
  .opponent { min-height: 49px; padding-block: 5px; }
  .pile-cards { min-height: 64px; }
  .pile-cards .playing-card { width: 47px; height: 64px; }
  .hand { height: calc(var(--card-height) + var(--card-selection-lift) + .4rem); }
  .game-screen.ce-game-screen {
    height: auto;
    min-height: 100dvh;
    gap: 8px;
    overflow: visible;
  }
  .ce-game-screen .hand {
    height: calc(var(--card-height) + var(--card-selection-lift) + .75rem);
    min-height: calc(var(--card-height) + var(--card-selection-lift) + .75rem);
  }
}
@media (max-width: 340px) {
  .screen { padding-left: max(9px, env(safe-area-inset-left)); padding-right: max(9px, env(safe-area-inset-right)); }
  .panel { padding: 16px; }
  .game-screen { gap: 4px; }
  .game-screen.ce-game-screen { gap: 8px; }
  .opponent { flex-basis: 82px; }
}
@media (max-width: 520px) {
  .mahjong-scoring-panel .section-heading { align-items: stretch; flex-direction: column; }
}
@media (min-width: 700px) {
  .screen:not(.game-screen) { padding-block: 40px; }
  .game-screen { border-inline: 1px solid rgb(255 255 255 / 10%); }
  .form-screen[data-screen="start-game"] { width: min(100%, 820px); }
  .game-options { grid-template-columns: 1fr 1fr; }
  .rules-choices { grid-template-columns: 1fr 1fr; }
  .mahjong-status { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .mahjong-centre { grid-template-columns: minmax(0, 1.6fr) minmax(180px, .5fr); }
  .mahjong-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .mahjong-hand .mahjong-tile { margin-right: 3px; }
  .mahjong-primary-actions { width: min(100%, 420px); align-self: center; }
}
@media (min-width: 900px) {
  .home-actions { grid-template-columns: 1fr 1fr; }
  .screen.game-screen { padding-inline: 24px; }
  .game-screen:not(.ce-game-screen) {
    width: min(100%, 840px);
    height: auto;
    min-height: 100dvh;
    grid-template-rows: auto auto minmax(118px, auto) auto auto auto minmax(132px, auto) auto;
    align-content: center;
    gap: 10px;
    overflow: visible;
  }
  .game-screen.ce-game-screen {
    width: min(100%, 960px);
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, .8fr);
    grid-template-areas:
      "header header"
      "opponents table"
      "status table"
      "decision decision"
      "hand hand"
      "primary primary"
      "secondary secondary";
    align-content: center;
    column-gap: 22px;
    row-gap: 12px;
  }
  .ce-game-screen > .game-header { grid-area: header; }
  .ce-game-screen > .opponents { grid-area: opponents; align-self: end; }
  .ce-game-screen > .ce-table { grid-area: table; }
  .ce-game-screen > .ce-status-region { grid-area: status; align-self: start; }
  .ce-game-screen > .ce-decision-panel { grid-area: decision; }
  .ce-game-screen > .hand-area { grid-area: hand; }
  .ce-game-screen > .ce-primary-actions { grid-area: primary; width: min(100%, 640px); justify-self: center; }
  .ce-game-screen > .ce-secondary-actions { grid-area: secondary; width: min(100%, 640px); justify-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
