:root {
  --bg-gradient: radial-gradient(circle at 50% 20%, #1a4329 0%, #0c2014 60%, #06110a 100%);
  --surface-card: rgba(20, 45, 30, 0.75);
  --surface-elevated: rgba(28, 62, 42, 0.85);
  --surface-modal: #132b1d;
  --border-color: rgba(255, 215, 0, 0.2);
  --border-active: #e6b800;
  --accent-gold: #f5c518;
  --accent-gold-hover: #ffd700;
  --accent-emerald: #10b981;
  --accent-emerald-hover: #059669;
  --accent-ruby: #ef4444;
  --accent-amber: #f59e0b;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-gold: #fde68a;
  --chip-bg: rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  user-select: none;
}

/* Glassmorphic Header */
header {
  background: rgba(10, 25, 16, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  box-sizing: border-box;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.cards-icon {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
  flex-shrink: 0;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #ffffff 0%, #ffd700 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Base button styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease-in-out;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-icon {
  padding: 8px 10px;
  border-radius: var(--radius-md);
}

.btn-primary {
  background: linear-gradient(135deg, #f5c518 0%, #d49a00 100%);
  color: #111827;
  border-color: #ffd700;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #ffd700 0%, #e6a800 100%);
  box-shadow: 0 0 12px rgba(245, 197, 24, 0.4);
}

.btn-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border-color: #34d399;
}
.btn-emerald:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}

.btn-danger-outline {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fff;
}

.btn-purple {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: white;
  border-color: #a78bfa;
}
.btn-purple:hover {
  background: linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
}

.btn-sm {
  padding: 5px 9px;
  font-size: 0.775rem;
  border-radius: var(--radius-sm);
}

/* Layout container */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Rules / Settings banner bar */
.rules-bar {
  background: var(--surface-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-lg);
}

.rules-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.rule-chip {
  background: var(--chip-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rule-chip span.label {
  color: var(--text-muted);
}
.rule-chip span.val {
  font-weight: 700;
  color: var(--accent-gold);
}

.rule-chip.total-pts span.val {
  color: #f87171;
}

/* Active Game Status Bar */
.game-info-card {
  background: var(--surface-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}

.round-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.round-badge {
  background: linear-gradient(135deg, rgba(245, 197, 24, 0.2), rgba(212, 154, 0, 0.1));
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  text-align: center;
}
.round-badge .num {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--accent-gold);
  line-height: 1;
}
.round-badge .lbl {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.dealer-indicator {
  display: flex;
  flex-direction: column;
}
.dealer-indicator .title {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.dealer-indicator .name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Segmented Navigation Tabs */
.tabs-nav {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 700;
  padding: 8px 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: var(--surface-card);
  color: var(--accent-gold);
  border-color: rgba(255, 215, 0, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Player Cards Grid */
.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.player-card {
  background: var(--surface-card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.player-card:hover {
  border-color: rgba(255, 215, 0, 0.3);
  transform: translateY(-2px);
}

.player-card.is-dealer {
  border-color: var(--accent-gold);
  box-shadow: 0 0 16px rgba(245, 197, 24, 0.15);
}

.player-card.is-out {
  opacity: 0.78;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(30, 18, 18, 0.85);
}

.player-card.is-rejoined {
  border-color: rgba(139, 92, 246, 0.5);
}

/* Redesigned Card Header Row */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.player-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #1f4e35, #0d281a);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent-gold);
  flex-shrink: 0;
}

.player-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.player-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.player-dealer-action {
  flex-shrink: 0;
}

/* Tag / Badge Styles */
.tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tag-first-dealer {
  background: rgba(255, 215, 0, 0.15);
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.35);
}

.tag-rejoin {
  background: rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.tag-out {
  background: #ef4444;
  color: #fff;
}

.dealer-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.dealer-badge.active {
  background: linear-gradient(135deg, #ffd700, #f59e0b);
  color: #0f172a;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
  border: 1px solid #fde047;
}

.btn-make-dealer {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-make-dealer:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

/* Card Score Box */
.card-score-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.score-main {
  display: flex;
  flex-direction: column;
}

.score-value {
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1;
}

.score-value.safe {
  color: #10b981;
}
.score-value.warning {
  color: #f59e0b;
}
.score-value.danger {
  color: #ef4444;
}

.score-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.score-status-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.pill-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.pill-status.safe {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.pill-status.danger {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.pill-status.out {
  background: rgba(239, 68, 68, 0.22);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.drop-status-text {
  font-size: 0.75rem;
  font-weight: 600;
}
.text-safe {
  color: #10b981;
}
.text-danger {
  color: #f59e0b;
}

/* Progress track */
.card-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.card-progress-fill.safe {
  background: linear-gradient(90deg, #10b981, #34d399);
}
.card-progress-fill.warning {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.card-progress-fill.danger {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

/* Footer Action */
.card-footer-action {
  margin-top: 2px;
}

.rejoin-closed-banner {
  font-size: 0.75rem;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  text-align: center;
  font-weight: 600;
}

.card-active-footer {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 2px;
}

.text-active {
  color: #34d399;
}

/* Scorecard Table View */
.table-wrapper {
  background: var(--surface-card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  position: relative;
  width: 100%;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.875rem;
}

.score-table th {
  background: rgba(12, 32, 20, 0.98);
  color: var(--text-gold);
  padding: 10px 12px;
  font-weight: 700;
  border-bottom: 2px solid rgba(255, 215, 0, 0.3);
  white-space: nowrap;
}

.score-table th.col-rnd {
  width: 64px;
  min-width: 64px;
}

.score-table th.col-dealer {
  width: 85px;
}

.score-table th.player-header {
  min-width: 95px;
}

.score-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  white-space: nowrap;
}

.score-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.score-table tr.total-row td {
  font-weight: 800;
  font-size: 1.05rem;
  background: rgba(0, 0, 0, 0.45);
  border-top: 2px solid rgba(255, 215, 0, 0.4);
  color: #fff;
  padding: 10px 10px;
}

.round-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.cell-val {
  font-weight: 700;
}
.cell-val.win {
  color: #10b981;
}
.cell-val.first-drop {
  color: #60a5fa;
}
.cell-val.mid-drop {
  color: #f59e0b;
}
.cell-val.full {
  color: #ef4444;
}

.cell-running {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--surface-modal);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: calc(100vh - 32px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
  margin: auto;
}

.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

/* Ensure forms inside modal card fill available height and enable flex scrolling */
.modal-card form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  margin: 0;
}

.modal-header {
  flex-shrink: 0;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
}

/* Modal Custom Scrollbar */
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(245, 197, 24, 0.35);
  border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(245, 197, 24, 0.65);
}

/* Pinned sticky modal footer */
.modal-footer {
  flex-shrink: 0;
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(14, 28, 20, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 5;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: normal;
}

.form-input, .form-select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: #fff;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus, .form-select:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(245, 197, 24, 0.2);
}

/* Round Entry Form Layout */
.round-entry-row {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease;
}

.round-entry-row:hover,
.round-entry-row:focus-within {
  border-color: rgba(245, 197, 24, 0.3);
}

.entry-player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.entry-player-name {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.entry-chip-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.entry-chip-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.entry-chip-btn.selected {
  background: var(--accent-gold);
  color: #000;
  border-color: #ffd700;
  font-weight: 800;
}

.entry-chip-btn.chip-win.selected {
  background: #10b981;
  color: #fff;
  border-color: #34d399;
}

.entry-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.entry-score-input {
  width: 86px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 6px 8px;
}

/* Re-join banner inside modal or card */
.rejoin-callout {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 0.85rem;
  color: #e9d5ff;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  background: var(--surface-card);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-state-icon {
  font-size: 3rem;
  opacity: 0.7;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #1f2937;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 0.875rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  animation: slideIn 0.2s ease-out;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.toast-success {
  border-color: #10b981;
  background: #064e3b;
}
.toast.toast-danger {
  border-color: #ef4444;
  background: #7f1d1d;
}

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

/* Setup View & Game Mode Selector Styles */
.setup-container {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setup-card {
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setup-header {
  text-align: center;
}

.setup-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}

.setup-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.section-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Mode Selection Cards */
.mode-selection-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-card {
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.mode-card:hover {
  border-color: rgba(255, 215, 0, 0.4);
  background: rgba(255, 255, 255, 0.04);
}

.mode-card.selected {
  border-color: var(--accent-gold);
  background: linear-gradient(135deg, rgba(245, 197, 24, 0.15), rgba(212, 154, 0, 0.08));
  box-shadow: 0 0 15px rgba(245, 197, 24, 0.2);
}

.mode-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mode-card-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-card.selected .mode-card-title {
  color: var(--accent-gold);
}

.mode-card-desc {
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.mode-card-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--accent-gold);
  color: #000;
  align-self: flex-start;
  text-transform: uppercase;
}

/* Player Management List in Setup */
.setup-players-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setup-add-bar {
  display: flex;
  gap: 8px;
}

.setup-add-bar input {
  flex: 1;
}

.setup-player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.setup-player-item {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.setup-player-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.player-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent-gold);
}

.setup-player-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-dealer-pick {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  font-size: 0.725rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-dealer-pick:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-dealer-pick.selected {
  background: var(--accent-gold);
  color: #000;
  border-color: #ffd700;
}

.btn-remove-player {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  line-height: 1;
  transition: all 0.15s ease;
}
.btn-remove-player:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* Double score banner for Best of 7 */
.double-score-banner {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.15));
  border: 1px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #fef3c7;
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-doubled-calc {
  font-size: 0.8rem;
  color: #f59e0b;
  font-weight: 700;
}

/* Touch and Mobile Base Optimizations */
html, body {
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

button, input, select {
  touch-action: manipulation;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  header {
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top, 8px));
    width: 100%;
    box-sizing: border-box;
  }
  .header-container {
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
  }
  .logo-area {
    gap: 6px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }
  .cards-icon {
    font-size: 18px;
    flex-shrink: 0;
  }
  .app-title {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .app-subtitle {
    display: none; /* Hide subtitle on mobile so title stays on single line */
  }
  .header-actions {
    gap: 4px;
    flex-shrink: 0;
  }
  .header-actions .btn-sm {
    padding: 6px 8px;
    font-size: 0.85rem;
    min-width: 34px;
    min-height: 34px;
  }
  /* On mobile screens, hide button text in header actions - clean, uniform icons */
  .header-actions .btn-text {
    display: none !important;
  }
  main {
    padding: 10px;
    gap: 12px;
  }
  .rules-bar {
    padding: 10px 12px;
  }
  .game-info-card {
    padding: 12px;
  }
  .players-grid {
    grid-template-columns: 1fr;
  }
  .modal-overlay {
    padding: 8px;
    align-items: center;
  }
  .modal-card {
    max-height: calc(100vh - 20px);
    border-radius: var(--radius-lg);
  }
  .mode-selection-grid {
    grid-template-columns: 1fr;
  }
  /* Prevent iOS Safari 16px auto-zoom */
  .form-input, .form-select, input[type="text"], input[type="number"] {
    font-size: 16px !important;
  }
  .entry-score-input {
    font-size: 16px !important;
    width: 78px;
    padding: 6px 4px;
  }
  /* Table horizontal touch scrolling */
  .table-wrapper {
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }
  /* Mobile Scoreboard Optimizations */
  .score-table th.col-dealer,
  .score-table td.col-dealer {
    display: none !important;
  }
  .rnd-dealer-mobile {
    display: block !important;
  }
  /* Sticky Round column on mobile scoreboard */
  .score-table th.col-rnd,
  .score-table td.col-rnd {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #0d281a;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.5);
    width: 62px;
    min-width: 62px;
    padding: 6px 4px;
    font-size: 0.8rem;
  }
  .score-table th.player-header {
    min-width: 76px;
    padding: 8px 4px;
    font-size: 0.8rem;
  }
  .score-table td {
    padding: 6px 4px;
    font-size: 0.8rem;
  }
  .cell-val {
    font-size: 0.825rem;
  }
  .cell-running {
    font-size: 0.65rem;
  }
  .score-table tr.total-row td {
    font-size: 0.95rem;
    padding: 8px 4px;
  }

  /* Segmented tabs on mobile */
  .tabs-nav {
    padding: 3px;
    gap: 3px;
  }
  .tab-btn {
    font-size: 0.775rem;
    padding: 7px 4px;
    gap: 4px;
  }

  /* Rules chips on mobile */
  .rules-chips {
    gap: 6px;
  }
  .rule-chip {
    padding: 3px 8px;
    font-size: 0.725rem;
  }
}

/* Small phones (<= 480px) */
@media (max-width: 480px) {
  .logo-area {
    gap: 6px;
  }
  .cards-icon {
    font-size: 18px;
  }
  .app-title {
    font-size: 0.9rem;
  }
  .setup-card {
    padding: 16px 12px;
  }
  .setup-add-bar {
    flex-direction: column;
  }
  .setup-add-bar button {
    width: 100%;
  }
}

