:root {
  -webkit-user-select: none;
  user-select: none;
  color-scheme: light;
  font: 100%/1.5 "DM Sans", system-ui, sans-serif;
  color: #1e2723;
  background: #f4f6f2;
}

:root, body, .round-hand, .statistics-content {
  touch-action: pan-x pan-y;
}

* { box-sizing: border-box; }
body { margin: 0; }
.site-header {
  padding-top: env(safe-area-inset-top, 0px);
  background: #fff;
  border-bottom: 1px solid #d6ded8;
}
.header-content, main { max-width: 66rem; margin: auto; padding: 1rem; }
.header-content, .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.header-content { min-height: 3rem; padding-block: .25rem; }
.brand { font-weight: 800; text-decoration: none; }
.site-header .header-action {
  display: grid;
  place-items: center;
  width: 2.375rem;
  height: 2.375rem;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.header-action img { display: block; width: 1.125rem; height: 1.125rem; }
.site-header .account-name {
  min-height: 2.375rem;
  padding: .25rem;
  border: 0;
  background: transparent;
  color: inherit;
}
.account-menu {
  inset: 3rem max(1rem, calc((100vw - 64rem) / 2)) auto auto;
  margin: env(safe-area-inset-top, 0px) 0 0;
  padding: .5rem;
  border: 1px solid #d6ded8;
  border-radius: .5rem;
  background: #fff;
  box-shadow: 0 .25rem 1rem #0002;
}
main { padding-bottom: 3rem; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 1rem; }
h1 { font-size: clamp(1.65rem, 4vw, 2.4rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
a { color: #235541; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.panel { min-width: 0; padding: clamp(1rem, 3vw, 1.5rem); background: #fff; border: 1px solid #d6ded8; border-radius: .75rem; }
.panel > a + h1 { margin-top: 1rem; }
.login { max-width: 25rem; margin: 2rem auto; }
.admin { margin-top: 1rem; }
form { display: grid; gap: .75rem; }
label { display: grid; gap: .25rem; min-width: 0; font-weight: 600; }
input, textarea, button { font: inherit; min-height: 2.75rem; border-radius: .4rem; }
input, textarea { width: 100%; padding: .5rem .65rem; border: 1px solid #798981; color: inherit; background: #fff; }
@media (pointer: coarse) {
  input, textarea { font-size: max(16px, 1em); }
}
textarea { resize: vertical; }
button { justify-self: start; padding: .45rem .85rem; border: 1px solid #235541; background: #235541; color: white; cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
:focus-visible { outline: 2px solid #326b9a; outline-offset: 2px; }
.game, .game-settings { padding: .75rem 0; border-top: 1px solid #d6ded8; }
details { margin-top: .5rem; }
details form { margin-top: .75rem; }
summary { cursor: pointer; font-weight: 600; }
.rules { white-space: pre-wrap; overflow-wrap: anywhere; }
#join { margin-bottom: 1.5rem; }
.room-list { list-style: none; padding: 0; }
.room-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; padding: .5rem 0; }
.room-members { min-width: 0; overflow-wrap: anywhere; }
.room-code { font-family: monospace; letter-spacing: .08em; }
.at-table {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: #145438;
  background-image:
    radial-gradient(ellipse at 50% 35%, #30835366, #07291c99),
    repeating-linear-gradient(45deg, #fff0 0 2px, #fff1 2px 3px),
    repeating-linear-gradient(135deg, #0000 0 2px, #0002 2px 3px);
}
.at-table main,
.at-table #view,
.table-room {
  display: flex;
  flex: 1;
  flex-direction: column;
}
.at-table main {
  width: 100%;
  max-width: none;
  padding: .5rem .75rem .75rem;
}
.table-room {
  --game-scale: 1;
  --player-height: calc(2.5rem * var(--game-scale));
  color: #fff;
}
.table-room a { color: inherit; }
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid #ffffff5c;
}
.statistics-dialog {
  width: min(60rem, calc(100% - 1.5rem));
  max-width: none;
  max-height: 90dvh;
  padding: 1rem;
  border: 1px solid #d6ded8;
  border-radius: .75rem;
  background: #f4f6f2;
  color: #1e2723;
}
.statistics-dialog::backdrop { background: #0006; }
.statistics-dialog h2 { margin: 0; }
.statistics-content { overflow: auto; margin-top: .75rem; }
.statistics-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.statistics-table caption { padding-bottom: .5rem; text-align: left; }
.statistics-table th,
.statistics-table td { padding: .45rem .65rem; border: 1px solid #d6ded8; text-align: center; white-space: nowrap; }
.statistics-table.compact :is(th, td) { padding-inline: .25rem; }
.statistics-table thead,
.statistics-table tfoot { background: #e4efe7; font-weight: 700; }
.statistics-table small { display: block; font-size: inherit; }
.statistics-table .goal-reached { background: #d6f4ba; }
.statistics-table .goal-missed { background: #f9e5e5; }
.table-share { display: flex; flex-wrap: wrap; justify-content: center; gap: .375rem; font-size: .75rem; }
.table-toolbar button,
.table-share button {
  min-height: 1.5rem;
  padding: .1rem .4rem;
  border-color: #ffffff80;
  background: #103e2e;
}
#toggle-jokers { flex: none; font-size: .75rem; }
#toggle-jokers[aria-pressed="true"] { background: #d6f4ba; color: #103e2e; }
#toggle-jokers:disabled { cursor: default; }
.settings-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(19rem, 80vw);
  height: 100%;
  max-height: none;
  padding: 1rem;
  border: 0;
  background: #f4f6f2;
  color: #1e2723;
  box-shadow: -4px 0 20px #0004;
}
.settings-drawer[open] { animation: drawer-in .18s ease-out; }
.settings-drawer::backdrop { background: #0002; }
.settings-drawer h2 { margin: 0; }
.settings-drawer label { display: flex; justify-content: space-between; }
.settings-drawer input[type="range"] { padding-inline: 0; accent-color: #235541; }
.settings-drawer #leave-room { margin-top: 1rem; }
.settings-drawer #undo-play { margin-top: 1rem; }
.settings-drawer [hidden] { display: none; }
@keyframes drawer-in { from { translate: 100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .settings-drawer[open] { animation: none; }
}
.copy-status { margin: .25rem 0 0; font-size: .875rem; }
.copy-status:empty { margin: 0; }
.table-info { width: fit-content; max-width: 100%; }
.table-play-area {
  position: relative;
  display: flex;
  flex: 1;
}
.ready-controls,
.pregame-controls {
  position: absolute;
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  justify-items: center;
  gap: .35rem;
}
.pregame-controls {
  display: grid;
  width: min(22rem, 90%);
  text-align: center;
}
.pregame-controls form { justify-items: center; gap: .35rem; }
.pregame-controls form button { justify-self: center; }
.ready-controls button,
.pregame-controls #ready-controls button {
  min-width: 6rem;
  border-color: #ffffff80;
  background: #103e2e;
}
.opening-hand-stepper { display: flex; align-items: center; gap: .375rem; }
.opening-hand-stepper input { width: 4.5rem; color: #1e2723; text-align: center; }
.opening-hand-stepper button { min-width: 2.75rem; }
.pregame-controls form button[aria-pressed="true"] {
  background: #d6f4ba;
  color: #103e2e;
}
.ready-controls [role="status"] { font-variant-numeric: tabular-nums; }
.bid-controls { width: min(calc(10rem * var(--game-scale)), 55%); text-align: center; }
.bid-controls button { justify-self: center; }
.bid-controls input { color: #1e2723; text-align: center; }
.bid-summary > * { display: block; }
.seat-label.active-turn { outline: 2px solid #ff4545; outline-offset: 2px; }
.seat-stats { flex: none; font-size: calc(.65rem * var(--game-scale)); white-space: nowrap; }
.seat-label:has(.seat-stats) { flex-direction: column; gap: 0; }
.seat-label .seat-name { max-width: 100%; }
.round-hand .card { touch-action: none; }
.played-cards {
  position: absolute;
  inset: 50% auto auto 50%;
  pointer-events: none;
}
.played-cards .card {
  position: absolute;
  translate: calc(-50% + var(--played-x)) calc(-50% + var(--played-y));
}
.turn-notice.card-grid {
  position: absolute;
  bottom: calc(50% + max(4.75rem, var(--_cardHeight) * 1.4));
  left: 50%;
  translate: -50% 0;
  z-index: 2;
  pointer-events: none;
}
.bid-controls .turn-notice.card-grid {
  position: static;
  translate: none;
}
.turn-notice strong {
  padding: .35rem .9rem;
  border: 2px solid #fff1c2;
  border-radius: 99px;
  background: #ffdc72;
  color: #302309;
  box-shadow: 0 0 1rem #ffdc7270;
  font-size: clamp(1rem, calc(1.1rem * var(--game-scale)), 1.5rem);
  white-space: nowrap;
  animation: turn-notice-fade 1.8s ease-in-out infinite alternate;
}
@keyframes turn-notice-fade {
  from { opacity: 1; }
  to { opacity: .5; }
}
@media (prefers-reduced-motion: reduce) {
  .turn-notice strong { animation: none; }
}
.final-ranks {
  position: absolute;
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  margin: 0;
  padding: .75rem 1.25rem;
  list-style: none;
  border: 1px solid #ffffff70;
  border-radius: .5rem;
  background: #103e2e;
  text-align: center;
}
.round-hand .dragging-card { opacity: .55; }
.remaining-deck,
.hand-area { position: absolute; }
.remaining-deck {
  right: 0;
  bottom: calc(100% + .375rem);
  display: grid;
  justify-items: center;
  gap: .25rem;
}
#bid-total { font-size: .75rem; font-variant-numeric: tabular-nums; }
.bid-controls button:disabled { cursor: default; }
.remaining-deck .back-stack-preview { gap: .25rem; font-size: .75rem; }
.empty-deck {
  width: var(--_cardWidth);
  height: var(--_cardHeight);
  border: 1px dashed #ffffff80;
  border-radius: .3rem;
}
.hand-area { inset: auto 0 calc(var(--player-height) + .15rem); }
.led-suit {
  display: block;
  width: calc(1.5rem * var(--game-scale));
  height: calc(1.5rem * var(--game-scale));
  padding: .2rem;
  margin: 0 auto .25rem;
  object-fit: contain;
}
.round-hand {
  border-top: 1px solid #fff;
  overflow-x: auto;
  overflow-y: hidden;
  padding-inline: .25rem;
  padding-bottom: .5rem;
}
.round-hand .card:first-child { margin-inline-start: auto; }
.round-hand .card:last-child { margin-inline-end: auto; }
.table-play-area:has(.round-hand:not([hidden])) .table-seats { min-height: calc(19rem * var(--game-scale)); }
.table-play-area [hidden] { display: none; }
.table-seats {
  position: relative;
  flex: 1;
  min-height: 12rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.table-seats li {
  --seat-width: min(28%, calc(8rem * var(--game-scale)));
  --seat-height: var(--player-height);
  position: absolute;
  left: calc((100% - var(--seat-width)) * var(--seat-x));
  top: calc((100% - var(--seat-height)) * var(--seat-y));
  width: var(--seat-width);
}
.seat-label {
  height: var(--seat-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  padding: .125rem .3rem;
  border: 1px solid #ffffff70;
  border-radius: .5rem;
  background: #103e2e;
  text-align: center;
  overflow-wrap: anywhere;
  overflow: hidden;
  font-size: calc(.875rem * var(--game-scale));
}
.table-seats li:not(.own-seat) {
  --seat-width: min(calc(8rem * var(--game-scale)), 28%, calc(90% / var(--opponent-count, 1)));
}
.opponent-hand.card-grid {
  --_cardWidth: calc(1.375rem * var(--game-scale));
  --_cardHeight: calc(2.035rem * var(--game-scale));
  flex-wrap: nowrap;
  gap: 0;
  width: 100%;
  margin-top: .25rem;
  justify-content: center;
}
.opponent-hand .card {
  flex: none;
  padding: .05rem;
}
.opponent-hand .card + .card {
  margin-left: clamp(calc(-1 * var(--_cardWidth)), calc((100% - var(--_cardWidth) * var(--hand-count)) / max(1, var(--hand-count) - 1)), calc(-.75rem * var(--game-scale)));
}
.opponent-hand .card-back::before { margin: .05rem; }
.seat-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-indicator { flex: none; color: #e1e9e4; }
.seat-indicator.is-ready { color: #cafa9f; font-weight: 800; }
#room-connection:empty { display: none; }
.clipboard-field {
  position: fixed;
  inset: 0 auto auto 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  -webkit-user-select: text;
  user-select: text;
}
#message { padding: .75rem 1rem; background: #e4efe7; border-radius: .4rem; }
#message.error { background: #f9e5e5; color: #7e2121; }

@media (max-width: 42rem) {
  .columns { grid-template-columns: 1fr; }
  .table-seats li:not(.own-seat) {
    left: calc((100% - var(--seat-width)) * var(--seat-mobile-x));
  }
}

@media (max-width: 23.75rem) {
  .table-seats.five-opponents li:not(.own-seat) {
    --seat-width: min(28%, calc(8rem * var(--game-scale)));
  }
  .table-seats.five-opponents li:nth-child(2),
  .table-seats.five-opponents li:nth-child(6) {
    top: calc(5.25rem * var(--game-scale));
  }
  .table-seats.five-opponents li:nth-child(3) { left: 0; }
  .table-seats.five-opponents li:nth-child(5) { left: calc(100% - var(--seat-width)); }
  .table-play-area:has(.five-opponents) .table-seats,
  .table-play-area:has(.five-opponents):has(.round-hand:not([hidden])) .table-seats {
    min-height: calc(23rem * var(--game-scale));
  }
}
