:root {
  --bg: #f4f1ea;
  --ink: #1d1d1b;
  --muted: #6b6a66;
  --panel: #ffffff;
  --line: #d9d4c7;
  --felt: #2f6b47;
  --felt-dark: #24563a;
  --accent: #b5322a;
  --team0: #2e5fa7;
  --team1: #a8641b;
  --card: #fffdf8;
  --red: #c0262d;
  --black: #1d1d1b;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--accent);
  text-decoration: none;
}

.offline {
  color: var(--accent);
  font-size: 0.9rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.home {
  max-width: 420px;
  margin: 48px auto;
  display: grid;
  gap: 12px;
}

.home h1 {
  margin: 0;
}

.notice {
  color: var(--muted);
}

button,
a.button {
  font: inherit;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

button:disabled {
  cursor: default;
  opacity: 0.5;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

input[type="text"] {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.name {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

.invite {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.invite input {
  flex: 1;
  min-width: 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.amount {
  min-width: 3ch;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
}

.trump-bar {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.trump-suit {
  font-weight: 700;
}

.big {
  font-size: 1.1rem;
  font-weight: 600;
}

/* The table: seats around a felt, the trick in the middle. */
.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  grid-template-areas:
    "felt info"
    "actions info"
    "hand hand";
  gap: 12px;
}

.felt {
  grid-area: felt;
  position: relative;
  min-height: 360px;
  background: radial-gradient(circle at center, var(--felt), var(--felt-dark));
  border-radius: 16px;
  color: #fff;
}

.info {
  grid-area: info;
  font-size: 0.9rem;
}

.info h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.info > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.info p {
  margin: 4px 0;
}

.actions {
  grid-area: actions;
}

.actions p {
  margin: 0 0 8px;
}

.hand {
  grid-area: hand;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
}

.seat {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
}

.seat.active {
  outline: 3px solid #f3d36b;
  background: rgba(0, 0, 0, 0.15);
}

.seat.top {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.seat.bottom {
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.seat.left {
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.seat.right {
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.seat-name {
  display: flex;
  gap: 6px;
  align-items: center;
  font-weight: 600;
}

.badge {
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
}

.badge.bid {
  background: #f3d36b;
}

.badge.muted {
  opacity: 0.7;
}

.backs {
  display: flex;
}

.backs .card + .card {
  margin-left: -26px;
}

.lobby-felt {
  min-height: 300px;
}

.lobby-seat {
  background: rgba(255, 255, 255, 0.12);
}

.team0 small,
.scores .team0 td:first-child,
.info .team0 {
  color: var(--team0);
}

.team1 small,
.scores .team1 td:first-child,
.info .team1 {
  color: var(--team1);
}

.felt .team0 small,
.felt .team1 small {
  color: #fff;
  opacity: 0.8;
}

.trick {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.played {
  position: absolute;
  left: 50%;
  top: 50%;
}

.played.bottom {
  transform: translate(-50%, -10%);
}

.played.top {
  transform: translate(-50%, -90%);
}

.played.left {
  transform: translate(-130%, -50%);
}

.played.right {
  transform: translate(30%, -50%);
}

/* Cards */
.card {
  width: 56px;
  height: 80px;
  border-radius: 6px;
  border: 1px solid #b9b3a4;
  background: var(--card);
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 0;
  font-weight: 700;
  line-height: 1.1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  user-select: none;
}

.card .rank {
  font-size: 1.15rem;
}

.card .suit {
  font-size: 1.4rem;
}

.card.red,
.suit-H,
.suit-D {
  color: var(--red);
}

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

button.card:not(:disabled):hover {
  transform: translateY(-4px);
}

button.card:disabled {
  opacity: 0.4;
}

.card.selected {
  transform: translateY(-10px);
  outline: 3px solid var(--accent);
}

.card.small {
  width: 38px;
  height: 54px;
}

.card.small .rank,
.card.small .suit {
  font-size: 0.9rem;
}

.card.back {
  width: 34px;
  height: 48px;
  background: repeating-linear-gradient(45deg, #8c2a24 0 4px, #a8382f 4px 8px);
  border: 2px solid #fff;
}

.last-trick {
  display: flex;
  gap: 4px;
}

.scores {
  width: 100%;
  border-collapse: collapse;
}

.scores td,
.scores th {
  padding: 3px 4px;
  text-align: left;
}

.scores .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.scores .winner {
  font-weight: 700;
}

footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  max-width: calc(100% - 32px);
}

@media (max-width: 760px) {
  .game {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "felt"
      "actions"
      "hand"
      "info";
  }

  .card {
    width: 44px;
    height: 64px;
  }

  .backs .card + .card {
    margin-left: -28px;
  }

  .felt {
    min-height: 320px;
  }
}
