:root {
  color-scheme: dark;
  --bg: #08110f;
  --felt: #12392f;
  --felt-2: #0d2a25;
  --panel: rgba(9, 18, 18, 0.82);
  --line: rgba(255, 255, 255, 0.16);
  --ink: #f6f1e8;
  --muted: #b8c3ba;
  --gold: #f1cb69;
  --red: #e54d4d;
  --green: #2fa66a;
  --yellow: #d8a820;
  --black: #172024;
  --blue: #71c8f4;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 20% 10%, rgba(113, 200, 244, 0.12), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(241, 203, 105, 0.13), transparent 28%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

.table {
  display: grid;
  grid-template-rows: auto auto minmax(330px, 1fr) auto;
  gap: 12px;
  width: min(1200px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px;
}

.start-screen {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 25%, rgba(241, 203, 105, 0.18), transparent 34%),
    rgba(4, 10, 9, 0.88);
  backdrop-filter: blur(12px);
}

.start-screen.hidden {
  display: none;
}

.start-panel {
  display: grid;
  width: min(560px, 100%);
  gap: 16px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(9, 18, 18, 0.92);
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.42);
}

.eyebrow {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.start-panel h2 {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: clamp(42px, 10vw, 74px);
  line-height: 0.9;
}

.start-panel > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.name-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.name-field input {
  min-height: 46px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  padding: 0 12px;
}

.name-field input:focus {
  border-color: rgba(241, 203, 105, 0.72);
  outline: 2px solid rgba(241, 203, 105, 0.18);
}

.legend-item {
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 750;
}

.legend-item b {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  font-size: 20px;
}

.start-actions {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 10px;
}

#startGameBtn,
#startLeaderboardBtn {
  min-height: 52px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 900;
}

#startGameBtn {
  background: var(--gold);
  color: #211707;
}

#startLeaderboardBtn {
  border: 1px solid rgba(241, 203, 105, 0.62);
  background: rgba(241, 203, 105, 0.12);
  color: var(--ink);
}

.topbar,
.scoreboard,
.hand-wrap,
.message,
.actions button,
dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 14px 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: 0;
  line-height: 0.95;
}

.topbar p,
.round-info,
.player-strip span,
.score-card small,
.bot-meta,
.message {
  color: var(--muted);
}

.round-info {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  font-size: 14px;
}

.round-info span,
.score-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  padding: 8px 10px;
}

#leaderboardBtn {
  min-height: 35px;
  padding: 0 12px;
  border: 1px solid rgba(241, 203, 105, 0.62);
  background: rgba(241, 203, 105, 0.18);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
}

.trump-pill {
  border-color: rgba(241, 203, 105, 0.78) !important;
  background: rgba(241, 203, 105, 0.18) !important;
  color: var(--ink);
  font-weight: 900;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
}

.score-card {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.score-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-card.current {
  border-color: rgba(241, 203, 105, 0.7);
}

.felt {
  position: relative;
  display: grid;
  min-height: 390px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.08), transparent 28%),
    radial-gradient(circle at center, var(--felt), var(--felt-2));
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.34);
}

.center {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  width: min(620px, calc(100% - 32px));
  gap: 12px;
  place-items: center;
  transform: translate(-50%, -50%);
}

.trick {
  display: grid;
  min-height: 154px;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 10px;
  width: 100%;
  align-items: end;
}

.played {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.played span {
  color: var(--muted);
  font-size: 12px;
}

.message {
  width: 100%;
  min-height: 45px;
  padding: 12px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 760;
  text-align: center;
}

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

.actions button,
#newGameBtn,
.choice-grid button {
  min-height: 40px;
  padding: 0 13px;
  background: var(--gold);
  color: #211707;
  cursor: pointer;
  font-weight: 800;
}

.opponent {
  position: absolute;
  display: grid;
  gap: 6px;
  min-width: 150px;
  justify-items: center;
}

.opponent.top {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
}

.opponent.left {
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
}

.opponent.right {
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
}

.bot-name {
  color: var(--ink);
  font-weight: 800;
}

.bot-cards {
  display: flex;
  height: 50px;
}

.card-back {
  width: 30px;
  height: 44px;
  margin-left: -12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background:
    linear-gradient(135deg, transparent 38%, rgba(241, 203, 105, 0.55) 39% 43%, transparent 44%),
    #18344b;
}

.card-back:first-child {
  margin-left: 0;
}

.hand-wrap {
  border-color: rgba(241, 203, 105, 0.36);
  padding: 14px;
  background: rgba(8, 15, 15, 0.92);
}

.player-strip {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
}

.player-strip > div {
  display: grid;
  gap: 2px;
}

.player-strip strong {
  color: var(--gold);
  font-size: 19px;
}

.hand {
  display: grid;
  min-height: 178px;
  grid-auto-flow: column;
  grid-auto-columns: 112px;
  gap: 12px;
  align-items: flex-end;
  overflow-x: auto;
  padding: 8px 3px 10px;
}

.card {
  display: grid;
  position: relative;
  width: 112px;
  height: 160px;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  padding: 13px;
  border: 2px solid rgba(18, 23, 26, 0.3);
  background:
    linear-gradient(180deg, #fffdf5, #efe8d9);
  color: var(--black);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.card::before {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--card-color, #51606a) 0 13px, transparent 13px),
    linear-gradient(180deg, var(--card-color, #51606a) 0 31px, transparent 31px);
  content: "";
  pointer-events: none;
}

.card::after {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(18, 23, 26, 0.14);
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 255, 255, 0.58), transparent 39%),
    linear-gradient(135deg, transparent 44%, rgba(18, 23, 26, 0.05) 45% 55%, transparent 56%);
  content: "";
  pointer-events: none;
}

.card-band {
  display: none;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-8px);
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.card.disabled {
  cursor: not-allowed;
  filter: grayscale(0.7) brightness(0.72);
}

.card.disabled:hover {
  transform: none;
}

.rank {
  position: relative;
  z-index: 1;
  display: grid;
  width: 76px;
  height: 76px;
  align-self: center;
  justify-self: center;
  place-items: center;
  border: 4px solid var(--card-color, #51606a);
  background: #fffdf7;
  box-shadow: 0 8px 18px rgba(31, 39, 42, 0.16);
  color: var(--card-text, #11181b);
  font-family: Georgia, serif;
  font-size: 49px;
  font-weight: 900;
  line-height: 0.9;
}

.suit-label {
  position: relative;
  z-index: 1;
  display: grid;
  align-self: end;
  place-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(18, 23, 26, 0.16);
  background: rgba(255, 255, 255, 0.72);
  color: #1c2427;
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.corner {
  display: none;
}

.suit-c {
  color: var(--blue);
}

.suit-d {
  color: var(--red);
}

.suit-h {
  color: var(--yellow);
}

.suit-s {
  color: var(--green);
}

.card.suit-c,
.trump-pill.suit-c,
.legend-item.suit-c {
  --card-color: #1577d2;
  --card-text: #0c4f94;
  color: #1577d2;
}

.card.suit-d,
.trump-pill.suit-d,
.legend-item.suit-d {
  --card-color: #d33d3d;
  --card-text: #9d2020;
  color: #d33d3d;
}

.card.suit-h,
.trump-pill.suit-h,
.legend-item.suit-h {
  --card-color: #d6a31d;
  --card-text: #956800;
  color: #d6a31d;
}

.card.suit-s,
.trump-pill.suit-s,
.legend-item.suit-s {
  --card-color: #19a05b;
  --card-text: #0d6538;
  color: #19a05b;
}

.special {
  border-color: rgba(18, 23, 26, 0.24);
}

.wizard-card {
  --card-color: #2878d8;
  --card-text: #33228f;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 255, 255, 0.88) 0 20%, transparent 21%),
    conic-gradient(from 20deg, #2878d8, #8b5cf6, #e54d9b, #f1c94f, #21b37a, #2878d8);
  border-color: rgba(255, 255, 255, 0.66);
  box-shadow: 0 13px 26px rgba(63, 72, 180, 0.32);
}

.jester-card {
  --card-color: #69727a;
  --card-text: #343a40;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0 8px, rgba(0, 0, 0, 0.04) 8px 16px),
    linear-gradient(180deg, #e8eaeb, #b8bec3);
  border-color: rgba(47, 54, 60, 0.38);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.22);
}

.wizard-card::before {
  background:
    radial-gradient(circle at 23% 22%, rgba(255, 255, 255, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 78% 23%, rgba(255, 255, 255, 0.75) 0 2px, transparent 3px),
    radial-gradient(circle at 72% 76%, rgba(255, 255, 255, 0.8) 0 3px, transparent 4px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.7) 0 10px, transparent 10px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.64) 0 28px, transparent 28px);
}

.wizard-card::after {
  border-color: rgba(255, 255, 255, 0.64);
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 255, 255, 0.74), transparent 35%),
    linear-gradient(135deg, transparent 42%, rgba(255, 255, 255, 0.42) 43% 47%, transparent 48% 53%, rgba(255, 255, 255, 0.28) 54% 58%, transparent 59%);
}

.jester-card::before {
  background:
    linear-gradient(90deg, rgba(68, 75, 82, 0.72) 0 13px, transparent 13px),
    linear-gradient(180deg, rgba(68, 75, 82, 0.72) 0 31px, transparent 31px);
}

.jester-card::after {
  border-color: rgba(47, 54, 60, 0.16);
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 255, 255, 0.46), transparent 38%),
    linear-gradient(135deg, transparent 44%, rgba(0, 0, 0, 0.06) 45% 55%, transparent 56%);
}

.wizard-card .rank {
  border-color: rgba(255, 255, 255, 0.76);
  background: rgba(255, 255, 255, 0.86);
}

.jester-card .rank {
  border-color: #69727a;
  background: rgba(247, 247, 244, 0.82);
}

dialog {
  width: min(540px, calc(100% - 28px));
  padding: 22px;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(2, 7, 7, 0.64);
}

dialog h2 {
  color: var(--gold);
  font-size: 26px;
}

dialog p {
  margin-top: 8px;
  color: var(--muted);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.dialog-head button,
.quiet-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.leaderboard-table {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.period-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 18px;
}

.period-tabs button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
}

.period-tabs button.active {
  border-color: rgba(241, 203, 105, 0.74);
  background: rgba(241, 203, 105, 0.18);
  color: var(--ink);
}

.leaderboard-row {
  display: grid;
  grid-template-columns: minmax(86px, 1.2fr) repeat(6, minmax(54px, 1fr));
  gap: 6px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

.leaderboard-row.header {
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.leaderboard-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiet-button {
  width: 100%;
  margin-top: 12px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 11px;
  margin-top: 18px;
}

.choice-grid button {
  min-height: 58px;
  font-size: 22px;
}

@media (max-width: 760px) {
  .table {
    padding: 8px;
    gap: 8px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .round-info {
    justify-content: flex-start;
  }

  #leaderboardBtn {
    width: 100%;
  }

  .scoreboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .felt {
    min-height: 340px;
  }

  .opponent {
    min-width: 104px;
  }

  .opponent.left,
  .opponent.right {
    top: 64%;
  }

  .trick {
    grid-template-columns: repeat(2, 1fr);
    min-height: 214px;
  }

  .card {
    width: 82px;
    height: 118px;
    padding: 9px;
  }

  .hand {
    min-height: 134px;
    grid-auto-columns: 82px;
    gap: 7px;
  }

  .rank {
    width: 52px;
    height: 52px;
    font-size: 34px;
  }

  .suit-label {
    font-size: 9px;
  }

  .leaderboard-row {
    grid-template-columns: minmax(76px, 1.2fr) repeat(6, minmax(38px, 1fr));
    font-size: 11px;
    padding: 7px;
  }

  .period-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .start-actions {
    grid-template-columns: 1fr;
  }
}
