/* ══════════════════════════════════════════════════════════
   ARW Prediction — Mobile-First Dark Theme
   ══════════════════════════════════════════════════════════ */
:root {
  --bg: #0a0b0f;
  --bg2: #12131a;
  --bg3: #1a1b26;
  --surface: #1e1f2e;
  --surface2: #262738;
  --border: #2a2b3d;
  --border2: #363752;
  --text: #e8e8f0;
  --text2: #9394a5;
  --text3: #5d5e72;
  --up: #22c55e;
  --up-bg: rgba(34,197,94,0.1);
  --up-border: rgba(34,197,94,0.3);
  --down: #ef4444;
  --down-bg: rgba(239,68,68,0.1);
  --down-border: rgba(239,68,68,0.3);
  --accent: #7c3aed;
  --accent2: #a78bfa;
  --accent-bg: rgba(124,58,237,0.1);
  --blue: #3b82f6;
  --yellow: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── Scrollbar ──────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── Nav ────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10,11,15,0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 800; letter-spacing: -0.5px;
  color: var(--text);
}
.nav-logo .mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; color: #fff;
}
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-balance {
  font-size: 13px; color: var(--accent2); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.nav-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer;
}

/* ── Page Container ─────────────────────── */
.page { padding: 16px; max-width: 480px; margin: 0 auto; }
@media (min-width: 768px) { .page { max-width: 640px; } }

/* ── Round Info Bar ─────────────────────── */
.round-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.round-bar-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.round-number { font-size: 13px; color: var(--text2); font-weight: 600; }
.round-status {
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px;
}
.round-status.betting { background: var(--up-bg); color: var(--up); border: 1px solid var(--up-border); }
.round-status.locked { background: rgba(245,158,11,0.1); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.round-status.settled { background: var(--accent-bg); color: var(--accent2); border: 1px solid rgba(124,58,237,0.3); }

.round-timer {
  font-size: 28px; font-weight: 800; text-align: center;
  font-variant-numeric: tabular-nums; letter-spacing: 1px;
  color: var(--text);
}
.round-timer.urgent { color: var(--down); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.5;} }

.round-bar-bottom {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; font-size: 12px; color: var(--text3);
}

/* ── Alpha Badge ────────────────────────── */
.alpha-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-bg); border: 1px solid rgba(124,58,237,0.3);
  border-radius: 20px; padding: 4px 12px;
  font-size: 12px; font-weight: 600; color: var(--accent2);
}
.alpha-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ── Price Display ──────────────────────── */
.price-display {
  text-align: center; padding: 16px 0;
}
.price-label { font-size: 12px; color: var(--text3); margin-bottom: 4px; }
.price-value {
  font-size: 32px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.price-value.up { color: var(--up); }
.price-value.down { color: var(--down); }
.price-change { font-size: 14px; font-weight: 600; margin-top: 4px; }
.price-change.up { color: var(--up); }
.price-change.down { color: var(--down); }

/* ── Pool Bar ───────────────────────────── */
.pool-bar {
  display: flex; height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--border); margin: 12px 0;
}
.pool-bar .up-fill { background: var(--up); transition: width 0.5s; }
.pool-bar .down-fill { background: var(--down); transition: width 0.5s; }

.pool-info {
  display: flex; justify-content: space-between; font-size: 12px;
}
.pool-info .up-info { color: var(--up); font-weight: 600; }
.pool-info .down-info { color: var(--down); font-weight: 600; }

/* ── Card View ──────────────────────────── */
.cards-container {
  display: flex; gap: 12px; overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  margin: 0 -16px; padding-left: 16px; padding-right: 16px;
}
.cards-container::-webkit-scrollbar { display: none; }

.round-card {
  min-width: calc(100vw - 48px); max-width: 420px;
  scroll-snap-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  flex-shrink: 0;
}
.round-card.past { opacity: 0.6; }
.round-card.current { border-color: var(--accent); box-shadow: 0 0 20px rgba(124,58,237,0.15); }
.round-card.next { border-style: dashed; }

.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.card-round { font-size: 14px; font-weight: 700; }
.card-result {
  font-size: 12px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px;
}
.card-result.up { background: var(--up-bg); color: var(--up); }
.card-result.down { background: var(--down-bg); color: var(--down); }

.card-prices {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-bottom: 16px;
}
.card-price-box {
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 12px; text-align: center;
}
.card-price-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.card-price-val { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

.card-pool {
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 12px;
}

/* ── Bet Panel ──────────────────────────── */
.bet-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 12px;
}
.bet-direction {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 16px;
}
.bet-btn {
  padding: 14px; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 800;
  border: 2px solid transparent;
  cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.bet-btn .arrow { font-size: 24px; }
.bet-btn .label { font-size: 13px; font-weight: 600; }
.bet-btn .payout { font-size: 11px; opacity: 0.7; }

.bet-btn.up {
  background: var(--up-bg); color: var(--up); border-color: var(--up-border);
}
.bet-btn.up:hover, .bet-btn.up.active {
  background: var(--up); color: #fff; border-color: var(--up);
}
.bet-btn.down {
  background: var(--down-bg); color: var(--down); border-color: var(--down-border);
}
.bet-btn.down:hover, .bet-btn.down.active {
  background: var(--down); color: #fff; border-color: var(--down);
}

.bet-amount-row {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.bet-input {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  color: var(--text); font-size: 16px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  outline: none; transition: border-color 0.15s;
}
.bet-input:focus { border-color: var(--accent); }
.bet-input::placeholder { color: var(--text3); }

.bet-shortcuts {
  display: flex; gap: 6px; margin-bottom: 16px;
}
.bet-shortcut {
  flex: 1; padding: 8px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-size: 12px; font-weight: 600;
  cursor: pointer; text-align: center; transition: all 0.15s;
}
.bet-shortcut:hover { border-color: var(--accent); color: var(--accent2); }

.bet-info {
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 16px; font-size: 13px;
}
.bet-info-row {
  display: flex; justify-content: space-between;
  padding: 4px 0; color: var(--text2);
}
.bet-info-row .val { color: var(--text); font-weight: 600; }
.bet-info-row .val.accent { color: var(--accent2); }

.bet-submit {
  width: 100%; padding: 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 800;
  border: none; cursor: pointer; transition: all 0.15s;
}
.bet-submit:hover { background: #6d28d9; }
.bet-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── View Toggle ────────────────────────── */
.view-toggle {
  display: flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px;
}
.view-toggle button {
  flex: 1; padding: 10px; background: none; border: none;
  color: var(--text3); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.view-toggle button.active {
  background: var(--accent-bg); color: var(--accent2);
}

/* ── Chart Area ─────────────────────────── */
.chart-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  height: 280px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 14px;
}

/* ── History / Leaderboard ──────────────── */
.section-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  margin: 24px 0 12px; display: flex; align-items: center; gap: 8px;
}
.section-title .badge {
  font-size: 11px; background: var(--surface2); color: var(--text2);
  padding: 2px 8px; border-radius: 10px; font-weight: 600;
}

.history-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;
}
.history-left .round-label { font-size: 12px; color: var(--text2); }
.history-left .direction { font-size: 14px; font-weight: 700; }
.history-left .direction.up { color: var(--up); }
.history-left .direction.down { color: var(--down); }
.history-right { text-align: right; }
.history-right .pnl { font-size: 14px; font-weight: 700; }
.history-right .pnl.positive { color: var(--up); }
.history-right .pnl.negative { color: var(--down); }
.history-right .amount { font-size: 11px; color: var(--text3); }

.rank-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  margin-bottom: 8px; display: flex; align-items: center; gap: 12px;
}
.rank-pos {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg3); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: var(--text2);
}
.rank-pos.top1 { background: #f59e0b; color: #000; }
.rank-pos.top2 { background: #94a3b8; color: #000; }
.rank-pos.top3 { background: #b45309; color: #fff; }
.rank-info { flex: 1; }
.rank-name { font-size: 14px; font-weight: 600; }
.rank-stats { font-size: 12px; color: var(--text2); }
.rank-value { font-size: 14px; font-weight: 700; color: var(--up); }

/* ── Bottom Nav ─────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(10,11,15,0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex; height: 56px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--text3);
  font-size: 10px; font-weight: 600; transition: color 0.15s;
}
.bottom-nav a.active { color: var(--accent2); }
.bottom-nav a .icon { font-size: 20px; }

/* ── Auth Pages ─────────────────────────── */
.auth-page {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 24px;
}
.auth-logo {
  text-align: center; margin-bottom: 28px;
}
.auth-logo .mark {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--accent); margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 900; color: #fff;
}
.auth-logo h1 { font-size: 22px; font-weight: 800; }
.auth-logo p { font-size: 13px; color: var(--text2); margin-top: 4px; }

.auth-field { margin-bottom: 14px; }
.auth-field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text2); margin-bottom: 6px;
}
.auth-field input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); font-size: 15px; outline: none;
  transition: border-color 0.15s;
}
.auth-field input:focus { border-color: var(--accent); }

.auth-submit {
  width: 100%; padding: 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 700; border: none;
  cursor: pointer; margin-top: 8px; transition: background 0.15s;
}
.auth-submit:hover { background: #6d28d9; }

.auth-link {
  text-align: center; margin-top: 16px; font-size: 13px; color: var(--text3);
}
.auth-link a { color: var(--accent2); text-decoration: none; }

/* ── Admin ──────────────────────────────── */
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.admin-header h1 { font-size: 20px; font-weight: 800; }

.admin-tabs {
  display: flex; gap: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 3px; margin-bottom: 16px;
}
.admin-tabs button {
  flex: 1; padding: 8px 12px; border: none; border-radius: 6px;
  background: none; color: var(--text3); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.admin-tabs button.active { background: var(--accent-bg); color: var(--accent2); }

.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.admin-table th {
  text-align: left; padding: 10px 12px; color: var(--text3);
  font-weight: 600; border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
}
.admin-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  color: var(--text2);
}
.admin-table tr:hover td { background: var(--bg3); }

.btn-sm {
  padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg3); color: var(--text2);
  cursor: pointer; transition: all 0.15s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent2); }
.btn-sm.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-sm.danger { background: var(--down); color: #fff; border-color: var(--down); }

/* ── Utility ────────────────────────────── */
.mb-safe { margin-bottom: calc(56px + env(safe-area-inset-bottom) + 16px); }
.text-up { color: var(--up); }
.text-down { color: var(--down); }
.text-accent { color: var(--accent2); }
.text-muted { color: var(--text2); }
.fw-800 { font-weight: 800; }
.tabnum { font-variant-numeric: tabular-nums; }
