:root {
  color-scheme: dark;
  font-family: 'Aptos', 'Segoe UI', system-ui, sans-serif;
  color: #fff8e8;
  background: #0f1737;
  --ink: #fff8e8;
  --muted: #c2d0ea;
  --navy: #131d42;
  --sun: #ffcf54;
  --hairline: #d6e4ff33;
  --red: #ed203a;
  --yellow: #ffd02b;
  --green: #0ca54b;
  --blue: #008ed4;
  --card-back-art: linear-gradient(150deg, #201a49 23%, #ff8332 23% 27%, #ffbd2f 27% 70%, #ff8332 70% 74%, #281c51 74%);
}

*, *::before, *::after { box-sizing: border-box; }
body { min-width: 280px; min-height: 100svh; margin: 0; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button:not(:disabled) { cursor: pointer; }
button:focus-visible { outline: 3px solid #fff196; outline-offset: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; white-space: nowrap; clip-path: inset(50%); }

.masthead, .game { width: min(100% - 34px, 1118px); margin-inline: auto; }
.masthead { min-height: 63px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wordmark { display: flex; align-items: center; gap: .18em; margin: 0; color: #fffaf2; font-size: clamp(1.35rem, 4.5vw, 2.05rem); line-height: 1; font-weight: 1000; font-style: italic; letter-spacing: -.085em; }
.wordmark strong { color: var(--sun); font-weight: inherit; }
.brand-mark { display: block; flex: 0 0 auto; width: clamp(41px, 7vw, 49px); height: auto; margin-right: 4px; filter: drop-shadow(0 4px 5px #090c328e); }

.header-actions, .hand-actions, .dialog-actions { display: flex; align-items: center; gap: 8px; }
.quiet-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 5px 11px; border: 1px solid var(--hairline); border-radius: 4px; background: transparent; color: var(--ink); font-size: .83rem; font-weight: 760; white-space: nowrap; }
.quiet-button:hover { background: #ffffff13; }
.header-actions { gap: 0; }
.header-actions > button + button::before { position: absolute; inset: 12px auto 12px 0; border-left: 1px solid var(--hairline); content: ''; }
.icon-button { position: relative; display: grid; width: 44px; height: 44px; place-items: center; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--ink); }
.icon-button:hover { background: #ffffff13; color: var(--sun); }
.question { display: grid; width: 20px; height: 20px; place-items: center; border: 1.5px solid currentColor; border-radius: 50%; font-size: .81rem; font-weight: 850; line-height: 1; }
.sound-icon { position: relative; display: block; width: 22px; height: 22px; }
.sound-icon::before, .sound-icon::after { position: absolute; content: ''; }
.sound-icon::before { top: 3px; left: 1px; width: 13px; height: 16px; clip-path: polygon(0 29%, 38% 29%, 100% 0, 100% 100%, 38% 71%, 0 71%); background: currentColor; }
.sound-icon::after { top: 4px; right: 1px; width: 11px; height: 14px; border-right: 2px solid currentColor; border-radius: 50%; }
.sound-button[aria-pressed='false'] .sound-icon { opacity: .72; }
.sound-button[aria-pressed='false'] .sound-icon::after { top: 10px; right: -1px; width: 10px; height: 2px; transform: rotate(-48deg); border: 0; border-radius: 1px; background: currentColor; }

.game { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.table { position: relative; overflow: clip; padding: 0 18px 8px; border: 1px solid var(--hairline); border-radius: 14px; background: linear-gradient(#10173570, #10173526 45%, #1017359e), url('./assets/venue.webp') center / 100% 100%, #172653; }
.table-topline { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-inline: 4px; border-bottom: 1px solid var(--hairline); text-shadow: 0 1px 4px #091332; }
.round-info { display: flex; align-items: baseline; gap: 9px; padding-left: 8px; border-left: 2px solid var(--sun); line-height: 1.15; }
#round { color: var(--ink); font-size: .87rem; font-style: italic; font-weight: 900; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; }
.target { color: var(--muted); font-size: .78rem; }
.restart-button { display: inline-flex; min-height: 44px; flex: 0 0 auto; align-items: center; gap: 5px; padding: 0 4px; border: 0; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 700; text-shadow: inherit; white-space: nowrap; }
.restart-button:hover { color: var(--sun); }
.restart-button:focus-visible { outline-offset: -2px; }
.restart-button > span { font-size: 1.2rem; line-height: 1; }

.arena { position: relative; display: grid; grid-template-columns: minmax(92px, 1fr) minmax(160px, 1.55fr) minmax(92px, 1fr); grid-template-rows: auto minmax(186px, 1fr) auto auto; grid-template-areas: '. north .' 'west center east' 'status status status' 'hand hand hand'; align-items: center; gap: 2px 6px; min-height: clamp(492px, 100svh - 132px, 710px); }
.arena::before, .arena::after { position: absolute; z-index: 0; pointer-events: none; content: ''; }
.arena::before { inset: 14% 10% 12%; border: 2px solid #7898cd96; border-radius: 49%; background: radial-gradient(ellipse at 50% 43%, transparent 20%, #0e194f9c 91%), url('./assets/felt.webp') center / cover, #203b84; box-shadow: 0 0 0 3px #141f4e, 0 7px 0 3px #203275, 0 16px 28px #080d37b8, inset 0 0 0 4px #263668, inset 0 0 22px #111d5485; }
.arena::after { inset: 21% 16% 19%; border: 1px solid #b1e6ff30; border-radius: 50%; }
.rivals { display: contents; }

.rival { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; isolation: isolate; }
.seat-west { grid-area: west; --seat-turn: -65deg; }
.seat-north { grid-area: north; --seat-turn: 180deg; align-self: start; justify-self: center; padding-top: 9px; }
.seat-east { grid-area: east; --seat-turn: 65deg; }
.rival-player { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.portrait { display: block; flex: 0 0 auto; width: 106px; height: 95px; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 5px 4px #10124782); user-select: none; }
.seat-north .rival-player { flex-direction: row; gap: 7px; }
.seat-north .portrait { width: 77px; height: 71px; }
.rival-details { display: grid; justify-items: center; gap: 3px; padding-top: 3px; line-height: 1.1; text-shadow: 0 1px 4px #091332; }
.seat-north .rival-details { justify-items: start; }
.rival-name { position: relative; font-size: 1rem; font-weight: 850; }
.rival-stats { display: flex; gap: 4px; color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rival-score::before { margin-right: 4px; content: '·'; }
.rival.playing .rival-name { color: var(--sun); }
.rival.playing .rival-name::before { position: absolute; top: .36em; left: -.75em; width: .33em; aspect-ratio: 1; transform: rotate(45deg); background: currentColor; content: ''; }
.rival.playing .rival-player { animation: seat-ready 250ms ease-out; }
.rival.one-card .rival-tally { color: var(--sun); font-weight: 850; }

.rival-fan { position: relative; display: grid; width: 94px; height: 43px; place-items: center; transform: rotate(var(--seat-turn)); pointer-events: none; }
.mini-card { position: absolute; width: 23px; height: 34px; border: 2px solid #fff4e7; border-radius: 4px; background: var(--card-back-art); box-shadow: 0 0 1px 1px #17185267; transform: translate(calc(var(--offset) * 8px), calc(var(--dip) * 1.5px)) rotate(calc(var(--offset) * 11deg)); }
@media (min-width: 731px) {
  .seat-west, .seat-east { flex-direction: row; gap: 2px; padding: 8px 4px; }
  .seat-west { justify-self: end; }
  .seat-east { justify-self: start; flex-direction: row-reverse; }
  .seat-west .rival-fan, .seat-east .rival-fan { margin-inline: -9px; }
}

.table-center { position: relative; z-index: 1; grid-area: center; display: grid; align-self: center; justify-items: center; gap: 7px; }
.piles { display: flex; align-items: start; justify-content: center; gap: clamp(16px, 4vw, 57px); }
.pile-wrap { display: grid; justify-items: center; gap: 7px; }
.draw-pile { margin-top: -12px; }
.discard-pile { margin-top: 9px; }
.pile-label { color: var(--ink); font-size: .71rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; text-shadow: 0 1px 4px #091332; white-space: nowrap; }
.discard { display: grid; position: relative; transform: rotate(7deg); }
.discard::before { position: absolute; inset: 1px; transform: rotate(-18deg); border: 1px solid #e7eeffc7; border-radius: 8px; background: #8ba8fa; box-shadow: 0 3px 6px #10184b8b; content: ''; }
.discard > .card { animation: dealt-in 215ms ease-out; }
.table-indicators { display: flex; min-height: 26px; align-items: center; gap: 9px; color: var(--ink); text-shadow: 0 1px 4px #091332; }
.direction { font-size: 1.3rem; line-height: 1; }
.color-tag { display: flex; align-items: center; gap: 6px; padding-left: 9px; border-left: 1px solid #d6e4ff59; font-size: .77rem; font-weight: 750; line-height: 1; }
.suit-red { --suit: var(--red); }
.suit-yellow { --suit: var(--yellow); }
.suit-green { --suit: #36d46d; }
.suit-blue { --suit: var(--blue); }
.suit-glyph { color: var(--suit); line-height: 1; -webkit-text-stroke: 1px #fff8e8a6; }

.card { --width: 98px; --face: #f9ecdb; --color-ink: #242355; position: relative; display: grid; flex: 0 0 auto; width: var(--width); aspect-ratio: 2 / 3; place-items: stretch; padding: 4px; border: 1px solid #fffefa; border-radius: 10px; background: #fffcf2; color: #fffdf3; box-shadow: 0 4px 7px #0909329c, 0 1px 0 #1a1849a3; isolation: isolate; user-select: none; }
.card-red { --face: var(--red); --color-ink: #d51833; }
.card-yellow { --face: var(--yellow); --color-ink: #966004; }
.card-green { --face: var(--green); --color-ink: #087e3a; }
.card-blue { --face: var(--blue); --color-ink: #0070af; }
.card-wild { --face: #151529; --color-ink: #151529; }
.face-art { position: relative; display: grid; place-items: center; overflow: hidden; border-radius: 6px; background: var(--face); }
.face-art::before { position: absolute; inset: 0; clip-path: polygon(0 36%, 100% 18%, 100% 64%, 0 82%); background: #fffdfa; content: ''; }
.card-glyph { position: relative; color: var(--color-ink); font-size: calc(var(--width) * .7); font-weight: 1000; line-height: .85; }
.card-glyph.flippable::after { position: absolute; right: 8%; bottom: -6%; left: 7%; height: max(1px, .048em); border-radius: 1em; background: currentColor; content: ''; }
.corner { position: absolute; z-index: 1; color: #fffefa; font-size: calc(var(--width) * .225); font-weight: 950; line-height: 1; text-shadow: 0 1px 2px #2611428c; }
.corner-top { top: 5%; left: 6%; }
.corner-bottom { right: 6%; bottom: 5%; transform: rotate(180deg); }
.face-suit { position: absolute; bottom: 6%; left: 8%; color: #fffefa; font-size: max(6px, calc(var(--width) * .09)); line-height: 1; }
.card-emblem { position: relative; display: grid; width: 58%; aspect-ratio: 1; place-items: center; color: var(--color-ink); }
.emblem-skip { width: 53%; border: max(2px, calc(var(--width) * .073)) solid currentColor; border-radius: 50%; }
.emblem-skip::after { width: 111%; height: max(2px, calc(var(--width) * .073)); transform: rotate(-43deg); background: currentColor; content: ''; }
.emblem-reverse::before, .emblem-reverse::after { position: absolute; width: 97%; height: 60%; clip-path: polygon(0 79%, 8% 52%, 21% 33%, 38% 23%, 56% 22%, 68% 27%, 71% 5%, 99% 57%, 58% 74%, 63% 52%, 54% 47%, 40% 47%, 28% 54%, 20% 67%, 15% 84%); background: currentColor; content: ''; }
.emblem-reverse::before { top: 0; transform: rotate(-17deg); }
.emblem-reverse::after { bottom: 0; transform: rotate(163deg); }
.emblem-tile { background: var(--color-ink); }
.emblem-draw2 .emblem-tile, .emblem-draw4 .emblem-tile { position: absolute; width: 46%; aspect-ratio: 2 / 3; border: max(1px, calc(var(--width) * .021)) solid #fffdf3; border-radius: 17%; box-shadow: 0 0 0 1px #21173345; }
.emblem-draw2 .emblem-tile:first-child { transform: translate(-27%, 12%) rotate(-21deg); }
.emblem-draw2 .emblem-tile:nth-child(2) { transform: translate(27%, -12%) rotate(8deg); }
.emblem-wild { width: 52%; grid-template-columns: repeat(2, 1fr); gap: 5%; transform: rotate(-17deg); overflow: hidden; border-radius: 44% 25%; }
.emblem-wild .emblem-tile { width: 100%; aspect-ratio: 1; }
.card-wild .emblem-tile:nth-child(1) { background: var(--red); }
.card-wild .emblem-tile:nth-child(2) { background: var(--yellow); }
.card-wild .emblem-tile:nth-child(3) { background: var(--green); }
.card-wild .emblem-tile:nth-child(4) { background: var(--blue); }
.emblem-draw4 .emblem-tile:nth-child(1) { transform: translate(-55%, 8%) rotate(-24deg); }
.emblem-draw4 .emblem-tile:nth-child(2) { transform: translate(-19%, -4%) rotate(-12deg); }
.emblem-draw4 .emblem-tile:nth-child(3) { transform: translate(19%, -9%) rotate(1deg); }
.emblem-draw4 .emblem-tile:nth-child(4) { transform: translate(55%, 3%) rotate(14deg); }
.card-back { place-items: center; transform: rotate(-9deg); border: 4px solid #fff6e8; background: repeating-linear-gradient(45deg, #ffffff15 0 1px, transparent 1px 5px), var(--card-back-art); box-shadow: 1px 1px 0 #20265e, 3px 3px 0 #ede9fb, 4px 4px 0 #242669, 6px 6px 0 #fbeff9, 0 8px 14px #0d124d9c; }
.card-back::before { position: absolute; inset: 4px; border: 1px solid #fffcdeab; border-radius: 5px; content: ''; }
.card-back-mark { display: grid; min-width: 71%; aspect-ratio: 2.25; place-items: center; clip-path: polygon(11% 0, 100% 0, 90% 100%, 0 100%); background: #251949; color: #fff8e8; transform: rotate(-14deg); font-size: calc(var(--width) * .26); font-style: italic; font-weight: 1000; line-height: 1; }
.card-back:not(:disabled):hover { transform: translateY(-5px) rotate(-12deg); filter: brightness(1.14); }
.card-back:disabled { filter: brightness(.83); }
.card-flight { --width: 74px; position: fixed; z-index: 4; transform: none; pointer-events: none; }

.table-status { z-index: 1; display: grid; grid-area: status; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; justify-items: center; align-content: center; gap: 3px 10px; width: min(100%, 340px); min-height: 50px; margin: 0 auto 2px; padding: 4px 6px; color: var(--ink); text-align: center; text-shadow: 0 1px 4px #091332; }
.table-status strong { grid-area: 1 / 2; font-size: .88rem; font-style: italic; font-weight: 900; letter-spacing: .09em; line-height: 1; text-transform: uppercase; }
.table-status::before, .table-status::after { grid-row: 1; width: 100%; border-top: 1px solid #d6e4ff55; content: ''; }
.table-status::before { grid-column: 1; }
.table-status::after { grid-column: 3; }
.table-status span { grid-area: 2 / 1 / 3 / -1; min-height: 2.5em; display: grid; place-items: start center; color: var(--muted); font-size: .8rem; line-height: 1.25; }
.table[data-human-turn='true'] .table-status strong { color: var(--sun); }
.table[data-human-turn='true'] .table-status::before, .table[data-human-turn='true'] .table-status::after { border-color: #ffcf5477; }

.hand-panel { position: relative; z-index: 1; display: grid; grid-area: hand; align-content: end; align-self: end; width: min(100%, 760px); min-width: 0; margin-inline: auto; }
.hand-panel::before { position: absolute; z-index: -1; inset: 16px 0 -36px; border: 1px solid #a2b8e574; border-radius: 50% 50% 0 0 / 28px 28px 0 0; background: var(--navy); box-shadow: 0 -4px 14px #10173555; content: ''; }
.table[data-human-turn='true'] .hand-panel::before { border-color: #ffcf5499; }
.hand-topline { display: flex; justify-content: space-between; align-items: end; gap: 9px; padding-inline: clamp(7px, 3.5vw, 30px); }
.hand-info { display: flex; align-items: end; gap: 6px; color: var(--ink); }
.player-portrait { width: 70px; height: 66px; }
.hand-info > div { padding-bottom: 3px; }
.hand-info h2 { margin: 0; font-size: 1.04rem; font-weight: 850; line-height: 1; }
.hand-info p { margin: 3px 0 0; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hand-separator { margin-inline: 4px; }
.primary-button { min-height: 44px; padding: 6px 15px; border: 0; border-radius: 4px; color: #211837; background: var(--sun); font-weight: 850; }
.primary-button:hover { background: #ffe28d; }
.duo-button { --duo-face: var(--sun); --duo-edge: #a86825; position: relative; isolation: isolate; min-height: 44px; padding: 4px 16px 7px; border: 0; border-radius: 4px; background: transparent; color: #211837; font-size: 1.29rem; font-style: italic; font-weight: 950; letter-spacing: -.055em; line-height: 1; }
.duo-button::before { position: absolute; z-index: -1; inset: 2px 5px 4px; transform: skewX(-11deg); border-radius: 4px; background: var(--duo-face); box-shadow: 0 3px var(--duo-edge); content: ''; }
.duo-button:not(:disabled):hover { --duo-face: #ffe28d; }
.duo-button:not(:disabled):active::before { transform: translateY(2px) skewX(-11deg); box-shadow: 0 1px var(--duo-edge); }
.duo-button:disabled { --duo-face: #283459; --duo-edge: #0b122c; color: #adb9d5; }
.duo-button[data-called='true'] { --duo-face: #245149; --duo-edge: #102e32; color: #c6f7df; }
.hand-scroll { overflow-x: auto; overflow-y: hidden; scrollbar-color: #879afb #2f3280; scrollbar-width: thin; overscroll-behavior-inline: contain; }
.hand { display: flex; width: max-content; min-width: 100%; min-height: 126px; align-items: center; justify-content: center; padding: 9px 17px 22px; }
.hand .card { --width: clamp(59px, 7vw, 79px); transform: translateY(var(--drop, 0px)) rotate(var(--tilt, 0deg)); transform-origin: 50% 80%; transition: transform 140ms ease, filter 140ms ease; }
.hand .card + .card { margin-inline-start: -15px; }
.hand .card[aria-disabled='true'] { cursor: default; filter: saturate(.91) brightness(.85); }
.table[data-human-turn='false'] .hand .card { filter: saturate(.79) brightness(.79); }
.hand .card[aria-disabled='false'] { transform: translateY(calc(var(--drop, 0px) - 3px)) rotate(var(--tilt, 0deg)); }
.hand .card[aria-disabled='false']:is(:focus-visible, :hover), .hand .new-card { z-index: 1; transform: translateY(calc(var(--drop, 0px) - 10px)) rotate(var(--tilt, 0deg)); }
.hand .new-card { outline: 2px solid var(--sun); outline-offset: 2px; }
@media (hover: none) { .hand .card[aria-disabled='false']:hover:not(:focus-visible, .new-card) { transform: translateY(calc(var(--drop, 0px) - 3px)) rotate(var(--tilt, 0deg)); } }

.dialog { width: min(100% - 24px, 448px); max-height: calc(100% - 24px); padding: 24px; border: 1px solid var(--hairline); border-top: 2px solid var(--sun); border-radius: 8px; background: var(--navy); color: var(--ink); box-shadow: 0 16px 48px #090c23bd; }
.dialog::backdrop { background: #090e26c9; }
.dialog h2 { margin: 0 26px 9px 0; font-size: 1.55rem; letter-spacing: -.035em; }
.dialog p, .rules-list { margin: 0 0 15px; color: #e9ecff; line-height: 1.45; }
.rules-list { display: grid; gap: 9px; padding-inline-start: 19px; }
.rules-list strong { color: var(--ink); }
.close-button { position: absolute; top: 11px; right: 11px; width: 44px; height: 44px; border: 0; border-radius: 4px; background: transparent; font-size: 1.4rem; line-height: 1; }
.close-button:hover { background: #ffffff13; color: var(--sun); }
.dialog-actions { justify-content: end; }
.color-picker {
  width: min(100% - 22px, 476px);
  padding: clamp(14px, 4vw, 24px);
}
.color-picker[open] { animation: picker-in 190ms ease-out; }
.color-picker-header { display: flex; min-height: 76px; align-items: center; gap: 14px; padding-inline-end: 41px; }
.wild-preview { flex: 0 0 auto; width: clamp(44px, 13vw, 57px); margin-inline-start: 2px; }
.wild-preview .card { --width: clamp(42px, 12vw, 54px); transform: rotate(-10deg); }
.color-picker .wild-label { margin: 0 0 2px; color: var(--sun); font-size: .8rem; font-weight: 850; line-height: 1.2; }
.color-picker h2 { margin: 0; color: #fff9ea; font-size: clamp(1.28rem, 5.2vw, 1.95rem); font-style: italic; font-weight: 950; line-height: 1.05; }
.color-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(4px, 2vw, 12px); margin-top: 16px; padding: 13px 0 1px; border-top: 1px solid #98a9ff3d; }
.color-option { --tilt: 0deg; display: grid; min-width: 0; grid-template-rows: 1fr auto; justify-items: center; gap: 9px; padding: 6px 2px 4px; border: 0; border-radius: 9px; background: transparent; color: #fff8ea; font-size: .9rem; font-weight: 850; }
.color-option:nth-child(1) { --tilt: -7deg; }
.color-option:nth-child(2) { --tilt: -3deg; }
.color-option:nth-child(3) { --tilt: 3deg; }
.color-option:nth-child(4) { --tilt: 7deg; }
.palette-card { --width: clamp(46px, 17.5vw, 85px); width: min(100%, var(--width)); transform: rotate(var(--tilt)); transition: transform 150ms ease-out, filter 150ms ease-out; }
.palette-glyph { position: relative; color: var(--color-ink); font-size: calc(var(--width) * .46); line-height: 1; }
.palette-card .corner { font-size: calc(var(--width) * .16); }
.color-option-label { white-space: nowrap; }
.color-option:focus-visible { z-index: 1; outline-offset: 2px; }
.color-option:is(:hover, :focus-visible) .palette-card { z-index: 1; transform: translateY(-6px) rotate(0deg); filter: brightness(1.1); }
.color-option:active .palette-card { transform: translateY(-2px) rotate(0deg) scale(.96); }
.result-dialog { text-align: center; }
.result-dialog h2 { margin-right: 0; }
.result-star { color: var(--sun); font-size: 2.8rem; line-height: 1.2; }
.result-scores { display: grid; gap: 5px; margin: 0 0 16px; padding: 0; list-style: none; }
.result-score { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 6px; background: #dedfff13; }

@keyframes dealt-in { from { opacity: .3; transform: translateY(-9px) rotate(-7deg) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes seat-ready { 45% { transform: translateY(-4px) scale(1.035); } }
@keyframes picker-in { from { opacity: .65; transform: translateY(9px) scale(.975); } to { opacity: 1; transform: none; } }

@media (max-width: 730px) {
  .masthead, .game { width: min(100% - 18px, 1118px); }
  .masthead { min-height: 57px; }
  .table { padding: 0 9px 5px; }
  .arena { grid-template-columns: minmax(58px, 1fr) minmax(133px, 1.48fr) minmax(58px, 1fr); min-height: clamp(488px, 100svh - 132px, 720px); }
  .arena::before { inset: 13% 3% 13%; }
  .arena::after { inset: 19% 8% 19%; }
  .rival-stats { gap: 3px; font-size: .68rem; }
  .rival-score::before { margin-right: 3px; }
  .rival-fan { --seat-turn: -18deg; width: 61px; height: 38px; }
  .seat-east .rival-fan { --seat-turn: 18deg; }
  .seat-north .rival-fan { --seat-turn: 180deg; }
  .mini-card { width: 19px; height: 28px; transform: translate(calc(var(--offset) * 6px), calc(var(--dip) * 1.3px)) rotate(calc(var(--offset) * 12deg)); }
  .portrait { width: 72px; height: 69px; }
  .seat-north .portrait { width: 68px; height: 63px; }
  .piles .card { --width: 75px; }
  .player-portrait { width: 61px; height: 59px; }
}

@media (max-width: 460px) {
  .masthead { min-height: 53px; }
  .quiet-button { padding-inline: 7px; font-size: .77rem; }
  .round-info { gap: 7px; }
  .arena { gap: 3px 3px; grid-template-rows: auto minmax(161px, 1fr) auto auto; }
  .arena::before { inset: 12% 0 15%; border-radius: 46%; }
  .portrait { width: clamp(54px, 16vw, 69px); height: clamp(53px, 16vw, 68px); }
  .rival-name { font-size: .9rem; }
  .piles { gap: 13px; }
  .piles .card { --width: clamp(53px, 15vw, 70px); }
  .pile-label { font-size: .63rem; letter-spacing: .035em; }
  .card { padding: 3px; border-radius: 7px; }
  .face-art { border-radius: 4px; }
  .card-back { border-width: 3px; }
  .hand { min-height: 100px; padding-inline: 12px; }
  .hand .card { --width: clamp(43px, 14vw, 62px); }
  .hand .card + .card { margin-inline-start: -13px; }
  .player-portrait { width: 57px; height: 55px; }
  .hand-actions { gap: 4px; }
}

@media (max-width: 340px) {
  .table { padding-inline: 5px; }
  .arena { grid-template-columns: minmax(54px, 1fr) minmax(126px, 1.48fr) minmax(54px, 1fr); }
  .round-info { gap: 5px; padding-left: 5px; }
  #round, .target, .restart-button { font-size: .72rem; }
  .rival-stats { display: grid; justify-items: center; gap: 1px; }
  .rival-score::before { content: none; }
  .seat-north .rival-stats { display: flex; }
  .seat-north .rival-score::before { content: '·'; }
  .rival-fan { width: 51px; }
  .hand-topline { padding-inline: 5px; }
}

@media (max-height: 700px) and (min-width: 731px) {
  .masthead { min-height: 53px; }
  .arena { min-height: 477px; }
  .piles .card { --width: 85px; }
  .hand { min-height: 105px; padding-block: 5px 13px; }
  .hand .card { --width: 68px; }
}

@media (orientation: portrait) and (max-width: 900px) {
  body { display: flex; min-height: 100dvh; flex-direction: column; }
  .masthead {
    width: 100%;
    min-height: calc(53px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--hairline);
  }
  .game { display: grid; flex: 1; width: 100%; padding: 0; }
  .table {
    display: grid;
    grid-template-rows: auto 1fr;
    padding: 0 max(8px, env(safe-area-inset-right)) max(3px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
    background: linear-gradient(180deg, #0b163b91, #10265545 43%, #10193787 75%, #0c173f9c), url('./assets/portrait-table.webp') center / 100% 100%, #173d8d;
  }
  .arena {
    grid-template-columns: minmax(54px, .65fr) minmax(126px, 1.45fr) minmax(54px, .65fr);
    grid-template-rows: auto minmax(151px, 1fr) auto auto;
    gap: 3px;
    min-height: 0;
  }
  .arena::before, .arena::after { content: none; }
  .seat-west, .seat-east { justify-self: stretch; flex-direction: column; padding: 0; }
  .seat-west .rival-fan, .seat-east .rival-fan { margin-inline: 0; }
  .seat-west .rival-fan { --seat-turn: -18deg; }
  .seat-east .rival-fan { --seat-turn: 18deg; }
  .piles { gap: clamp(10px, 3vw, 20px); }
  .piles .card { --width: clamp(48px, 16vw, 91px); }
  .draw-pile { margin-top: -16px; }
  .discard-pile { margin-top: 11px; }
  .table-center { gap: 9px; }
  .hand-panel { width: min(100%, 620px); }
  .hand-panel::before {
    inset: 10px -10px -25px;
  }
  .hand-topline { padding-inline: max(4px, 3vw); }
  .hand { min-height: 104px; padding: 8px 13px 17px; }
  .hand .card { --width: clamp(43px, 14.35vw, 77px); }
  .hand .card + .card { margin-inline-start: -14px; }
}

@media (orientation: portrait) and (max-width: 460px) and (max-height: 630px) {
  .seat-north .portrait { width: 59px; height: 55px; }
  .rival-fan { height: 33px; }
  .player-portrait { width: 49px; height: 48px; }
  .hand { min-height: 94px; padding-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .discard > .card, .rival.playing .rival-player, .color-picker[open] { animation: none; }
  .hand .card, .palette-card { transition: none; }
}
