/* Teen Patti Ledger — casino felt (Solitaire ref): blurred table + white UI + crimson/black accents */

:root {
  /* Felt greens from reference */
  --felt-a: #24c55e;
  --felt-b: #1dae50;
  --felt-deep: #0f5132;
  --glass-white: rgba(255, 255, 255, 0.14);
  --glass-white-strong: rgba(255, 255, 255, 0.92);

  --bg: #178c48;
  --bg-elevated: linear-gradient(165deg, #ffffff 0%, #f8fafc 48%, #f1f5f9 100%);
  --bg-elevated-solid: #ffffff;
  --bg-input: #ffffff;
  --border: rgba(15, 40, 25, 0.14);
  --text: #0f172a;
  --text-muted: #475569;
  --suit-black: #020617;
  --crimson: #e11d48;
  --crimson-bright: #f43f5e;
  --primary: #16a34a;
  --primary-dim: #15803d;
  --primary-glow: rgba(22, 163, 74, 0.4);
  --gold: #ca8a04;
  --gold-bright: #eab308;
  --lime: #166534;
  --teal-accent: #0d9488;
  --purple-deep: #5b21b6;
  --purple-banner: linear-gradient(135deg, #15803d 0%, #0f5132 100%);
  --forest: #14532d;
  --danger: #e11d48;
  --danger-hover: #f43f5e;
  --owed: #e11d48;
  --positive: #15803d;
  --radius: 18px;
  --radius-pill: 999px;
  --shadow: 0 16px 48px rgba(0, 35, 18, 0.2);
  --shadow-warm: 0 8px 28px rgba(22, 101, 52, 0.18);
  --shadow-glass: 0 4px 24px rgba(0, 40, 22, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.98);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --transition: 0.22s ease;
  --tap-min: 44px;
  --form-max: min(100%, 42rem);
  --shell-max: min(100%, 1520px);
  /* Rhythm — padding & gaps between text, controls, and panel edges */
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 40px;
  --pad-section: clamp(22px, 4.5vw, 40px);
  --pad-card: clamp(16px, 3.5vw, 24px);
  --gap-stack: clamp(16px, 2.8vw, 24px);
  --bid-input-min-h: 52px;
  --bid-input-pad-y: 12px;
  --bid-input-pad-x: 16px;
  --bid-input-font: clamp(1.05rem, 3.2vw, 1.2rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  height: 100%;
  max-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--felt-b);
  background-image: linear-gradient(105deg, var(--felt-a) 0%, #1db954 42%, var(--felt-b) 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

/* Blurred felt table (assets/felt-table.png — Solitaire-style reference) */
body::before {
  content: "";
  position: fixed;
  inset: -40px;
  z-index: 0;
  pointer-events: none;
  background: url("assets/felt-table.png") center / cover no-repeat;
  filter: blur(22px) saturate(1.1) brightness(0.9);
  transform: scale(1.07);
  opacity: 0.94;
}

/* Depth + readability over blurred felt */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 95% 80% at 50% 100%, rgba(0, 35, 22, 0.42) 0%, transparent 58%),
    linear-gradient(180deg, rgba(0, 45, 28, 0.22) 0%, transparent 38%),
    linear-gradient(90deg, rgba(36, 197, 94, 0.08) 0%, transparent 50%, rgba(29, 174, 80, 0.1) 100%);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  position: relative;
  z-index: 101;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: var(--space-3) var(--space-4);
  padding-top: max(var(--space-3), env(safe-area-inset-top));
  background: var(--glass-white);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  border-bottom: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow: 0 8px 32px rgba(0, 35, 20, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.header-inner {
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 clamp(var(--space-3), 3vw, var(--space-6));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
}

.header-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  min-width: 0;
}

.logo-cards {
  display: block;
  width: 72px;
  height: 24px;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.35));
  animation: logoFloat 5s ease-in-out infinite;
}

.app-title {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(0, 35, 18, 0.45);
}

.header-toggles {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.toggle-btn {
  min-height: 40px;
  min-width: 64px;
  padding: 0 var(--space-3);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: clamp(10px, 2vw, 12px);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 35, 18, 0.12);
  transition: border-color var(--transition), color var(--transition), box-shadow var(--transition), transform 0.15s ease, filter 0.2s ease, background var(--transition);
}

.toggle-btn:active {
  transform: scale(0.96);
}

.toggle-btn-reference {
  min-width: auto;
  padding: 0 var(--space-4);
}

.toggle-btn:hover {
  border-color: rgba(22, 163, 74, 0.45);
  color: var(--felt-deep);
  background: #ffffff;
}

.toggle-btn-reference[aria-pressed="true"] {
  color: #ffffff;
  background: linear-gradient(180deg, var(--felt-a) 0%, var(--primary-dim) 100%);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 16px rgba(0, 50, 28, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.toggle-btn-reference[aria-pressed="true"]:hover {
  color: #ffffff;
  filter: brightness(1.05);
}

.toggle-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  max-width: var(--shell-max);
  margin: 0 auto;
  width: 100%;
  padding: clamp(var(--space-4), 2.5vw, var(--space-6)) clamp(var(--space-4), 4vw, 48px);
  padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, min(28vw, 400px));
  gap: clamp(var(--space-4), 2vw, var(--space-6));
  align-items: stretch;
  align-content: stretch;
  overflow: hidden;
}

.app-shell.is-rules-collapsed {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
  max-width: min(100%, 960px);
}

.main {
  width: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-align: start;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.section.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#section-setup,
#section-settlement {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#section-dashboard.dashboard-view {
  overflow: hidden;
}

.main > .section.panel {
  min-height: 0;
}

/* --- Dashboard: responsive grid + touch-sized controls (scales with viewport) --- */
.dashboard-view.panel {
  padding: var(--pad-section);
  width: 100%;
  max-width: 100%;
}

.dashboard-stack {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(var(--gap-stack), 3vw, var(--space-6));
}

.dashboard-actions {
  flex-shrink: 0;
  width: 100%;
  padding-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.player-rows-wrap {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* One full-width column on phones; 2+ columns only when each cell can fit forms */
.dashboard-view .player-rows {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
  width: 100%;
  display: grid;
  gap: var(--gap-stack);
  grid-template-columns: 1fr;
  align-content: start;
  align-items: stretch;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

@media (min-width: 540px) {
  .dashboard-view .player-rows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .dashboard-view .player-rows {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (min-width: 1200px) {
  .dashboard-view .player-rows {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

.dashboard-view .dash-top {
  margin-bottom: var(--space-2);
  flex-shrink: 0;
  width: 100%;
}

.dashboard-view .dash-head-main .panel-title {
  margin-bottom: var(--space-3);
  font-size: clamp(1.1rem, 2.8vw, 1.35rem);
  text-align: start;
}

.dashboard-view .meta-line {
  font-size: clamp(0.85rem, 2.2vw, 0.95rem);
}

.dashboard-view .payment-history-panel {
  padding: var(--pad-card);
  margin-bottom: 0;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.dashboard-view .payment-history-title {
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  margin-bottom: var(--space-3);
}

.dashboard-view .payment-history-total-row {
  margin-bottom: var(--space-3);
  padding: var(--space-3) 0;
}

.dashboard-view .payment-history-list.payment-history-detail {
  max-height: min(140px, 22dvh);
}

.dashboard-view .actions-row {
  margin-bottom: 0;
  gap: var(--space-3);
  width: 100%;
}

.dashboard-view .btn {
  min-height: var(--tap-min);
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  padding: 0 var(--space-4);
}

.dashboard-view .btn-back {
  min-height: var(--tap-min);
  padding: 0 var(--space-4);
  font-size: clamp(0.85rem, 2.2vw, 0.95rem);
}

.dashboard-view .player-card {
  padding: var(--pad-card);
  min-width: 0;
  width: 100%;
}

.dashboard-view .player-card-header {
  margin-bottom: var(--space-3);
  gap: var(--space-3);
}

.dashboard-view .player-name {
  font-size: clamp(0.95rem, 2.8vw, 1.05rem);
}

.dashboard-view .balance {
  font-size: clamp(0.9rem, 2.5vw, 1rem);
}

.dashboard-view .player-row-grid {
  gap: var(--space-3);
  grid-template-columns: 1fr;
}

@media (min-width: 420px) {
  .dashboard-view .player-row-grid {
    grid-template-columns: minmax(10.5rem, 1fr) auto;
    align-items: end;
  }
}

.dashboard-view .bid-field {
  min-width: 0;
  width: 100%;
}

.dashboard-view .bid-field label {
  font-size: clamp(0.8rem, 2.4vw, 0.9rem);
  margin-bottom: var(--space-3);
  font-weight: 600;
}

.dashboard-view .bid-field input[type="number"] {
  min-height: var(--bid-input-min-h);
  padding: var(--bid-input-pad-y) var(--bid-input-pad-x);
  font-size: var(--bid-input-font);
  font-weight: 600;
  line-height: 1.2;
  width: 100%;
  min-width: 0;
  border-radius: 18px;
  border-width: 2px;
}

.dashboard-view .control {
  font-size: clamp(0.8rem, 2.2vw, 0.875rem);
}

.dashboard-view .controls {
  gap: var(--space-3);
}

.dashboard-view .add-player-box {
  margin-top: var(--space-2);
  padding: var(--pad-card);
}

.dashboard-actions .actions-row {
  margin-bottom: 0;
}

@media (min-width: 520px) {
  .setup-names {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.rules-sidebar {
  position: relative;
  align-self: stretch;
  min-height: 0;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* [hidden] must win over display:flex — otherwise the aside stays in the layout below main */
.rules-sidebar[hidden] {
  display: none !important;
}

.rules-sidebar-inner.panel.wiki-shell {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: linear-gradient(165deg, rgba(15, 81, 50, 0.94) 0%, rgba(8, 50, 32, 0.97) 55%, rgba(5, 35, 24, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: var(--shadow-glass), 0 16px 48px rgba(0, 30, 18, 0.45);
  backdrop-filter: blur(16px);
}

.wiki-tabs {
  display: flex;
  flex-shrink: 0;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.wiki-tab {
  flex: 1;
  min-height: 44px;
  padding: var(--space-3) var(--space-2);
  font-family: inherit;
  font-size: clamp(0.72rem, 2.2vw, 0.85rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(248, 250, 252, 0.65);
  background: transparent;
  border: none;
  border-radius: 14px 14px 0 0;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), box-shadow var(--transition);
}

.wiki-tab:hover {
  color: #fffbeb;
  background: rgba(255, 255, 255, 0.06);
}

.wiki-tab-active {
  color: var(--text) !important;
  background: #ffffff !important;
  box-shadow: 0 -2px 14px rgba(0, 35, 20, 0.18), inset 0 1px 0 rgba(255, 255, 255, 1);
}

.wiki-tab:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.wiki-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-4) var(--space-4) var(--space-5);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.wiki-panel-body[hidden] {
  display: none !important;
}

.wiki-lead {
  margin: 0 0 var(--space-4);
  font-size: clamp(0.85rem, 2.3vw, 0.95rem);
  line-height: 1.6;
  color: rgba(248, 250, 252, 0.88);
  text-align: left;
}

.wiki-step {
  margin: 0 0 var(--space-4);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.wiki-step-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(135deg, #15803d 0%, #0f5132 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.wiki-step-banner--teal {
  background: linear-gradient(135deg, #0d9488 0%, #0f5132 100%);
}

.wiki-step-banner--amber {
  background: linear-gradient(135deg, #ca8a04 0%, #854d0e 100%);
}

.wiki-step-banner--lime {
  background: linear-gradient(135deg, #22c55e 0%, #166534 100%);
}

.wiki-step-banner--orange {
  background: linear-gradient(135deg, #e11d48 0%, #9f1239 100%);
}

.wiki-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, var(--felt-a) 0%, var(--primary-dim) 100%);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 40, 22, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.wiki-step-title {
  margin: 0;
  font-size: clamp(0.82rem, 2.2vw, 0.95rem);
  font-weight: 700;
  color: #fff;
  text-align: left;
  line-height: 1.3;
}

.wiki-step-text {
  margin: 0;
  padding: var(--space-3) var(--space-4) var(--space-4);
  font-size: clamp(0.78rem, 2vw, 0.88rem);
  line-height: 1.6;
  color: rgba(226, 232, 240, 0.92);
  text-align: left;
}

.wiki-app-card {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(0, 45, 28, 0.55) 0%, rgba(8, 55, 35, 0.72) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.wiki-app-card-title {
  margin: 0 0 var(--space-3);
  font-size: clamp(0.85rem, 2.3vw, 0.95rem);
  font-weight: 700;
  color: #bbf7d0;
  text-align: left;
}

.wiki-app-list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: clamp(0.78rem, 2vw, 0.88rem);
  line-height: 1.6;
  color: rgba(248, 250, 252, 0.9);
  text-align: left;
}

.wiki-app-list li {
  margin-bottom: var(--space-3);
  padding-right: var(--space-1);
}

.wiki-app-list li:last-child {
  margin-bottom: 0;
}

.rules-sidebar-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: var(--space-2);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.rules-mini-title {
  margin: var(--space-4) 0 var(--space-3);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}

.rules-mini-title-first {
  margin-top: 0;
}

#panel-wiki-reference .rules-mini-title {
  color: #bbf7d0;
}

#panel-wiki-reference .rules-caption,
#panel-wiki-reference .rules-list {
  color: rgba(248, 250, 252, 0.9);
}

#panel-wiki-reference .rules-list-app li {
  margin-bottom: var(--space-2);
  padding-right: var(--space-1);
}

#panel-wiki-reference .rules-list-app li:last-child {
  margin-bottom: 0;
}

.rules-hand-ranking-figure {
  margin: 0 0 var(--space-4);
  padding: clamp(10px, 2.5vw, 16px);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  box-sizing: border-box;
  width: 100%;
}

#panel-wiki-reference .rules-hand-ranking-figure {
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
}

.rules-hand-ranking-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  object-fit: contain;
  object-position: top center;
}

.rules-cards-art {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.rules-caption {
  margin: var(--space-3) 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: center;
}

.rules-visual {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-2);
}

.rules-list {
  margin: 0 0 var(--space-4);
  padding-left: 0;
  list-style-position: inside;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  text-align: center;
}

.rules-list-app {
  list-style: disc;
}

@media (max-width: 900px) {
  .app-shell:not(.is-rules-collapsed) {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    max-width: min(100%, 900px);
  }

  .app-shell:not(.is-rules-collapsed) .main {
    order: 1;
    min-height: 0;
  }

  .app-shell:not(.is-rules-collapsed) .rules-sidebar {
    order: 2;
    position: static;
    max-height: min(42dvh, 320px);
    flex-shrink: 0;
  }
}

.panel:not(.wiki-shell) {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad-section);
  box-shadow: var(--shadow-glass), var(--shadow-warm);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.panel:not(.wiki-shell):hover {
  box-shadow: var(--shadow-glass), var(--shadow-warm), 0 0 0 1px rgba(22, 163, 74, 0.18);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-start;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  text-align: start;
}

.panel-head .panel-title {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.dash-panel-head {
  margin-bottom: 0;
  width: 100%;
  justify-content: flex-start;
  align-items: flex-start;
}

.dash-head-main {
  flex: 1;
  min-width: 0;
}

.dash-head-main .panel-title {
  margin-bottom: var(--space-3);
}

.btn-back {
  flex-shrink: 0;
  min-height: 44px;
  min-width: auto;
  padding: 0 var(--space-4);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: clamp(10px, 2vw, 12px);
}

.btn-back:hover {
  color: var(--felt-deep);
  border-color: rgba(22, 163, 74, 0.4);
  background: #fff;
}

.panel-title {
  margin: 0 0 var(--space-4);
  font-family: var(--font);
  font-size: clamp(1.25rem, 3.5vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--felt-deep);
  text-align: start;
  width: 100%;
  text-shadow: none;
}

.section.hidden,
.hidden[hidden] {
  display: none !important;
}

.form {
  width: 100%;
  max-width: var(--form-max);
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-4);
}

.form .field {
  margin-bottom: 0;
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.form label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: start;
}

.form input[type="number"],
.form input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.form input:focus {
  outline: none;
  border-color: rgba(22, 163, 74, 0.55);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
}

.setup-names {
  display: grid;
  gap: var(--space-4);
  margin-bottom: 0;
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 var(--space-5);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: clamp(10px, 2vw, 14px);
  cursor: pointer;
  transition: transform 0.1s ease, filter var(--transition);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  width: 100%;
  max-width: min(100%, 22rem);
  margin-left: 0;
  margin-right: 0;
  align-self: flex-start;
  color: var(--text);
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 6px 20px rgba(0, 35, 20, 0.14), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
  transition: transform 0.18s ease, box-shadow 0.25s ease, filter 0.2s ease, border-color 0.2s ease;
  animation: btnGlowPulse 3s ease-in-out infinite;
}

.btn-primary:hover {
  filter: none;
  transform: translateY(-2px);
  border-color: rgba(22, 163, 74, 0.45);
  box-shadow: 0 10px 28px rgba(0, 45, 25, 0.18), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
}

.dashboard-view .btn-primary {
  animation-duration: 2.6s;
}

/* Full-width primary buttons in multi-button rows; setup keeps a compact CTA */
.dashboard-view .actions-row .btn-primary,
#section-settlement .actions-row .btn-primary {
  max-width: none;
  flex: 1 1 160px;
  width: auto;
  align-self: stretch;
}

#form-setup .btn-primary {
  max-width: min(100%, 24rem);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: var(--shadow-glass);
  border-radius: clamp(10px, 2vw, 12px);
}

.btn-secondary:hover {
  border-color: rgba(22, 163, 74, 0.4);
  color: var(--felt-deep);
}

.btn-ghost {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.45);
  border: 1px dashed rgba(15, 80, 50, 0.35);
  border-radius: clamp(10px, 2vw, 12px);
}

.btn-ghost:hover {
  color: var(--felt-deep);
  border-color: rgba(22, 163, 74, 0.45);
  background: rgba(255, 255, 255, 0.92);
}

.btn-danger {
  color: #fff;
  background: var(--crimson);
  border-radius: clamp(10px, 2vw, 12px);
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.35);
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.dash-top {
  margin-bottom: var(--space-3);
}

.payment-history-panel {
  margin-bottom: var(--space-4);
  padding: var(--pad-card);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 252, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass), inset 0 1px 0 rgba(255, 255, 255, 1);
  backdrop-filter: blur(8px);
}

.payment-history-title {
  margin: 0 0 var(--space-3);
  font-size: 1rem;
  font-weight: 700;
  color: var(--felt-deep);
  text-align: start;
}

.payment-history-list {
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

.payment-history-list.payment-history-detail {
  max-height: 220px;
  overflow-y: auto;
}

.payment-history-aggregated {
  margin-bottom: var(--space-3);
}

.btn-toggle-payment-log {
  width: auto;
  min-width: min(100%, 280px);
  margin-top: var(--space-2);
  margin-bottom: var(--space-3);
  margin-left: 0;
  margin-right: 0;
  display: inline-block;
}

.payment-log-details {
  margin-top: var(--space-3);
}

.payment-log-details.hidden {
  display: none !important;
}

.payment-log-detail-title {
  margin: 0 0 var(--space-3);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

.payment-history-line {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.payment-history-line:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.payment-history-empty {
  margin: 0 0 var(--space-4);
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: start;
}

.payment-history-total-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-start;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
  font-size: 1rem;
}

.payment-history-total-label {
  color: var(--text-muted);
}

.payment-history-total-amt {
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  color: var(--felt-deep);
}

.btn-reset-payment-log {
  width: auto;
  min-width: min(100%, 220px);
  max-width: 220px;
  margin-left: 0;
  margin-right: 0;
  display: inline-block;
}

.dash-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: var(--space-3) var(--space-5);
  margin-top: var(--space-2);
  text-align: start;
}

.meta-line {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.pot-amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dim);
  animation: potShine 3s ease-in-out infinite;
}

.player-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.player-card {
  padding: var(--pad-card);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-glass);
  transition: border-color var(--transition);
}

.player-card.folded {
  opacity: 0.85;
  border-style: dashed;
}

.player-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  text-align: start;
}

.player-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.balance {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.balance.positive {
  color: var(--positive);
}

.balance.negative {
  color: var(--owed);
}

.balance.zero {
  color: var(--text-muted);
}

.player-row-grid {
  display: grid;
  gap: var(--space-3);
}

@media (min-width: 420px) {
  .player-row-grid {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}

.bid-field label {
  display: block;
  margin-bottom: var(--space-3);
  font-size: clamp(0.8rem, 2.2vw, 0.9rem);
  font-weight: 600;
  color: var(--text-muted);
  text-align: start;
}

.bid-field input[type="number"] {
  width: 100%;
  min-height: var(--bid-input-min-h);
  padding: var(--bid-input-pad-y) var(--bid-input-pad-x);
  font-size: var(--bid-input-font);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  background: #fffefb;
  border: 2px solid rgba(22, 163, 74, 0.28);
  border-radius: 18px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
}

.bid-field input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  align-items: center;
  justify-content: flex-start;
}

.control {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
}

.control input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.winner-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.winner-wrap input {
  width: 18px;
  height: 18px;
  accent-color: var(--suit-black);
}

.actions-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

@media (min-width: 400px) {
  .actions-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: flex-start;
  }

  .actions-row .btn {
    flex: 1 1 160px;
    min-width: min(100%, 140px);
  }

  .actions-row .btn-primary {
    width: auto;
  }
}

.add-player-box {
  margin-top: var(--space-3);
  padding: var(--pad-card);
  background: rgba(255, 255, 255, 0.65);
  border: 1px dashed rgba(22, 163, 74, 0.4);
  border-radius: 16px;
  text-align: start;
  max-width: var(--form-max);
}

.add-player-box label {
  display: block;
  margin-bottom: var(--space-3);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.inline-field {
  display: flex;
  gap: var(--space-3);
}

.inline-field input {
  flex: 1;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.settlement-panel-head {
  margin-bottom: var(--space-4);
}

.settlement-panel-head .panel-title {
  width: 100%;
}

.settlement-block {
  margin-bottom: var(--space-5);
}

.settlement-subtitle {
  margin: 0 0 var(--space-3);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--felt-deep);
  text-align: start;
}

.settlement-rounds {
  min-height: 1rem;
}

.settlement-agg-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-4);
  text-align: start;
}

.settlement-round-detail {
  margin-top: var(--space-3);
}

.settlement-round-detail.hidden {
  display: none !important;
}

.settlement-by-round-title {
  margin: 0 0 var(--space-3);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

.btn-toggle-settlement-rounds {
  width: auto;
  min-width: min(100%, 280px);
  margin-top: var(--space-2);
  margin-left: 0;
  margin-right: 0;
  display: inline-block;
}

.settlement-round-block {
  margin-bottom: var(--space-4);
  padding: var(--pad-card);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-glass);
}

.settlement-round-heading {
  margin: 0 0 var(--space-3);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.settlement-round-list {
  margin: 0;
  padding: 0;
  padding-left: 1.25rem;
  list-style-position: outside;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
  text-align: start;
}

.settlement-round-item {
  margin-bottom: var(--space-2);
}

.settlement-rounds-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

.settlement-actions-split {
  margin-top: var(--space-4);
  align-items: stretch;
  justify-content: flex-start;
}

@media (min-width: 400px) {
  .settlement-actions-split {
    flex-direction: row;
  }

  .settlement-actions-split .btn {
    flex: 1;
    min-width: min(100%, 160px);
  }
}

.settle-intro {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: start;
  line-height: 1.55;
  max-width: min(100%, 40rem);
}

.settlement-list {
  margin: 0 0 var(--space-5);
  padding: 0;
  list-style: none;
  width: 100%;
  max-width: min(100%, 40rem);
}

.settlement-list li {
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  background: linear-gradient(90deg, rgba(220, 252, 231, 0.5) 0%, rgba(255, 255, 255, 0.98) 12%, rgba(255, 255, 255, 0.98) 100%);
  border-left: 4px solid var(--primary-dim);
  border-radius: 0 14px 14px 0;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: start;
  box-shadow: var(--shadow-glass);
}

.settle-none {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
  font-style: italic;
  text-align: start;
  max-width: min(100%, 40rem);
}

.toast {
  position: fixed;
  bottom: max(var(--space-5), env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  max-width: min(90vw, 28rem);
  padding: var(--space-3) var(--space-5);
  font-size: 0.9rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(15, 80, 50, 0.18);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-glass), 0 12px 40px rgba(0, 35, 20, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: toastPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ========== Motion: game table energy ========== */

#section-setup.panel,
#section-settlement.panel {
  animation: panelFadeIn 0.5s ease backwards;
}

.dashboard-view.panel {
  animation: panelFadeIn 0.55s ease backwards;
}

.player-card {
  transition: transform 0.2s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.player-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 40, 22, 0.14), 0 0 0 1px rgba(22, 163, 74, 0.22);
}

.dashboard-view .player-card {
  animation: cardDealIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.dashboard-view .player-card:nth-child(1) {
  animation-delay: 0.02s;
}
.dashboard-view .player-card:nth-child(2) {
  animation-delay: 0.06s;
}
.dashboard-view .player-card:nth-child(3) {
  animation-delay: 0.1s;
}
.dashboard-view .player-card:nth-child(4) {
  animation-delay: 0.14s;
}
.dashboard-view .player-card:nth-child(5) {
  animation-delay: 0.18s;
}
.dashboard-view .player-card:nth-child(6) {
  animation-delay: 0.22s;
}
.dashboard-view .player-card:nth-child(7) {
  animation-delay: 0.26s;
}
.dashboard-view .player-card:nth-child(8) {
  animation-delay: 0.3s;
}
.dashboard-view .player-card:nth-child(9) {
  animation-delay: 0.34s;
}
.dashboard-view .player-card:nth-child(10) {
  animation-delay: 0.38s;
}
.dashboard-view .player-card:nth-child(11) {
  animation-delay: 0.42s;
}
.dashboard-view .player-card:nth-child(12) {
  animation-delay: 0.46s;
}

.dashboard-view .player-card:nth-child(1) {
  border-top: 3px solid #22c55e;
}
.dashboard-view .player-card:nth-child(2) {
  border-top: 3px solid #16a34a;
}
.dashboard-view .player-card:nth-child(3) {
  border-top: 3px solid #15803d;
}
.dashboard-view .player-card:nth-child(4) {
  border-top: 3px solid #0d9488;
}
.dashboard-view .player-card:nth-child(5) {
  border-top: 3px solid #e11d48;
}
.dashboard-view .player-card:nth-child(6) {
  border-top: 3px solid #166534;
}
.dashboard-view .player-card:nth-child(7) {
  border-top: 3px solid #4ade80;
}
.dashboard-view .player-card:nth-child(8) {
  border-top: 3px solid #14532d;
}
.dashboard-view .player-card:nth-child(9) {
  border-top: 3px solid #34d399;
}
.dashboard-view .player-card:nth-child(10) {
  border-top: 3px solid #047857;
}
.dashboard-view .player-card:nth-child(11) {
  border-top: 3px solid #86efac;
}
.dashboard-view .player-card:nth-child(12) {
  border-top: 3px solid #065f46;
}

.dashboard-view .payment-history-panel {
  animation: potStripGlow 4s ease-in-out infinite;
}

.wiki-tab {
  transition: transform 0.18s ease, color 0.2s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.wiki-tab:active {
  transform: scale(0.97);
}

.wiki-step {
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}

.wiki-step:hover {
  transform: translateX(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

/* Successful round: gold wash + pot bounce */
body.round-celebrate::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.35) 0%, rgba(34, 197, 94, 0.2) 45%, transparent 58%);
  animation: celebrateFlash 0.85s ease-out forwards;
}

body.round-celebrate .pot-amount {
  animation: potCelebrate 0.75s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

body.round-celebrate .dashboard-view.panel {
  animation: panelCelebrate 0.6s ease-out;
}

/* New game started */
body.game-start-flash::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.22) 0%, rgba(36, 197, 94, 0.22) 42%, rgba(15, 81, 50, 0.12) 60%, transparent 70%);
  animation: gameStartFlash 0.65s ease-out forwards;
}

@keyframes logoFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes btnGlowPulse {
  0%,
  100% {
    box-shadow: 0 6px 20px rgba(0, 35, 20, 0.14), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
  }
  50% {
    box-shadow: 0 8px 26px rgba(0, 50, 28, 0.2), 0 0 0 1px rgba(22, 163, 74, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.04);
  }
}

@keyframes panelFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardDealIn {
  from {
    opacity: 0;
    transform: translateY(12px) rotate(-1deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

@keyframes potStripGlow {
  0%,
  100% {
    box-shadow: var(--shadow-glass), inset 0 1px 0 rgba(255, 255, 255, 1);
  }
  50% {
    box-shadow: var(--shadow-glass), inset 0 1px 0 rgba(255, 255, 255, 1), 0 0 22px rgba(22, 163, 74, 0.15);
  }
}

@keyframes potShine {
  0%,
  100% {
    text-shadow: 0 0 0 transparent;
    filter: drop-shadow(0 0 0 transparent);
  }
  50% {
    text-shadow: 0 0 12px rgba(34, 197, 94, 0.45);
    filter: drop-shadow(0 0 5px rgba(22, 101, 52, 0.35));
  }
}

@keyframes toastPop {
  0% {
    transform: translateX(-50%) translateY(12px) scale(0.92);
  }
  70% {
    transform: translateX(-50%) translateY(-4px) scale(1.03);
  }
  100% {
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes celebrateFlash {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes potCelebrate {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.2);
  }
  70% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes panelCelebrate {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.008);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes gameStartFlash {
  0% {
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after,
  .logo-cards,
  .btn-primary,
  .dashboard-view .btn-primary,
  #section-setup.panel,
  #section-settlement.panel,
  .dashboard-view.panel,
  .dashboard-view .player-card,
  .dashboard-view .payment-history-panel,
  .pot-amount,
  .toast.visible,
  body.round-celebrate::after,
  body.game-start-flash::after {
    animation: none !important;
  }

  body.round-celebrate .pot-amount {
    animation: none !important;
  }

  .player-card:hover,
  .panel:not(.wiki-shell):hover {
    transform: none;
  }

  .btn-primary:hover {
    transform: none;
  }
}
