:root {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #193e34;
  background: #f4efe2;
  font-synthesis: none;
  --ink: #193e34;
  --muted: #5f6c5e;
  --line: #dcd3bc;
  --paper: #fbf8ef;
  --accent: #ab4838;
  --gold: #e8bf76;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-width: 320px;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .44; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid #b97e3c; outline-offset: 3px; }

.masthead { padding-top: env(safe-area-inset-top, 0px); border-bottom: 1px solid var(--line); }
.topbar, .shell { width: min(1120px, calc(100% - 72px)); margin: auto; }
.topbar { min-height: 80px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark, .entry-icon {
  display: grid; place-items: center; width: 39px; height: 39px; border-radius: 12px;
  background: var(--ink); color: #f8ecd1; font: 27px Georgia, serif;
}
.brand strong { font-size: 16px; letter-spacing: .06em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.header-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 10px; }
.languages { display: flex; padding: 2px; border-radius: 20px; border: 1px solid var(--line); }
.languages button {
  min-height: 26px; padding: 0 8px; border: 0; border-radius: 20px;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 650;
}
.languages button[aria-pressed="true"] { color: var(--paper); background: var(--ink); }
.sort-control {
  position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 32px;
  cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap;
}
.sort-control input { position: absolute; right: 0; width: 36px; height: 24px; min-height: 0; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.sort-track { position: relative; width: 36px; height: 22px; border: 1px solid #c6c6ad; border-radius: 30px; background: #e4dfcf; pointer-events: none; }
.sort-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fffdf5; box-shadow: 0 1px 3px #44351f40; transition: transform .15s; }
.sort-control input:checked + .sort-track { border-color: var(--ink); background: var(--ink); }
.sort-control input:checked + .sort-track::after { transform: translateX(14px); }
.sort-control input:focus-visible + .sort-track { outline: 2px solid #b97e3c; outline-offset: 3px; }

.lobby { display: grid; grid-template-columns: 1.25fr 1fr; gap: 46px; padding: 52px 0 48px; align-items: start; }
.intro { min-width: 0; }
h1, h2, p { margin: 0; }
.intro h1 {
  font-family: "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
  font-size: clamp(3.25rem, 6.8vw, 6.5rem);
  font-weight: 900; line-height: .94; letter-spacing: -.065em;
}
:lang(en) .intro h1 { font-family: Georgia, serif; font-size: clamp(2.7rem, 6.2vw, 6rem); }
.intro-subtitle { margin-top: 10px; color: var(--muted); font-size: 15px; font-weight: 650; letter-spacing: .08em; }

.showcase, .felt {
  position: relative; isolation: isolate;
  background:
    radial-gradient(ellipse at 50% 20%, #43715a 0%, transparent 65%),
    repeating-linear-gradient(125deg, #ffffff06 0px 1px, transparent 1px 4px),
    #214d3d;
}
.showcase {
  margin-top: 18px; height: 240px; border-radius: 22px; overflow: hidden;
  border: 1px solid #1b4235; box-shadow: inset 0 0 22px #061e1555;
}
.showcase-rail, .felt-rail { position: absolute; inset: 10px; border: 1px solid #efd6a653; border-radius: inherit; pointer-events: none; z-index: -1; }
.fan { position: absolute; inset: 0; display: grid; place-items: center; transform: translateY(9px); }
.art-card {
  grid-area: 1/1; position: relative; display: grid; place-items: center; width: 103px; height: 145px;
  border-radius: 10px; background: #fbf4e4; color: #204738; font-family: Georgia, serif;
  border: 1px solid #eddab3; box-shadow: 0 7px 12px #061e1577;
}
.art-card::before { content: ""; position: absolute; inset: 6px; border: 1px solid currentColor; opacity: .18; border-radius: 6px; }
.art-card b { font-size: 64px; font-weight: 400; }
.art-card span { position: absolute; top: 10px; left: 11px; font-size: 18px; line-height: 1; font-weight: 700; }
.art-card span small { display: block; font-size: 15px; text-align: center; }
.art-card .corner-bottom { inset: auto 11px 10px auto; transform: rotate(180deg); }
.art-diamond { transform: translate(-72px, 13px) rotate(-22deg); color: var(--accent); }
.art-spade { transform: translate(-6px, -7px) rotate(-6deg); }
.art-heart { transform: translate(64px, 12px) rotate(19deg); color: var(--accent); }
.showcase-suits { position: absolute; right: 21px; bottom: 15px; color: #e3d2a8a0; font: 13px Georgia, serif; }

.entry { background: var(--paper); padding: clamp(25px, 4vw, 44px); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 13px 34px #5343260d; }
.entry-icon { margin-bottom: 17px; background: #efe5cb; color: var(--ink); width: 36px; height: 36px; font-size: 22px; }
.entry h2 { font-size: 29px; letter-spacing: -.025em; }
.entry-lead { margin: 7px 0 25px; color: var(--muted); font-size: 14px; }
.entry label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.access-shell { width: min(420px, calc(100% - 32px)); margin: clamp(32px, 9vh, 96px) auto; }
.access-shell h1 { margin-bottom: 24px; font-size: 28px; }
#access-error { margin-top: 10px; color: var(--accent); font-size: 14px; }
.avatar-field { container-type: inline-size; min-inline-size: 0; margin: 15px 0 3px; padding: 0; border: 0; }
.avatar-field legend { margin-bottom: 7px; padding: 0; font-size: 13px; font-weight: 700; }
.avatar-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
@container (min-width: 294px) {
  .avatar-picker { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.entry .avatar-option { position: relative; margin: 0; cursor: pointer; }
.avatar-option input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; clip-path: inset(50%); }
.avatar-tile {
  display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 50px;
  border: 1px solid var(--line); border-radius: 8px; background: #fffdf7;
  color: var(--muted); font-size: 10px; line-height: 1.2; text-align: center;
}
.avatar-icon { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.avatar-tile .avatar-icon { font-size: 21px; line-height: 1; }
.avatar-option input:checked + .avatar-tile { border-color: #41634f; background: #e8eddb; color: var(--ink); box-shadow: inset 0 0 0 1px #41634f; }
.avatar-option input:focus-visible + .avatar-tile { outline: 2px solid #b97e3c; outline-offset: 2px; }
input { min-width: 0; width: 100%; min-height: 47px; padding: 0 12px; border: 1px solid #d5cbb3; border-radius: 9px; background: #fffdf7; color: var(--ink); font-size: 15px; }
input::placeholder { color: #76766a; }
#room-code { letter-spacing: .1em; }
#room-code::placeholder { letter-spacing: normal; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 43px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; font-size: 14px;
  font-weight: 750; white-space: nowrap; transition: filter .15s, transform .15s;
}
.button:not(:disabled):hover { filter: brightness(1.1); }
.button:not(:disabled):active { transform: translateY(1px); }
.primary { background: #1c4b3b; color: #fff9e8; }
.secondary { background: #f1ead8; border-color: #d9ceb5; color: var(--ink); }
.full { width: 100%; justify-content: space-between; margin-top: 12px; min-height: 48px; }
.full span { font-size: 19px; }
.divider { text-align: center; display: flex; align-items: center; gap: 10px; margin: 23px 0 17px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: #e1d9c4; }
.join-row { display: flex; gap: 8px; }
.join-row .button { min-width: 64px; }

.room { padding: 25px 0 30px; }
#room-label { font-family: ui-monospace, monospace; letter-spacing: .08em; }
.room-tags, .room-links { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.room-links { justify-content: flex-end; }
.room-links .button { font-size: 12px; min-height: 32px; padding: 0 9px; }
.felt {
  display: grid; grid-template: auto auto auto minmax(100px, 1fr) auto auto auto / minmax(0, 1fr) minmax(165px, 1.75fr) minmax(0, 1fr);
  gap: 8px 10px; min-height: 837px; padding: 20px clamp(15px, 3vw, 32px) 24px;
  outline: 1px solid #193b30; border-radius: 23px; box-shadow: inset 0 0 35px #102f2466;
  color: #fff5d9;
  --card-w: 46px; --card-step: 28px; --card-height: 60px;
}
.table-content { display: contents; }
.table-top { grid-area: 1 / 1 / 2 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center; }
.round-tag { font-size: 12px; font-weight: 700; padding: 6px 9px; border-radius: 24px; color: #fff0ce; background: #0d302487; white-space: nowrap; }
.multiplier { text-align: center; color: var(--gold); }
.bottom-pack { display: flex; gap: 4px; align-items: center; --reserve-width: 36px; --reserve-height: 48px; }
.bottom-pack i {
  width: var(--reserve-width); height: var(--reserve-height); border-radius: 5px; border: 1px solid #d7c699;
  background: repeating-linear-gradient(135deg, #526b50 0 2px, #31543c 2px 4px);
}
.bottom-pack .card { width: var(--reserve-width); height: var(--reserve-height); border-radius: 5px; }
.bottom-pack .card-corner { font-size: 15px; padding: 4px; }
.bottom-pack .joker .card-corner { font-size: 6px; }

.seat {
  display: flex; gap: 8px; align-items: center; justify-self: start; min-width: 0; max-width: 100%;
  padding: 7px; border: 1px solid #f8edc335; border-radius: 11px; background: #143b30;
}
.seat.left { grid-area: 2 / 1; align-self: start; }
.seat.right { grid-area: 2 / 3; justify-self: end; align-self: start; }
.seat.bottom { grid-area: 6 / 2; justify-self: center; align-self: end; }
.seat.playing {
  position: relative; z-index: 1; transform: scale(1.5); max-width: calc(100% / 1.5);
  border-color: #ff766c; box-shadow: 0 0 0 2px #ed5a4f80;
}
.seat.left.playing { transform-origin: left top; margin-bottom: 38px; }
.seat.right.playing { transform-origin: right top; margin-bottom: 38px; }
.seat.bottom.playing { transform-origin: center bottom; margin-top: 38px; }
.seat.playing.overtime { animation: overtime-border 1s ease-in-out infinite alternate; }
@keyframes overtime-border {
  to { border-color: #97352f; box-shadow: 0 0 0 2px #ed5a4f15; }
}
.turn-clock { display: inline-block; margin-top: 3px; color: #ffb2a9; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.seat.empty { background: #1d4232a0; }
.add-bot { min-height: 44px; color: inherit; text-align: left; border-style: dashed; }
.add-bot:not(:disabled):hover { border-color: var(--gold); background: #315645; }
.remove-bot {
  flex: 0 0 auto; min-width: 36px; min-height: 36px; padding: 0;
  border: 1px solid #efd6a653; border-radius: 8px; background: transparent; color: #fff5d9; font-size: 17px;
}
.remove-bot:not(:disabled):hover { background: #ffffff20; }
.avatar { display: grid; place-items: center; width: 33px; height: 33px; flex: 0 0 33px; border-radius: 8px; background: #ebdfba; color: #335644; font-size: 15px; font-weight: 800; }
.avatar.avatar-icon { font-size: 21px; }
.empty .avatar { background: #ffffff20; color: #e9e0c2; }
.seat-meta { min-width: 0; }
.seat-name { display: flex; gap: 4px; align-items: center; }
.seat strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.seat-name span { font-size: 10px; color: #ebcf90; white-space: nowrap; }
.seat small { display: block; margin-top: 3px; color: #ded9be; font-size: 11px; }
.role { padding: 3px 4px; border-radius: 4px; background: #ced9bc; color: #1c4b3b; font-size: 10px; font-weight: 750; white-space: nowrap; }
.role.landlord { background: #efc286; color: #733d22; }
.table-status { grid-area: 4 / 2; align-self: center; text-align: center; padding: 15px 4px; min-width: 0; }
.table-status strong, .table-status > span { display: block; overflow-wrap: anywhere; }
.table-status > strong { font-size: clamp(1.15rem, 3vw, 2rem); font-weight: 800; }
.table-status > span { margin-top: 7px; color: #f1e4c2; font-size: 13px; line-height: 1.5; }
.table-status .button { margin-top: 14px; }
.gold { background: #e9c580; color: #302922; }
.waiting-line { opacity: .95; }
.score-list { list-style: none; padding: 0; margin: 9px auto 0; max-width: 260px; font-size: 13px; }
.score-list li { display: flex; justify-content: space-between; padding: 5px 8px; gap: 10px; border-bottom: 1px solid #e9dfb540; }
.score-list li span { overflow-wrap: anywhere; text-align: left; }
.score-list strong.gain { color: #f5d78d; }

.move { min-width: 0; align-self: start; text-align: center; }
.move.left { grid-area: 4 / 1; }
.move.right { grid-area: 4 / 3; }
.move.bottom { grid-area: 5 / 1 / 6 / -1; }
.move-label { display: inline-block; padding: 3px 8px; color: #fff0ce; font-size: 11px; border-radius: 20px; background: #153e31; }
.target .move-label { color: #513a24; background: #edd5a0; }
.played-cards { display: flex; flex-wrap: wrap; justify-content: center; row-gap: 5px; margin-top: 5px; padding-inline: calc(var(--card-w) - var(--card-step)); }
.side-cards { display: flex; flex-wrap: wrap; row-gap: 4px; min-width: 0; }
.side-cards.left { grid-area: 3 / 1; }
.side-cards.right { grid-area: 3 / 3; justify-content: flex-end; }
.side-cards.revealed { padding-inline: calc(var(--card-w) - var(--card-step)); }
.side-cards .card-back {
  width: var(--card-height); height: var(--card-w); border-radius: 6px; border: 1px solid #e2d2a3;
  background: repeating-linear-gradient(135deg, #57745a 0 3px, #294c3a 3px 6px);
}
.side-cards .card-back + .card-back { margin-left: calc(6px - var(--card-height)); }

.room-chat {
  --chat-height: 146px;
  --chat-input-height: 32px;
  position: relative; grid-area: 6 / 3; align-self: end; justify-self: end;
  display: flex; flex-direction: column; justify-content: flex-end;
  width: min(100%, 234px); min-width: 0; height: var(--chat-height); pointer-events: none;
}
.chat-log {
  position: absolute; z-index: -1; inset-inline: 0; bottom: calc(var(--chat-input-height) + 4px);
  max-height: calc(2 * var(--chat-height) - var(--chat-input-height) - 4px);
  display: flex; flex-direction: column; justify-content: flex-end; justify-content: unsafe flex-end;
  overflow: hidden; overflow: clip; text-align: right; overflow-wrap: anywhere;
  padding-top: 10px; mask-image: linear-gradient(to bottom, transparent, #000 10px);
  font-size: 12px; line-height: 1.4; text-shadow: 0 1px 3px #102a20;
}
.chat-log p { flex: none; }
.chat-log p + p { margin-top: 4px; }
.chat-log strong { margin-right: 3px; color: var(--gold); }
.chat-form { display: flex; gap: 4px; min-width: 0; pointer-events: auto; }
.chat-form input {
  min-height: var(--chat-input-height); padding: 0 6px; border-radius: 6px; font-size: 14px;
  color: inherit; background: transparent; border-color: #f1e4c290; text-align: right;
}
.chat-form input::placeholder { color: #f1e4c2; }
.chat-form .button { min-height: var(--chat-input-height); padding: 0 7px; border-radius: 6px; font-size: 12px; }

#hand-area { grid-area: 7 / 1 / 8 / -1; min-width: 0; padding: 14px clamp(12px, 2vw, 22px); border-top: 1px solid #efd6a653; }
.hand-heading { display: flex; justify-content: space-between; gap: 5px; align-items: center; margin-bottom: 6px; }
.hand-heading strong { font-size: 14px; }
.hand-heading span, .hand-heading small { margin-left: 9px; font-size: 12px; color: #f1e4c2; }
.hand-heading small { text-align: right; }
.hand-cards {
  display: flex; flex-wrap: wrap; justify-content: center; row-gap: 11px; padding: 12px 10px 0;
  -webkit-user-select: none; user-select: none;
}
.card {
  position: relative; isolation: isolate; display: inline-block; vertical-align: top; flex-shrink: 0;
  border: 1px solid #c9c4b4; border-radius: 8px; color: #1f3730; background: #fffdf5;
  padding: 0; box-shadow: 0 2px 3px #163b291e;
}
.card.red { color: #a33732; }
.card-corner { display: block; position: relative; padding: 4px 0 0 4px; text-align: left; font: 700 18px/1 Georgia, serif; z-index: 1; }
.card-corner small { display: block; width: 12px; text-align: center; font: inherit; font-size: .95em; line-height: .9; }
.joker .card-corner {
  writing-mode: vertical-rl; text-orientation: upright; white-space: nowrap;
  font: 800 8px/1 -apple-system, sans-serif; letter-spacing: -.07em;
}
:is(.hand-cards, .played-cards, .side-cards.revealed) .card { width: var(--card-w); height: var(--card-height); text-align: left; }
:is(.hand-cards, .played-cards, .side-cards.revealed) .card + .card { margin-left: calc(var(--card-step) - var(--card-w)); }
:is(.hand-cards, .played-cards, .side-cards.revealed) .card-corner { position: absolute; top: 0; left: 0; }
.hand-cards button.card { transition: transform .12s, background-color .12s; }
.hand-cards button.selected { transform: translateY(-10px); border-color: #bc823f; background: #f8e8bd; }
.hand-cards button:focus-visible { z-index: 2; }
@media (hover: hover) {
  .hand-cards button:not(.selected):hover { transform: translateY(-4px); }
}
.actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions .button { min-width: 75px; }
.actions [data-action="bid"][data-value="1"] { background: #f6e1ac; color: #302418; }
.actions [data-action="bid"][data-value="2"] { background: #edbf68; color: #302418; }
.actions [data-action="bid"][data-value="3"] { background: #d9923f; color: #302418; }
.actions [data-action="pass"] { background: #f1e5cf; border-color: #d9c7a8; color: #41362c; }
.actions .play-button { min-width: 105px; background: #edbf68; border-color: #d9a44c; color: #302418; }
.actions [data-action="recommend"] { background: #d9e8f5; border-color: #b9cfe2; color: #24445d; }
.actions [data-action="clearSelection"] { background: #f3d9d2; border-color: #dfb8af; color: #633d35; }
.bomb-effect { position: absolute; pointer-events: none; z-index: 2; inset: 25% 0 auto; display: grid; place-items: center; }
.bomb-effect span {
  display: grid; place-items: center; min-width: 106px; min-height: 66px; padding: 0 14px;
  color: #563321; background: #ffc76e; border: 3px solid #ffe4a7; border-radius: 50%;
  font-size: 24px; font-weight: 800; box-shadow: 0 0 35px #ffb654; animation: bomb-burst .55s ease-out both;
}
@keyframes bomb-burst {
  0% { opacity: 0; transform: scale(.45); }
  22% { opacity: 1; transform: scale(1.18); }
  55% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.12); }
}

.history { min-width: 0; padding: 20px 0 28px; border-top: 1px solid var(--line); }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.history-heading h2 { font-size: 22px; }
.history-heading .button { font-size: 13px; }
.history-status { padding: 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--paper); }
.history-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.history-table table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.history-table th, .history-table td { padding: 8px 13px; border-bottom: 1px solid var(--line); text-align: center; }
.history-table thead th { min-width: 90px; max-width: 11rem; color: var(--muted); overflow-wrap: anywhere; }
.history-table thead th:first-child, .history-table tfoot th, .history-table .history-date { text-align: left; white-space: nowrap; }
.history-table .history-date { background: #efe8d6; font-weight: 650; vertical-align: top; padding-block: 17px; }
.history-table tfoot th, .history-table tfoot td { padding-block: 12px; border-bottom: 0; background: #e7eddf; font-weight: 750; }
.history-delete { min-height: 36px; padding: 0 9px; border: 1px solid #dfc0b6; border-radius: 7px; background: transparent; color: #8c392f; font-size: 12px; }
.history-delete:hover { background: #f4e3db; }
.history-table:focus-visible { outline: 2px solid #b97e3c; outline-offset: 3px; }
.monitor { padding-block: 24px; }
.monitor-heading, .monitor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.monitor-heading { justify-content: space-between; margin-bottom: 14px; }
.monitor-actions a { text-decoration: none; }
.monitor .history-status { margin-bottom: 10px; }
.monitor table { white-space: nowrap; }
.monitor td:first-child { font-family: ui-monospace, monospace; }
.monitor-online { color: #23704c; font-weight: 750; }
.feedback {
  position: fixed; z-index: 5; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 28px); padding: 11px 15px; border-radius: 9px;
  background: #163f33; color: white; box-shadow: 0 4px 22px #25372b4b; font-size: 14px;
}
.feedback.error { background: #8c392f; }

.modal-panel {
  width: min(420px, calc(100% - 32px)); margin: auto; padding: 22px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--paper); color: var(--ink); box-shadow: 0 16px 45px #061c1866;
}
.modal-panel::backdrop { background: #0c2922a6; }
.modal-panel > p { margin-top: 5px; color: var(--muted); font-size: 14px; }
.bot-options { display: grid; gap: 8px; margin: 15px 0; }
.bot-option {
  display: grid; gap: 4px; padding: 10px 12px; min-height: 52px; text-align: left;
  border: 1px solid var(--line); border-radius: 9px; background: #fffdf7; color: var(--ink);
}
.bot-option:not(:disabled):hover { border-color: #708475; background: #e8eddb; }
.bot-option span { color: var(--muted); font-size: 12px; }
.bot-dialog form { display: flex; justify-content: flex-end; }
.history-dialog fieldset { min-inline-size: 0; margin: 16px 0 0; padding: 0; border: 0; }
.history-dialog label { display: block; margin-bottom: 7px; font-weight: 700; font-size: 13px; }
.dialog-error { margin-top: 6px; color: #8c392f; font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.danger { background: #8c392f; color: #fff; }

@media (min-width: 1024px) {
  body:has(.room:not([hidden])) .topbar { min-height: 60px; }
  .room { padding-block: 12px; overflow-anchor: none; }

  .felt {
    /* Reserve space for highlights, card rows and controls throughout the round. */
    height: clamp(768px, calc(100dvh - 85px), 837px);
    min-height: 0;
    padding-block: 12px;
    row-gap: 6px;
    grid-template-rows: 48px 94px calc(2 * var(--card-height) + 4px) minmax(0, 1fr)
      calc(var(--card-height) + 30px) 96px calc(var(--card-height) + 84px);
    --card-height: 54px;
    --card-step: 21px;
  }

  .seat { padding-block: 4px; }
  .seat.playing { margin-block: 0; }
  .seat small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .turn-clock { display: block; margin-top: 0; }
  .side-cards { align-content: start; }
  .table-status { grid-area: 3 / 2 / 5 / 3; }
  .played-cards, .side-cards.revealed {
    display: grid;
    grid-template-columns: repeat(min(var(--card-count), var(--cards-per-row, 10)), minmax(0, var(--card-step)));
    gap: 4px 0;
    padding-inline: 0 calc(var(--card-w) - var(--card-step));
  }
  :is(.played-cards, .side-cards.revealed) .card + .card { margin-left: 0; }
  :is(.hand-cards, .played-cards, .side-cards.revealed) .card:not(.joker) .card-corner { font-size: 16px; padding-left: 3px; }
  .move.bottom { width: min(100%, 540px); justify-self: center; --cards-per-row: 20; }
  .room-chat {
    --chat-height: 126px;
    --chat-extra-width: 80px;
    grid-area: 5 / 3 / 7 / 4;
    width: min(351px, calc(100% + var(--chat-extra-width)));
  }
  .chat-form { align-self: flex-end; width: calc(100% - var(--chat-extra-width)); }

  #hand-area {
    display: grid;
    grid-template-rows: 18px calc(var(--card-height) + 10px) 36px;
    gap: 4px;
    padding-block: 5px;
  }
  .hand-heading { margin: 0; }
  .hand-cards { flex-wrap: nowrap; padding-top: 8px; }
  .actions { margin: 0; }
  .actions .button { min-height: 36px; }
}

@media (min-width: 1024px) and (max-height: 860px) {
  .felt { height: clamp(736px, calc(100dvh - 85px), 837px); --card-height: 48px; }
}

@media (max-width: 820px) {
  .topbar, .shell { width: calc(100% - 36px); }
  .lobby { gap: 23px; }
  .felt { grid-template-columns: minmax(0, 1fr) minmax(130px, 1.2fr) minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .topbar, .shell { width: calc(100% - 28px); }
  .topbar { min-height: 58px; gap: 8px; }
  .brand { gap: 7px; min-width: 0; }
  .brand strong { font-size: 14px; letter-spacing: .025em; }
  .brand-mark { width: 34px; height: 34px; flex: 0 0 34px; }
  .languages button { min-height: 44px; }
  .header-controls { flex-shrink: 0; max-width: 69%; gap: 3px 9px; padding-block: 4px; }
  .sort-control { min-height: 44px; font-size: 11px; }
  .lobby { grid-template-columns: 1fr; padding: 22px 0; }
  .intro h1 { line-height: 1.04; }
  .showcase { height: 135px; margin-top: 12px; }
  .fan { transform: scale(.69) translateY(7px); }
  input { font-size: 16px; }
  .button { min-height: 44px; }
  .button, .languages button, .hand-cards button { touch-action: manipulation; }
  .room { padding: 14px 0 22px; }
  .room-links .button { min-height: 36px; padding: 0 7px; }
  .round-tag { padding-inline: 7px; }
  .history-table th, .history-table td { padding-inline: 10px; }
  .history-table thead th { min-width: 76px; }
  .history-delete { min-height: 44px; }
  .remove-bot { min-width: 38px; min-height: 44px; }
  .felt {
    min-height: 594px; padding: 10px 9px 14px; gap: 6px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto auto auto minmax(64px, 1fr) auto auto auto;
    --card-w: 42px; --card-step: 22px; --card-height: 54px;
  }
  .felt-rail { inset: 6px; }
  .table-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr); }
  .room-links { grid-area: 1 / 2; }
  .bottom-pack { grid-area: 2 / 1 / 3 / -1; justify-self: center; --reserve-width: 31px; --reserve-height: 43px; }
  .bottom-pack .card-corner { padding: 3px; font-size: 13px; }
  .seat.left { grid-area: 2 / 1; }
  .seat.right { grid-area: 2 / 2; }
  .seat.bottom { grid-area: 7 / 1; justify-self: start; }
  .seat.bottom.playing { transform-origin: left bottom; }
  .room-chat { grid-area: 7 / 2; --chat-height: 126px; --chat-input-height: 36px; }
  .chat-form input { font-size: 16px; }
  .seat { gap: 4px; padding: 4px; }
  .avatar { width: 25px; height: 25px; flex-basis: 25px; }
  .avatar.avatar-icon { font-size: 17px; }
  .seat small { font-size: 9px; }
  .seat strong { font-size: 11px; }
  .role { font-size: 9px; }
  .side-cards.right { grid-area: 3 / 2; }
  .move.left { grid-area: 4 / 1; }
  .move.right { grid-area: 4 / 2; }
  .move.bottom { grid-area: 6 / 1 / 7 / -1; }
  .table-status { grid-area: 5 / 1 / 6 / -1; }
  #hand-area { grid-area: 8 / 1 / 9 / -1; padding: 11px 10px; }
  .hand-cards { padding-top: 10px; }
  :is(.hand-cards, .played-cards, .side-cards.revealed) .card-corner { font-size: 16px; }
  :is(.hand-cards, .played-cards, .side-cards.revealed) .joker .card-corner { font-size: 6.5px; }
  .actions { margin-top: 10px; }
  .actions .button { flex: 1 1 60px; min-width: 0; padding-inline: 6px; }
  .actions .play-button { flex-grow: 2; }
}

@media (min-width: 360px) and (max-width: 600px) and (orientation: portrait) {
  html.iphone:has(.room:not([hidden])) { overscroll-behavior-y: none; }
  .iphone:has(.room:not([hidden])) :is(.topbar, .shell) { width: calc(100% - 16px); }
  .iphone:has(.room:not([hidden])) .topbar { min-height: 50px; }
  .iphone:has(.room:not([hidden])) .header-controls { padding-block: 0; }
  .iphone .room { padding-block: 6px; overflow-anchor: none; }

  .iphone .felt {
    /* Keep the same tracks as the Safari toolbar and round contents change. */
    height: clamp(626px, calc(100svh - 63px - env(safe-area-inset-top) - env(safe-area-inset-bottom)), 760px);
    min-height: 626px;
    padding: 8px;
    gap: 4px 6px;
    grid-template-rows: 64px 75px 45px 65px minmax(72px, 1fr) 65px 72px 124px;
    --card-w: 34px;
    --card-height: 42px;
    --card-step: clamp(14px, 4vw, 17.5px);
  }

  .iphone .table-top { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 30px 32px; gap: 2px 4px; }
  .iphone .round-tag { font-size: 11px; padding: 4px 5px; }
  .iphone .room-links .button { min-height: 30px; padding-inline: 5px; font-size: 11px; }
  .iphone .bottom-pack { --reserve-width: 25px; --reserve-height: 32px; }
  .iphone .bottom-pack .joker .card-corner { padding: 0 2px; font-size: 5px; }
  .iphone .seat { padding-block: 2px; }
  .iphone .seat.playing { margin-block: 0; }
  .iphone .seat small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .iphone .turn-clock { display: block; margin-top: 0; font-size: 12px; }
  .iphone .seat .remove-bot { min-width: 29px; min-height: 34px; }

  .iphone .side-cards { flex-wrap: nowrap; align-self: start; }
  .iphone :is(.side-cards.revealed, .played-cards) {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-inline: 0;
    overscroll-behavior-x: contain;
  }
  .iphone .side-cards.right.revealed { justify-content: safe flex-end; }
  .iphone .played-cards { justify-content: safe center; margin-top: 3px; }
  .iphone .move-label { padding: 2px 6px; font-size: 10px; }
  .iphone :is(.hand-cards, .played-cards, .side-cards.revealed) .card-corner { padding: 3px 0 0 2px; font-size: 13px; }
  .iphone :is(.hand-cards, .played-cards, .side-cards.revealed) .joker .card-corner { font-size: 6px; }

  .iphone .table-status { padding: 2px; }
  .iphone .table-status > strong { font-size: 16px; }
  .iphone .table-status > span { margin-top: 2px; font-size: 11px; line-height: 1.25; }
  .iphone .table-status .button { min-height: 30px; margin-top: 4px; padding-inline: 8px; font-size: 12px; }
  .iphone .table-status.result { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 6px; text-align: left; }
  .iphone .table-status.result > strong { grid-area: 1 / 1; }
  .iphone .table-status.result > span:first-of-type { grid-area: 2 / 1; }
  .iphone .table-status.result > :is(.button, .waiting-line) { grid-area: 1 / 2 / 3 / 3; align-self: center; margin: 0; }
  .iphone .score-list {
    grid-area: 3 / 1 / 4 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px;
    max-width: none; margin: 3px 0 0; font-size: 11px;
  }
  .iphone .score-list li { min-width: 0; padding: 2px 3px; gap: 3px; }
  .iphone .score-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .iphone .room-chat { --chat-height: 72px; --chat-input-height: 29px; }
  .iphone #hand-area { display: grid; grid-template-rows: 16px 52px 44px; gap: 3px; padding: 2px 6px; }
  .iphone .hand-heading { margin: 0; }
  .iphone .hand-cards { flex-wrap: nowrap; padding: 10px 0 0; }
  .iphone .actions { flex-wrap: nowrap; gap: 4px; margin: 0; }
  .iphone .actions .button { padding-inline: 3px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .seat.playing.overtime { animation: none; }
  .bomb-effect span { animation: none; }
}
