:root {
  color-scheme: dark;
  --felt: #d8a0a7;
  --felt-dark: #4f1020;
  --ink: #151313;
  --paper: #fffdf9;
  --muted: #f3dfe2;
  --gold: #f6d7dc;
  --red: #8a2638;
  --black: #1a1a20;
  --line: rgba(255, 255, 255, 0.18);
  --panel: rgba(82, 36, 48, 0.5);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  overflow: hidden;
  background: var(--felt-dark);
  color: white;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

#felt {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

.table {
  position: relative;
  z-index: 1;
  width: min(1220px, calc(100vw - 28px));
  height: 100vh;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto auto;
  gap: 14px;
  padding: 18px 0 20px;
}

.cover {
  position: relative;
  min-height: calc(100vh - 38px);
  display: grid;
  place-content: center;
  gap: 20px;
  text-align: center;
  padding-top: 138px;
}

.cover h1 {
  font-size: clamp(4rem, 13vw, 9rem);
}

.howto-card {
  position: absolute;
  top: 12px;
  left: 50%;
  width: 112px;
  aspect-ratio: 0.72;
  display: grid;
  place-items: center;
  gap: 6px;
  border: 4px solid rgba(255, 253, 249, 0.92);
  border-radius: 14px;
  background:
    radial-gradient(circle at 74% 20%, rgba(216, 160, 167, 0.42), transparent 34%),
    rgba(255, 253, 249, 0.92);
  color: #4f1020;
  box-shadow: 0 22px 56px rgba(79, 16, 32, 0.28);
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.6rem;
  font-weight: 950;
  line-height: 1;
  transform-origin: center bottom;
  translate: -50% 0;
  animation: howtoDeal 620ms cubic-bezier(0.2, 0.82, 0.22, 1) both;
  transition:
    transform 190ms ease,
    box-shadow 190ms ease,
    filter 190ms ease;
}

.howto-card span {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 0.92rem;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.howto-card:hover {
  transform: translateY(-5px) rotate(-4deg) scale(1.04);
  box-shadow: 0 30px 70px rgba(79, 16, 32, 0.36);
  filter: brightness(1.03);
}

.rules-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(79, 16, 32, 0.58);
}

.rules-card {
  width: min(680px, calc(100vw - 40px));
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: clamp(24px, 6vw, 56px);
  border: 4px solid rgba(255, 253, 249, 0.94);
  background:
    radial-gradient(circle at 80% 18%, rgba(255, 253, 249, 0.82), transparent 34%),
    linear-gradient(135deg, rgba(79, 16, 32, 0.94), rgba(138, 38, 56, 0.86) 44%, rgba(216, 160, 167, 0.88) 74%, rgba(255, 253, 249, 0.9));
  box-shadow: 0 30px 90px rgba(79, 16, 32, 0.42);
  color: #fffdf9;
  text-align: left;
  animation: rulesCardIn 260ms ease both;
}

.rules-modal:not(.hidden) {
  animation: rulesFadeIn 180ms ease both;
}

.rules-spade {
  width: 76px;
  aspect-ratio: 0.72;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 253, 249, 0.92);
  border-radius: 10px;
  background: rgba(255, 253, 249, 0.9);
  color: #4f1020;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.4rem;
}

.rules-card h2 {
  margin: 0;
  color: #fffdf9;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  text-align: center;
}

.rules-card ol {
  width: min(480px, 100%);
  margin: 0;
  padding-left: 26px;
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-weight: 850;
}

.rules-card li + li {
  margin-top: 8px;
}

#closeRulesButton {
  min-width: 150px;
  min-height: 48px;
  border: 0;
  background: #fffdf9;
  color: #4f1020;
  font-weight: 950;
  cursor: pointer;
  transition:
    transform 160ms ease,
    filter 160ms ease;
}

#closeRulesButton:hover {
  transform: translateY(-3px);
  filter: brightness(1.04);
}

@keyframes howtoDeal {
  0% {
    opacity: 0;
    transform: translateY(38px) rotate(10deg) scale(0.82);
  }

  100% {
    opacity: 1;
    transform: translateY(0) rotate(0) scale(1);
  }
}

@keyframes rulesFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rulesCardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.9);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.cover label {
  width: min(420px, calc(100vw - 48px));
  justify-self: center;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 850;
  text-align: left;
  text-transform: uppercase;
}

.cover input,
.bot-options select {
  height: 54px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  padding: 0 14px;
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
}

.cover-actions {
  width: min(720px, calc(100vw - 48px));
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.cover-actions button {
  min-height: 84px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0)),
    var(--gold);
  color: #1d160c;
  padding: 14px;
  font-size: clamp(1.45rem, 4vw, 2.25rem);
  font-weight: 950;
  cursor: pointer;
  line-height: 1;
  transition:
    transform 130ms ease,
    filter 130ms ease;
}

#playBotsButton {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
    #6f1d2c;
  color: white;
}

#playFriendsButton {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.02)),
    #d8a0a7;
  color: #311019;
}

#playTournamentButton {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(246, 215, 220, 0.88)),
    #fffdf9;
  color: #5a1424;
}

.cover-actions button:hover {
  transform: translateY(-3px);
  filter: brightness(1.04);
}

.difficulty-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 5;
  width: min(520px, calc(100vw - 48px));
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.06)),
    rgba(92, 92, 98, 0.72);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.22);
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.difficulty-panel.hidden {
  display: grid;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-50% + 14px)) scale(0.96);
  visibility: hidden;
}

.difficulty-panel h2 {
  margin: 0;
  font-size: 1.45rem;
}

.difficulty-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.difficulty-buttons button {
  min-height: 64px;
  border: 1px solid rgba(240, 198, 107, 0.42);
  background: var(--gold);
  color: #1d160c;
  font-weight: 950;
  cursor: pointer;
}

.bot-options {
  width: 100%;
  justify-self: stretch;
}

.bot-options.hidden {
  display: none;
}

.lobby {
  grid-row: 1 / -1;
  width: min(760px, calc(100vw - 48px));
  justify-self: center;
  align-self: center;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: none;
  padding: 22px;
  text-align: center;
}

.lobby h2,
.lobby p {
  margin: 0;
}

.lobby label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.lobby input,
.lobby select {
  height: 44px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 0 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.lobby select {
  min-width: 76px;
}

.lobby-row,
.mode-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.lobby-row.hidden {
  display: none;
}

.lobby button {
  min-height: 44px;
  border: 0;
  background: var(--gold);
  color: #1d160c;
  padding: 0 14px;
  font-weight: 950;
  cursor: pointer;
}

.lobby-message {
  margin: 0;
  min-height: 32px;
  color: white;
  font-size: 1rem;
  font-weight: 850;
  line-height: 1.35;
}

.invite-link {
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.topbar,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 7vw, 5.4rem);
  line-height: 0.9;
  background: linear-gradient(110deg, #4f1020 0%, #8a2638 34%, #d8a0a7 68%, #fffdf9 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.score-strip {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  max-width: min(600px, 56vw);
}

.score-card,
.opponent,
.center-table,
.bid-panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04)),
    var(--panel);
  backdrop-filter: blur(7px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.16);
}

.score-card {
  padding: 10px;
  min-height: 72px;
  min-width: 116px;
}

.score-card span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.score-card strong {
  display: block;
  font-size: 1.35rem;
}

.score-card em {
  display: block;
  color: var(--gold);
  font-size: 0.76rem;
  font-style: normal;
  margin-top: 2px;
}

.play-area {
  position: relative;
  min-height: 410px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.16), transparent 58%),
    rgba(90, 90, 96, 0.22);
  overflow: hidden;
}

.opponent {
  position: absolute;
  min-width: 150px;
  min-height: 86px;
  padding: 12px;
}

.judgement-board {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 3;
  width: 172px;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 253, 249, 0.32);
  background:
    linear-gradient(135deg, rgba(255, 253, 249, 0.2), rgba(255, 253, 249, 0.06)),
    rgba(79, 16, 32, 0.62);
  box-shadow: 0 18px 46px rgba(79, 16, 32, 0.22);
}

.judgement-board h2 {
  margin: 0;
  color: var(--gold);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.judgement-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.judgement-row strong {
  color: #fffdf9;
  font-size: 1.1rem;
}

.opponent h2 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.opponent p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.north {
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
}

.northwest {
  left: 22%;
  top: 16px;
  transform: translateX(-50%);
}

.northeast {
  right: 22%;
  top: 16px;
  transform: translateX(50%);
}

.west {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.east {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.southeast {
  right: 16px;
  bottom: 16px;
}

.center-table {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100% - 360px));
  min-height: 240px;
  transform: translate(-50%, -50%);
  padding: 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04)),
    rgba(92, 92, 98, 0.64);
  backdrop-filter: none;
}

.round-info {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.round-info strong {
  color: var(--gold);
}

#trumpLabel {
  font-size: clamp(1.45rem, 4vw, 2.5rem);
  line-height: 1;
  text-align: center;
}

.trump-suit.black {
  color: #111111;
}

.trump-suit.red {
  color: #d0182d;
}

.round-order,
.trump-order {
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: center;
}

.trump-order {
  color: var(--muted);
  margin-top: -8px;
}

.winner-banner {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.8rem, 8vw, 5.8rem);
  font-weight: 950;
  line-height: 0.92;
  text-align: center;
}

.trick-pile {
  position: relative;
  min-height: 132px;
}

.played-card {
  position: absolute;
}

.played-card[data-seat="You"] {
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
}

.played-card[data-seat="West"] {
  left: 0;
  top: 50%;
  transform: translateY(-50%) rotate(-8deg);
}

.played-card[data-seat="North"] {
  left: 50%;
  top: 0;
  transform: translateX(-50%) rotate(3deg);
}

.played-card[data-seat="Northwest"] {
  left: 24%;
  top: 12px;
  transform: translateX(-50%) rotate(-5deg);
}

.played-card[data-seat="Northeast"] {
  right: 24%;
  top: 12px;
  transform: translateX(50%) rotate(5deg);
}

.played-card[data-seat="East"] {
  right: 0;
  top: 50%;
  transform: translateY(-50%) rotate(8deg);
}

.played-card[data-seat="Southeast"] {
  right: 20%;
  bottom: 0;
  transform: translateX(50%) rotate(7deg);
}

.message {
  margin: 0;
  min-height: 44px;
  color: white;
  font-weight: 750;
  line-height: 1.35;
}

.controls {
  align-items: stretch;
}

.bid-panel {
  flex: 1;
  min-height: 78px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.bid-panel > span {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.bid-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bid-buttons button,
.deal-button {
  border: 0;
  cursor: pointer;
  min-height: 48px;
  transition:
    transform 130ms ease,
    filter 130ms ease;
}

.bid-buttons button {
  min-width: 48px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 950;
}

.deal-button {
  min-width: 150px;
  padding: 0 18px;
  background: var(--gold);
  color: #1d160c;
  font-weight: 950;
}

.bid-buttons button:hover,
.deal-button:hover,
.card-button.playable:hover .card {
  transform: translateY(-3px);
  filter: brightness(1.04);
}

.hand {
  min-height: 190px;
  display: flex;
  justify-content: center;
  align-items: end;
  gap: clamp(6px, 0.9vw, 12px);
  padding: 8px 8px 0;
}

.card-button {
  border: 0;
  padding: 0;
  background: transparent;
}

.card {
  width: clamp(78px, 9vw, 112px);
  aspect-ratio: 0.7;
  border: 3px solid rgba(255, 253, 249, 0.96);
  border-radius: 8px;
  background:
    radial-gradient(circle at 80% 18%, rgba(216, 160, 167, 0.34), transparent 34%),
    linear-gradient(135deg, rgba(255, 253, 249, 0.98), rgba(243, 223, 226, 0.94) 48%, rgba(255, 253, 249, 0.92)),
    var(--paper);
  color: #111111;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 8px;
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.34),
    0 0 0 1px rgba(0, 0, 0, 0.18);
  user-select: none;
}

.card.red {
  color: #d0182d;
}

.card.back {
  background:
    radial-gradient(circle at 70% 24%, rgba(216, 160, 167, 0.78), transparent 34%),
    repeating-linear-gradient(45deg, #6f1d2c 0 7px, #4f1020 7px 14px),
    #6f1d2c;
  border: 5px solid var(--paper);
}

.card.playable {
  cursor: pointer;
}

.card-button.playable {
  cursor: pointer;
}

.card-button:disabled {
  cursor: default;
}

.card-button.dim .card {
  opacity: 0.74;
}

.rank {
  font-size: 1.45rem;
  font-weight: 950;
}

.pip {
  display: grid;
  place-items: center;
  font-size: clamp(2.4rem, 5.4vw, 4.2rem);
}

.suit {
  text-align: right;
  font-size: 1.42rem;
}

.mini-backs {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.mini-card {
  width: 20px;
  height: 30px;
  border-radius: 3px;
  border: 2px solid var(--paper);
  background:
    radial-gradient(circle at 70% 22%, rgba(216, 160, 167, 0.74), transparent 34%),
    repeating-linear-gradient(45deg, #6f1d2c 0 4px, #4f1020 4px 8px);
}

.hidden {
  display: none;
}

@media (max-width: 860px) {
  .table {
    grid-template-rows: auto minmax(520px, 1fr) auto auto;
  }

  .rules-card {
    padding: 24px 20px;
  }

  .rules-card ol {
    font-size: 1rem;
  }

  .topbar,
  .controls,
  .lobby {
    display: grid;
    grid-template-columns: 1fr;
  }

  .score-strip {
    min-width: 0;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .center-table {
    width: calc(100% - 28px);
    top: 58%;
  }

  .judgement-board {
    right: 10px;
    top: 10px;
    width: 142px;
    padding: 10px;
  }

  .north {
    top: 10px;
  }

  .west {
    top: 122px;
  }

  .east {
    top: 122px;
  }

  .bid-panel {
    display: grid;
  }
}
