:root {
  --bg-top: #173b33;
  --bg-bottom: #071712;
  --felt: #0f5d46;
  --felt-glow: rgba(148, 232, 201, 0.16);
  --panel: rgba(246, 235, 218, 0.92);
  --panel-border: rgba(255, 255, 255, 0.18);
  --ink: #1d1b17;
  --muted: #5c554b;
  --accent: #c38f2b;
  --accent-strong: #f0b64c;
  --blue: #113f67;
  --red: #7b2430;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --mono: "Courier Prime", "SFMono-Regular", Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia,
    serif;
  --sans: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--sans);
  color: #f7f4ec;
  background:
    radial-gradient(circle at top, rgba(240, 182, 76, 0.16), transparent 36%),
    radial-gradient(circle at 20% 20%, rgba(101, 211, 166, 0.14), transparent 24%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(18px);
  opacity: 0.28;
  z-index: 0;
}

body::before {
  top: -9rem;
  right: -8rem;
  background: rgba(240, 182, 76, 0.3);
}

body::after {
  bottom: -11rem;
  left: -8rem;
  background: rgba(61, 134, 112, 0.42);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1480px, calc(100vw - 32px));
  margin: 24px auto 40px;
}

.hero,
.control-strip,
.side-card,
.table-card {
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  background: linear-gradient(140deg, rgba(17, 48, 40, 0.9), rgba(11, 24, 20, 0.92));
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #f5d58d;
}

.hero h1,
.card-header h2,
.center-header h2 {
  margin: 0;
  font-family: var(--serif);
  letter-spacing: 0.02em;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
}

.hero-copy,
.status-text {
  max-width: 58ch;
  margin: 12px 0 0;
  line-height: 1.55;
  color: rgba(247, 244, 236, 0.84);
}

.hero-status {
  width: min(320px, 100%);
  align-self: center;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(245, 236, 220, 0.16), rgba(255, 255, 255, 0.05));
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.status-loading {
  background: rgba(195, 143, 43, 0.18);
  color: #f7d486;
}

.status-ready {
  background: rgba(88, 207, 166, 0.18);
  color: #b4f2da;
}

.status-error {
  background: rgba(206, 89, 89, 0.2);
  color: #ffd3d3;
}

.control-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  background: rgba(17, 35, 29, 0.84);
}

.control-field {
  display: grid;
  gap: 8px;
  min-width: 150px;
}

.control-wide {
  min-width: min(320px, 100%);
  flex: 1 1 320px;
}

.control-field span {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(247, 244, 236, 0.76);
}

.control-field input,
.control-field select {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(245, 239, 226, 0.96);
  color: var(--ink);
  font: inherit;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-left: auto;
}

.button {
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  color: #f9f4ea;
  background: rgba(246, 235, 218, 0.2);
  cursor: pointer;
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    opacity 120ms ease;
}

.button-sand {
  background: rgba(17, 63, 103, 0.12);
  color: var(--ink);
}

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

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button-primary {
  background: linear-gradient(135deg, #c38f2b, #f0b64c);
  color: #2c210c;
}

.button-ghost {
  background: rgba(88, 207, 166, 0.18);
  color: #c8f7e7;
}

.arena {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  gap: 18px;
  margin-top: 18px;
}

.ai-strip {
  align-items: center;
}

.control-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: rgba(245, 239, 226, 0.16);
}

.control-check input {
  width: 18px;
  height: 18px;
}

.side-card,
.table-card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.side-card {
  padding: 20px;
  background: linear-gradient(180deg, rgba(244, 237, 224, 0.97), rgba(231, 221, 200, 0.96));
  color: var(--ink);
}

.card-header {
  margin-bottom: 16px;
}

.card-header.compact {
  margin-bottom: 12px;
}

.card-header h2,
.center-header h2 {
  font-size: 1.5rem;
}

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

.summary-item {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(17, 63, 103, 0.08);
}

.summary-label,
.stack-label,
.legal-label,
.team-meta {
  display: block;
  color: var(--muted);
}

.summary-item strong,
.team-score strong {
  font-family: var(--serif);
  font-size: 1.2rem;
}

.scoreboard {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.team-score {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.6);
}

.team-zero {
  border-left: 5px solid var(--blue);
}

.team-one {
  border-left: 5px solid var(--red);
}

.team-name {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.legal-box {
  margin-top: 18px;
}

.ai-box {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(17, 63, 103, 0.12);
}

.ai-summary-grid {
  margin-top: 8px;
}

.ai-status-block {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(17, 63, 103, 0.08);
}

.ai-line {
  margin: 0;
  line-height: 1.4;
}

.ai-line + .ai-line {
  margin-top: 8px;
}

.metrics-grid {
  margin-top: 14px;
}

.ai-button-row {
  margin-top: 14px;
  margin-left: 0;
}

.benchmark-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(17, 63, 103, 0.12);
}

.benchmark-score-card {
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(17, 63, 103, 0.08);
}

.benchmark-score-card strong {
  display: block;
  margin-top: 6px;
  font-family: var(--serif);
  font-size: 2.2rem;
}

.benchmark-score-note {
  margin: 10px 0 0;
  color: var(--muted);
}

.compact-log {
  max-height: 260px;
}

.legal-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.legal-pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(17, 63, 103, 0.12);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.table-card {
  padding: 20px;
  background:
    radial-gradient(circle at center, var(--felt-glow), transparent 44%),
    linear-gradient(180deg, rgba(13, 46, 39, 0.98), rgba(9, 28, 24, 0.98));
}

.felt-board {
  position: relative;
  min-height: 740px;
  border-radius: 34px;
  background:
    radial-gradient(circle at 50% 46%, rgba(198, 231, 219, 0.12), transparent 26%),
    linear-gradient(180deg, rgba(16, 87, 68, 0.96), rgba(11, 64, 50, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.felt-board::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px dashed rgba(245, 213, 141, 0.2);
  border-radius: 28px;
  pointer-events: none;
}

.seat-panel,
.center-well {
  position: absolute;
  border-radius: 22px;
}

.seat-panel {
  width: 240px;
  min-height: 154px;
  padding: 14px;
  background: rgba(247, 241, 231, 0.94);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.2);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.seat-panel.is-current {
  background: linear-gradient(180deg, rgba(255, 247, 226, 0.98), rgba(246, 231, 194, 0.98));
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.24);
}

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

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

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

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

.center-well {
  top: 50%;
  left: 50%;
  width: min(420px, calc(100% - 620px));
  min-width: 360px;
  min-height: 340px;
  padding: 18px;
  transform: translate(-50%, -50%);
  background: rgba(8, 37, 30, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.center-header,
.seat-header,
.center-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.center-chip {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  text-align: right;
}

.center-chip span {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(247, 244, 236, 0.72);
}

.center-chip strong {
  display: block;
  margin-top: 4px;
  font-family: var(--serif);
  color: #fff5de;
}

.center-details {
  margin-top: 18px;
  align-items: stretch;
}

.upcard-stack {
  flex: 1;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
}

.stack-label {
  margin-bottom: 8px;
  color: rgba(247, 244, 236, 0.7);
}

.card-slot,
.trick-grid {
  min-height: 96px;
}

.last-message {
  margin: 0;
  line-height: 1.45;
  color: rgba(247, 244, 236, 0.94);
}

.trick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.trick-play {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 92px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  animation: fade-up 220ms ease;
}

.trick-meta {
  display: grid;
  gap: 4px;
}

.trick-meta strong {
  color: #fff7e8;
}

.seat-name {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
}

.seat-subline {
  margin: 6px 0 0;
  color: var(--muted);
}

.seat-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 6px;
}

.badge {
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(17, 63, 103, 0.1);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge.team-0 {
  color: var(--blue);
}

.badge.team-1 {
  color: var(--red);
}

.card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.playing-card {
  display: inline-grid;
  gap: 4px;
  width: 56px;
  min-height: 76px;
  padding: 8px 6px;
  border-radius: 12px;
  border: 1px solid rgba(29, 27, 23, 0.14);
  background: linear-gradient(180deg, #fffdf8, #f0e6d6);
  color: #1e1a15;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.16);
  transform-origin: center;
  animation: card-deal 240ms ease;
}

.playing-card.small {
  width: 52px;
  min-height: 72px;
}

.playing-card.hidden {
  place-items: center;
  background:
    linear-gradient(135deg, rgba(17, 63, 103, 0.92), rgba(12, 36, 57, 0.96)),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.06),
      rgba(255, 255, 255, 0.06) 4px,
      transparent 4px,
      transparent 8px
    );
  color: #f5e8cf;
}

.playing-card.red {
  color: #8a2136;
}

.card-rank {
  font-weight: 700;
  font-size: 1rem;
}

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

.card-text {
  font-size: 0.72rem;
  opacity: 0.7;
}

.log-card {
  display: flex;
  flex-direction: column;
}

.log-list {
  margin: 0;
  padding-left: 20px;
  overflow: auto;
  max-height: 760px;
}

.log-list li {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  line-height: 1.45;
  animation: fade-up 180ms ease;
}

@keyframes card-deal {
  from {
    transform: translateY(8px) scale(0.96);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes fade-up {
  from {
    transform: translateY(4px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1240px) {
  .arena {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary-card,
  .log-card {
    order: 2;
  }
}

@media (max-width: 920px) {
  .hero {
    flex-direction: column;
  }

  .button-row {
    margin-left: 0;
  }

  .felt-board {
    min-height: 980px;
  }

  .center-well {
    width: calc(100% - 48px);
    min-width: 0;
    top: 52%;
  }

  .seat-panel {
    width: calc(100% - 48px);
    min-height: 138px;
  }

  .seat-top {
    top: 24px;
  }

  .seat-right,
  .seat-left {
    top: auto;
    transform: none;
  }

  .seat-right {
    right: 24px;
    bottom: 264px;
  }

  .seat-left {
    left: 24px;
    bottom: 424px;
  }

  .seat-bottom {
    bottom: 24px;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100vw - 16px, 100%);
    margin: 8px auto 24px;
  }

  .hero,
  .control-strip,
  .side-card,
  .table-card {
    border-radius: 20px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .center-details,
  .center-header,
  .seat-header {
    flex-direction: column;
    align-items: start;
  }

  .seat-badges {
    justify-content: start;
  }

  .trick-grid {
    grid-template-columns: 1fr;
  }
}
