:root {
  --bg: var(--palette-bg, #edeee4);
  --paper: var(--palette-paper, #f7f3e6);
  --ink: var(--palette-ink, #183a30);
  --line: var(--palette-line, #bccbc2);
  --accent: var(--palette-accent, #246448);
  --wash: var(--palette-wash, #e1eadd);
  --red-suit: #a21c38;
  --card-height: clamp(52px, 14vw, 78px);
  --card-width: clamp(38px, 10vw, 56px);
  background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
body.large { font-size: 1.13rem; }
a { color: inherit; }
button, select { min-height: 44px; padding: .4em .65em; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--ink); font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { font-weight: 700; background: var(--accent); color: var(--palette-primary-ink, white); }
.masthead, main, .game-footer { width: min(100% - 20px, 720px); margin-inline: auto; }
.masthead { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding-block: 10px; }
.masthead h1 { display: flex; align-items: center; gap: 8px; margin: 0; font: bold clamp(1.45rem, 6vw, 2rem)/1 Georgia, serif; }
.accessibility, .selectors { display: flex; align-items: center; gap: 8px; }
.accessibility label { white-space: nowrap; }
.selectors { grid-column: 1 / -1; }
.selectors select { flex: 1; min-inline-size: 0; }
.game-toolbar, .game-tools { display: flex; align-items: center; gap: 6px; }
.game-toolbar { justify-content: space-between; margin-block: 6px 10px; }
.game-toolbar button { min-inline-size: 44px; }
.new-game-buttons { display: flex; flex: none; }
.new-game-buttons #new { border-start-end-radius: 0; border-end-end-radius: 0; }
#new-options {
  display: grid; place-items: center; padding-inline: 0; background: var(--wash);
  border-start-start-radius: 0; border-end-start-radius: 0;
}
#new-options span {
  width: 10px; height: 10px; border: solid currentColor; border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
}
.game-tools button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.game-tools button:disabled { opacity: .55; cursor: default; }
.history-label { display: none; }
@media (min-width: 600px) {
  .history-icon { display: none; }
  .history-label { display: inline; }
}
@media (max-width: 470px) { .toolbar-label { display: none; } }
@media (max-width: 420px) {
  .game-toolbar, .game-tools { gap: 3px; }
  .game-toolbar button { inline-size: clamp(33px, 10.6vw, 44px); min-inline-size: 0; padding-inline: 0; }
  .game-toolbar button.shared-settings-button { inline-size: clamp(33px, 10.6vw, 44px); min-inline-size: 0; }
}
.table {
  position: relative; isolation: isolate;
  display: grid; align-content: center; gap: 3px;
  padding: 12px 10px; min-block-size: 326px; border: 1px solid var(--line); border-radius: 16px;
  background: #164937; color: #fff; text-align: center;
}
#table-action {
  position: absolute; inset: 0; z-index: 1; width: 100%;
  border: 0; border-radius: inherit; background: transparent;
}
#table-action:focus-visible { outline: 2px solid var(--gc-theme-current, #edce7b); outline-offset: -4px; }
.table .seat .player-avatar-button { z-index: 2; }
.opponents {
  display: flex; justify-content: center; gap: 6px; inline-size: min(100%, 520px);
  margin-inline: auto; margin-block-end: -40px; z-index: 2; pointer-events: none;
}
.opponents:has(.seat:nth-child(2)) { justify-content: space-between; }
.seat { position: relative; display: grid; justify-items: center; gap: 3px; inline-size: min(40%, 145px); min-inline-size: 0; }
.opponents .seat { inline-size: min(33%, 145px); }
.opponents .seat-data { grid-row: 1; }
.opponents .player-avatar-button, #human .player-avatar-button { pointer-events: auto; }
#human { margin-block-start: -24px; z-index: 2; pointer-events: none; }
#human .seat { margin-inline: auto; }
.seat-avatar { position: relative; display: grid; place-items: center; inline-size: 48px; block-size: 48px; border-radius: 50%; border: 1px solid var(--gc-theme-panel-line, #aac8b4); }
.seat.current .seat-avatar { outline: 2px solid var(--gc-theme-current, #edce7b); outline-offset: 2px; }
.seat .player-avatar-button { position: relative; inline-size: 100%; block-size: 100%; min-block-size: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; font-weight: 750; }
.seat .player-avatar-button > img { inline-size: 100%; block-size: 100%; border-radius: 50%; object-fit: cover; }
.seat .player-avatar-button > .player-avatar-portrait { object-fit: contain; }
.seat-avatar .player-avatar-pencil { inset-inline: -4px auto; }
.seat-data { max-inline-size: 100%; min-inline-size: 0; line-height: 1.15; text-shadow: 0 1px 2px #0007; }
.seat-data strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-bid {
  display: inline-block; min-inline-size: 2.5em; margin-block-start: 2px; padding: 1px 5px;
  border-radius: 6px; background: var(--paper); color: var(--ink); font-size: .75rem;
  font-weight: 700; font-variant-numeric: tabular-nums; text-shadow: none;
}
.seat:is(.current, .winner) strong { color: #f7db86; }
.bomb-badge {
  position: absolute; inset-inline-start: calc(100% - 8px); inset-block-start: 50%;
  transform: translateY(-50%); z-index: 2; padding: 2px 4px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink);
  font-size: 1rem; font-weight: 700; line-height: 1.15; white-space: nowrap;
}
.trick-count {
  position: absolute; inset-inline-end: -5px; inset-block-end: -2px; z-index: 2;
  min-inline-size: 18px; padding-inline: 3px; border-radius: 6px;
  border: 1px solid var(--gc-theme-panel-line, #aac8b4); background: var(--paper); color: var(--ink);
  font-size: .72rem; font-weight: 750; pointer-events: none;
}
.seat-cards { display: grid; grid-template-columns: minmax(46px, 1fr) 36px; align-items: center; gap: 5px; block-size: 32px; }
.hand-fan { display: flex; justify-content: center; align-items: center; }
.mini-back, .mini-face { display: block; flex: none; inline-size: 19px; block-size: 26px; border-radius: 4px; }
.mini-back { background: var(--card-back-pattern) var(--card-back-color); border: 1px solid var(--card-back-edge); }
.mini-face { background: #fbf7e8; color: #152d26; border: 1px solid #aeb6a8; font-size: .54rem; font-weight: 750; text-align: start; padding: 1px; }
.mini-face.red { color: #a21c38; }
.hand-fan > span { rotate: var(--angle); transform-origin: center bottom; }
.hand-fan > span + span { margin-inline-start: -15px; }
.trick-stack { position: relative; inline-size: 36px; block-size: 25px; }
.trick-stack .mini-back { position: absolute; inset-inline-start: var(--stack-offset); inset-block-start: 3px; inline-size: 27px; block-size: 19px; }
.round-header {
  padding: 8px 10px; margin-block-end: 6px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--paper);
}
#round-info { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: baseline; }
.round-trump { text-align: end; }
.trump-symbol.red { color: var(--red-suit); font-weight: 700; }
.round-dealer, .round-contract { grid-column: 1 / -1; overflow-wrap: anywhere; font-size: .9em; }
#status { margin: 3px 0 0; min-block-size: 1.4em; overflow-wrap: anywhere; }
#received-card { margin: 3px 0 0; font-size: .88em; overflow-wrap: anywhere; }
#received-card .red { color: var(--red-suit); }
#table-hint {
  justify-self: center; margin: 0; padding: 2px 8px; border-radius: 10px;
  font-size: .75rem; font-weight: 700; line-height: 1.2; text-align: center;
}
#table-hint:empty { min-block-size: calc(1.2em + 4px); visibility: hidden; }
@media (max-width: 360px) {
  #table-hint { font-size: .7rem; }
}
.trick-felt {
  display: grid; place-items: center; inline-size: min(100%, 520px);
  min-block-size: clamp(178px, 43vw, 212px); margin-inline: auto;
  padding-block: 26px;
}
#bid-log {
  position: relative; inline-size: min(70%, 17rem); max-block-size: 100px;
  overflow: auto; overscroll-behavior: contain; margin: 0; padding: 0 5px;
  list-style: none; font-size: .82em; text-align: start;
}
#bid-log li {
  display: flex; justify-content: space-between; gap: 6px;
  padding: 2px 5px; border-block-end: 1px solid var(--gc-theme-panel-line, #aac8b4);
}
#bid-log li:last-child { border: 0; background: var(--wash); color: var(--ink); border-radius: 5px; }
#bid-log bdi { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trick-felt:has(#bid-log:not([hidden])) #trick { display: none; }
.trick { position: relative; display: flex; align-items: start; justify-content: center; gap: 3px; }
.contract-announcement { max-inline-size: 15ch; font-size: 1.15em; overflow-wrap: anywhere; }
.trick-wheel {
  display: grid; align-items: center; justify-items: center; gap: 0;
  grid-template-columns: repeat(3, clamp(39px, 10vw, 54px));
  grid-template-rows: repeat(2, clamp(46px, 12vw, 68px));
}
.trick figure { margin: 0; min-inline-size: 0; max-inline-size: 5rem; }
.trick-wheel figure { position: relative; inline-size: max-content; }
.trick-wheel [data-position="west"] { grid-area: 1 / 1; align-self: end; translate: 7px 9px; }
.trick-wheel [data-position="east"] { grid-area: 1 / 3; align-self: end; translate: -7px 9px; }
.trick-wheel [data-position="north"] { grid-area: 1 / 2; translate: 0 -9px; }
.trick-wheel [data-position="south"] { grid-area: 2 / 2; translate: 0 4px; }
.trick-wheel [data-position="west"] .card { rotate: -13deg; }
.trick-wheel [data-position="east"] .card { rotate: 13deg; }
.trick-wheel [data-position="north"] .card { rotate: -6deg; }
.trick-wheel [data-position="south"] .card { rotate: 6deg; }
.winning-card .card { position: relative; }
.trick-mark {
  position: absolute; inset: auto 3px 3px auto; display: grid; place-items: center;
  inline-size: 18px; block-size: 18px; border-radius: 50%;
  background: #f7db86; color: #25352a; font-size: .78rem;
}
[data-position="north"] .trick-mark { inset: 3px 3px auto auto; }
.trick figcaption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75em; }
.trick-wheel figcaption { max-inline-size: clamp(42px, 12vw, 60px); }
.trick .played { margin-inline: auto; }
.card { inline-size: var(--card-width); block-size: var(--card-height); border: 1px solid #aeb6a8; border-radius: 7px; background: #fbf7e8; color: #152d26; font-weight: 800; box-shadow: 0 2px 4px #0003; }
.card.red { color: var(--red-suit); }
.card:disabled { opacity: .65; }
.card.played { display: grid; place-items: center; }
.flying-card { position: fixed; z-index: 10; pointer-events: none; }
:root[data-theme="contrast"] .seat-data { text-shadow: none; color: #111; }
:root[data-theme="contrast"] .seat:is(.current, .winner) strong { background: #111; color: #fff; border-radius: 4px; padding-inline: 3px; }
:root[data-theme="contrast"] .trick-mark { background: #111; color: #fff; }
.hand-panel, #score, #trick-history { margin-block: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.hand {
  display: grid; direction: ltr; margin-inline: auto;
  inline-size: min(calc(100% - 8px), calc(var(--gaps) * (var(--card-width) - 7px) + var(--card-width)));
  grid-template-columns: repeat(var(--gaps), minmax(0, 1fr)) var(--card-width);
}
.hand:has(> :only-child) { inline-size: var(--card-width); grid-template-columns: var(--card-width); }
.hand button {
  position: relative; display: grid; align-content: start; justify-items: start;
  padding: 4px 3px; line-height: 1.1; rotate: var(--angle); translate: 0 var(--drop);
  transform-origin: center bottom;
}
.hand button:focus-visible { z-index: 1; }
.hand button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 3px var(--accent), 0 2px 4px #0003;
  background: var(--wash);
}
.hand .received-card:disabled {
  opacity: 1; box-shadow: inset 3px 0 var(--accent), inset 0 2px var(--accent), 0 2px 4px #0003;
}
.actions { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-block-end: 5px; }
.actions:empty { display: none; }
.hand-panel #actions { display: flex; min-block-size: 44px; align-content: start; }
.hand-panel #hand { min-block-size: calc(var(--card-height) + 8px); align-content: start; }
@media (max-width: 405px) {
  .hand-panel #actions { min-block-size: 94px; }
}
.actions .chosen { outline: 2px solid var(--accent); }
.bid-spin { display: inline-flex; align-items: stretch; direction: ltr; }
.bid-spin button { min-inline-size: 44px; }
.bid-spin button:first-child { border-start-end-radius: 0; border-end-end-radius: 0; }
.bid-spin button:last-child { border-start-start-radius: 0; border-end-start-radius: 0; }
.bid-spin input {
  inline-size: 4.25rem; border: solid var(--line); border-width: 1px 0;
  background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; text-align: center;
  appearance: textfield;
}
.bid-spin input::-webkit-inner-spin-button { appearance: none; }
.bid-spin input:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.bid-spin button:disabled, #actions button:disabled { opacity: .55; cursor: default; }
summary { cursor: pointer; font-weight: 700; }
#scores { overflow-x: auto; }
#score { padding: 8px 12px; }
#score > summary { font-weight: 650; }
#trick-history { padding-inline: 12px; }
#trick-history-list > details { margin-block-start: 6px; padding: 6px; border-block-start: 1px solid var(--line); }
.history-tricks, .history-trick-cards { list-style: none; margin: 0; padding: 0; }
.history-tricks > li { padding-block: 6px; border-block-end: 1px solid var(--line); }
.history-tricks p { margin: 0 0 4px; font-size: .85em; }
.history-trick-cards { display: grid; grid-template-columns: repeat(var(--players), minmax(0, 1fr)); gap: 4px; }
.history-trick-cards li { display: grid; gap: 3px; justify-items: center; align-content: start; font-size: .75em; overflow-wrap: anywhere; }
.history-trick-cards .took-trick { font-weight: 750; }
.history-trick-cards .card { position: relative; inline-size: 38px; block-size: 50px; }
#scores table {
  width: 100%; table-layout: fixed; border-collapse: collapse; margin-block-start: 8px;
  font-size: .83em; text-align: end; font-variant-numeric: tabular-nums;
}
#scores :is(th, td) { padding: 4px; border-block-end: 1px solid var(--line); }
#scores th:first-child { width: 34%; text-align: start; overflow-wrap: anywhere; }
#scores .score-total { font-weight: 750; background: var(--wash); }
#scores table + table { margin-block-start: 12px; }
.score-breakdown caption { margin-block-end: 3px; text-align: start; font-weight: 750; }
.score-name { overflow-wrap: anywhere; }
@media (max-width: 390px) {
  #scores :is(th, td) { padding-inline: 2px; }
}
dialog { max-inline-size: min(32rem, 100% - 24px); width: 100%; max-block-size: 90dvh; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); padding: 14px; }
dialog::backdrop { background: #061a16a0; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-block-end: 8px; }
.dialog-heading h2 { margin: 0; }
#new-dialog .actions {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px; margin-block: 16px 0;
}
#new-dialog .actions button { overflow-wrap: anywhere; }
.player-options { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.player-options legend { margin-block-end: 6px; font-weight: 650; }
.player-options > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pagat-option { grid-column: 1 / -1; }
.player-options label {
  display: flex; align-items: center; gap: 7px; min-block-size: 48px; padding: 6px 9px;
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
}
.player-options label:has(:checked) { border-color: var(--accent); background: var(--wash); font-weight: 700; }
.player-options input { flex: none; margin: 0; accent-color: var(--accent); }
.focus-game :is(.masthead, .game-footer, .game-install) { display: none; }
.focus-game main {
  --screen-top: max(4px, env(safe-area-inset-top));
  --screen-bottom: max(4px, env(safe-area-inset-bottom));
  --score-space: calc(1.4em + 24px);
  padding-block: var(--screen-top) var(--screen-bottom);
}
.focus-game main:has(#trick-history:not([hidden])) { --score-space: calc(2.8em + 48px); }
.focus-game .play-area {
  --card-width: clamp(32px, min(10vw, 5.4dvh), 56px);
  --card-height: calc(var(--card-width) * 1.4);
  display: grid;
  grid-template-rows: auto auto minmax(min-content, 1fr) auto;
  gap: 5px;
  min-block-size: calc(100dvh - var(--screen-top) - var(--screen-bottom) - var(--score-space));
}
.focus-game:has(.game-update:not([hidden])) .play-area { min-block-size: 0; }
.focus-game :is(.game-toolbar, .round-header, .hand-panel) { margin-block: 0; }
.focus-game .round-header { padding: 4px 8px; }
.focus-game #round-info { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
.focus-game .round-dealer { grid-column: 1; }
.focus-game .round-contract { grid-column: 2; text-align: end; }
.focus-game :is(.round-dealer, .round-contract) {
  display: flex; gap: .25em; font-size: .84em; white-space: nowrap;
}
.focus-game .round-contract { justify-content: end; }
.focus-game #round-info bdi { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
.focus-game #status { margin-block-start: 1px; min-block-size: 0; font-size: .9em; }
.focus-game .table {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-block-size: 284px; padding: 6px 8px; gap: 2px;
}
.focus-game .opponents { margin-block-end: -26px; }
.focus-game #human { margin-block-start: -24px; }
.focus-game .seat { gap: 1px; }
.focus-game .seat-data { display: flex; align-items: center; gap: 4px; }
.focus-game .seat-bid { flex: none; margin: 0; }
.focus-game .seat-cards { block-size: 28px; }
.focus-game .trick-felt { min-block-size: 0; padding-block: 10px; }
.focus-game .trick-wheel { grid-template-rows: repeat(2, calc(var(--card-height) * .75)); }
.focus-game #bid-log { max-block-size: min(81px, 100%); }
.focus-game .hand-panel { padding: 4px; }
.focus-game .hand-panel #actions { min-block-size: 44px; margin-block-end: 2px; gap: 4px; }
.focus-game .bid-spin input { inline-size: clamp(3rem, 11vw, 4.25rem); }
.focus-game :is(#score, #trick-history) { margin-block: 6px 0; }

@media (orientation: portrait) and (max-height: 660px) {
  .focus-game .round-header { line-height: 1.25; }
  .focus-game .table { min-block-size: 236px; }
  .focus-game .opponents { margin-block-end: -32px; }
  .focus-game #human { margin-block-start: -30px; }
  .focus-game .seat-avatar { inline-size: 42px; block-size: 42px; }
  .focus-game .seat-cards { block-size: 25px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .focus-game .play-area {
    grid-template: "toolbar toolbar" auto "table round" auto "table hand" minmax(0, 1fr)
      / minmax(0, 1fr) minmax(0, 1fr);
  }
  .focus-game .game-toolbar { grid-area: toolbar; }
  .focus-game .round-header { grid-area: round; line-height: 1.2; }
  .focus-game .table { grid-area: table; min-block-size: 212px; }
  .focus-game .hand-panel { grid-area: hand; align-content: center; }
  .focus-game .opponents { margin-block-end: -7px; }
  .focus-game #human { margin-block-start: -7px; }
  .focus-game .seat {
    grid-template: "avatar name" auto "avatar cards" auto / auto minmax(0, 1fr);
    align-items: center; justify-items: start; gap: 1px 5px;
    inline-size: min(calc(50% - 3px), 145px);
  }
  .focus-game .seat-avatar { grid-area: avatar; }
  .focus-game .seat-data { grid-area: name; }
  .focus-game .seat-cards { grid-area: cards; }
  .focus-game .seat-avatar { inline-size: 42px; block-size: 42px; }
  .focus-game .seat-cards { block-size: 25px; }
  .focus-game .trick-felt { padding-block: 4px; }
  .focus-game .bid-spin input { inline-size: 3rem; }
}

:root { --muted: var(--palette-muted, #566860); --radius: 12px; }
:root[data-scenery] body:not(.theme-preview) > main {
  background: var(--gc-scene-display, none) center / cover no-repeat;
  border-radius: 16px;
}
:root[data-scenery] :is(main > .table, main .play-area > .table) {
  border-color: var(--gc-theme-table-line, var(--line));
}
.focus-game #my-progress { display: none; }
#my-progress { margin-block: 4px 8px; }
.new-label { display: none; }
@media (min-width: 700px) {
  .new-label { display: inline; }
  .new-icon { display: none; }
}
[dir="rtl"] :is(.trick-wheel, .hand, .opponents, .hand-fan, .bid-spin) { direction: ltr; }
[dir="rtl"] .seat { direction: rtl; }
[dir="rtl"] :is(.card, .mini-face, .progress-count) { direction: ltr; }
#confirm-import .actions, .settings-backup-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.table .seat-data strong {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--gc-theme-panel);
  color: var(--gc-theme-panel-ink);
  text-shadow: none;
}
.table .seat:is(.current, .winner) strong {
  background: var(--paper);
  color: var(--ink);
  outline: 1px solid var(--gc-theme-current);
}
#theme-gallery button:disabled { cursor: default; }
.theme-preview { padding: 10px 12px; }
.theme-preview main { width: 100%; }
.theme-preview .table { min-block-size: 314px; box-shadow: none; }
.theme-preview .hand-panel { margin-block-start: 10px; }
.theme-preview .hand { --gaps: 4; justify-content: center; min-block-size: 90px; }
.theme-preview .hand .card { padding: 4px; }
.theme-preview .mini-back { inline-size: 31px; block-size: 43px; }
.theme-preview .opponents { margin-block-end: -35px; }

#variant-stats { display: grid; gap: .65em; }
.variant-stats-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5em .9em;
  margin: 0;
  padding: .65em .8em;
  font-size: .88em;
}
.variant-stats-card dt { color: var(--muted); overflow-wrap: anywhere; }
.variant-stats-card dd { margin: 0; font-weight: 700; }
#variant-stats-note { color: var(--muted); font-size: .88em; }
