@font-face {
  font-family: "Bricolage Grotesque";
  src: url('/fonts/bricolage-grotesque.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url('/fonts/vazirmatn.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: DSEG7;
  src: url('/fonts/dseg7-classic.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Lalezar;
  src: url('/fonts/lalezar-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Lalezar;
  src: url('/fonts/lalezar-arabic.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFC;
}
@property --phase-card-scale {
  syntax: '<number>';
  inherits: true;
  initial-value: 1;
}
:root {
  color-scheme: light;
  --ink: #1d2430;
  --soft: #495366;
  --line: #232838;
  --paper: rgb(246, 235, 224);
  --surface: #fffefa;
  --violet: #bfaff6;
  --violet-soft: #eee8fc;
  --sky: #b6def4;
  --sky-soft: #eaf6fc;
  --sun: #ffdf7b;
  --sun-soft: #fff1c5;
  --leaf: #c5e493;
  --leaf-soft: #ecf5df;
  --rose: #f9b1c3;
  --rose-soft: #ffe7eb;
  --focus: #5b40b3;
  --card-scale: 1.5;
  --picked-trim: #394d9c;
  --avatars-art: url('/scene/rug-avatars.webp?v=32');
  --game-font: "Bricolage Grotesque",Vazirmatn,system-ui,sans-serif;
  --name-font: var(--game-font);
}
:root:lang(fa) {
  --game-font: Vazirmatn,system-ui,sans-serif;
  --name-font: Lalezar,Vazirmatn,system-ui,sans-serif;
}
* { box-sizing: border-box }
html, body { width: 100%; height: 100%; overflow: hidden }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.45 var(--game-font) }
a { color: inherit; text-decoration: none }
button, input, select { font: inherit }
button, select { cursor: pointer }
button:disabled { cursor: default; opacity: .5 }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px }
[hidden] { display: none !important }
p, h1, h2 { margin: 0 }

.table {
  --bar-top: max(9px, env(safe-area-inset-top));
  --score-height: calc(4.125rem + 2px);
  --felt-top: clamp(127px, 22dvh, 215px);
  --rug-height-limit: max(0px, calc(100dvh - var(--felt-top) - max(12px, env(safe-area-inset-bottom))));
  --rug-width-limit: calc(100vw - var(--pad-left) - var(--pad-right));
  --rug-width: min(var(--rug-width-limit), calc(var(--rug-height-limit) * 1.5));
  --rug-height: calc(var(--rug-width) / 1.5);
  --rug-center: calc(var(--felt-top) + var(--rug-height) / 2);
  --side-seat: clamp(47px, 8.9vw, 195px);
  --figure-size: clamp(124px, 25dvh, 216px);
  --table-card: calc(clamp(36px, 7.8dvh, 65px) * var(--card-scale));
  --kitty-card: calc(clamp(36px, 7.5dvh, 55px) * var(--card-scale) * var(--phase-card-scale) * .5);
  --hand-height: 0px;
  --hand-extra-space: 32px;
  --pad-left: max(22px, env(safe-area-inset-left));
  --pad-right: max(22px, env(safe-area-inset-right));
  --pad-bottom: max(10px, env(safe-area-inset-bottom));
  --voice-size: 44px;
  --phase-card-scale: 1;
  position: relative;
  isolation: isolate;
  overflow: clip;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto var(--hand-height) auto;
  height: 100vh;
  height: 100dvh;
  padding: var(--felt-top) var(--pad-right) var(--pad-bottom) var(--pad-left);
  background: var(--paper);
  transition: --phase-card-scale 480ms cubic-bezier(.22,.72,.3,1);
}
.table[data-phase] { --hand-height: min(46dvh, 434px) }
.table:is([data-phase="discard"], [data-phase="play"]) { --hand-height: calc(min(46dvh, 434px) + var(--hand-extra-space)) }
.table[data-phase="bid"] { --phase-card-scale: 1.2 }
.table:has(.hand-area[hidden]) { --hand-height: 0px }
.rug {
  position: absolute;
  inset: var(--felt-top) auto auto 50%;
  translate: -50% 0;
  width: var(--rug-width);
  height: var(--rug-height);
  z-index: -2;
  pointer-events: none;
  filter: drop-shadow(0 9px 14px #28204444);
}
.rug-surface { position: absolute; inset: 0; overflow: hidden }
.rug-surface::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('/scene/persian-rug.webp') center / 100% 100% no-repeat;
  clip-path: inset(3.4% .65% 4.1%);
  filter: hue-rotate(278deg) saturate(.9) brightness(1.18);
}
@media (orientation: portrait) {
  .table {
    --rug-width: min(var(--rug-width-limit), calc(var(--rug-height-limit) / 1.5));
    --rug-height: calc(var(--rug-width) * 1.5);
  }
  .rug-surface::before {
    inset: 50% auto auto 50%;
    width: 150%;
    height: calc(100% / 1.5);
    translate: -50% -50%;
    rotate: 90deg;
  }
}
.bar {
  position: absolute;
  inset: var(--bar-top) var(--pad-right) auto var(--pad-left);
  z-index: 7;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: 'menu score brand';
  align-items: center;
  gap: 8px;
  min-height: 44px;
  direction: ltr;
}
.brand {
  grid-area: brand;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  font-weight: 750;
  white-space: nowrap;
}
.brand b { color: var(--ink); font-weight: 800 }
.brand span { color: var(--focus); font-size: 1.3em }
.bar-actions { grid-area: brand; justify-self: end; display: flex; align-items: center; gap: 8px; direction: ltr }
.share-table { display: grid; place-items: center; width: 38px; height: 38px; min-height: 38px; padding: 7px }
.share-table.ghost { background: var(--sky) }
.share-table.ghost:hover { background: var(--violet) }
.table-banter {
  position: absolute; z-index: 6; pointer-events: none;
  right: var(--pad-right); top: calc(var(--bar-top) + var(--score-height) + 7px);
  display: grid; justify-items: right; gap: 6px;
  width: min(15rem, 42vw);
}
.banter-comment {
  min-width: 0; max-width: 100%; padding: 5px 9px;
  border: 1.5px solid var(--line); border-radius: 12px 5px 12px 12px;
  background: var(--violet-soft); color: var(--ink);
  box-shadow: 2px 3px 0 var(--line);
  font: 750 1rem/1.3 Vazirmatn,system-ui,sans-serif;
  animation: banter-in 220ms cubic-bezier(.16,.75,.3,1) both;
}
.banter-speaker {
  display: block; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--focus); font-size: .8125rem; font-weight: 850;
}
.banter-leaving { animation: banter-out 220ms ease-in both }
@keyframes banter-in { from { opacity: 0; translate: 10px -6px; scale: .97 } }
@keyframes banter-out { to { opacity: 0; translate: 7px -5px; scale: .98 } }
@media (max-width: 480px) { .banter-comment { padding: 4px 7px; font-size: .875rem } }
@media (prefers-reduced-motion: reduce) { .banter-comment { animation: none } }
.share-table svg { display: block; width: 22px; height: 22px }
#inviteLink { display: block; width: 100%; margin-block: 12px; direction: ltr }
.claimed-hands { position: absolute; top: 50%; left: 50%; translate: -50% -50%; width: min(560px, 94%); max-height: 96%; overflow: auto; padding: 10px; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); pointer-events: auto }
.claimed-hands h2 { margin: 0 0 8px; font-size: 1.1rem; text-align: center; color: var(--ink) }
.claim-players { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px }
.claim-player { min-width: 0; padding: 6px; border: 1px solid #a1a8bc; border-radius: 8px; background: var(--sky-soft) }
.claim-player bdi { display: block; font-size: .875rem; overflow-wrap: anywhere }
.claim-player small { font-size: .875rem; color: var(--soft) }
.claim-winner { border-color: var(--line); background: var(--sun-soft) }
.claim-cards { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px }
.claim-cards .card { --card-width: clamp(26px, 5vw, 42px); animation: lay-remaining .25s ease-out both }
@keyframes lay-remaining { from { opacity: 0; transform: translateY(15px) } to { opacity: 1; transform: translateY(0) } }
@media (prefers-reduced-motion: reduce) { .claim-cards .card { animation: none } }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap }
.table-options { grid-area: menu; position: relative; justify-self: start }
.options-toggle {
  display: grid;
  place-items: center;
  inline-size: 38px;
  block-size: 38px;
  border: 2px solid var(--line);
  border-radius: 11px;
  background: var(--violet);
  color: var(--ink);
  list-style: none;
  cursor: pointer;
}
.options-toggle::-webkit-details-marker { display: none }
.options-toggle span { width: 17px; height: 2px; border-radius: 2px; background: currentColor; box-shadow: 0 -5px currentColor, 0 5px currentColor }
.options-toggle:hover, .table-options[open] .options-toggle { background: var(--sun) }
.table-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  display: grid;
  gap: 7px;
  width: min(238px, calc(100vw - 26px));
  max-height: calc(100dvh - 66px);
  overflow: auto;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 4px 5px 0 var(--line);
}
.table-setting { display: grid; gap: 4px; color: var(--soft); font-size: .88rem }
.table-setting:has(select[hidden]) { display: none }
.table-menu .ghost, .table-menu select { min-height: 36px; background-color: var(--violet-soft); border-color: var(--line); font-size: .9rem }
.table-menu .ghost { text-align: start; padding: 5px 10px }
.table-menu .ghost:hover { background-color: var(--violet) }
:root[dir="rtl"] :is(.brand, .score, .table-menu) { direction: rtl }
.score {
  grid-area: score;
  justify-self: center;
  display: grid;
  grid-template-rows: 1.125rem 1.5rem 1.5rem;
  inline-size: 12.5rem;
  block-size: var(--score-height);
  padding: 0;
  border: 1px solid #303849;
  border-radius: 8px;
  overflow: hidden;
  color: #f6f6fa;
  background: #242835;
  box-shadow: 0 3px 9px #1d243047;
}
.score:hover { border-color: var(--violet) }
.score-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 3.25rem 3.5rem;
  align-items: stretch;
  text-align: center;
  min-inline-size: 0;
}
.score-row > * {
  display: grid;
  place-items: center;
  min-inline-size: 0;
  white-space: nowrap;
}
.score-head {
  color: #d9ddeb;
  background: #353e52;
  font-size: .75rem;
  line-height: 1;
}
.score-rivals { border-block-start: 1px solid #ffffff1c }
.score-ours { --led: #90ff55 }
.score-rivals { --led: #ff6864 }
.score-row .score-name {
  display: flex;
  align-items: center;
  gap: .32rem;
  padding-inline: .35rem;
  text-align: start;
}
.score-label {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .875rem;
  font-weight: 650;
}
.score-marker {
  display: grid;
  place-items: center;
  flex: 0 0 .85rem;
  block-size: 1rem;
}
.score-trump {
  border-radius: 2px;
  color: #18221d;
  background: var(--surface);
  font: 1rem/1 system-ui, sans-serif;
}
.score-trump-red { color: #aa2c34 }
.score strong {
  color: var(--led);
  background: #151822;
  font: 400 1rem/1 DSEG7, monospace;
  unicode-bidi: isolate;
}
.total-score {
  border-inline-start: 1px solid #ffffff16;
  color: #e7e8ef;
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

.arena {
  position: relative;
  grid-area: 1 / 1;
  min-width: 0;
}
.table:not([data-phase]) .arena { position: static }
.table[data-phase] .arena { container-type: size }
.center {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  --trick-card-base: min(var(--table-card), 31cqh);
  --card-width: calc(var(--trick-card-base) * 1.35);
}
#middle, #collection { position: absolute; inset: 0 }
#collection { z-index: 8 }
.ground {
  position: absolute;
  z-index: 1;
  top: var(--rug-center);
  left: 50%;
  translate: -50% -50%;
  pointer-events: none;
}
.trick {
  position: absolute;
  inset: 0;
  height: min(100%, calc(var(--trick-card-base) * 3.25));
  --trick-middle: clamp(50%, calc(100% - var(--trick-card-base) * 1.54), 62%);
  --trick-spacing: min(var(--card-width), 21cqw);
}
.trick .card {
  position: absolute;
  left: calc(50% + (var(--seat-x) + var(--jitter-x)) * var(--trick-spacing));
  top: calc(var(--trick-middle) + (var(--seat-y) + var(--jitter-y)) * var(--trick-card-base));
  translate: -50% -50%;
}
.trick .face { transform: perspective(650px) rotateX(27deg) rotateZ(var(--tilt, 0deg)) }
.trick .flight-back { position: absolute; inset: 0; border-radius: inherit; backface-visibility: hidden }
.play-north { --seat-x: .30; --seat-y: -.77 }
.play-south { --seat-x: -.30; --seat-y: .77 }
.play-west { --seat-x: -1.49; --seat-y: -.06 }
.play-east { --seat-x: 1.49; --seat-y: .06 }

.player-figure {
  position: absolute;
  z-index: -1;
  isolation: isolate;
  width: var(--figure-width, var(--figure-size));
  aspect-ratio: 1;
  transform-origin: 50% 90%;
  pointer-events: none;
  transition: scale 480ms ease;
}
.player-figure::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--avatars-art) no-repeat var(--avatar-x, 60%) var(--avatar-row, 0%) / 600% 200%;
  filter: brightness(var(--portrait-light, 1)) saturate(var(--portrait-color, 1)) blur(var(--portrait-blur, 0px)) drop-shadow(0 5px 5px #30235457);
  transition: filter 340ms ease;
}
.figure-caption {
  position: absolute;
  bottom: 100%;
  left: 50%;
  translate: -50% 0;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: max-content;
  max-width: min(8.5rem, 31vw);
}
.figure-name {
  max-width: 100%;
  padding: 2px 7px;
  overflow: hidden;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--seat-accent);
  color: var(--ink);
  font: 750 clamp(.92rem, 2vw, 1.28rem)/1.15 var(--name-font);
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
  pointer-events: auto;
}
.figure-north {
  --seat-accent: var(--rose);
  --figure-width: calc(var(--figure-size) * .84);
  top: max(calc(var(--bar-top) + var(--score-height) + 10px), calc(var(--felt-top) - var(--figure-width) * .69));
  transform-origin: 50% 0;
  left: 50%;
  translate: -50% 0;
}
.figure-north .figure-caption { left: 77%; top: 12%; bottom: auto; translate: none }
.figure-west, .figure-east { --avatar-row: 100%; top: calc(var(--rug-center) - var(--figure-size) * .57) }
.figure-west { --seat-accent: var(--sky); left: max(var(--side-seat), calc(50% - var(--rug-width) / 2)); translate: -50% 0 }
.figure-east { --seat-accent: var(--sun); right: max(var(--side-seat), calc(50% - var(--rug-width) / 2)); translate: 50% 0 }
@media (max-width: 580px) {
  .figure-west .figure-caption { translate: -31% 0 }
  .figure-east .figure-caption { translate: -69% 0 }
}
.defense-badge {
  display: block;
  max-width: 100%; padding: 2px 6px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--leaf-soft); color: var(--ink);
  font-size: .8125rem; font-weight: 700; line-height: 1.18; text-align: center; text-wrap: balance;
}
.defense-amount { color: #47368e; font-weight: 850; font-variant-numeric: tabular-nums; white-space: nowrap }
.defense-double { background: var(--sun-soft) }
.defense-doubled { background: var(--rose) }
.figure-heading { position: relative; display: grid; min-width: 0; max-width: 100% }
.seat-markers { display: flex; gap: 3px; font: 1rem/1.2 system-ui, sans-serif; white-space: nowrap }
.figure-heading .seat-markers { position: absolute; right: calc(100% + 2px); top: -.35rem }
.south .seat-markers {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 1px 5px #28204430;
}
.figure-east::after { scale: -1 1 }
.player-figure.active { scale: 1.12 }
.player-figure.active .figure-name { box-shadow: 2px 2px 0 var(--line) }
.player-figure.auction-passed { --portrait-light: .46; --portrait-color: .5; --portrait-blur: 1px }
.player-figure.auction-passed .figure-name { background: #e0e1e6 }

.seat {
  z-index: 2;
  position: absolute;
  display: grid;
  justify-items: center;
  align-items: center;
  gap: 4px;
  min-width: 32px;
  min-height: 26px;
  color: var(--ink);
  max-width: 24%;
  text-align: center;
}
.south {
  position: absolute; left: 50%; bottom: max(5px, env(safe-area-inset-bottom));
  translate: -50% 0; pointer-events: none; z-index: 6;
}
.seat-label {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: .45em;
  max-width: 100%;
  min-width: 54px;
  padding: 4px 9px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--sky-soft);
  font-size: .95rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
}
.seat-label .player-name { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; font: 400 1.25em/1 var(--name-font) }
.seat-label small {
  color: var(--soft);
  font-size: .82rem;
  font-weight: 450;
}
.seat-label .high-bid { color: var(--focus); font-weight: 700 }
.seat.auction-passed .held-backs { filter: brightness(.5) saturate(.55) blur(.65px) }
.seat.auction-passed .seat-label { border-color: #777c89; background: #ececf1 }
.seat.auction-passed .offer { color: var(--soft) }
.seat.active .seat-label {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px var(--violet);
}


.panel {
  position: absolute;
  z-index: 6;
  top: calc(50% + 16px);
  left: 50%;
  translate: -50% -50%;
  width: min(340px, calc(100% - var(--pad-left) - var(--pad-right)));
  padding: 24px;
  border: 2px solid var(--line);
  border-radius: 23px;
  background: var(--surface);
  box-shadow: 6px 7px 0 var(--line);
}
.panel h1, dialog h2 { margin-bottom: 14px; font-size: 1.55rem; font-weight: 800 }
.panel p { margin-bottom: 14px; color: var(--soft) }
.panel label { display: block; margin-bottom: 5px; color: var(--soft); font-size: .9rem }
.panel input:not(:where([type=checkbox], [type=radio])) { width: 100%; margin-bottom: 10px }
.panel .check { display: flex; align-items: center; gap: 7px }
.panel input[type=checkbox] { accent-color: var(--focus) }
.button-row { display: grid; gap: 7px }
.welcome-panel, .room-lobby { max-height: calc(100dvh - 68px); overflow: clip }
.welcome-panel {
  width: min(528px, calc(100% - var(--pad-left) - var(--pad-right) - 5px));
  padding: clamp(13px, 3.2dvh, 24px);
  text-align: center;
}
.welcome-panel h1 { font: 800 clamp(2.2rem, 7vw, 3.9rem)/1 var(--name-font); margin: 5px 0 13px }
.lobby-suits { display: flex; justify-content: center; gap: 5px; direction: ltr }
.lobby-suits span {
  width: 24px; height: 29px; display: grid; place-items: center;
  border: 1.5px solid var(--line); border-radius: 6px; color: var(--ink);
  background: var(--leaf); font: 700 1rem/1 Georgia,serif;
}
.lobby-suits span:first-child { rotate: -10deg; background: var(--violet) }
.lobby-suits span:nth-child(2) { background: var(--rose) }
.lobby-suits span:last-child { rotate: 10deg; background: var(--sun) }
.lobby-suits .red { color: #a02849 }
.identity-entry { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 9px; margin-bottom: 13px; text-align: start }
.welcome-panel .name-field label { color: var(--ink); font-weight: 750; margin-bottom: 4px }
.welcome-panel .name-field input { margin: 0; background: var(--sky-soft); border: 2px solid var(--line); font-weight: 650 }
.welcome-panel .name-field input::placeholder { color: var(--soft) }
.welcome-panel .check { margin-block-end: 10px; text-align: start }
.welcome-panel .check input { flex: none }
.welcome-panel .invite-status { margin: 0 0 9px; color: var(--focus); font-size: .93rem }
.mode-buttons { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; min-inline-size: 0; margin: 0 0 12px; padding: 0; border: 0 }
.welcome-panel .mode-button {
  position: relative; display: grid;
  min-width: 0; overflow: hidden; margin: 0;
  border: 2px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink);
  text-align: start; cursor: pointer;
}
.mode-classic { --mode-art: var(--sky); --mode-wash: var(--sky-soft) }
.mode-jokers { --mode-art: var(--sun); --mode-wash: var(--sun-soft) }
.mode-art {
  --sample-card: clamp(40px, min(15vw, 11.5dvh), 94px);
  position: relative; display: block; direction: ltr;
  min-height: calc(var(--sample-card) * 1.72 + 7px);
  overflow: hidden; border-bottom: 2px solid var(--line);
  background: var(--mode-wash);
}
.mode-art::before {
  content: ''; position: absolute; inset: 0 0 auto auto; width: 33%; aspect-ratio: 1;
  border-end-start-radius: 100%; background: var(--mode-art);
}
.mode-art .card {
  --card-width: var(--sample-card);
  position: absolute; top: 50%; left: 50%;
  translate: -79% -48%; rotate: -13deg;
  filter: drop-shadow(1px 3px 1px #1d24304d);
}
.mode-art .card + .card { translate: -24% -49%; rotate: 11deg }
.mode-details { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 6px; justify-content: space-between; padding: 7px 10px }
.mode-name { font-size: clamp(.92rem, 3.7vw, 1.18rem); font-weight: 800; line-height: 1.08 }
.mode-points { padding: 2px 6px; border-radius: 999px; background: var(--mode-art); font-size: .8rem; font-weight: 800; font-variant-numeric: tabular-nums }
.mode-selected {
  display: none; place-items: center;
  position: absolute; inset: 6px 6px auto auto;
  width: 24px; height: 24px; border: 2px solid var(--line);
  border-radius: 50%; background: var(--line); color: white; font: 700 .9rem/1 system-ui,sans-serif;
}
.mode-button:hover { box-shadow: 2px 2px 0 var(--line) }
.mode-button:has(input:checked) { box-shadow: 3px 3px 0 var(--line) }
.mode-button:has(input:checked) .mode-art { background: var(--mode-art) }
.mode-button:has(input:checked) .mode-art::before { background: var(--surface) }
.mode-button:has(input:checked) .mode-selected { display: grid }
.mode-button:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px }
.mode-button input:focus-visible { outline: none }
.welcome-actions { grid-template-columns: repeat(2,minmax(0,1fr)); padding-block-start: 9px; border-block-start: 1px solid #23283838 }
.welcome-actions .primary { min-height: 42px; padding-inline: 7px; font-size: 1rem; line-height: 1.24 }
.welcome-actions .solo-action { background: var(--leaf) }
.welcome-actions .solo-action:hover { background: #b7d885 }
.welcome-actions .quiet { grid-column: 1/-1; justify-self: center; padding-block: 3px }
@media (max-height: 550px) and (orientation: landscape) {
  .welcome-panel:has(.mode-buttons) {
    display: grid; gap: 5px 15px;
    grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
    grid-template-areas: 'suits modes' 'title modes' 'identity modes' 'actions actions';
    width: min(680px, calc(100% - var(--pad-left) - var(--pad-right) - 5px));
  }
  .welcome-panel .lobby-suits { grid-area: suits; align-self: end }
  .welcome-panel h1 { grid-area: title; margin: 4px 0; align-self: center }
  .welcome-panel .identity-entry { grid-area: identity; align-self: end; margin: 0 0 5px }
  .mode-buttons { grid-area: modes; margin: 0 3px 6px 0 }
  .welcome-actions { grid-area: actions }
}
@media (max-height: 640px) and (orientation: portrait) {
  .welcome-panel { padding: 12px }
  .welcome-panel h1 { margin-block-end: 7px }
  .identity-entry { margin-block-end: 8px }
  .mode-art { --sample-card: clamp(39px, min(15vw, 10.5dvh), 66px) }
  .mode-buttons { margin-block-end: 8px }
}

@media (max-height: 470px) and (orientation: portrait) {
  .welcome-panel .lobby-suits { display: none }
}
.panel.room-lobby {
  width: min(500px, calc(100% - var(--pad-left) - var(--pad-right) - 5px));
  padding: clamp(11px, 2.8dvh, 21px) clamp(12px, 3.5vw, 23px);
  text-align: center;
}
.room-lobby h1 { margin-bottom: 2px }
.room-lobby .room-occupancy { margin: 0 0 4px; font-size: .9rem; color: var(--soft) }
.room-table {
  --lobby-portrait: clamp(42px, min(14vmin, 10.5dvh), 76px);
  position: relative; isolation: isolate; direction: ltr;
  display: grid; gap: 0 5px;
  grid-template-columns: repeat(3,minmax(0,1fr));
  grid-template-areas: '. north .' 'west . east' '. south .';
  width: min(100%, 390px); margin-inline: auto;
  align-items: center; justify-items: center;
}
.room-felt {
  position: absolute; z-index: -1; inset: 22% 13%; display: grid; place-items: center;
  border: 2px solid var(--line); border-radius: 50%;
  background: var(--violet); box-shadow: inset 0 0 0 5px var(--violet-soft), 0 4px 0 var(--line);
  pointer-events: none;
}
.room-felt .card {
  grid-area: 1 / 1; --card-width: clamp(22px, 5vmin, 36px);
  translate: -18% 0; rotate: -13deg;
}
.room-felt .card + .card { translate: 19% 0; rotate: 12deg }
.room-seat {
  position: relative; display: grid; justify-items: center; gap: 0;
  width: 100%; min-width: 0;
}
.room-seat-south { grid-area: south }
.room-seat-north { grid-area: north }
.room-seat-west { grid-area: west; --lobby-portrait-row: 100% }
.room-seat-east { grid-area: east; --lobby-portrait-row: 100%; --lobby-portrait-flip: -1 }
.room-seat .avatar-button, .room-seat .avatar-thumb {
  width: var(--lobby-portrait); height: var(--lobby-portrait); min-height: 0;
}
.room-seat .avatar-thumb { border: 0; border-radius: 0; background: none }
.room-seat .avatar-thumb::before {
  background-position: var(--avatar-x, 60%) var(--lobby-portrait-row, 0%);
  scale: var(--lobby-portrait-flip, 1) 1; transform-origin: center;
}
.room-seat-open .avatar-thumb { opacity: .57; filter: saturate(.6) }
.room-seat-name {
  display: block; max-width: 100%; padding: 2px 7px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: .85rem; font-weight: 750; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap;
}
.room-seat-open .room-seat-name { border-style: dashed; color: var(--soft) }
.room-seat-south .room-seat-name { background: var(--leaf) }
.room-seat .swap-seat {
  position: absolute; top: 3px; right: 0;
  min-width: 26px; min-height: 26px; padding: 0 3px;
  background: var(--violet-soft); color: var(--ink);
}
.swap-seat[aria-pressed="true"] { border-color: var(--focus); background: var(--violet) }
.room-lobby .swap-hint { margin: 5px 0 0; font-size: .83rem; color: var(--focus) }
.room-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px; margin-top: 10px }
.room-actions button { min-height: 36px; padding: 4px 9px; font-size: .9rem }
.room-actions .ghost { background: var(--sky) }
.room-waiting { color: var(--soft); font-size: .875rem }
.room-waiting-list {
  container-type: inline-size; min-width: 0;
  margin-block-start: 10px; padding: 6px 8px;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--violet-soft); text-align: start;
}
.room-waiting-list:has(.queue-empty), .room-waiting-header {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.room-waiting-list h2 { margin: 0; font-size: .9rem; font-weight: 800 }
.room-waiting-list .queue-empty { margin: 0; font-size: .82rem }
.room-waiting-pages { display: flex; gap: 3px }
.room-waiting-pages button { min-width: 26px; min-height: 26px; padding: 0 5px; background: var(--surface); font-size: 1.1rem; line-height: 1 }
.room-waiting-list .waiting-player {
  grid-template-columns: auto minmax(0,1fr) minmax(0,2fr) auto;
  gap: 4px 6px; padding-block: 5px; font-size: .85rem;
  border-top: 1px solid #23283838;
}
.room-waiting-rows { margin-block-start: 4px }
.room-waiting-list:has(.queue-empty) .room-waiting-rows { margin: 0 }
.room-waiting-list .avatar-thumb { width: 27px; height: 27px }
.room-waiting-list .waiting-player bdi { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.room-waiting-list .waiting-player :is(select,button) { grid-column: auto; min-height: 34px; margin: 0; padding-block: 3px }
.room-waiting-list .waiting-player select { min-width: 0; padding-inline: 6px 23px; text-overflow: ellipsis }
.room-waiting-list .waiting-player button { padding-inline: 7px; white-space: nowrap }
@container (max-width: 355px) {
  .room-waiting-list .waiting-player { grid-template-columns: auto minmax(0,1fr) auto }
  .room-waiting-list .waiting-player bdi { grid-column: 2 / -1 }
  .room-waiting-list .waiting-player select { grid-column: 1 / 3 }
}
@media (max-height: 550px) and (orientation: landscape) and (min-width: 540px) {
  .panel.room-lobby:has(.room-waiting-list) {
    display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr);
    align-items: center; gap: 12px; width: min(730px, calc(100% - var(--pad-left) - var(--pad-right) - 5px));
  }
  .room-waiting-list { margin-block-start: 0 }
}
@media (max-height: 520px) and (orientation: portrait) {
  .room-table { --lobby-portrait: clamp(29px, 8.5dvh, 44px) }
}
.avatar-thumb { display: block; flex: none; position: relative; overflow: hidden; width: 40px; height: 40px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--violet-soft) }
.avatar-thumb::before { content: ''; position: absolute; inset: 0; background: var(--avatars-art) no-repeat var(--avatar-x, 60%) 0% / 600% 200%; scale: 1.8; transform-origin: 50% 15% }
.ghost.avatar-button { display: inline-flex; align-items: center; gap: 8px; padding: 0; min-height: 0; border: 0; background: transparent; color: var(--ink); text-align: start }
.avatar-button:hover .avatar-thumb, .avatar-button:focus-visible .avatar-thumb { border-color: var(--focus) }
.avatar-dialog { width: min(480px, 94vw); background: var(--surface); padding: clamp(13px, 3vw, 22px) }
.avatar-dialog-header { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 13px }
.avatar-dialog-header h2 { margin: 0; font-size: clamp(1.15rem, 4vw, 1.5rem) }
.avatar-dialog-header button { min-height: 32px; padding: 4px 9px; background: var(--sky-soft) }
.avatar-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px }
.avatar-option { display: grid; place-items: center; gap: 5px; padding: 7px 4px; background: var(--sky-soft); color: var(--ink); border: 1.5px solid var(--line); border-radius: 9px; font-size: .85rem }
.avatar-option:is(:hover,[aria-pressed="true"]) { border-color: var(--focus); background: var(--violet) }
.avatar-option .avatar-thumb { width: min(76px, 19vw); height: min(76px, 19vw) }
.avatar-targets { display: grid; gap: 6px }
.avatar-targets .ghost.avatar-button { padding: 4px; border-radius: 6px; background: var(--violet-soft) }
#avatarError:empty { display: none }
#avatarError { color: #9b2b4b; margin-top: 8px }
@media (max-height: 465px) and (orientation: landscape) {
  .welcome-panel h1 { margin: 2px 0 7px }
  .room-table { --lobby-portrait: clamp(34px, 9.5dvh, 42px) }
}
.primary, .ghost, select, .panel input:not(:where([type=checkbox], [type=radio])) {
  min-height: 40px;
  border: 1.5px solid var(--line);
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.primary { background: var(--sun); color: var(--ink); font-weight: 800 }
.ghost { background: var(--violet-soft); font-weight: 700 }
.ghost:hover { background: var(--violet) }
.primary:hover:not(:disabled) { background: #f5d067 }
select {
  appearance: none;
  padding-inline-end: 29px;
  background:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%) left 9px center / 5px 5px no-repeat,
    linear-gradient(135deg, var(--ink) 50%, transparent 50%) left 14px center / 5px 5px no-repeat,
    var(--surface);
}
:root[dir="ltr"] select { background-position: right 14px center, right 9px center, center }
.dock { position: relative; grid-area: 2 / 1; z-index: 3; display: grid; justify-items: center; gap: 3px; padding: 5px 0; text-align: center }
#turnStatus { min-height: 1.35em; padding: 2px 8px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--leaf); color: var(--ink); font-weight: 800 }
#turnStatus:empty { display: none }
.contract { padding: 2px 8px; border-radius: 7px; background: var(--surface); color: var(--ink); font-size: .875rem }
#controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px }
#controls:not(:empty) { margin-top: 4px }
.table-voice {
  position: absolute; z-index: 8; right: max(10px, env(safe-area-inset-right)); bottom: var(--pad-bottom);
  display: grid; justify-items: right; gap: 4px; max-width: min(55vw, 16rem);
}
.table:is([data-phase="play"], [data-phase="discard"]):has(> .table-voice:not([hidden])) .hand-area { margin-bottom: calc(var(--voice-size) + 4px) }
.voice-buttons, .voice-feedback { display: flex; align-items: center; justify-content: center; gap: 5px }
.voice-buttons { direction: ltr }
.voice-talk, .voice-speaker { display: inline-grid; place-items: center; min-height: var(--voice-size) }
.ghost.voice-talk {
  width: var(--voice-size); padding: 0; border-radius: 50%; background: var(--leaf);
  touch-action: manipulation;
}
.voice-mic { position: relative; display: block; width: 20px; height: 22px }
.voice-mic::before, .voice-mic::after, .voice-mic span { position: absolute; content: ''; box-sizing: border-box }
.voice-mic::before { inset: 0 6px 7px; border-radius: 999px; background: currentColor }
.voice-mic::after { inset: 8px 2px 3px; border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 8px 8px }
.voice-mic span { inset: 18px 9px 0; background: currentColor }
.voice-talk[aria-disabled="true"] { cursor: default; opacity: 1; background: white; color: black; border-color: black }
.voice-talk[data-live="true"] { background: #8c2e51; border-color: var(--line); color: white }
.voice-mic-state {
  padding: 3px 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: .8125rem; font-weight: 750; white-space: nowrap;
}
.voice-mic-state[data-live="true"] { background: var(--rose-soft); color: #792546 }
.voice-speaker { min-inline-size: var(--voice-size); padding-inline: 8px }
.voice-feedback {
  flex-wrap: wrap; padding: 4px 7px; font-size: .8125rem;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface);
}
.voice-feedback:has(#voiceStatus:empty):has(#voiceRetry[hidden]) { display: none }
.voice-feedback .quiet { padding: 2px 5px; color: var(--focus); text-decoration: underline }
@media (max-width: 880px) {
  .table[data-phase="bid"]:has(> .table-voice:not([hidden])) { padding-bottom: calc(var(--pad-bottom) + var(--voice-size) + 6px) }
  .table[data-phase="bid"] .table-voice { display: flex; align-items: end; max-width: calc(100% - 24px); direction: ltr }
  .table[data-phase="bid"] .voice-buttons { flex: none }
}
#message {
  position: absolute;
  z-index: 10;
  bottom: 8px;
  left: 50%;
  translate: -50% 0;
  max-width: min(440px, 92%);
  color: var(--ink);
  background: var(--rose-soft);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  text-align: center;
}
#message:empty { display: none }

.card {
  position: relative;
  display: block;
  width: var(--card-width, 52px);
  height: calc(var(--card-width, 52px) * 1.5);
  padding: 0;
  flex: 0 0 var(--card-width, 52px);
  border: 0;
  border-radius: 6%;
  background: none;
  user-select: none;
}
.face {
  position: absolute;
  inset: 0;
  border-radius: 5% / 3.33%;
  background: #fff url('/cards/faces.webp?v=28') no-repeat;
  background-size: 1300% 400%;
  box-shadow: inset 0 0 0 1px #25231f, 0 1px 3px #08171058;
}
.hand-area {
  position: relative;
  grid-area: 3 / 1;
  z-index: 3;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding-block-start: var(--ground-clearance, 0px);
  width: min(100%, 1040px);
  justify-self: center;
  --card-width: calc(clamp(55px, min(12.75dvh, 25vw), 121px) * var(--card-scale) * var(--phase-card-scale) * 1.35);
}
/* Give the bidder room for two full fans while choosing the buried cards. */
.table[data-phase="discard"]:has(.hand.discard-hand) {
  --hand-height: min(66dvh, 650px, calc(100dvh - var(--felt-top) - 88px));
}
.hand-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px }
.hand-tools:has(> :not([hidden])) { padding-block-end: 3px }
.hand-viewport { grid-row: 2; min-height: 0; margin-block-end: var(--bid-cover, 0px); overflow: clip }
.hand { position: relative; height: 100%; min-height: 0; scale: var(--hand-fit, 1); transform-origin: 50% 0 }
#sortHand, #groupJokers { min-height: 27px; padding: 3px 9px; font-size: .8rem; background: var(--sky-soft) }
#sortHand:hover, #groupJokers:hover { background: var(--sky) }
.hand.compact-hand { --selected-lift: -15px; --hover-lift: -4px }
.hand .card {
  position: absolute;
  left: calc(50% + var(--grip-x, 0px) - var(--card-width) * .5);
  top: calc(var(--grip-y, 0px) - var(--card-width) * 1.29);
  transform-origin: 50% 86%;
  transform: translate(var(--card-x, 0px), var(--card-y, 0px)) rotate(var(--angle, 0deg));
}
.hand .card:disabled { opacity: 1 }
.hand .card:disabled.dim { filter: brightness(.58) saturate(.7) }
.hand .face { transition: transform 130ms ease, box-shadow 130ms ease }
.hand .card:is(:focus-visible, .selected, .queued, .play-choice) .face {
  box-shadow: inset 0 0 0 1px #25231f, 0 0 0 2px var(--violet), 0 4px 10px #161c11b3;
  transform: translateY(var(--selected-lift, -26px));
}
.hand .card.queued .face { box-shadow: inset 0 0 0 3px #527d43, 0 0 0 2px var(--leaf) }
.hand .card:focus-visible { outline: none }
@media (hover: hover) {
  .hand .card:not(:is(.selected,.queued,.play-choice,:focus-visible)):hover .face { transform: translateY(var(--hover-lift, -8px)) }
}
@media (prefers-reduced-motion: reduce) { .hand .face { transition: none } }
.kitty {
  --card-width: var(--kitty-card);
  display: flex;
  align-items: center;
  justify-content: center;
  direction: ltr;
}
.kitty .back { margin-left: calc(var(--card-width) * -.32); transform: rotate(var(--angle)) }
.kitty .back:first-child { margin-left: 0 }
.card.back, .flight-back {
  background: #423c91;
  border: 1px solid #ede8ff;
  box-shadow: 0 2px 5px #0819109c;
}
.back::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid var(--violet);
  border-radius: 2px;
  background:
    repeating-linear-gradient(45deg, transparent 0 4px, #bfaff680 4px 5px),
    repeating-linear-gradient(-45deg, #463f96 0 4px, #bfaff6a6 4px 5px);
}
dialog {
  max-width: min(650px, 94vw);
  max-height: 90dvh;
  overflow: auto;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 5px 6px 0 var(--line);
}
dialog::backdrop { background: #25224991 }
.waiting-dialog { width: min(570px, 94vw) }
#waitingBody > p { margin-bottom: 14px }
.waiting-player { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding-block: 14px; border-top: 1px solid #a4a8bb }
.waiting-player bdi { overflow-wrap: anywhere }
.waiting-player select { grid-column: 1 / -1; width: 100%; min-width: 0 }
.waiting-player button { grid-column: 1 / -1 }
dialog ol { padding-inline-start: 23px }
dialog li { margin-bottom: 9px }
dialog .muted { margin-bottom: 12px; color: var(--soft) }
dialog a:focus-visible, dialog a:hover { text-decoration: underline }

@media (max-width: 580px) {
  .table {
    --pad-left: max(12px, env(safe-area-inset-left));
    --pad-right: max(12px, env(safe-area-inset-right));
    --hand-extra-space: 29px;
    --felt-top: clamp(148px, 21dvh, 175px);
    --figure-size: clamp(80px, 25vw, 133px);
    --side-seat: clamp(41px, 11.5vw, 68px);
    --table-card: calc(clamp(33px, 10.5vw, 51px) * var(--card-scale));
  }
  .bar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px }
  .score { inline-size: min(12.5rem,100%) }
  .brand { gap: 4px }
  .brand b { display: none }
  .bar-actions:has(.share-table:not([hidden])) .brand { display: none }
  .share-table { width: 34px; height: 34px; min-height: 34px; padding: 5px }
  .options-toggle { inline-size: 34px; block-size: 34px }
  .seat-label { min-width: 43px; padding: 3px 5px; font-size: .85rem }
  .seat-label small { font-size: .72rem }
  .west, .east { max-width: 23% }

}
@media (max-height: 560px) and (orientation: landscape) {
  .table {
    --felt-top: clamp(90px, 23dvh, 115px);
    --score-height: calc(3.5rem + 2px);
    --figure-size: clamp(66px, 21dvh, 110px);
    --table-card: calc(clamp(24px, 7.5dvh, 38px) * var(--card-scale));
    --kitty-card: calc(clamp(24px, 6.6dvh, 43px) * var(--card-scale) * var(--phase-card-scale) * .5);
  }
  .score { grid-template-rows: 1rem 1.25rem 1.25rem }
  .hand-area { --card-width: calc(clamp(49px, 12dvh, 74px) * var(--card-scale) * var(--phase-card-scale) * 1.35) }
}

@media (max-height: 520px) {
  .panel { padding: 12px 16px }
  .panel h1 { margin-bottom: 6px; font-size: 1.2rem }
  .welcome-panel h1 { font-size: clamp(1.75rem, 6vw, 2.65rem) }
  .panel label { margin-bottom: 2px }
  .panel .button-row { gap: 4px }
  .panel .button-row button, .panel input:not([type=checkbox]), .panel select { min-height: 32px; padding-block: 4px }
  .panel input:not([type=checkbox]), .panel select { margin-bottom: 5px }
  #sortHand { min-height: 25px; font-size: .76rem; padding-block: 2px }
}

.panel select { width: 100%; margin-bottom: 10px }
#controls label { font-size: .85rem; color: var(--soft) }
.joker-face {
  display: grid;
  place-items: center;
  container-type: inline-size;
  background: #fff;
  color: #131212;
}
.color-joker { color: #d94030 }
.joker-art { position: absolute; inset: 10% 17%; padding: 4%; border: 1px solid #7a72a570; border-radius: 5%; background: #fffefa url('/cards/jester.webp?v=32') center / contain no-repeat content-box }
.black-joker .joker-art { filter: grayscale(1) }
.joker-index { position: absolute; top: 5%; left: 5%; display: grid; justify-items: center; gap: .7cqw; font: 800 11.9cqw/.94 'Arial Narrow', 'Liberation Sans',sans-serif }
.joker-index.bottom { inset: auto 6% 5% auto; rotate: 180deg }
.held-cards {
  display: flex;
  align-items: center;
  gap: 6px;
  direction: ltr;
  min-height: 19px;
  padding: 2px 5px;
  border-radius: 6px;
  color: var(--ink);
}
.held-backs { display: flex; align-items: center }
.held-backs .card {
  --card-width: calc(33px * var(--phase-card-scale));
  border-radius: 2px;
  box-shadow: none;
}
.held-backs .card + .card { margin-left: -28px }
.held-backs .back::before { inset: 1px; border: 0 }


@media (max-width: 580px) {
  .held-backs { position: relative; left: 0; margin-inline: -3px }
  .held-backs .card + .card { margin-left: -31px }
  .seat .held-cards { max-width: 100px }
}

.bid-picker {
  width: 100%; padding: 8px 10px 7px; border: 2px solid var(--line); border-radius: 18px;
  color: var(--ink); background: var(--violet-soft);
  box-shadow: 3px 4px 0 var(--line);
}
.bid-picker:not(.bid-readonly) { background: #e8defb }
.bid-instrument { grid-area: gauge; position: relative; width: min(100%, 270px, 33dvh); justify-self: center; min-width: 0; margin: 0; direction: ltr }
.bid-gauge { position: relative; width: 100%; aspect-ratio: 300 / 186; touch-action: none; user-select: none; cursor: grab; border-radius: 14px }
.bid-gauge[aria-disabled="true"] { cursor: default }
.is-dragging .bid-gauge { cursor: grabbing }
.bid-gauge svg { display: block; width: 100%; height: 100%; overflow: visible }
.bid-arc { fill: none; stroke: #9586bf; stroke-width: 6; stroke-linecap: round }
.bid-progress { fill: none; stroke: var(--focus); stroke-width: 6; stroke-linecap: round }
.bid-tick { stroke: #756895; stroke-width: 1.3 }
.bid-tick.major { stroke: var(--line); stroke-width: 2 }
.bid-tick-label { fill: var(--ink); font: 750 20px var(--game-font); direction: ltr }
.bid-needle { transform-origin: 150px 128px; transition: transform 150ms ease-out }
.is-dragging .bid-needle { transition: none }
.bid-needle-blade { fill: #b63356; filter: drop-shadow(0 1px 1px #b633563d) }
.bid-hub { fill: var(--sun); stroke: var(--line); stroke-width: 3 }
.bid-seat-marker { fill: var(--driver-color); stroke: var(--line); stroke-width: 1.5 }
.bid-seat-marker.is-off { fill: #777685; stroke: #484858 }
.bid-selected { grid-area: selected; display: grid; align-content: center; justify-items: center; min-height: 48px; padding: 4px 6px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--leaf); color: #25392c; text-align: center }
.bid-selected strong { font: 400 1.25rem DSEG7,monospace; font-variant-numeric: tabular-nums }
.bid-selected small { color: #384c3b; font-size: .75rem }
/* Physical compass positions match drawSeats(), independently of text direction. */
.bid-compass {
  --bid-side-width: clamp(68px, 19vw, 104px);
  display: grid; grid-template-columns: var(--bid-side-width) minmax(0,1fr) var(--bid-side-width);
  grid-template-areas: '. north .' 'west gauge east';
  gap: 8px; align-items: center; margin-top: 6px; direction: ltr;
}
.bid-driver-north { grid-area: north }
.bid-driver-west { grid-area: west }
.bid-driver-east { grid-area: east }
.bid-driver {
  display: grid; min-width: 0; overflow: hidden;
  border: 2px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); text-align: start;
  box-shadow: 2px 2px 0 #232838bf;
}
.bid-driver-north { width: var(--bid-side-width); justify-self: center }
.bid-driver-portrait {
  position: relative; isolation: isolate; display: block; aspect-ratio: 1.55;
  overflow: hidden; border-block-end: 2px solid var(--line);
  background: color-mix(in srgb, var(--driver-color) 29%, var(--surface));
}
.bid-driver-portrait::after {
  content: ''; position: absolute; z-index: -1; inset: 0 0 auto auto;
  width: 29%; aspect-ratio: 1; border-end-start-radius: 100%;
  background: var(--driver-color);
}
.bid-driver-portrait .avatar-thumb {
  position: absolute; inset: 0 0 auto; width: 100%; height: auto; aspect-ratio: 1;
  border: 0; border-radius: 0; background: none;
}
.bid-driver-portrait .avatar-thumb::before { scale: 1.06; transform-origin: 50% 0 }
.bid-driver-details {
  display: grid; justify-items: start; align-content: center; gap: 4px;
  padding: 5px 7px 6px; min-width: 0;
}
:root[dir="rtl"] .bid-driver-details { direction: rtl }
.bid-driver-name {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: clamp(.875rem, 2.8vw, 1.0625rem); font-weight: 850; line-height: 1.2;
}
.bid-driver-value {
  min-width: 2.75em; padding: 1px 6px; border-radius: 999px;
  background: var(--driver-color); color: var(--ink);
  text-align: center; font-size: .875rem; font-weight: 750; font-variant-numeric: tabular-nums;
}
.bid-driver.is-turn { outline: 2px solid var(--focus); outline-offset: 1px }
.bid-driver.is-leading { box-shadow: 0 0 0 2px #af5b19 }
.bid-driver.is-off .bid-driver-portrait { filter: saturate(.4) brightness(.86) }
.bid-driver.is-off .bid-driver-details { background: #e6e6ec }
.bid-dial-hint { margin: 5px 0 0; color: var(--soft); text-align: center; font-size: .875rem; line-height: 1.2 }

/* Keep the cards above the instrument panel instead of covering their ranks. */
.table[data-phase="bid"] :is(.rug, .player-figure, .ground) {
  filter: blur(6px);
  pointer-events: none;
}
.table[data-phase="bid"] {
  --bid-hand-height: min(23dvh, 220px);
  grid-template-rows: minmax(0,1fr) minmax(0,var(--bid-hand-height)) auto;
}
.table[data-phase="bid"] .hand-area { grid-area: 2 / 1 }
.table[data-phase="bid"] .ground { top: calc(var(--felt-top) + 82px); --kitty-card: 22px }
.table[data-phase="bid"] .dock {
  position: relative; grid-area: 3 / 1; z-index: 6; justify-self: center; align-self: end;
  width: min(530px,100%); max-width: 100%; margin: 0; padding: 3px 0;
  grid-template-areas: 'dial' 'actions'; grid-template-columns: minmax(0,1fr); gap: 6px;
  border: 0; background: none; box-shadow: none;
}
.table[data-phase="bid"] #bidDisplay { grid-area: dial; width: 100% }
.table[data-phase="bid"] #controls {
  grid-area: actions; display: grid; grid-template-areas: 'pass selected bid';
  grid-template-columns: minmax(0,1fr) minmax(88px,auto) minmax(0,1fr);
  width: 100%; gap: 8px; margin: 0; padding: 3px 0; align-items: stretch; direction: ltr;
  border-radius: 10px;
}
.table[data-phase="bid"] #controls .bid-pass { grid-area: pass }
.table[data-phase="bid"] #controls .bid-confirm { grid-area: bid }
.table[data-phase="bid"] #controls button { min-height: 48px; padding: 4px 8px; font-size: 1rem }

@media (max-width: 400px) {
  .bid-compass { gap: 5px }
  .bid-tick-label { font-size: 24px }
}
@media (max-height: 700px) {
  .bid-compass { --bid-side-width: clamp(63px, 16vw, 83px); gap: 5px }
  .bid-driver-portrait { aspect-ratio: 1.8 }
  .bid-driver-details { padding: 3px 6px 4px; gap: 2px }
  .bid-dial-hint { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%) }
}
@media (max-height: 560px) and (orientation: landscape) {
  .table[data-phase="bid"] { --felt-top: clamp(78px, 19dvh, 107px); --bid-hand-height: min(20dvh, 110px) }
  .bid-instrument { width: min(100%, 180px, 35dvh) }
}
@media (max-height: 460px) and (orientation: landscape) {
  .bid-compass {
    grid-template-columns: repeat(3,var(--bid-side-width)) minmax(0,1fr);
    grid-template-areas: 'west north east gauge';
  }
  .bid-instrument { width: min(100%, 180px, 45dvh) }
}
@media (prefers-reduced-motion: reduce) { .bid-needle { transition: none } }

@media (max-width: 580px) and (orientation: portrait) {
  .table[data-phase="bid"] { --bid-hand-height: min(25dvh, 185px) }
}
@media (max-width: 580px) and (max-height: 590px) and (orientation: portrait) {
  .table {
    --felt-top: clamp(86px, 20dvh, 117px);
    --table-card: calc(clamp(25px, 7.2dvh, 37px) * var(--card-scale));
  }
}
.seat { transition: scale 550ms ease; transform-origin: center }
.seat.active { scale: 1.21; z-index: 5 }
.held-backs {
  display: grid;
  place-items: center;
  width: calc(72px * var(--phase-card-scale));
  height: calc(50px * var(--phase-card-scale));
}
.held-backs .card, .held-backs .card + .card {
  grid-area: 1 / 1;
  margin: 0;
  transform-origin: 50% 100%;
  transform: rotate(var(--fan-angle));
}
@media (max-width: 580px) {
  .held-backs { width: calc(58px * var(--phase-card-scale)); height: calc(44px * var(--phase-card-scale)) }
  .held-backs .card { --card-width: calc(28px * var(--phase-card-scale)) }
  .seat.active { scale: 1.12 }
}
@media (prefers-reduced-motion: reduce) { .seat, .player-figure, .player-figure::after, .table { transition: none } }

/* Each fan grips the avatar's palm and opens toward the table. */
.west, .east { --side-fan-width: 36px; --side-fan-height: 25px; --side-card-width: 16.5px }
.figure-west { --palm-x: var(--avatar-side-hand-x, .8); --palm-y: var(--avatar-side-hand-y, .77); --hand-rotation: 90deg }
.figure-east { --palm-x: calc(1 - var(--avatar-side-hand-x, .8)); --palm-y: var(--avatar-side-hand-y, .77); --hand-rotation: -90deg }
.figure-north { --palm-x: var(--avatar-front-hand-x, .26); --palm-y: var(--avatar-front-hand-y, .74); --hand-rotation: 180deg }
.player-figure .seat {
  --held-fan-width: calc(var(--side-fan-width, 36px) * var(--phase-card-scale));
  --held-fan-height: calc(var(--side-fan-height, 25px) * var(--phase-card-scale));
  display: block; width: 0; height: 0; min-width: 0; min-height: 0; max-width: none;
  left: calc(var(--palm-x) * 100%); top: calc(var(--palm-y) * 100%); right: auto;
  translate: none; scale: 1; z-index: 2;
}
.figure-north .seat {
  --north-card-width: clamp(12px, calc(var(--figure-width) * .14), 26px);
  --held-fan-width: calc(var(--north-card-width) * 2.18 * var(--phase-card-scale));
  --held-fan-height: calc(var(--north-card-width) * 1.5 * var(--phase-card-scale));
}
.player-figure .seat .held-cards { position: absolute; inset: auto; left: 0; top: 0; width: 0; min-height: 0; padding: 0; display: block }
.player-figure .seat .held-backs {
  position: absolute; left: 0; top: 0; width: var(--held-fan-width); height: var(--held-fan-height);
  margin: 0; translate: -50% -100%; transform-origin: 50% 100%; rotate: var(--hand-rotation);
}
:is(.west, .east) .held-backs .card { --card-width: calc(var(--side-card-width) * var(--phase-card-scale)) }
.figure-north .held-backs .card { --card-width: calc(var(--north-card-width) * var(--phase-card-scale)) }
.player-figure .seat-label { position: absolute; left: 0; bottom: calc(var(--held-fan-width) * .5 + 8px); translate: -50% 0; min-width: 0; max-width: none }
@media (max-width: 580px) {
  .west, .east { --side-fan-width: 29px; --side-fan-height: 22px; --side-card-width: 14px }
}
@media (max-width: 1024px) {
  /* Anchor the visible back, rather than the transparent sprite tile, to
     the screen edge. Active-player enlargement keeps that same anchor. */
  .figure-west {
    left: calc(-1 * var(--figure-size) * var(--avatar-back-inset, .2));
    translate: none;
    transform-origin: calc(var(--avatar-back-inset, .2) * 100%) 90%;
  }
  .figure-east {
    right: calc(-1 * var(--figure-size) * var(--avatar-back-inset, .2));
    translate: none;
    transform-origin: calc((1 - var(--avatar-back-inset, .2)) * 100%) 90%;
  }
}

.claim-notice {
  position: absolute; z-index: 14; top: calc(var(--felt-top) + 18px); left: 50%;
  translate: -50% 0; display: grid; gap: 3px; width: max-content;
  max-width: calc(100% - 30px); padding: 10px 20px; text-align: center;
  color: var(--ink); background: var(--sun-soft); border: 2px solid var(--line);
  border-radius: 14px; box-shadow: 3px 4px 0 var(--line); pointer-events: none;
  animation: claim-pop 320ms cubic-bezier(.2,.75,.24,1) both;
}
.claim-notice span { font-size: .86rem; color: var(--soft) }
@keyframes claim-pop { from { opacity: 0; transform: translateY(-10px) scale(.96) } }
#kittyFlight { position: fixed; inset: 0; z-index: 12; pointer-events: none }
.card.kitty-flying { position: absolute; border: 3px solid var(--picked-trim) }
.hand .kitty-picked .face { outline: 4px solid var(--picked-trim); outline-offset: -4px }
@media (prefers-reduced-motion: reduce) { .claim-notice { animation: none } }

.table:is([data-phase="play"],[data-phase="bid"]) #turnStatus {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
.table[data-phase="play"] .dock:not(:has(#controls:not(:empty))) { padding: 0 }
.trump-choices { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 5px; padding: 4px 8px; border: 2px solid var(--line); border-radius: 10px; color: var(--ink); font-size: .85rem; background: var(--violet-soft) }
.trump-choices .ghost { min-height: 30px; min-width: 32px; padding: 3px 7px; background: var(--surface); font-size: 1.15rem; line-height: 1 }
.trump-choices .red-trump { color: #ab2847 }

.quiet { display: inline-flex; align-items: center; justify-content: center; padding: 6px 10px; border: 0; background: none; color: var(--focus); font: inherit; cursor: pointer }
.quiet:hover { text-decoration: underline }
dialog.library {
  width: min(940px, calc(100vw - 26px));
  max-width: none;
  max-height: 89dvh;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 5px 6px 0 var(--line);
}
.library-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 30px);
  background: var(--violet);
  border-bottom: 2px solid var(--line);
}
.library-bar h2 { margin: 0; font-size: clamp(1.15rem, 4vw, 1.5rem) }
.library-body { display: grid; gap: 14px; padding: clamp(15px, 4vw, 28px) }
.library-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px }
.library-actions:empty, .review-picker:empty { display: none }
.library .ghost, .library .primary { display: inline-flex; align-items: center; justify-content: center; font-size: 14px }
.library .ghost { background: var(--sky-soft); border-color: var(--line) }
.library .ghost:hover { background: var(--sky) }
.library-entry { display: grid; justify-items: start; gap: 10px }
.email-sign-in { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: end; width: 100% }
.email-sign-in label { display: grid; gap: 4px; min-width: 0 }
.email-sign-in input { width: 100%; min-width: 0 }
.account-status:empty { display: none }
@media (max-width: 480px) { .email-sign-in { grid-template-columns: 1fr } }
.library-entry small, .saved-game-meta { color: var(--soft); font-size: 13px }
.library-empty { color: var(--soft); padding: 15px 0 }
.saved-games { display: grid; gap: 7px }
.saved-game { display: grid; grid-template-columns: minmax(0,1fr) minmax(6em,.64fr) auto auto; align-items: center; gap: 12px; padding: 10px 13px; border: 1.5px solid var(--line); border-radius: 11px; background: var(--sky-soft); }
.saved-game:hover { border-color: var(--focus) }
.saved-game-heading { min-width: 0; display: grid; gap: 4px }
.saved-game-heading h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.saved-game-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; line-height: 1.15 }
.saved-game h3, .review-deal h3 { margin: 0; font-size: 15px }
.saved-game-date { display: grid; justify-items: start; gap: 1px; border-inline-start: 2px solid var(--focus); padding-inline-start: 9px; line-height: 1.2; color: var(--ink) }
.saved-game-date strong { font-size: clamp(.9rem, 2.5vw, 1.08rem); font-weight: 780 }
.saved-game-date small { color: var(--soft); font-size: .75rem }
.saved-tally { display: flex; gap: 9px; color: var(--ink); font-size: .86rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap }
.saved-game .library-actions { gap: 5px; flex-wrap: nowrap }
.saved-game .library-actions :is(.ghost,.primary) { gap: 4px; min-height: 32px; padding: 4px 8px }
.saved-action-icon { display: none }
@media (max-width: 680px) {
  .saved-game { gap: 6px; padding: 7px }
  .saved-tally { gap: 2px; flex-direction: column; font-size: .72rem }
  .saved-game .library-actions :is(.ghost,.primary) { min-width: 27px; min-height: 29px; padding: 3px }
  .saved-action-icon { display: inline }
  .saved-action-caption { display: none }
  .saved-game-heading h3 { font-size: .9rem }
  .saved-game-date { padding-inline-start: 6px }
  .saved-game-meta { font-size: .69rem }
  .saved-game .game-state { font-size: .64rem; padding: 2px 5px }
}
.game-state { padding: 2px 8px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); font-size: 12px; white-space: nowrap }
.game-state.active { background: var(--sun) }
.game-state.finished { background: var(--leaf) }
.review-picker, .review-tally { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px }
.review-picker label { display: flex; align-items: center; gap: 7px }
.review-picker select { background-color: var(--sky-soft); font-size: 14px }
.review-tally { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 14px }
.review-scroll { overflow-x: auto; border: 1.5px solid var(--line); border-radius: 12px }
.review-table { width: 100%; min-width: 430px; border-spacing: 0; text-align: center; font-size: 14px }
.review-table th, .review-table td { padding: 7px 6px; border-bottom: 1px solid #b4b7c5; vertical-align: middle }
.review-table thead th { color: var(--ink); background: var(--violet-soft); white-space: nowrap }
.review-table tbody tr:nth-child(even) { background: #eef0f7 }
.review-table tbody tr:last-child > * { border-bottom: 0 }
.review-table td > strong, .review-table td > small { display: block }
.review-table td > small { color: var(--soft); font-size: 12px }
.review-winner { background: var(--sun-soft); box-shadow: inset 0 -2px #98783099 }
.replay-card { --card-width: clamp(32px, 5.2vw, 48px); margin-inline: auto }
.review-detail { padding: 10px 13px; border: 1px solid #9e9eb2; border-radius: 9px; background: var(--violet-soft) }
.review-detail summary { color: var(--focus); cursor: pointer }
.review-bids { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-bottom: 0; font-size: 14px }
.review-deal { display: grid; gap: 13px; margin-top: 10px }
.review-strip { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px }
.review-strip .replay-card { margin: 0; --card-width: 31px }
