:root {
  --bg-top: #44177b;
  --bg-mid: #1a1b3a;
  --bg-bottom: #0d1224;
  --card-bg: rgba(27, 33, 58, 0.85);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --gold: #f59e0b;
  --b-color: #2563eb;
  --i-color: #6366f1;
  --n-color: #9333ea;
  --g-color: #16a34a;
  --o-color: #ea580c;
  --green: #10b981;
  --red: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(170deg, var(--bg-top) 0%, var(--bg-mid) 40%, var(--bg-bottom) 100%);
  color: var(--text-main);
  min-height: 100vh;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px 14px 78px;
  position: relative;
}

.hidden { display: none !important; }

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.2s ease; }

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

.toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  background: #1e293b; border: 1px solid var(--gold); color: #fff;
  padding: 10px 16px; border-radius: 12px; z-index: 200; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45); max-width: 90%; text-align: center;
}

.top-header, .sub-header, .wallet-header-row {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}

.brand-row { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand-dot {
  width: 28px; height: 28px; border-radius: 50%; background: var(--gold);
  color: #111; display: grid; place-items: center; font-weight: 900;
}

.pill-btn, .back-btn {
  background: rgba(255,255,255,0.08); border: 1px solid var(--card-border);
  color: var(--text-main); padding: 7px 14px; border-radius: 10px; font-size: 13px; cursor: pointer;
}

.hero-title { text-align: center; margin: 18px 0 22px; }
.hero-title h1 { font-size: 28px; line-height: 1.25; font-weight: 800; }
.accent-gold { color: var(--gold); }

.glass-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 16px; margin-bottom: 14px;
  backdrop-filter: blur(10px);
}

.card-heading { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; margin-bottom: 14px; }
.tri { color: var(--gold); }

.stake-list { display: flex; flex-direction: column; gap: 10px; }
.stake-btn {
  width: 100%; border: none; border-radius: 12px; padding: 14px; color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer; transition: transform 0.12s;
}
.stake-btn:active { transform: scale(0.98); }
.stake-green { background: linear-gradient(90deg, #10b981, #06b6d4); }
.stake-blue { background: linear-gradient(90deg, #0ea5e9, #3b82f6); }
.stake-purple { background: linear-gradient(90deg, #8b5cf6, #6366f1); }
.stake-orange { background: linear-gradient(90deg, #f97316, #f59e0b); }

.stats-card { text-align: center; display: flex; flex-direction: column; gap: 14px; }
.stat-num { font-size: 26px; font-weight: 800; }
.stat-label { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.stat-divider { height: 1px; background: var(--card-border); }

/* Rules */
.amh-title { color: var(--gold); font-weight: 700; font-size: 16px; }
.rules-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.rule-tab {
  background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-muted);
  border-radius: 10px; padding: 8px 4px; font-size: 11px; cursor: pointer;
}
.rule-tab.active { background: rgba(255,255,255,0.14); color: var(--gold); border-color: var(--gold); }
.rules-progress { height: 4px; background: rgba(255,255,255,0.1); border-radius: 4px; margin-bottom: 14px; overflow: hidden; }
.rules-progress-fill { height: 100%; background: linear-gradient(90deg, #8b5cf6, #ec4899); transition: width 0.25s; }
.rule-step-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.rule-step-card h4 { margin-bottom: 6px; color: #fff; font-size: 14px; }
.rule-step-card p { color: var(--gold); font-size: 13px; line-height: 1.5; }
.rule-danger { border-color: rgba(239, 68, 68, 0.5); background: rgba(127, 29, 29, 0.25); }

/* Cartela Select */
.wallet-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.mini-box {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 6px 8px; text-align: center;
}
.mini-box small { display: block; font-size: 10px; color: var(--text-muted); }
.mini-box strong { font-size: 14px; }
.timer-box { display: grid; place-items: center; color: var(--gold); }

.cartela-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px;
  max-height: 260px; overflow-y: auto; padding: 4px; margin-bottom: 12px;
}
.cartela-num-btn {
  border: none; border-radius: 7px; padding: 8px 0; font-weight: 700; font-size: 12px;
  background: #ea580c; color: #fff; cursor: pointer;
}
.cartela-num-btn.selected { background: #10b981; box-shadow: 0 0 0 2px #fff; }
.cartela-num-btn.taken { background: #dc2626; opacity: 0.45; cursor: not-allowed; }

.preview-section { text-align: center; }
.preview-title { color: var(--gold); font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.primary-join-btn {
  width: 100%; margin-top: 12px; padding: 14px; border: none; border-radius: 12px;
  background: linear-gradient(90deg, #10b981, #059669); color: #fff; font-weight: 800; font-size: 15px; cursor: pointer;
}

/* 5x5 Bingo Card */
.bingo-card-5x5 {
  background: rgba(15, 23, 42, 0.85); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 8px;
}
.bingo-headers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 6px; }
.bingo-headers span {
  text-align: center; font-weight: 800; font-size: 13px; padding: 4px 0; border-radius: 6px; color: #fff;
}
.hdr-b { background: var(--b-color); }
.hdr-i { background: var(--i-color); }
.hdr-n { background: var(--n-color); }
.hdr-g { background: var(--g-color); }
.hdr-o { background: var(--o-color); }

.card-cells-5x5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.card-cell {
  background: #f1f5f9; color: #0f172a; border-radius: 7px; padding: 8px 0;
  text-align: center; font-weight: 800; font-size: 14px; cursor: pointer; user-select: none;
}
.preview-card .card-cell { background: #1e293b; color: #f8fafc; border: 1px solid rgba(255,255,255,0.08); }
.card-cell.free { background: #16a34a !important; color: #fff !important; }
.card-cell.marked { background: #f97316 !important; color: #fff !important; }
.card-cell.win-highlight { background: #16a34a !important; color: #fff !important; box-shadow: 0 0 0 2px #fde047; }

/* Live Game */
.game-top-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 10px; }
.g-stat { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 9px; padding: 5px; text-align: center; }
.g-stat small { display: block; font-size: 10px; color: var(--text-muted); }
.g-stat strong { font-size: 13px; }

.live-layout { display: grid; grid-template-columns: 1.05fr 1.15fr; gap: 8px; align-items: start; }
.board-left { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; padding: 6px; }
.bingo-headers.compact span { font-size: 11px; padding: 3px 0; }
.board-75-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.b75-cell {
  background: rgba(255,255,255,0.08); color: #cbd5e1; border-radius: 5px;
  text-align: center; padding: 4px 0; font-size: 11px; font-weight: 700;
}
.b75-cell.called { background: #16a34a; color: #fff; }
.b75-cell.latest { background: #ea580c; color: #fff; }

.recent-calls-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px; padding: 6px 8px; margin-bottom: 8px;
}
.recent-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.call-pill { font-size: 11px; font-weight: 800; padding: 3px 7px; border-radius: 999px; background: var(--n-color); color: #fff; }
.sound-icon-btn { background: none; border: none; font-size: 18px; cursor: pointer; }

.current-call-box {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px;
  padding: 12px 8px; text-align: center; margin-bottom: 8px;
}
.call-ball {
  width: 68px; height: 68px; margin: 0 auto 6px; border-radius: 50%;
  background: #fff; border: 4px solid var(--gold); color: var(--n-color);
  display: grid; place-items: center; font-weight: 900; font-size: 18px;
}
.call-amharic { font-size: 12px; color: var(--gold); font-weight: 600; }

.auto-row, .setting-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 8px 12px; margin-bottom: 8px; font-size: 13px;
}
.cartela-badge { text-align: center; margin-top: 6px; font-size: 12px; color: var(--gold); font-weight: 700; }

.live-actions { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; margin-top: 12px; }
.act-btn { border: none; border-radius: 10px; padding: 12px 6px; font-weight: 800; color: #fff; cursor: pointer; }
.act-red { background: #ef4444; }
.act-orange { background: #f97316; }
.act-bingo { background: linear-gradient(90deg, #f59e0b, #10b981); font-size: 15px; }

/* Switch */
.switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0; background: #334155; border-radius: 22px; transition: 0.2s;
}
.slider:before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
input:checked + .slider { background: #10b981; }
input:checked + .slider:before { transform: translateX(20px); }

/* History, Wallet, Profile */
.page-title { font-size: 22px; font-weight: 800; margin-bottom: 12px; }
.sub-section-title { font-size: 16px; font-weight: 700; margin: 14px 0 8px; }
.total-games-box .big-num { font-size: 28px; font-weight: 800; margin-top: 4px; }
.list-stack { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; padding: 12px;
}
.hist-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.badge-status { padding: 3px 9px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.badge-won { background: rgba(16,185,129,0.2); color: #34d399; }
.badge-lost { background: rgba(239,68,68,0.2); color: #f87171; }
.hist-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; font-size: 12px; color: var(--text-muted); }
.hist-metrics strong { display: block; color: #fff; font-size: 14px; }

.phone-verify-card { display: flex; justify-content: space-between; align-items: center; }
.badge-verified { background: rgba(16,185,129,0.2); color: #34d399; padding: 4px 10px; border-radius: 999px; font-size: 12px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: rgba(0,0,0,0.25); padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.seg-btn { border: none; background: transparent; color: var(--text-muted); padding: 9px; border-radius: 9px; font-weight: 700; cursor: pointer; }
.seg-btn.active { background: rgba(255,255,255,0.14); color: #fff; }

.stats-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-tile { margin-bottom: 0; }
.stat-tile small { display: block; color: var(--text-muted); margin-bottom: 6px; font-size: 12px; }
.stat-tile strong { font-size: 20px; }

.inline-form { display: flex; gap: 8px; margin: 8px 0 12px; }
.inline-form input {
  flex: 1; background: rgba(0,0,0,0.25); border: 1px solid var(--card-border);
  border-radius: 10px; padding: 10px; color: #fff;
}
.btn-sm { background: #3b82f6; border: none; color: #fff; padding: 0 16px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.secondary-btn {
  width: 100%; background: rgba(245,158,11,0.18); border: 1px solid var(--gold);
  color: var(--gold); padding: 10px; border-radius: 10px; font-weight: 700; cursor: pointer;
}
.hint-text { font-size: 12px; color: var(--text-muted); margin-top: 10px; }

.profile-hero { text-align: center; padding: 14px 0 18px; }
.avatar-circle {
  width: 68px; height: 68px; border-radius: 50%; margin: 0 auto 10px;
  background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.25);
  display: grid; place-items: center; font-size: 28px; font-weight: 800;
}

/* Win Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5, 8, 20, 0.85);
  display: grid; place-items: center; z-index: 150; padding: 16px;
}
.win-card {
  width: 100%; max-width: 360px; background: #1f2937; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px; padding: 20px; text-align: center;
}
.crown-badge {
  width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--gold); display: grid; place-items: center; font-size: 26px;
}
.win-title { color: #facc15; font-size: 26px; font-weight: 900; }
.win-sub { font-weight: 700; margin: 6px 0 12px; }
.win-cartela-label { color: var(--gold); font-weight: 700; margin-bottom: 10px; font-size: 14px; }
.auto-next-pill {
  margin-top: 14px; display: inline-block; padding: 8px 16px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2); font-size: 13px; color: #cbd5e1;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: rgba(13, 18, 36, 0.96);
  border-top: 1px solid var(--card-border); display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 0; z-index: 100;
}
.nav-item {
  background: none; border: none; color: var(--text-muted); font-size: 18px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; padding: 4px 0;
}
.nav-item span { font-size: 11px; }
.nav-item.active { color: #60a5fa; }
