/* Artifact platform tokens — auto-resolved */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0 20px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--primary-tint);
  color: var(--primary);
  border-radius: var(--radius-md);
}
.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}
.brand-sub {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.header-actions { display: flex; gap: 8px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  flex: 1;
  min-width: 90px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); }
.tab-active {
  background: var(--primary);
  color: #fff;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card-header h2 { margin: 0 0 4px; font-size: 1.1rem; }
.card h3 { margin: 0 0 12px; font-size: 1rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  background: var(--surface-2);
  color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost {
  background: transparent;
  border-color: var(--neutral);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-lg { padding: 12px 20px; font-size: 1rem; }
.btn-chip {
  padding: 6px 12px;
  background: var(--primary-tint);
  color: var(--primary);
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}
.btn-chip:hover { background: var(--primary); color: #fff; }

/* ---------- Inputs ---------- */
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--neutral);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.input-lg { padding: 14px 16px; font-size: 1.1rem; font-weight: 600; }

/* ---------- Setup grid ---------- */
.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 28px;
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
}
.chip-captain {
  background: var(--primary-tint);
  color: var(--primary);
}
.chip-sold {
  background: var(--success);
  color: #fff;
}
.chip-top {
  background: var(--accent);
  color: #fff;
}
.chip-live {
  background: var(--danger);
  color: #fff;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.points-pill {
  padding: 4px 10px;
  background: var(--primary-tint);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ---------- Captains board ---------- */
.captains-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 720px) {
  .captains-board { grid-template-columns: repeat(2, 1fr); }
}
.captain-card {
  background: var(--surface);
  border: 2px solid var(--neutral);
  border-radius: var(--radius-lg);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
  color: var(--text);
  transition: border-color 0.15s, transform 0.1s;
}
.captain-card:hover { transform: translateY(-2px); }
.captain-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.captain-top { border-color: var(--accent); }
.captain-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.captain-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.captain-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.captain-points strong {
  font-size: 1.4rem;
  color: var(--primary);
}

/* ---------- Stage ---------- */
.stage-card { padding: 24px; }
.stage-empty { text-align: center; padding: 20px 0; }
.stage-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.stage-head h2 { margin: 0; font-size: 1.1rem; color: var(--text-muted); font-weight: 500; }
.stage-name {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
  color: var(--text);
}
.stage-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--neutral);
  border-radius: var(--radius-md);
  padding: 14px;
}
.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
}
.stat-value.sm { font-size: 1.1rem; }
.stat-sub { font-size: 0.8rem; margin-top: 4px; }

.bid-form {
  background: var(--bg);
  border: 1px solid var(--neutral);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}
.bid-label { display: block; margin-bottom: 10px; font-size: 0.9rem; color: var(--text-muted); }
.bid-label strong { color: var(--primary); }
.bid-row { display: flex; gap: 8px; }
.bid-row .input { flex: 1; }
.quick-bids { display: flex; gap: 6px; margin-top: 10px; }
.error {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.stage-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.stage-actions .btn { flex: 1; }

.bid-history { border-top: 1px solid var(--neutral); padding-top: 14px; }
.bid-history h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 8px; }
.bid-history ul { list-style: none; padding: 0; margin: 0; }
.bid-history li {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.bid-history li.bid-top {
  background: var(--primary-tint);
  color: var(--primary);
  font-weight: 700;
}
.bid-amt { font-weight: 700; }

/* ---------- Pool ---------- */
.pool { display: flex; flex-wrap: wrap; gap: 8px; }
.pool-chip {
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--neutral);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.pool-chip:hover:not(:disabled) {
  background: var(--primary-tint);
  border-color: var(--primary);
  color: var(--primary);
}
.pool-chip:disabled { opacity: 0.4; cursor: not-allowed; }
.pool-chip-live {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pool-chip-live:hover { background: var(--primary); color: #fff; }
.pool-chip-static { cursor: default; }
.pool-chip-static:hover { background: var(--surface-2); color: var(--text); border-color: var(--neutral); }
.live-dot {
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

/* ---------- Teams (results) ---------- */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (max-width: 720px) {
  .teams-grid { grid-template-columns: 1fr; }
}
.team-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.team-head h3 { margin: 0; font-size: 1.15rem; }
.team-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--neutral);
}
.team-list { list-style: none; padding: 0; margin: 0; }
.team-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--neutral);
}
.team-list li:last-child { border-bottom: none; }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.small { font-size: 0.85rem; }
.danger-zone { border-color: var(--danger); }

.empty {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border: 1px dashed var(--neutral);
  border-radius: var(--radius-lg);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty h2 { margin: 0 0 8px; }

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  font-size: 0.9rem;
}

.app-footer {
  text-align: center;
  padding: 30px 10px 10px;
  color: var(--text-muted);
}

.loading-screen {
  display: grid;
  place-items: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--text-muted);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--neutral);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Dialog ---------- */
.dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: calc(100% - 32px);
}
.dialog::backdrop { background: var(--scrim); }
.dialog h3 { margin: 0 0 8px; }
.dialog-menu {
  display: flex;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
  justify-content: flex-end;
}
