:root {
  color-scheme: dark;
  --felt: #17221c;
  --panel: #202d24;
  --ink: #f6ebd1;
  --muted: #c3c1a7;
  --line: #495346;
  --mint: rgb(68% 90% 60%);
  --native-felt: rgb(7.9% 10.5% 10%);
  --gold: #e6b675;
  font-family: system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  color: var(--ink);
  background: radial-gradient(ellipse at 12% 0%, #344735, var(--felt) 54%, #111914);
}
button, input, summary { font: inherit; }
button, input {
  border: 1px solid var(--line);
  border-radius: .65rem;
  padding: .64rem .95rem;
  min-height: 2.75rem;
}
button { color: var(--ink); background: #29392d; font-weight: 650; cursor: pointer; }
button:disabled { cursor: default; }
button:not(:disabled):hover { border-color: var(--mint); }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input { color: var(--ink); background: #151e18; width: 100%; min-width: 0; }
.primary { background: var(--mint); border-color: var(--mint); color: #17221c; }
.primary:disabled { opacity: .55; }
h1, h2, .brand { font-family: Georgia, 'Times New Roman', serif; font-weight: 400; }
h1 { font-size: clamp(1.8rem, 4vw, 2.9rem); line-height: 1.05; margin: 0 0 .7rem; }
h2 { font-size: 1.55rem; margin: 0 0 .7rem; }
p { line-height: 1.5; color: var(--muted); }
p:empty { display: none; }
.brand { display: flex; align-items: center; gap: .7rem; font-size: clamp(1.55rem, 5vw, 2.25rem); white-space: nowrap; }
.brand-mark {
  display: grid; place-items: center; aspect-ratio: 1; width: 2.5rem; border-radius: .65rem;
  background: var(--mint); color: #253522; font-size: 2rem; line-height: 1;
}
.panel { padding: clamp(1rem, 3vw, 1.45rem); border: 1px solid var(--line); border-radius: 1rem; background: var(--panel); }
form label { display: block; font-weight: 650; margin-bottom: .45rem; }
.masthead, .workspace { max-width: 75rem; margin: auto; padding: 1rem clamp(.65rem, 3vw, 1.75rem); }
.masthead, nav, .actions { display: flex; align-items: center; gap: .55rem; }
.masthead { justify-content: space-between; border-bottom: 1px solid var(--line); }
.workspace + .masthead { border-top: 1px solid var(--line); border-bottom: 0; }
.brand-group { display: flex; align-items: center; gap: .65rem; }
#settings-menu { position: relative; }
#settings-toggle {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem;
  border: 1px solid var(--line); border-radius: .65rem; background: #29392d; cursor: pointer;
}
#settings-toggle::-webkit-details-marker { display: none; }
#settings-toggle svg { width: 1.35rem; height: 1.35rem; }
#settings-toggle, .settings-options button, .color-choice { -webkit-tap-highlight-color: transparent; }
.settings-options {
  position: absolute; z-index: 5; inset: calc(100% + .35rem) auto auto 0;
  display: grid; gap: .2rem; min-width: 9rem; padding: .35rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: .7rem;
  box-shadow: 0 .4rem 1.25rem #1119;
}
.workspace + .masthead .settings-options { inset: auto auto calc(100% + .35rem) 0; }
.settings-options button, .settings-options a { text-align: start; }
.settings-options a {
  padding: .56rem .7rem; border: 1px solid var(--line); border-radius: .55rem;
  background: #29392d; color: var(--ink); font-weight: 650; text-decoration: none;
}
.settings-options a:hover { border-color: var(--mint); }
nav button { padding-inline: clamp(.5rem, 2.5vw, .95rem); }
.about-toggle {
  display: inline-flex; align-items: center; gap: .4rem;
}
.about-toggle svg { width: 1.1em; height: 1.1em; }
.actions { flex-wrap: wrap; }
.lobby { max-width: 29rem; margin: clamp(.4rem, 6vw, 3rem) auto; }
.lobby form { margin: 1.35rem 0 0; }
.lobby input { max-width: 12rem; letter-spacing: .12em; text-transform: uppercase; }
.lobby-actions { margin-top: 1rem; }
#join-invite { width: 100%; min-height: 3.25rem; font-size: 1.1rem; }
#invite-lobby-link { display: inline-block; margin-top: 1rem; color: var(--muted); font-size: .88rem; }
#privacy-note { margin: 1rem 0 0; font-size: .82rem; }
.table { max-width: 31rem; margin: 0 auto; }
.table.with-board { max-width: none; display: grid; gap: .9rem; grid-template-columns: minmax(0, 1fr) minmax(16rem, .49fr); align-items: start; }
.sidebar { display: grid; gap: .85rem; }
.turn-heading { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .65rem; }
#turn { font-size: clamp(1.5rem, 3vw, 2.35rem); margin: 0; }
#turn.other-turn {
  color: #c5cabd; font-family: system-ui, sans-serif; font-style: italic; font-weight: 350;
  font-size: clamp(1.2rem, 2.4vw, 1.85rem);
}
#online-count {
  display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .55rem; border: 1px solid var(--line);
  border-radius: 1rem; color: var(--muted); font-size: .78rem; white-space: nowrap;
}
#online-count::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: var(--mint); }
.room-label { color: var(--gold); font: 700 .76rem ui-monospace, monospace; letter-spacing: .09em; text-transform: uppercase; margin-top: 0; }
#game-detail { margin: 0; font-size: .88rem; }
.match .actions { margin-top: .75rem; }
.scores { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; list-style: none; }
.scores li {
  display: flex; align-items: center; gap: .35rem; border: 1px solid var(--line);
  border-radius: 2rem; padding: .25rem .55rem; font-size: .81rem;
}
.scores li::before { content: ""; width: .65rem; aspect-ratio: 1; border-radius: 50%; background: var(--chip); }
.scores:empty { display: none; }
.board {
  --chip-x: 57.5%;
  --chip-y: 58.2%;
  position: relative; isolation: isolate;
  display: grid; grid-template: repeat(10, minmax(0, 1fr)) / repeat(10, minmax(0, 1fr));
  gap: clamp(2px, .4vw, 5px);
  aspect-ratio: 1; padding: clamp(4px, .6vw, 9px); border-radius: .9rem;
  border: 1px solid var(--line); background: #111b15; container-type: inline-size;
}
.board[data-theme="warm-stone"] { background: #4c4b41; border-color: #656351; }
[data-theme="warm-stone"] .tile:not(.corner, .target) { color: #252d2a; background: #b8b1a1; }
[data-theme="warm-stone"] .tile.red:not(.target) { color: #622e2c; }
[data-theme="warm-stone"] .tile.corner { color: #dac190; background: #535644; }
[data-theme="warm-stone"] .tile:not(.corner) .watermark { opacity: .15; }
.board[data-theme="soft-slate"] { background: #20292c; border-color: #516066; }
[data-theme="soft-slate"] .tile:not(.corner, .target) { color: #dde3dd; background: #3c474c; }
[data-theme="soft-slate"] .tile.red:not(.target) { color: #f1b8a4; }
[data-theme="soft-slate"] .tile.corner { color: #dec395; background: #2f3b3c; }
[data-theme="soft-slate"] .tile:not(.corner) .watermark { opacity: .13; }
.board[data-theme="deep-felt"] {
  background: #3c4c40; border-color: #526252; gap: 1px; padding: 4px; overflow: hidden;
}
[data-theme="deep-felt"] .tile { border-radius: 0; }
[data-theme="deep-felt"] .tile:not(.corner, .target) { color: #d5dfd2; background: #25352c; }
[data-theme="deep-felt"] .tile.red:not(.target) { color: #e3b39e; }
[data-theme="deep-felt"] .tile.corner { color: #dec395; background: #303e2e; }
[data-theme="deep-felt"] .tile:not(.corner) .watermark { visibility: hidden; }
.tile, .card {
  position: relative; display: grid; place-items: center; isolation: isolate; min-height: 0; min-width: 0; padding: 0;
  border: 0; border-radius: .3rem; color: #243b32; background: #e9ddbb; line-height: 1;
}
.tile.red, .card.red { color: #8c3e35; }
.tile.corner { background: #3b4931; color: var(--gold); }
.face { position: absolute; inset: 8% auto auto 8%; font: 800 clamp(.56rem, 2.1cqw, 1.06rem) ui-monospace, monospace; }
.watermark { font: 400 clamp(1.15rem, 5.2cqw, 2.7rem) Georgia, serif; opacity: .40; }
.corner .watermark {
  position: absolute; top: var(--chip-y); left: var(--chip-x); translate: -50% -50%;
  opacity: .9; font-size: clamp(.75rem, 3.7cqw, 1.85rem);
}
.tile:disabled { pointer-events: none; }
.tile.target { background: var(--mint); box-shadow: inset 0 0 0 2.5px white; z-index: 1; }
.tile.target:active { opacity: .83; }
.tile.wild-target {
  background: #769c6c;
  box-shadow: inset 0 0 0 2.5px rgb(255 255 255 / .67);
}
.placement-highlight {
  position: absolute; inset: 0; z-index: 1; pointer-events: none; border-radius: inherit;
  opacity: 0;
  background: rgb(255 221 143 / .24);
  box-shadow: inset 0 0 0 2px #ffe3a2, inset 0 0 0 4px #815514, 0 0 8px #ffd67c99;
  animation: placement-highlight 2500ms ease-out;
}
@keyframes placement-highlight {
  0%, 20% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .placement-highlight { animation-timing-function: steps(1, end); }
}
#board-feedback {
  position: absolute; top: 50%; left: 50%; translate: -50% -50%; z-index: 3; pointer-events: none;
  padding: .55rem .95rem; border: 1px solid var(--gold); border-radius: .65rem;
  color: var(--ink); background: var(--felt); box-shadow: 0 2px 12px #101714a6;
  font-weight: 650; white-space: nowrap;
}
#board-feedback:empty { opacity: 0; }
.chip {
  position: absolute; width: 54%; aspect-ratio: 1; border-radius: 50%;
  top: var(--chip-y); left: var(--chip-x); translate: -50% -50%;
  display: grid; place-items: center; color: #17221c; font-size: 1.55cqw;
  background: var(--chip); border: 1px solid #fff8; box-shadow: inset 0 0 0 .22em #17221c44, 0 2px 2px #10171475;
}
.seat-0 { --chip: var(--mint); }
.seat-1 { --chip: rgb(99% 57% 43%); }
.seat-2 { --chip: rgb(52% 76% 97%); }
.seat-3 { --chip: rgb(91% 79% 52%); }
.sequence-layer {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none;
}
.sequence-line, .ribbon-beam { stroke-linecap: round; }
.sequence-line {
  stroke: color-mix(in oklab, var(--chip) 64%, var(--native-felt)); stroke-width: var(--sequence-width, .047);
}
.ribbon-edge { stop-color: var(--chip); }
.ribbon-light { stop-color: white; }
.ribbon-glow { stroke: var(--chip); stroke-opacity: .4; }
.ribbon-outline { stroke: color-mix(in oklab, var(--chip) 37%, var(--native-felt)); }
.ribbon-ring-edge { fill: none; stroke: color-mix(in oklab, var(--chip) 45%, var(--native-felt)); }
.ribbon-ring-light { fill: none; stroke: color-mix(in oklab, white 65%, var(--chip)); }
.ribbon-spark { fill: rgb(97% 93% 83% / .95); }
#hand-panel { overflow: clip; }
.hand-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.hand-heading:has(#player-name-form:not([hidden])) h2 { margin: 0; }
#player-name-form { width: min(10rem, 55%); }
#player-name { min-height: 2.25rem; padding: .35rem .55rem; }
#player-name::placeholder { color: var(--muted); }
.hand + .actions { margin-top: .35rem; }
.hand + .actions:not(:has(> button:not([hidden]))) { display: none; }
.hand {
  --card-width: min(67px, 20%);
  --step: min(var(--card-width) * .77, (100% - var(--card-width) - 16px) / var(--gaps, 1));
  position: relative; isolation: isolate; height: 152px;
  touch-action: pan-y pinch-zoom; user-select: none;
}
.card {
  --fan-slot: calc(var(--slot) + var(--drag-slot-shift, 0));
  --card-tilt: calc(var(--fan-slot) * 5deg);
  --card-y: calc(7px + var(--fan-slot) * var(--fan-slot) * 1.5px);
  position: absolute; top: 50%;
  left: calc(50% - var(--card-width) / 2 + var(--slot) * var(--step) + var(--drag-offset, 0px));
  width: var(--card-width); aspect-ratio: 1 / 1.39; border: 1px solid #fff6; border-radius: .55rem;
  z-index: calc(4 + var(--fan-slot));
  transform: translateY(calc(-50% + var(--card-y))) rotate(var(--card-tilt));
  box-shadow: 0 2px 5px #121a15a6;
}
.card[aria-pressed="true"], .card.dragging { --card-y: -8px; --card-tilt: 0deg; }
.card.dragging { z-index: 9; cursor: grabbing; }
.card .watermark { font-size: 1.95rem; margin-top: .22rem; }
.card .face { font-size: .8rem; }
.jack-wild { --jack-stripe: rgb(27% 48% 43%); }
.jack-removal { --jack-stripe: rgb(58% 38% 22%); }
.jack-stripes {
  position: absolute; inset: 32% auto max(9%, 1rem) 9%; display: flex; gap: 2px;
}
.jack-stripes::before, .jack-wild .jack-stripes::after {
  content: ""; width: 2px; border-radius: 999px; background: var(--jack-stripe);
}
.jack-role {
  position: absolute; inset: auto auto 8% 38%; translate: -50%;
  font: 800 .5rem/1 ui-monospace, monospace;
}
.card[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--mint), 0 3px 9px rgb(68% 90% 60% / .45); }
.card[aria-disabled="true"] { opacity: .68; cursor: grab; }
.card[aria-disabled="true"].dragging { cursor: grabbing; }
.card.replacement::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 3px rgb(91% 79% 52%); opacity: 0;
  animation: replacement-border 1350ms linear;
}
@keyframes replacement-border {
  0%, 66.6667% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .hand:not(:has(.dragging)) .card { transition: transform 180ms ease-out; }
  .card.replacement:not(.dragging) { animation: replacement-slide 340ms ease-out; }
}
@keyframes replacement-slide {
  from { translate: min(100%, 44px) 0; }
  to { translate: 0 0; }
}
#notice { font-size: .88rem; color: var(--gold); text-align: center; }
dialog { max-width: min(31rem, calc(100% - 2rem)); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: .9rem; padding: 1.25rem; }
dialog::backdrop { background: #101613cc; }
dialog li { margin-block: .65rem; line-height: 1.45; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; }
#colors[open] {
  width: min(34rem, calc(100% - 1.5rem)); max-width: none; max-height: 86dvh;
  display: flex; flex-direction: column; gap: .8rem; overflow: hidden;
}
.color-choices {
  display: grid; gap: .65rem; padding: 3px; overflow-y: auto; overscroll-behavior: contain;
}
.color-choice {
  position: relative; display: grid; grid-template-columns: 48% 1fr; gap: .8rem; align-items: center;
  min-height: clamp(7.5rem, 20dvh, 10rem); padding: .65rem;
  background: #29392d; border: 1px solid var(--line); border-radius: .65rem; cursor: pointer;
}
.color-choice:has(:checked) { border-color: var(--mint); box-shadow: inset 0 0 0 1px var(--mint); }
.color-choice:has(:focus-visible) { outline: 2px solid var(--gold); outline-offset: 1px; }
.color-choice input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.board.board-sample {
  grid-template: repeat(3, minmax(0, 1fr)) / repeat(4, minmax(0, 1fr));
  grid-column: 1; grid-row: 1; justify-self: start;
  width: 100%; max-width: 10rem; padding: 3px; aspect-ratio: 4 / 3;
  border-radius: .45rem;
}
.color-choice > span:last-child { grid-column: 2; grid-row: 1; }
.board-sample .face { font-size: clamp(.43rem, 5.7cqw, .61rem); }
.board-sample .watermark { font-size: clamp(.8rem, 13cqw, 1.2rem); }
#sounds { width: 25rem; }
.sound-options { display: grid; gap: .7rem; margin-top: .8rem; }
.sound-options label {
  display: flex; gap: .75rem; align-items: center; justify-content: space-between;
  padding: .7rem; border: 1px solid var(--line); border-radius: .65rem; cursor: pointer;
}
.sound-options input { flex: none; margin: 0; width: 1.25rem; height: 1.25rem; min-height: 0; accent-color: var(--mint); }
.sound-options label:has(:disabled) { cursor: default; color: var(--muted); }
.sound-options small { display: block; margin-top: .25rem; color: var(--muted); }
#share-invite { width: 28rem; }
#share-invite label { display: block; margin: .85rem 0 .35rem; color: var(--muted); }
.invite-row { display: flex; gap: .5rem; position: relative; }
#invite-link { cursor: copy; }
#share-device { flex: 0 0 2.75rem; display: grid; place-items: center; padding: 0; }
#share-device svg { width: 1.4rem; height: 1.4rem; }
#copy-link { margin-top: .85rem; }
#copied {
  position: absolute; z-index: 1; pointer-events: none; left: 50%; bottom: calc(100% + .35rem);
  translate: -50%; border-radius: .55rem; background: var(--mint); color: #17221c;
  padding: .3rem .65rem; font-size: .85rem; font-weight: 700;
}
#copied:empty { opacity: 0; }
#invite-status { margin: .65rem 0 0; font-size: .88rem; }
#about { width: 20rem; }
.build-info { font: .85rem/1.6 ui-monospace, monospace; }
.about-credit { color: var(--ink); margin-bottom: 0; }
@media (max-width: 760px) {
  .table.with-board, .table.with-board .sidebar { display: contents; }
  .workspace:has(.with-board) { display: flex; flex-direction: column; gap: .7rem; }
  .turn-heading { order: 0; }
  .board { order: 1; width: 100%; max-width: 33rem; align-self: center; }
  #hand-panel { order: 2; }
  .match { order: 3; }
  #notice { order: 4; }
}
@media (max-width: 460px) {
  .masthead { flex-wrap: wrap; gap: .35rem; }
  .masthead nav, .brand-group, .brand { gap: .35rem; }
  .brand { font-size: clamp(1.2rem, 4.7vw, 1.55rem); }
  .brand-mark { width: 2.05rem; font-size: 1.65rem; }
  .masthead nav button { padding-inline: .48rem; }
}

.passkey-page {
  width: min(100% - 2rem, 34rem);
  margin: 12vh auto 3rem;
}
.passkey-page form, .passkey-page section {
  display: grid;
  gap: .75rem;
  justify-items: start;
}
.passkey-page input { width: min(100%, 24rem); }
.passkey-accounts { padding-left: 1.25rem; }
.passkey-accounts li { margin: 1rem 0; overflow-wrap: anywhere; }
.passkey-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }

.passkey-page #passkey-status:empty { display: none; }
.account-page { width: min(100% - 2rem, 37rem); margin: 2rem auto 3rem; }
.account-page .panel + .panel { margin-top: .9rem; }
.account-page .panel h2 { margin-top: 0; }
.account-page .color-choices { margin-top: .65rem; }
.account-page #account-email { overflow-wrap: anywhere; }
