body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at top right, rgba(245, 185, 66, 0.1), transparent 40%),
    radial-gradient(circle at bottom left, rgba(56, 189, 248, 0.08), transparent 42%),
    var(--bg-base);
}

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px 48px;
}

.brand-header {
  text-align: center;
  margin: 8px 0 20px;
}

.brand-title {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent-gold);
}

.brand-subtitle {
  margin: 6px 0 0;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

/* Cards & Panels */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.muted {
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.small {
  font-size: 0.8rem;
}

.mono {
  font-family: var(--font-mono);
}

/* Status Banner / Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(92vw, 480px);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
  z-index: 1000;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
}

.toast.success {
  background: #064e3b;
  border-color: var(--accent-emerald);
}

.toast.error {
  background: #7f1d1d;
  border-color: var(--accent-danger);
}

.alert-banner {
  background: var(--accent-danger-dim);
  border: 1px solid var(--accent-danger);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

/* Forms & Inputs */
.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input,
.select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 0.98rem;
  color: var(--text-primary);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent-gold);
}

.input-code {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: center;
  font-size: 1.2rem;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row > * {
  flex: 1;
}

.row-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-gold);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--accent-gold);
  color: #111827;
}

.btn-success {
  background: var(--accent-emerald);
  color: #052e16;
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--accent-danger);
  color: #ffffff;
}

.btn-sm {
  padding: 7px 11px;
  font-size: 0.84rem;
}

/* Segmented Tabs */
.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  background: var(--bg-input);
  padding: 5px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 6px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.tab-btn.active {
  background: var(--bg-elevated);
  color: var(--accent-gold);
}

/* Avatars */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-strong);
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 34px;
  height: 34px;
  font-size: 1.15rem;
}

.avatar-md {
  width: 46px;
  height: 46px;
  font-size: 1.5rem;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 2rem;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.avatar-option {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--border-subtle);
  background: var(--bg-input);
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-option.selected {
  border-color: var(--accent-gold);
  background: var(--accent-gold-dim);
}

/* Active Session Top HUD */
.hud {
  background: linear-gradient(135deg, #162036, #111827);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 14px;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hud-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hud-name {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-balance {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--accent-emerald);
  margin: 10px 0 8px;
  letter-spacing: -0.01em;
}

.hud-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.pill-gold {
  color: var(--accent-gold);
  background: var(--accent-gold-dim);
  border-color: rgba(245, 185, 66, 0.35);
}

.pill-green {
  color: var(--accent-emerald);
  background: var(--accent-emerald-dim);
  border-color: rgba(16, 185, 129, 0.35);
}

.pill-red {
  color: #fca5a5;
  background: var(--accent-danger-dim);
  border-color: rgba(239, 68, 68, 0.45);
}

.pill-blue {
  color: var(--accent-blue);
  background: var(--accent-blue-dim);
  border-color: rgba(56, 189, 248, 0.35);
}

/* Quick Chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chip:hover:not(:disabled) {
  border-color: var(--accent-gold);
}

/* Horse Racing Cards */
.horse-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.horse-card {
  width: 100%;
  text-align: left;
  background: var(--bg-input);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.horse-card.selected {
  border-color: var(--accent-gold);
  background: rgba(245, 185, 66, 0.1);
}

.horse-lane {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.horse-info {
  flex: 1;
  min-width: 0;
}

.horse-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.horse-trait {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.horse-odds {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.96rem;
  color: var(--accent-gold);
  flex-shrink: 0;
}

/* Lucky 80 Grid */
.keno-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin: 10px 0 12px;
}

.keno-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.keno-cell.selected {
  background: var(--accent-gold);
  color: #111827;
  border-color: var(--accent-gold);
}

.keno-cell.drawn {
  border-color: var(--accent-blue);
  box-shadow: inset 0 0 0 1px var(--accent-blue);
}

.keno-cell.selected.drawn {
  background: var(--accent-emerald);
  color: #052e16;
  border-color: var(--accent-emerald);
}

.cost-box {
  background: var(--accent-gold-dim);
  border: 1px solid rgba(245, 185, 66, 0.4);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  text-align: center;
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--accent-gold);
  margin: 12px 0;
}

.drawn-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.ball {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
  font-size: 0.76rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Lists & Tables */
.list-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.payout-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  margin-top: 8px;
}

.payout-table th,
.payout-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.payout-table th {
  color: var(--text-secondary);
  font-weight: 600;
}

/* Host QR & Code Box */
.code-banner {
  background: var(--bg-input);
  border: 1px dashed var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  margin-bottom: 12px;
}

.code-big {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  color: var(--accent-gold);
}

.qr-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.qr-wrap img {
  width: 170px;
  height: 170px;
  border-radius: var(--radius-md);
  background: #ffffff;
  padding: 8px;
}

/* Final Leaderboard */
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.leaderboard-row.rank-1 {
  border-color: var(--accent-gold);
  background: rgba(245, 185, 66, 0.12);
}

.rank-badge {
  width: 34px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
}