/* ====================================================
   EMMAFEST 28 · DARK FESTIVAL UI
   Fonts: Syne (display) + Outfit (body)
   ==================================================== */

:root {
  /* backgrounds */
  --bg:        #05050f;
  --bg2:       #09091a;
  --bg3:       #0e0e24;
  --card:      #111128;
  --card2:     #16163a;

  /* borders */
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);

  /* accent palette */
  --purple:    #b45eff;
  --purple2:   #7c3aed;
  --pink:      #ff3d9a;
  --cyan:      #00e5ff;
  --gold:      #ffd54f;
  --gold2:     #f59e0b;
  --green:     #00e676;
  --red:       #ff1744;

  /* text */
  --txt:       #f0f0f8;
  --txt2:      #9090b8;
  --txt3:      #50507a;

  /* glow shadows */
  --glow-purple: 0 0 24px rgba(180,94,255,0.35);
  --glow-gold:   0 0 20px rgba(255,213,79,0.3);
  --glow-green:  0 0 20px rgba(0,230,118,0.3);
  --glow-pink:   0 0 20px rgba(255,61,154,0.3);

  /* layout */
  --r:   14px;
  --r-s: 9px;
  --nav-h: 50px;
  --hdr-h: 56px;
}

/* ==============================
   RESET & BASE
   ============================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

body {
  font-family: 'Outfit', sans-serif;
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 80% 60% at 15% 10%, rgba(124,58,237,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 90%, rgba(255,61,154,0.08) 0%, transparent 60%);
}

/* ==============================
   SCREEN SYSTEM
   ============================== */
.screen { display: none; height: 100dvh; width: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ==============================
   LOADING SCREEN
   ============================== */
#screen-loading {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.loading-inner { text-align: center; }

.loading-emoji {
  font-size: 4rem;
  display: block;
  margin-bottom: 1rem;
  animation: floatY 2s ease-in-out infinite;
}

.loading-sub {
  color: var(--txt3);
  font-size: 0.85rem;
  margin-top: 1.25rem;
  letter-spacing: 0.05em;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--bg3);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

/* ==============================
   BRAND TITLE (shared)
   ============================== */
.brand-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(2rem, 8vw, 2.8rem);
  font-weight: 900;
  color: var(--txt);
  letter-spacing: -1px;
  margin-bottom: 0.5rem;
}

.brand-title span {
  background: linear-gradient(130deg, var(--purple) 0%, var(--pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==============================
   SETUP SCREEN
   ============================== */
#screen-setup {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.setup-bg-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 20% 50%, rgba(124,58,237,0.18) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 50%, rgba(255,61,154,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.setup-inner {
  width: 100%;
  max-width: 400px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.setup-emoji {
  font-size: 4.5rem;
  display: block;
  margin-bottom: 1.25rem;
  animation: floatY 2.5s ease-in-out infinite;
}

.setup-subtitle {
  color: var(--txt2);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.setup-note {
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--txt3);
}

/* ==============================
   APP HEADER
   ============================== */
.app-header {
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-logo { font-size: 1.3rem; }

.header-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--txt);
  letter-spacing: -0.3px;
}

.header-title strong {
  background: linear-gradient(130deg, var(--purple), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.hdr-name {
  font-size: 0.72rem;
  color: var(--txt2);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hdr-coins {
  display: flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(120deg, rgba(255,213,79,0.15), rgba(245,158,11,0.1));
  border: 1px solid rgba(255,213,79,0.35);
  border-radius: 30px;
  padding: 3px 11px 3px 8px;
}

.coin-dot { font-size: 0.85rem; }

.coin-count {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--gold);
  min-width: 20px;
  text-align: right;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.coin-count.bump {
  animation: bumpScale 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

/* ==============================
   NAVIGATION
   ============================== */
.app-nav {
  height: var(--nav-h);
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

.app-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  flex: 1;
  min-width: max-content;
  padding: 0 0.7rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--txt3);
  font-family: 'Outfit', sans-serif;
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.nav-btn:hover { color: var(--txt2); background: rgba(255,255,255,0.03); }

.nav-btn.active {
  color: var(--purple);
  border-bottom-color: var(--purple);
  background: rgba(180,94,255,0.07);
}

.nav-btn.hidden { display: none; }

/* ==============================
   MAIN CONTENT AREA
   ============================== */
.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 1.1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--card2) transparent;
}

.tab::-webkit-scrollbar { width: 3px; }
.tab::-webkit-scrollbar-thumb { background: var(--card2); border-radius: 2px; }
.tab::-webkit-scrollbar-track { background: transparent; }

.tab.active { display: block; }

/* ==============================
   SECTION HEADS
   ============================== */
.section-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.section-head h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: var(--txt);
  letter-spacing: -0.3px;
}

.live-dot {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.08em;
}

.live-pulse {
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(0,230,118,0.6);
  animation: livePulse 1.5s infinite;
  display: inline-block;
}

/* ==============================
   CARDS
   ============================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.15rem;
  margin-bottom: 0.9rem;
  transition: border-color 0.2s;
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--txt);
  margin-bottom: 1rem;
  letter-spacing: -0.2px;
}

/* ==============================
   FORM FIELDS
   ============================== */
.field-group { margin-bottom: 0.85rem; }

.field-label {
  display: block;
  font-size: 0.71rem;
  font-weight: 700;
  color: var(--txt2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

.field {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r-s);
  color: var(--txt);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.field:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(180,94,255,0.18);
}

.field::placeholder { color: var(--txt3); }

.field-select option { background: var(--card); color: var(--txt); }

/* ==============================
   BUTTONS
   ============================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.72rem 1.2rem;
  border: none;
  border-radius: var(--r-s);
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-full { width: 100%; }
.btn-lg { padding: 0.9rem 1.5rem; font-size: 1rem; border-radius: var(--r); }

.btn-sm { padding: 0.38rem 0.7rem; font-size: 0.75rem; border-radius: 6px; }

.btn-primary {
  background: linear-gradient(130deg, var(--purple) 0%, var(--purple2) 100%);
  color: #fff;
  box-shadow: var(--glow-purple);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); box-shadow: 0 0 32px rgba(180,94,255,0.5); }

.btn-gold {
  background: linear-gradient(130deg, var(--gold) 0%, var(--gold2) 100%);
  color: #15120a;
  box-shadow: var(--glow-gold);
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 0 28px rgba(255,213,79,0.5); }

.btn-success {
  background: linear-gradient(130deg, var(--green) 0%, #00c853 100%);
  color: #0a1a10;
  box-shadow: var(--glow-green);
}
.btn-success:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }

.btn-warn {
  background: linear-gradient(130deg, #ff9100 0%, #e65100 100%);
  color: #fff;
}
.btn-warn:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }

.btn-danger {
  background: linear-gradient(130deg, var(--red) 0%, #b71c1c 100%);
  color: #fff;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
}
.btn-row .btn { flex: 1; }

/* ==============================
   LEADERBOARD
   ============================== */
.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.lb-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  transition: all 0.35s ease;
  animation: slideIn 0.3s ease both;
}

.lb-item.me {
  background: linear-gradient(120deg, rgba(180,94,255,0.12), rgba(124,58,237,0.08));
  border-color: rgba(180,94,255,0.4);
  box-shadow: var(--glow-purple);
}

.lb-item.coin-flash { animation: coinFlash 0.5s ease; }

.lb-rank {
  font-size: 1.15rem;
  min-width: 34px;
  text-align: center;
  font-weight: 800;
}

.lb-rank-num {
  font-family: 'Syne', sans-serif;
  font-size: 0.85rem;
  color: var(--txt3);
  font-weight: 800;
}

.lb-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-coins {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--gold);
  white-space: nowrap;
}

/* ==============================
   TRANSACTIONS LIST
   ============================== */
.tx-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.875rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  font-size: 0.83rem;
  gap: 0.5rem;
  animation: slideIn 0.25s ease;
}

.tx-item.in  { border-left: 3px solid var(--green); }
.tx-item.out { border-left: 3px solid var(--red); }
.tx-item.sys { border-left: 3px solid var(--cyan); }

.tx-icon { font-size: 1rem; flex-shrink: 0; }

.tx-names {
  flex: 1;
  color: var(--txt2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-amt {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 0.88rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.tx-amt.pos { color: var(--green); }
.tx-amt.neg { color: var(--red); }
.tx-amt.neu { color: var(--cyan); }

/* ==============================
   GAMES LIST
   ============================== */
.games-list { display: flex; flex-direction: column; gap: 0.75rem; }

.game-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: var(--r-s);
  animation: slideIn 0.3s ease;
}

.game-info { flex: 1; }

.game-name {
  font-family: 'Syne', sans-serif;
  font-size: 0.97rem;
  font-weight: 800;
  color: var(--txt);
  margin-bottom: 0.25rem;
}

.game-reward {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold);
}

.game-emoji {
  font-size: 2rem;
  opacity: 0.8;
  margin-left: 0.75rem;
}

/* ==============================
   BETS LIST
   ============================== */
.bets-list { display: flex; flex-direction: column; gap: 0.5rem; }

.bet-card {
  padding: 0.9rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--pink);
  border-radius: var(--r-s);
  animation: slideIn 0.25s ease;
}

.bet-players {
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
}

.bet-amount {
  font-size: 0.82rem;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 0.45rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 30px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-pending { background: rgba(255,213,79,0.15); color: var(--gold); border: 1px solid rgba(255,213,79,0.35); }
.badge-win     { background: rgba(0,230,118,0.15); color: var(--green); border: 1px solid rgba(0,230,118,0.35); }
.badge-loss    { background: rgba(255,23,68,0.15); color: var(--red); border: 1px solid rgba(255,23,68,0.35); }

/* Admin bets */
.adm-bet-item {
  padding: 0.875rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-s);
  margin-bottom: 0.5rem;
}

.adm-bet-info {
  font-size: 0.88rem;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.adm-bet-info strong { color: var(--txt); }
.adm-bet-info .amt { color: var(--gold); font-weight: 700; }

.adm-bet-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.adm-bet-actions .btn { flex: 1; min-width: max-content; }

/* ==============================
   EMPTY STATE
   ============================== */
.empty {
  text-align: center;
  color: var(--txt3);
  font-size: 0.85rem;
  padding: 2.5rem 1rem;
  background: var(--card);
  border: 1px dashed var(--border2);
  border-radius: var(--r-s);
}

.empty-icon { font-size: 2.5rem; display: block; margin-bottom: 0.6rem; opacity: 0.5; }

/* ==============================
   TOAST NOTIFICATIONS
   ============================== */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.45rem;
  align-items: center;
  width: min(92%, 400px);
  pointer-events: none;
}

.toast {
  width: 100%;
  padding: 0.8rem 1.15rem;
  border-radius: var(--r-s);
  font-size: 0.87rem;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  transition: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: auto;
}

.toast.show { opacity: 1; transform: translateY(0) scale(1); }

.toast-success { background: rgba(0,180,90,0.92); color: #fff; border: 1px solid rgba(0,230,118,0.4); box-shadow: 0 8px 24px rgba(0,230,118,0.25); }
.toast-error   { background: rgba(200,20,40,0.92); color: #fff; border: 1px solid rgba(255,23,68,0.4); box-shadow: 0 8px 24px rgba(255,23,68,0.25); }
.toast-info    { background: rgba(100,60,200,0.92); color: #fff; border: 1px solid rgba(180,94,255,0.4); box-shadow: 0 8px 24px rgba(180,94,255,0.25); }
.toast-warn    { background: rgba(200,130,0,0.92); color: #fff; border: 1px solid rgba(255,213,79,0.4); box-shadow: 0 8px 24px rgba(255,213,79,0.25); }

/* ==============================
   ANIMATIONS
   ============================== */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes floatY   { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
@keyframes slideIn  { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
@keyframes bumpScale{ 0%{transform:scale(1)} 50%{transform:scale(1.35)} 100%{transform:scale(1)} }
@keyframes livePulse{
  0%   { box-shadow: 0 0 0 0 rgba(0,230,118,0.6); }
  70%  { box-shadow: 0 0 0 7px rgba(0,230,118,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,230,118,0); }
}
@keyframes coinFlash{
  0%  { background: rgba(255,213,79,0.25); box-shadow: 0 0 0 0 rgba(255,213,79,0.5); }
  50% { background: rgba(255,213,79,0.15); box-shadow: 0 0 20px rgba(255,213,79,0.4); }
  100%{ background: var(--card); box-shadow: none; }
}

/* ==============================
   RESPONSIVE
   ============================== */
@media (min-width: 480px) {
  .app-header { padding: 0 1.5rem; }
  .tab { padding: 1.25rem; }
  .nav-btn { font-size: 0.78rem; }
}

@media (min-width: 768px) {
  .tab { padding: 1.5rem; max-width: 680px; margin: 0 auto; }
  .card { padding: 1.4rem; }
}

/* Safe area for notched phones */
.app-main { padding-bottom: env(safe-area-inset-bottom, 0); }
