:root {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-accent: radial-gradient(circle at top, #1e293b 0%, #0f172a 55%);
  --panel: rgba(15, 23, 42, 0.86);
  --panel-border: rgba(148, 163, 184, 0.18);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-strong: #0ea5e9;
  --secondary: #334155;
  --accent: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 18px 48px rgba(2, 6, 23, 0.35);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-accent);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  transition: transform 0.16s ease, opacity 0.16s ease, background-color 0.16s ease;
}

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

button:active {
  transform: translateY(0);
}

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

button:disabled:hover {
  transform: none;
}

input {
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
}

input:focus {
  outline: 2px solid rgba(56, 189, 248, 0.4);
  border-color: rgba(56, 189, 248, 0.5);
}

label span,
.card-header p,
.player-meta,
.stat-label,
.pot-label,
.eyebrow,
.status-message {
  color: var(--muted);
}

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.hero h1 {
  margin: 0.2rem 0 0.5rem;
  font-size: clamp(2rem, 4vw, 3.25rem);
}

.hero-copy {
  max-width: 52ch;
  margin: 0;
  color: var(--text);
  opacity: 0.9;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.setup-card,
.pot-card,
.status-card {
  grid-column: span 4;
}

.players-card {
  grid-column: 1 / -1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.card-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.card-header p {
  margin: 0.35rem 0 0;
}

.split-controls {
  display: grid;
  gap: 0.5rem;
  justify-items: start;
}

.split-selection-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.stack-form,
.pot-form {
  display: grid;
  gap: 1rem;
}

.quick-bets {
  display: grid;
  gap: 0.55rem;
}

.player-card .quick-bets {
  margin-bottom: 1.55rem;
}

.quick-bets-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.quick-bets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.chip-btn {
  min-width: 4rem;
  padding: 0.65rem 0.85rem;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text);
}

.chip-btn-clear {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.28);
}

.pot-breakdown {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.pot-breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  color: var(--muted);
}

.pot-breakdown-row strong {
  color: var(--text);
}

.pot-breakdown-row.side-pot strong {
  color: #fcd34d;
}

.pot-breakdown-row.uncalled-bet strong {
  color: #fdba74;
}

.pot-breakdown-row.manual-adjustment strong {
  color: #c4b5fd;
}

.pot-breakdown-empty {
  color: var(--muted);
}

.pot-display {
  text-align: right;
}

.pot-display strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 2rem;
  color: #f8fafc;
}

.button-row,
.button-grid {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.player-card .button-grid {
  margin-top: 0.2rem;
}

.button-grid > button {
  flex: 1 1 calc(50% - 0.75rem);
}

.button-grid > .all-in-btn,
.button-grid > .split-select-btn {
  flex-basis: 100%;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.accent-btn,
.warning-btn,
.danger-btn,
.icon-btn {
  padding: 0.85rem 1rem;
  color: #f8fafc;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
}

.secondary-btn {
  background: rgba(51, 65, 85, 0.95);
}

.ghost-btn {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.accent-btn {
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid rgba(34, 197, 94, 0.28);
  color: #dcfce7;
}

.warning-btn {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #fef3c7;
}

.split-select-btn.is-selected {
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: #e0f2fe;
}

.danger-btn,
.icon-btn {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #fee2e2;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat-grid article {
  padding: 1rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.stat-grid strong {
  display: block;
  margin-top: 0.45rem;
  font-size: 1.2rem;
}

.status-message {
  min-height: 1.5rem;
  margin: 1rem 0 0;
}

.players-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.player-card {
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.7);
}

.player-card-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.player-card-header h3 {
  margin: 0;
}

.player-chip-block {
  margin: 1rem 0;
}

.player-chip-block span {
  display: block;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.player-chip-block strong {
  font-size: 1.9rem;
}

.player-amount-field {
  display: block;
  margin-bottom: 1rem;
}

.empty-state {
  border: 1px dashed rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 980px) {
  .setup-card,
  .pot-card,
  .status-card {
    grid-column: 1 / -1;
  }

  .hero {
    flex-direction: column;
  }
}

@media (max-width: 640px) and (hover: none) and (pointer: coarse) {
  body {
    overflow-x: hidden;
  }

  button,
  input {
    touch-action: manipulation;
  }

  .app-shell {
    width: 100%;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    padding-left: max(0.75rem, env(safe-area-inset-left));
  }

  .hero {
    gap: 1rem;
  }

  .hero h1 {
    font-size: clamp(1.8rem, 8vw, 2.35rem);
  }

  .hero-copy {
    max-width: none;
    font-size: 0.98rem;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .hero-actions > button {
    width: 100%;
  }

  .card {
    padding: 1rem;
  }

  .card-header,
  .player-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .split-selection-status {
    text-align: left;
  }

  .pot-display {
    text-align: left;
  }

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

  .players-list {
    grid-template-columns: 1fr;
  }

  .player-card {
    padding: 0.95rem;
  }

  .remove-player-btn {
    align-self: stretch;
  }

  .button-grid > button,
  .button-row > button {
    flex: 1 1 100%;
  }

  .quick-bets-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .chip-btn {
    width: 100%;
    min-width: 0;
    font-size: 0.95rem;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn,
  .accent-btn,
  .warning-btn,
  .danger-btn,
  .icon-btn,
  input {
    min-height: 48px;
  }

  input {
    font-size: 16px;
  }
}

/* Landscape phones: make the top section less cramped */
@media (max-height: 520px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .app-shell {
    padding: 1rem 0 1.5rem;
  }

  .hero {
    margin-bottom: 1rem;
  }

  .layout {
    gap: 0.75rem;
  }

  .card {
    padding: 1rem;
  }

  .setup-card,
  .pot-card {
    grid-column: span 6;
  }

  .status-card {
    grid-column: 1 / -1;
  }
}
