/* Batak – dark card table. Mobile first; wider screens add room and a sidebar. */

:root {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273449;
  --surface-3: #334155;
  --line: rgb(148 163 184 / 0.18);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #4ade80;
  --accent-hover: #6ee7a0;
  --accent-ink: #052e16;
  --accent-soft: rgb(74 222 128 / 0.14);
  --gold: #fde68a;
  --danger: #f87171;
  --suit-red: #f87171;
  --felt-1: #1d4d3b;
  --felt-2: #133528;
  --felt-3: #0d261d;
  --card-face: #f8fafc;
  --card-red: #dc2626;
  --card-black: #0f172a;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.25), 0 8px 24px rgb(0 0 0 / 0.28);
  --shadow-lg: 0 24px 60px rgb(0 0 0 / 0.5);
  --fast: 150ms;
  --normal: 220ms;
  --slow: 250ms;
  --ease: cubic-bezier(0.2, 0.7, 0.25, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background-color: var(--bg);
  background-image: radial-gradient(1100px 520px at 50% -12%, #18264a 0%, rgb(15 23 42 / 0) 70%);
  background-repeat: no-repeat;
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

svg {
  fill: currentColor;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sprites {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ------------------------------ controls ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.1;
  cursor: pointer;
  transition: background-color var(--fast) ease, border-color var(--fast) ease, box-shadow var(--fast) ease, transform var(--fast) ease;
}

.btn:hover {
  background: var(--surface-3);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
}

.btn:disabled:hover {
  background: var(--surface-2);
}

.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-icon {
  width: 16px;
  height: 16px;
  flex: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--fast) ease, color var(--fast) ease;
}

.icon-btn:hover {
  background: var(--surface-3);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.lang-btn {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

kbd {
  display: inline-block;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgb(255 255 255 / 0.06);
  color: var(--muted);
  font: 700 10.5px/1 var(--font);
}

.tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Suit icons in the dark interface; card faces use their own colours. */
.red {
  color: var(--suit-red);
}

.black {
  color: var(--text);
}

/* ------------------------------- header ------------------------------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 4px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 22px;
  height: 22px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px rgb(74 222 128 / 0.35));
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.new-game {
  padding: 0 12px;
}

/* -------------------------------- layout ------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 8px;
}

.play {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  min-width: 0;
}

.infobar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.pill-label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.trump-value {
  display: inline-flex;
  align-items: center;
  min-width: 14px;
}

.trump-value .suit {
  width: 16px;
  height: 16px;
}

.spacer {
  flex: 1;
}

.sidebar {
  display: none;
}

.app-footer {
  display: flex;
  justify-content: center;
  padding: 0 12px 4px;
  font-size: 12px;
}

.app-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--fast) ease;
}

.app-footer a:hover {
  color: var(--accent);
}

/* --------------------------------- table ------------------------------- */

.table {
  --side: 64px;
  --tw: 58px;
  --th: calc(var(--tw) * 1.4);
  --back: 15px;
  --back-step: 3px;
  position: relative;
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr) var(--side);
  grid-template-rows: auto minmax(min-content, 1fr) auto auto;
  grid-template-areas:
    "top top top"
    "left trick right"
    "status status status"
    "hand hand hand";
  gap: 4px;
  min-width: 0;
  padding: 6px;
  overflow: hidden;
  border-radius: var(--radius);
  background: radial-gradient(ellipse 85% 70% at 50% 42%, var(--felt-1) 0%, var(--felt-2) 58%, var(--felt-3) 100%);
  box-shadow: inset 0 0 0 1px rgb(74 222 128 / 0.14), inset 0 0 70px rgb(0 0 0 / 0.45), var(--shadow);
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.table::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: radial-gradient(rgb(255 255 255 / 0.03) 1px, transparent 1px);
  background-size: 4px 4px;
  pointer-events: none;
}

/* --------------------------------- seats ------------------------------- */

.seat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 6px 4px;
  border: 1px solid rgb(255 255 255 / 0.06);
  border-radius: var(--radius);
  background: rgb(2 6 23 / 0.32);
  transition: box-shadow var(--normal) ease, background-color var(--normal) ease;
}

.seat.active {
  background: rgb(2 6 23 / 0.5);
  box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgb(74 222 128 / 0.35);
}

.seat.won {
  box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgb(253 230 138 / 0.45);
}

.seat-top {
  grid-area: top;
  flex-direction: row;
  justify-self: center;
  gap: 12px;
  padding: 5px 12px;
}

.seat-left {
  grid-area: left;
  align-self: center;
}

.seat-right {
  grid-area: right;
  align-self: center;
}

.seat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.seat-name {
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.chip.dealer {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--gold);
  color: #422006;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.seat-stats {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1px;
  font-size: 12px;
}

.seat-top .seat-stats,
.seat-you .seat-stats {
  flex-direction: row;
  gap: 10px;
}

.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
}

.stat-label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 800;
}

.stat-suit {
  width: 11px;
  height: 11px;
}

.declarer .bid .stat-value {
  color: var(--accent);
}

.backs {
  position: relative;
  display: block;
  flex: none;
  width: calc(var(--back) + (var(--n) - 1) * var(--back-step));
  height: calc(var(--back) * 1.4);
}

.card.back.mini {
  --w: var(--back);
  position: absolute;
  top: 0;
  left: calc(var(--i) * var(--back-step));
  border-radius: 2.5px;
  background: linear-gradient(160deg, #2c5282, #1e3a5f);
  box-shadow: inset 0 0 0 1px rgb(226 232 240 / 0.85), 0 1px 2px rgb(0 0 0 / 0.45);
}

/* ------------------------------ status line ---------------------------- */

.status {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
}

.seat-you {
  flex: none;
  flex-direction: row;
  gap: 10px;
  padding: 4px 10px;
}

.message {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: #f1f5f9;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.45);
}

.message.warn {
  color: var(--gold);
}

/* --------------------------------- cards ------------------------------- */

.card {
  --w: 60px;
  position: relative;
  display: block;
  flex: none;
  width: var(--w);
  height: calc(var(--w) * 1.4);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: calc(var(--w) * 0.1);
}

.card.face {
  overflow: hidden;
  background: linear-gradient(160deg, #ffffff 0%, var(--card-face) 55%, #e8edf4 100%);
  box-shadow: inset 0 0 0 1px rgb(15 23 42 / 0.14), 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 10px rgb(0 0 0 / 0.28);
  font-family: var(--font);
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
}

.card.face.red {
  color: var(--card-red);
}

.card.face.black {
  color: var(--card-black);
}

.card.face svg {
  color: inherit;
}

.corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--w) * 0.03);
  width: calc(var(--w) * 0.26);
}

.corner.tl {
  top: calc(var(--w) * 0.07);
  left: calc(var(--w) * 0.04);
}

.corner.br {
  right: calc(var(--w) * 0.04);
  bottom: calc(var(--w) * 0.07);
  rotate: 180deg;
}

.rank {
  font-size: calc(var(--w) * 0.27);
  font-weight: 800;
  letter-spacing: -0.05em;
}

.pip {
  width: calc(var(--w) * 0.17);
  height: calc(var(--w) * 0.17);
}

.centre {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.big {
  width: calc(var(--w) * 0.44);
  height: calc(var(--w) * 0.44);
}

.big.ace {
  width: calc(var(--w) * 0.6);
  height: calc(var(--w) * 0.6);
  filter: drop-shadow(0 1px 0 rgb(15 23 42 / 0.12));
}

.court .centre {
  inset: calc(var(--w) * 0.24) calc(var(--w) * 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--w) * 0.05) 0;
  border: max(1px, calc(var(--w) * 0.025)) solid currentColor;
  border-radius: calc(var(--w) * 0.06);
}

.court.red .centre {
  background: rgb(220 38 38 / 0.07);
}

.court.black .centre {
  background: rgb(15 23 42 / 0.06);
}

.court-letter {
  font-family: var(--serif);
  font-size: calc(var(--w) * 0.4);
  font-weight: 700;
}

.court-pip {
  width: calc(var(--w) * 0.13);
  height: calc(var(--w) * 0.13);
}

.court-pip.bottom {
  rotate: 180deg;
}

/* ------------------------------ the trick ------------------------------ */

.trick {
  grid-area: trick;
  position: relative;
  min-width: 0;
  min-height: calc(var(--th) * 2.1);
}

/* A faint ring on the felt where the trick is played. */
.trick::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(var(--th) * 2.25);
  height: calc(var(--th) * 2.25);
  border: 1px solid rgb(255 255 255 / 0.06);
  border-radius: 50%;
  background: radial-gradient(circle, rgb(255 255 255 / 0.035) 0%, rgb(255 255 255 / 0) 70%);
  translate: -50% -50%;
  pointer-events: none;
}

.trick .card {
  --w: var(--tw);
  position: absolute;
  left: calc(50% - var(--tw) / 2 + var(--dx) * var(--tw));
  top: calc(50% - var(--th) / 2 + var(--dy) * var(--th));
  transform: rotate(var(--rot));
}

.trick .card[data-slot="0"] {
  --dx: 0;
  --dy: 0.5;
  --rot: 2deg;
}

.trick .card[data-slot="1"] {
  --dx: 0.86;
  --dy: 0;
  --rot: 7deg;
}

.trick .card[data-slot="2"] {
  --dx: 0;
  --dy: -0.5;
  --rot: -3deg;
}

.trick .card[data-slot="3"] {
  --dx: -0.86;
  --dy: 0;
  --rot: -7deg;
}

/* ------------------------------- your hand ----------------------------- */

.hand {
  grid-area: hand;
  position: relative;
  width: 100%;
  min-width: 0;
}

.hand .card {
  --w: var(--cw);
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cw);
  height: var(--ch);
  cursor: pointer;
  transition: transform var(--normal) var(--ease), translate var(--fast) ease, filter var(--normal) ease, box-shadow var(--fast) ease;
}

.hand.instant .card {
  transition: none;
}

.hand .card.illegal {
  filter: brightness(0.56) saturate(0.45);
  cursor: not-allowed;
}

.hand .card.selected {
  box-shadow: 0 0 0 3px var(--accent), 0 12px 24px rgb(0 0 0 / 0.5);
}

.hand .card.dealt {
  animation: deal-in var(--fast) var(--ease) backwards;
}

@media (hover: hover) {
  .hand.your-turn .card:not(.illegal, .selected):hover {
    translate: 0 -6px;
  }
}

@keyframes deal-in {
  from {
    opacity: 0;
    translate: 0 -120px;
  }
}

/* ------------------------------ centre panel --------------------------- */

.panel {
  grid-area: trick;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: center;
  justify-self: center;
  width: min(100%, 360px);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(15 23 42 / 0.9);
  box-shadow: var(--shadow);
  animation: panel-in var(--slow) var(--ease);
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.panel-title {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.panel-note,
.panel-result {
  margin: 0;
  font-size: 13px;
  text-align: center;
}

.panel-note {
  color: var(--muted);
}

.panel-result {
  color: #bbf7d0;
  font-weight: 700;
}

.calls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.call {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
}

.call.pass {
  opacity: 0.6;
}

.call.high {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgb(74 222 128 / 0.5);
  color: #bbf7d0;
}

.bids {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
}

.bid-btn {
  padding: 0;
  font-size: 16px;
  font-weight: 800;
}

.bid-btn.typing {
  box-shadow: 0 0 0 2px var(--accent);
}

.pass-btn {
  grid-column: span 2;
}

.trumps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.trump-btn {
  position: relative;
  flex-direction: column;
  gap: 2px;
  min-height: 74px;
  padding: 8px 6px 10px;
}

.trump-suit {
  width: 26px;
  height: 26px;
  margin-bottom: 2px;
}

.trump-name {
  font-size: 13.5px;
  font-weight: 750;
}

.trump-count {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}

.trump-btn kbd {
  position: absolute;
  top: 5px;
  left: 5px;
}

.trump-btn .tag {
  position: absolute;
  bottom: -8px;
  left: 50%;
  translate: -50% 0;
}

.trump-btn.suggested {
  border-color: rgb(74 222 128 / 0.6);
  background: rgb(74 222 128 / 0.1);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* -------------------------- score sheet, last trick -------------------- */

.score-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.score-table th,
.score-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  vertical-align: top;
}

.score-table thead th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.score-table thead th.you {
  color: var(--accent);
}

.score-table tbody th {
  color: var(--muted);
  font-weight: 750;
  white-space: nowrap;
}

.sheet-suit {
  width: 11px;
  height: 11px;
  margin-left: 3px;
  vertical-align: -1px;
}

.score-table td.declarer {
  border-radius: 8px;
  background: rgb(74 222 128 / 0.09);
}

.score-table td.declarer.down {
  background: rgb(248 113 113 / 0.1);
}

.score-table .points {
  display: block;
  font-size: 14px;
  font-weight: 800;
}

.score-table .points.negative {
  color: var(--danger);
}

.score-table .detail,
.score-table .running {
  display: block;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.score-table tfoot th,
.score-table tfoot td {
  padding-top: 8px;
  border-bottom: 0;
  font-size: 14px;
  font-weight: 800;
}

.score-table tfoot td.leader {
  color: var(--accent);
}

.last-trick {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.last-trick li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.last-trick .card {
  --w: 50px;
}

.last-trick .winner .card {
  box-shadow: 0 0 0 2px var(--accent), 0 6px 14px rgb(0 0 0 / 0.4);
}

.last-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.last-trick .winner .last-name {
  color: var(--text);
}

.last-trick .tag {
  position: absolute;
  top: -7px;
  right: 50%;
  translate: 50% 0;
}

.empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* -------------------------------- dialogs ------------------------------ */

dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

dialog[open] {
  animation: dialog-in var(--slow) var(--ease);
}

dialog::backdrop {
  background: rgb(2 6 23 / 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

.dialog-box {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 26px);
  max-height: calc(100dvh - 26px);
  margin: 0;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 8px 18px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.dialog-body {
  min-height: 0;
  padding: 4px 18px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog-body > p {
  margin: 0;
}

.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
}

.summary {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.summary p {
  margin: 0;
  font-weight: 650;
}

.summary p + p {
  color: var(--accent);
}

.legend {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

#last-body .last-trick {
  max-width: 320px;
  margin: 10px auto 4px;
}

#last-body .last-trick .card {
  --w: 62px;
}

.setting {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.setting legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.segmented label {
  position: relative;
  flex: 1;
}

.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 700;
  transition: background-color var(--fast) ease, color var(--fast) ease;
}

.segmented input:checked + span {
  background: var(--accent);
  color: var(--accent-ink);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rules section + section {
  margin-top: 14px;
}

.rules h3 {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 15px;
}

.rules ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
}

.rules li {
  color: #cbd5e1;
  font-size: 14px;
}

/* ------------------------------ breakpoints ---------------------------- */

@media (max-width: 359px) {
  .new-game {
    width: 40px;
    padding: 0;
  }

  .new-game span {
    display: none;
  }

  /* The trump label too (the contract one already goes below 420 px): the info bar fits 320 px. */
  .pill .pill-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (max-width: 419px) {
  .contract .pill-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (max-width: 439px) {
  /* A little less air on phones: the last deal, a five-letter name and a two-digit contract still fit. */
  .infobar {
    gap: 4px;
  }

  .infobar .pill {
    padding: 0 8px;
  }
}

@media (min-width: 600px) {
  .app-header {
    padding: 8px 16px;
  }

  .brand {
    font-size: 21px;
  }

  .layout {
    padding: 0 16px;
  }

  .play {
    gap: 8px;
  }

  .table {
    --side: 104px;
    --tw: 72px;
    --back: 18px;
    --back-step: 3.5px;
    gap: 6px;
    padding: 12px;
  }

  .seat {
    padding: 8px 6px;
  }

  .seat-name {
    font-size: 14px;
  }

  .stat {
    font-size: 13px;
  }

  .message {
    font-size: 15px;
  }

  .panel {
    padding: 14px;
  }

  .trumps {
    gap: 10px;
  }
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    padding-bottom: 4px;
  }

  .table {
    --side: 120px;
    --tw: 88px;
    --back: 20px;
    --back-step: 4px;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
  }

  .side-card {
    padding: 12px 14px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .side-card h2 {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .side-card .last-trick {
    padding-top: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
