:root {
  --cream-bg: #F8FAFC;
  --surface-white: #FFFFFF;
  --dark-charcoal: #0F172A;
  --slate-navy: #1E293B;
  --muted-slate: #475569;
  --light-slate: #94A3B8;
  --blaze-orange: #FF5722;
  --blaze-orange-dark: #D84315;
  --blaze-orange-light: #FFEBE5;
  --gold-accent: #FFB300;
  --gold-dark: #FF8F00;
  --gold-light: #FFF8E1;
  --cyan-badge: #00B4D8;
  --cyan-badge-light: #E0F7FA;
  --success-green: #10B981;
  --success-green-dark: #059669;
  --success-green-light: #D1FAE5;
  --error-red: #EF4444;
  --error-red-light: #FEE2E2;
  --info-blue: #3B82F6;
  --border-subtle: #E2E8F0;
  --font-display: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html, body {
  min-height: 100%;
  background: #E2E8F0;
  font-family: var(--font-body);
  color: var(--dark-charcoal);
  font-size: 14px;
  line-height: 1.45;
}

#app-shell {
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--cream-bg);
  position: relative;
  box-shadow: 0 0 40px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  body {
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
    padding: 0;
  }
  #app-shell.wide-admin {
    max-width: 960px;
  }
}

#app-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* Toast / Snackbar */
#toast-container {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9500;
  width: calc(100% - 32px);
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--dark-charcoal);
  color: #FFFFFF;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUpFade 0.25s ease-out;
  pointer-events: auto;
}

.toast.success { border-left: 4px solid var(--success-green); }
.toast.error { border-left: 4px solid var(--error-red); }
.toast.info { border-left: 4px solid var(--cyan-badge); }

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

/* Splash Screen */
.splash-screen {
  min-height: 100dvh;
  background: radial-gradient(circle at 50% 35%, rgba(255, 87, 34, 0.28) 0%, rgba(15, 23, 42, 0) 55%),
              linear-gradient(180deg, #0F172A 0%, #1E293B 100%);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}

.splash-logo-wrap {
  width: 128px;
  height: 128px;
  border-radius: 28px;
  padding: 6px;
  background: linear-gradient(135deg, #FF5722, #FFB300);
  box-shadow: 0 0 42px rgba(255, 87, 34, 0.5);
  margin-bottom: 22px;
  animation: pulseLogo 2s infinite ease-in-out;
}

.splash-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 22px;
}

@keyframes pulseLogo {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.splash-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #FFFFFF;
}

.splash-subtitle {
  color: var(--blaze-orange);
  font-weight: 800;
  letter-spacing: 2.5px;
  font-size: 12px;
  text-transform: uppercase;
  margin-top: 4px;
}

.splash-progress-wrap {
  width: 100%;
  max-width: 280px;
  margin-top: 38px;
}

.splash-progress-bar {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.splash-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FF5722, #FFB300);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.splash-status {
  margin-top: 10px;
  font-size: 12px;
  color: #CBD5E1;
  font-weight: 600;
}

/* Common Layout & Cards */
.screen-scroll {
  flex: 1;
  padding: 16px 16px 94px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.screen-scroll.no-bottom-nav {
  padding-bottom: 28px;
}

.screen-scroll.has-sticky-bottom {
  padding-bottom: 96px;
}

.card {
  background: var(--surface-white);
  border-radius: 18px;
  border: 1px solid var(--border-subtle);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.card-dark {
  background: linear-gradient(155deg, #0F172A 0%, #1E293B 100%);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-orange {
  background: linear-gradient(110deg, #FF5722 0%, #FF7A00 100%);
  color: #FFFFFF;
  border: none;
}

.top-app-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.top-bar-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  color: var(--dark-charcoal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-white);
  color: var(--dark-charcoal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s, background 0.15s;
}

.icon-btn:active { transform: scale(0.95); }

.icon-btn-dark {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
}

/* Pills & Badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.pill-tickets {
  background: var(--gold-light);
  color: #B45309;
  border: 1px solid #FDE68A;
}

.pill-cash {
  background: #DCFCE7;
  color: var(--success-green-dark);
  border: 1px solid #BBF7D0;
}

.pill-orange {
  background: var(--blaze-orange-light);
  color: var(--blaze-orange-dark);
}

.pill-cyan {
  background: var(--cyan-badge-light);
  color: #0284C7;
}

.pill-dark {
  background: var(--dark-charcoal);
  color: #FFFFFF;
}

.pill-green {
  background: var(--success-green-light);
  color: var(--success-green-dark);
}

.pill-red {
  background: var(--error-red-light);
  color: #B91C1C;
}

.bell-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #F1F5F9;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--dark-charcoal);
}

.bell-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--error-red);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFFFFF;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 13px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s, background 0.15s;
}

.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 12px; border-radius: 10px; }
.btn-xs { min-height: 30px; padding: 4px 10px; font-size: 11px; border-radius: 8px; }
.btn-full { width: 100%; }

.btn-primary { background: var(--blaze-orange); color: #FFFFFF; }
.btn-primary:hover:not(:disabled) { background: var(--blaze-orange-dark); }
.btn-dark { background: var(--dark-charcoal); color: #FFFFFF; }
.btn-success { background: var(--success-green); color: #FFFFFF; }
.btn-danger { background: var(--error-red); color: #FFFFFF; }
.btn-gold { background: var(--gold-accent); color: var(--dark-charcoal); }
.btn-outline {
  background: var(--surface-white);
  color: var(--dark-charcoal);
  border: 1px solid #CBD5E1;
}
.btn-outline-orange {
  background: var(--blaze-orange-light);
  color: var(--blaze-orange-dark);
  border: 1px solid #FDBA74;
}

/* Forms */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--dark-charcoal);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-control {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--dark-charcoal);
  background: #FFFFFF;
  outline: none;
  transition: border-color 0.15s;
}

.input-control:focus { border-color: var(--blaze-orange); }
.input-control:disabled { background: #F1F5F9; color: var(--muted-slate); }
.input-has-right { padding-right: 44px; }

.input-action-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--muted-slate);
  cursor: pointer;
  padding: 6px;
  font-size: 12px;
  font-weight: 700;
}

textarea.input-control {
  min-height: 92px;
  resize: vertical;
}

select.input-control {
  cursor: pointer;
}

/* Segmented Tabs & Chips */
.segmented {
  display: flex;
  background: #F1F5F9;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.seg-btn {
  flex: 1;
  padding: 9px 10px;
  border-radius: 9px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-slate);
  cursor: pointer;
}

.seg-btn.active {
  background: #FFFFFF;
  color: var(--blaze-orange);
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: #F1F5F9;
  color: var(--dark-charcoal);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.chip.active-orange {
  background: var(--blaze-orange);
  border-color: var(--blaze-orange);
  color: #FFFFFF;
  font-weight: 700;
}

.chip.active-dark {
  background: var(--dark-charcoal);
  border-color: var(--dark-charcoal);
  color: #FFFFFF;
  font-weight: 700;
}

/* Horizontal Carousel */
.h-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.h-scroll::-webkit-scrollbar { display: none; }

.announcement-card {
  min-width: 270px;
  max-width: 270px;
  flex-shrink: 0;
}

/* Progress Bars */
.progress-track {
  width: 100%;
  height: 7px;
  background: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--blaze-orange);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-fill.green { background: var(--success-green); }

/* Tournament Card & Detail Hero */
.tournament-card {
  transition: transform 0.12s, box-shadow 0.15s;
  cursor: pointer;
}
.tournament-card:hover {
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.hero-banner {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  min-height: 205px;
  background: #0F172A;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
}

.hero-banner img.hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.48;
}

.hero-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.35) 0%, rgba(15, 23, 42, 0.92) 100%);
}

.hero-banner > * {
  position: relative;
  z-index: 2;
}

/* Countdown Digits */
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.countdown-box {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}

.countdown-val {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 800;
  color: #FFFFFF;
}

.countdown-lbl {
  font-size: 10px;
  color: #94A3B8;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Interactive Slot Grid */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}

.slot-cell {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #CBD5E1;
  background: #F8FAFC;
  color: var(--dark-charcoal);
  cursor: pointer;
}

.slot-cell.taken {
  background: #E2E8F0;
  border-color: #CBD5E1;
  color: #94A3B8;
  cursor: not-allowed;
}

.slot-cell.mine {
  background: #DCFCE7;
  border-color: var(--success-green);
  color: var(--success-green-dark);
}

.slot-cell.selected {
  background: var(--blaze-orange);
  border-color: var(--blaze-orange-dark);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(255, 87, 34, 0.35);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: #FFFFFF;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 50;
  box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.06);
}

.bottom-nav-item {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 12px;
  color: var(--muted-slate);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.bottom-nav-item.active {
  color: var(--blaze-orange);
  font-weight: 800;
}

.bottom-nav-item.active .nav-icon-wrap {
  background: var(--blaze-orange-light);
  color: var(--blaze-orange);
}

.nav-icon-wrap {
  padding: 4px 14px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Sticky Bottom Action Bar */
.sticky-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: #FFFFFF;
  border-top: 1px solid var(--border-subtle);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
}

/* Modals */
.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-root.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 90dvh;
  overflow-y: auto;
  background: #FFFFFF;
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  animation: popIn 0.2s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Helpers */
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted-slate); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.bold { font-weight: 700; }
.extrabold { font-weight: 800; }
.black { font-weight: 900; }
.divider { height: 1px; background: var(--border-subtle); margin: 12px 0; }
.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 6px;
  border-bottom: 1px solid #F1F5F9;
  cursor: pointer;
}
.menu-row:last-child { border-bottom: none; }
.sql-box {
  background: #0F172A;
  color: #E2E8F0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  padding: 14px;
  border-radius: 12px;
  max-height: 300px;
  overflow: auto;
  white-space: pre;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #CBD5E1;
  border-radius: 999px;
  transition: 0.2s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #FFFFFF;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background: var(--success-green); }
.switch input:checked + .slider:before { transform: translateX(20px); }
