:root {
  --ink: #182c25;
  --muted: #7c887f;
  --cream: #f2efe6;
  --gold: #b99a58;
  --line: #e5dfd0;
  --felt: #155041;
  --felt2: #0d382f;
  --red: #b84b42;
  --shadow: 0 14px 35px #14292312;
  --premium-gold: #d6bc79;
  --premium-dark: #0e3028;
}

body {
  background:
    radial-gradient(ellipse at 12% 0%, #fffdf6 0, transparent 34%),
    radial-gradient(ellipse at 92% 20%, #e8e2d3 0, transparent 30%),
    var(--cream);
  background-attachment: fixed;
}

.app-shell {
  max-width: 1660px;
  padding-inline: clamp(18px, 4vw, 64px);
}

.topbar {
  height: 88px;
  border-bottom-color: #c9b98266;
}

.brand {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  letter-spacing: 2.8px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-color: #c6a95e;
  background: linear-gradient(145deg, #fffdf6, #eee7d5);
  box-shadow: inset 0 0 0 3px #fffdf680, 0 3px 10px #6f582021;
}

.round-indicator {
  padding: 8px 11px;
  border: 1px solid #d8ceb1;
  border-radius: 99px;
  background: #fffdf57a;
}

.game-layout {
  gap: clamp(22px, 3.4vw, 52px);
  padding-top: 34px;
}

.score-card {
  position: relative;
  overflow: hidden;
  padding: 20px 19px 17px;
  border: 1px solid #3f6859;
  border-radius: 9px;
  background:
    radial-gradient(ellipse at 95% 0%, #c9ac5d20, transparent 42%),
    linear-gradient(145deg, #204c3d, #12392f 76%);
  box-shadow: 0 14px 32px #122d252b, inset 0 1px #ffffff12;
  color: #f3eedf;
}

.score-heading,
.score-live {
  color: #d9c991;
}

.contract-name {
  color: #fff8e9;
  font-size: 25px;
}

.score-rule {
  background: linear-gradient(90deg, #d4b86c88, #d4b86c12);
}

.score-row {
  color: #c5d2c9;
}

.score-row strong {
  color: #fff8e9;
}

.score-row strong small {
  color: #bdc9c0;
}

.player-mode {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #78857a;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .7px;
}

.player-mode select {
  max-width: 90px;
  border: 1px solid #ddd5c1;
  border-radius: 5px;
  padding: 7px 6px;
  background: #fffdf7;
  color: #45594c;
  font: 600 9px 'DM Sans', sans-serif;
}

.spectate-button,
.retry-online-button,
.retry-online-top {
  width: 100%;
  border: 1px solid #d8cfb1;
  border-radius: 4px;
  padding: 10px;
  background: #f6f3e9;
  color: #796a43;
  font: 600 10px 'DM Sans', sans-serif;
  cursor: pointer;
}

.retry-online-top {
  width: auto;
  padding: 8px 10px;
}

.retry-online-button {
  margin: 8px 0;
}

.analysis-button {
  margin-top: 9px;
  border: 1px solid #d6c58f;
  border-radius: 5px;
  padding: 10px 13px;
  background: #fffaf0;
  color: #7f6b3c;
  font: 600 10px 'DM Sans', sans-serif;
  cursor: pointer;
}

.analysis-summary {
  display: grid;
  gap: 6px;
  margin: 16px 0;
}

.analysis-summary p,
.training-progress,
.settings-shortcuts {
  margin: 0;
  color: #758077;
  font-size: 11px;
  line-height: 1.5;
}

.analysis-tricks {
  max-height: min(48vh, 420px);
  overflow-y: auto;
  border-top: 1px solid #e6e1d5;
}

.analysis-trick {
  border-bottom: 1px solid #e6e1d5;
  color: #5d7062;
  font-size: 10px;
}

.analysis-trick summary {
  padding: 10px 2px;
  cursor: pointer;
  font-weight: 700;
}

.analysis-trick ul {
  display: grid;
  gap: 5px;
  margin: 0 0 10px;
  padding-left: 16px;
  color: #808b81;
}

.training-question {
  margin: 18px 0 14px;
  color: #405849;
  font: 600 16px/1.45 'Playfair Display', serif;
}

.training-answers {
  display: grid;
  gap: 8px;
}

.training-answer {
  border: 1px solid #e1ddcf;
  border-radius: 5px;
  padding: 11px 12px;
  background: #fffefa;
  color: #596b5f;
  font: 500 11px 'DM Sans', sans-serif;
  text-align: left;
  cursor: pointer;
}

.training-answer.answer-correct {
  border-color: #6e9b79;
  background: #edf6ee;
}

.training-answer.answer-wrong {
  border-color: #c88379;
  background: #fbefed;
}

.training-feedback {
  min-height: 38px;
  margin: 12px 0;
  color: #697b6b;
  font-size: 11px;
  line-height: 1.5;
}

.training-next {
  display: block;
  margin-left: auto;
}

.setting-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 2px;
  border-bottom: 1px solid #e7e3d8;
  color: #526457;
  font-size: 12px;
}

.setting-option input {
  accent-color: #486c53;
}

.setting-volume {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px 12px;
  padding: 10px 2px;
  border-bottom: 1px solid #e7e3d8;
  color: #526457;
  font-size: 11px;
}

.setting-volume output {
  color: #8c7849;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.setting-volume input {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0;
  accent-color: #486c53;
  cursor: pointer;
}

.settings-shortcuts {
  margin-top: 15px;
}

.settings-shortcuts kbd {
  display: inline-block;
  border: 1px solid #d7d2c4;
  border-radius: 3px;
  padding: 1px 5px;
  background: #f3f1e9;
  color: #4f6254;
  font: 600 10px monospace;
}

body.high-contrast {
  --muted: #45564a;
  --line: #938c7c;
  color: #10231a;
  background: #fff;
}

body.high-contrast .table-note,
body.high-contrast .action-dock,
body.high-contrast .hand-area {
  border-color: #776c50;
}

body.high-contrast .table-note,
body.high-contrast .hand-hint,
body.high-contrast .score-row,
body.high-contrast .stats-empty {
  color: #34483a;
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: .01ms !important;
}

.trick-history {
  margin-top: 10px;
  border: 1px solid #ded5bf;
  border-radius: 7px;
  background: #fffdf7;
  color: #69766d;
  font-size: 9px;
}

.trick-history summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  color: #657369;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  list-style: none;
}

.trick-history summary::-webkit-details-marker {
  display: none;
}

.trick-history summary b {
  color: #a38d57;
  font-variant-numeric: tabular-nums;
}

.trick-history-list {
  max-height: 190px;
  overflow-y: auto;
  padding: 0 12px 8px;
}

.trick-history-entry {
  border-top: 1px solid #efede6;
  padding: 9px 0;
}

.trick-history-entry strong {
  color: #4d6254;
  font-size: 9px;
}

.trick-history-entry ul {
  display: grid;
  gap: 4px;
  margin: 7px 0 0;
  padding: 0;
  list-style: none;
  color: #899187;
  font-size: 8px;
}

.table-note {
  border: 1px solid #e6dfce;
  border-left: 3px solid var(--gold);
  border-radius: 7px;
  background: #fffdf7b8;
  box-shadow: 0 5px 16px #263a2e08;
}

.legend-card {
  border-top-color: #d8cfbc;
}

.table-topline {
  color: #77857b;
  font-weight: 600;
  letter-spacing: .04em;
}

.turn-pill {
  border: 1px solid #d8c78f;
  background: linear-gradient(135deg, #fbf7e8, #eee4c7);
  color: #735f2e;
  box-shadow: inset 0 1px #ffffffb0;
}

.felt-table {
  isolation: isolate;
  border-radius: 48% / 45%;
  background:
    radial-gradient(ellipse at 50% 44%, #236451 0%, #185342 42%, #104236 73%, #0b322b 100%);
  box-shadow:
    inset 0 0 0 2px #f2dc9b,
    inset 0 0 0 5px #a98848,
    inset 0 0 0 8px #0c3a30,
    inset 0 0 48px #041f1933,
    0 20px 38px #14292326;
}

.felt-table::before {
  position: absolute;
  z-index: 1;
  inset: 15px;
  border: 1px solid #e8d89a45;
  border-radius: inherit;
  content: '';
  pointer-events: none;
}

.felt-table::after {
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    radial-gradient(ellipse at center, transparent 0 31%, #f0d78d0a 31.2%, transparent 31.6%),
    repeating-linear-gradient(127deg, #ffffff04 0 1px, transparent 1px 5px);
  content: '';
  pointer-events: none;
}

.table-ornament {
  z-index: 1;
  width: 205px;
  height: 205px;
  border-color: #e4d1931c;
  box-shadow: 0 0 0 12px #e4d19308, 0 0 0 24px #e4d19305;
}

.center-mark {
  z-index: 1;
  color: #f4e7bf21;
}

.seat {
  text-shadow: 0 1px 8px #071d18a6;
}

.avatar {
  border-color: #ffffff70;
  box-shadow: 0 3px 10px #051c1752;
}

.seat.active-seat .avatar,
.player-bar.active-seat .avatar {
  box-shadow: 0 0 0 3px #f1d78b, 0 0 20px #efcf726b;
}

.player-bar {
  padding: 10px 12px;
  border: 1px solid #e4ddcc;
  border-radius: 8px;
  background: #fffdf7a8;
  box-shadow: 0 6px 18px #283b2e0a;
}

.player-badge {
  border: 1px solid #ddcea2;
  border-radius: 99px;
  background: #f4eedb;
  color: #776331;
}

.hand-heading {
  color: #65766c;
}

.card {
  border-color: #d8d2c5;
  border-radius: 7px;
  background:
    linear-gradient(145deg, #ffffff 0%, #fffefa 48%, #f1eee5 100%);
  box-shadow: 0 5px 12px #13251d22, inset 0 0 0 2px #ffffffa8;
}

.card.playable {
  border-color: #c4a75d;
  box-shadow: 0 6px 14px #7c682738, inset 0 0 0 2px #fffdf2;
}

.card.playable:hover,
.card.selected {
  box-shadow: 0 12px 21px #10241b38, 0 0 0 2px #d4b96f;
}

.action-dock {
  min-height: 80px;
  border: 1px solid #ded5bf;
  border-radius: 9px;
  background: linear-gradient(130deg, #fffefa, #f8f5ec);
  box-shadow: 0 10px 25px #182b2212, inset 0 1px #ffffff;
}

.dock-icon {
  border: 1px solid #e5d9b7;
  background: linear-gradient(145deg, #fbf6e6, #ede4ce);
  color: #987c3c;
}

.bid-button,
.call-button {
  border-color: #e0d8c6;
  border-radius: 6px;
  box-shadow: inset 0 1px #ffffff;
  transition: transform .16s, border-color .16s, box-shadow .16s, background .16s;
}

.bid-button:hover,
.call-button:hover {
  transform: translateY(-2px);
  border-color: #bba25f;
  box-shadow: 0 5px 12px #5d4a2018;
}

.confirm-button,
.new-game-button {
  border: 1px solid #345447;
  border-radius: 6px;
  background: linear-gradient(145deg, #244d3f, #15382f);
  box-shadow: inset 0 1px #ffffff20, 0 4px 10px #102a211c;
  transition: transform .16s, box-shadow .16s, filter .16s;
}

.confirm-button:not(:disabled):hover,
.new-game-button:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: inset 0 1px #ffffff24, 0 7px 16px #102a2128;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.card[role='button']:focus-visible {
  outline: 3px solid #d6bc79;
  outline-offset: 3px;
}

.modal-card {
  border: 1px solid #d8c995;
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 100% 0%, #eee5cc 0, transparent 33%),
    #fbfaf5;
  box-shadow: 0 28px 90px #07181180, inset 0 1px #ffffff;
}

.online-button {
  border-radius: 6px;
  box-shadow: inset 0 1px #ffffff, 0 3px 8px #17271c0b;
}

.chat-panel {
  border-color: #d8c995;
  border-radius: 12px;
  box-shadow: 0 20px 55px #10241b3b;
}

.chat-header {
  background: linear-gradient(120deg, #1f4b3c, #0e3028);
}

.chat-message {
  padding: 8px 10px;
  border: 1px solid #eee8d9;
  border-radius: 8px;
  background: #fffefa;
}

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 7px 14px;
  margin: 8px 2px 15px;
  padding: 12px 14px;
  border: 1px solid #e2dece;
  border-radius: 5px;
  background: linear-gradient(120deg, #fffefa, #f2efe4);
  box-shadow: 0 4px 12px #1429230a;
}

.score-breakdown[hidden] {
  display: none;
}

.score-breakdown-title {
  grid-column: 1 / -1;
  color: #889086;
  font-size: 8px;
  letter-spacing: 1.2px;
}

.score-breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #778278;
  font-size: 10px;
}

.score-breakdown-row b {
  color: #56645a;
  font-variant-numeric: tabular-nums;
}

.score-breakdown-row.score-positive b {
  color: #2e7150;
}

.score-breakdown-row.score-negative b {
  color: #a05043;
}

.hand-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hint-button {
  flex: 0 0 auto;
  border: 1px solid #d9c99d;
  border-radius: 99px;
  padding: 5px 10px;
  background: #f7f3e6;
  color: #806b3c;
  font: 600 9px 'DM Sans', sans-serif;
  cursor: pointer;
}

.hint-button:hover,
.hint-button:focus-visible {
  background: #eee6d0;
  outline: 2px solid #b49955;
  outline-offset: 2px;
}

.card.hinted {
  z-index: 4;
  border-color: #b39851;
  box-shadow: 0 0 0 3px #d6bd7966, 0 8px 18px #101c163d;
  transform: translateY(-12px);
}

.stats-modal {
  max-width: 660px;
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 20px 0 24px;
}

.stats-metric {
  min-width: 0;
  border: 1px solid #e7e3d8;
  border-radius: 5px;
  padding: 11px 9px;
  background: #fffefa;
}

.stats-metric span,
.stats-metric strong {
  display: block;
}

.stats-metric span {
  color: #889087;
  font-size: 8px;
  line-height: 1.4;
}

.stats-metric strong {
  margin-top: 5px;
  color: #324d3d;
  font: 600 18px 'Playfair Display', serif;
  overflow-wrap: anywhere;
}

.stats-history-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e7e3d8;
  padding-bottom: 8px;
  color: #858e84;
  font-size: 8px;
  letter-spacing: 1.2px;
}

.stats-reset {
  border: 0;
  background: none;
  color: #9b684e;
  font: 500 9px 'DM Sans', sans-serif;
  cursor: pointer;
}

.stats-history {
  display: grid;
  max-height: 245px;
  overflow-y: auto;
}

.stats-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #efede6;
  padding: 10px 2px;
  color: #536258;
  font-size: 10px;
}

.stats-history-row strong,
.stats-history-row small {
  display: block;
}

.stats-history-row small {
  margin-top: 3px;
  color: #939a90;
  font-size: 8px;
}

.stats-history-row > b {
  flex: 0 0 auto;
  font-size: 9px;
}

.stats-win {
  color: #347352;
}

.stats-loss {
  color: #a25649;
}

.stats-empty,
.stats-privacy {
  color: #90988e;
  font-size: 9px;
  line-height: 1.5;
}

.stats-empty {
  padding: 14px 2px;
}

.stats-privacy {
  margin: 14px 0 0;
  text-align: center;
}

.membership-button {
  border: 1px solid #c4aa67;
  border-radius: 4px;
  padding: 9px 12px;
  background: linear-gradient(145deg, #f8f2df, #e9dfc2);
  color: #634e23;
  font: 700 10px 'DM Sans', sans-serif;
  cursor: pointer;
  box-shadow: inset 0 1px #ffffffb0;
}

.membership-button:hover,
.membership-button:focus-visible {
  background: linear-gradient(145deg, #fff9e8, #eadcae);
  outline: 2px solid #b49955;
  outline-offset: 2px;
}

.membership-modal {
  max-width: 760px;
}

.membership-intro {
  max-width: 620px;
}

.membership-plans {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0 12px;
}

.membership-plan {
  display: flex;
  flex-direction: column;
  border: 1px solid #e6e2d6;
  border-radius: 6px;
  padding: 18px;
  background: #fffefa;
}

.membership-plan-featured {
  border-color: #c7ad6b;
  background: linear-gradient(150deg, #fffdf6, #f4f0e2);
  box-shadow: inset 0 0 0 1px #c7ad6b33;
}

.plan-kicker {
  color: #9b8651;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.membership-plan h3 {
  margin: 8px 0 3px;
  color: #30483b;
  font: 600 21px 'Playfair Display', serif;
}

.plan-price {
  margin: 0;
  color: #273d33;
  font: 600 23px 'Playfair Display', serif;
}

.plan-price span,
.plan-annual {
  color: #8b9287;
  font: 400 10px 'DM Sans', sans-serif;
}

.plan-annual {
  margin: 4px 0 0;
}

.token-wallet-refill {
  margin: 5px 0 0;
  color: #52745e;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.membership-plan ul {
  display: grid;
  gap: 9px;
  margin: 17px 0;
  padding: 0;
  color: #69776d;
  font-size: 10px;
  list-style: none;
}

.membership-plan li::before {
  content: '✦';
  margin-right: 7px;
  color: #ad9251;
}

.plan-current,
.membership-cta {
  margin-top: auto;
  border: 1px solid #e7e4da;
  border-radius: 4px;
  padding: 10px;
  background: #f4f3ed;
  color: #7f887d;
  font: 600 9px 'DM Sans', sans-serif;
  text-align: center;
}

.membership-cta {
  border-color: #d8cfb1;
  background: #eee9d8;
  color: #796a43;
  cursor: pointer;
}

.membership-cta:hover,
.membership-cta:focus-visible {
  outline: 2px solid #b49955;
  outline-offset: 2px;
}

.membership-disclosure {
  margin: 12px 0 0;
  color: #858d83;
  font-size: 9px;
  line-height: 1.5;
  text-align: center;
}

.token-commerce-legal {
  margin: 10px 0;
  color: #657266;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.token-commerce-legal a {
  color: #315b47;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.token-ledger-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e8e4d9;
}

.token-ledger-section h3 {
  margin: 0 0 7px;
  color: #526457;
  font-size: 10px;
  letter-spacing: .5px;
}

.token-ledger-section ol {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.token-ledger-section li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  color: #788276;
  font-size: 8px;
}

.token-ledger-section li strong {
  min-width: 28px;
  color: #9d584b;
  font-size: 9px;
  text-align: right;
}

.token-ledger-section li strong.token-credit {
  color: #4f785a;
}

.token-ledger-section time {
  color: #9aa097;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chat-toggle {
  border: 1px solid #a88c4e;
  background: linear-gradient(145deg, #244d3f, #102f27);
  box-shadow: 0 9px 24px #102c2848, inset 0 1px #ffffff25;
}

.toast {
  border: 1px solid #d4b86c;
  border-radius: 99px;
  box-shadow: 0 10px 28px #061c1766;
}

@media (max-width: 760px) {
  .app-shell {
    padding-inline: 14px;
  }

  .topbar {
    height: auto;
    min-height: 72px;
    flex-wrap: wrap;
    gap: 8px;
    padding-block: 10px;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

  .membership-button {
    padding: 8px;
    font-size: 9px;
  }

  .hand-controls {
    gap: 5px;
  }

  .hint-button {
    padding: 5px 7px;
  }

  .membership-modal {
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 22px;
  }

  .membership-plans {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 16px;
  }

  .membership-plan {
    padding: 14px;
  }

  .stats-modal {
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 22px;
  }

  .stats-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 15px 0 18px;
  }

  .stats-metric:last-child {
    grid-column: 1 / -1;
  }

  .felt-table {
    border-radius: 40% / 35%;
    box-shadow:
      inset 0 0 0 1px #f2dc9b,
      inset 0 0 0 4px #a98848,
      inset 0 0 0 7px #0c3a30,
      inset 0 0 34px #041f1933,
      0 14px 28px #14292322;
  }

  .felt-table::before {
    inset: 12px;
  }

  .player-bar {
    padding: 8px 9px;
  }
}

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