/* ===== ROOT VARIABLES ===== */
:root {
  --bg-deep: #060810;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-border: rgba(255,255,255,0.08);
  --accent-green: #00F5A0;
  --accent-red: #FF3B5C;
  --accent-violet: #BF5FFF;
  --accent-yellow: #FFD700;
  --accent-cyan: #00D4FF;
  --accent-orange: #FF6B2B;
  --text-primary: #F0F4FF;
  --text-muted: rgba(240,244,255,0.45);
  --font-main: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-card: 20px;
  --radius-pill: 50px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== BACKGROUND ===== */
.bg-grid {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}
.glow-orb { position: fixed; border-radius: 50%; filter: blur(80px); pointer-events: none; z-index: 0; }
.orb1 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(0,245,160,0.10), transparent 70%); top: -100px; left: -100px; animation: orbFloat 8s ease-in-out infinite; }
.orb2 { width: 350px; height: 350px; background: radial-gradient(circle, rgba(255,59,92,0.08), transparent 70%); bottom: 100px; right: -80px; animation: orbFloat 10s ease-in-out infinite reverse; }
.orb3 { width: 300px; height: 300px; background: radial-gradient(circle, rgba(191,95,255,0.07), transparent 70%); top: 50%; left: 50%; transform: translate(-50%,-50%); animation: orbFloat 12s ease-in-out infinite; }
@keyframes orbFloat { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-30px) scale(1.05); } }

/* ===== APP WRAPPER ===== */
.app-wrapper {
  position: relative; z-index: 1;
  max-width: 480px; margin: 0 auto;
  min-height: 100vh;
  display: flex; flex-direction: column;
  padding-bottom: 90px;
}

/* ===== HEADER ===== */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 12px;
  background: rgba(6,8,16,0.90);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0,212,255,0.10);
  position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #FFD700, #FF6B2B, #FF3B5C);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 18px rgba(255,107,43,0.45);
}
.logo-text { display: flex; flex-direction: column; line-height: 1; }
.logo-title {
  font-size: 17px; font-weight: 900; letter-spacing: 3px;
  background: linear-gradient(90deg, #FFD700, #FF6B2B);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.logo-sub { font-size: 8px; font-weight: 600; letter-spacing: 3px; color: var(--text-muted); text-transform: uppercase; }
.header-right { display: flex; align-items: center; gap: 10px; }
.live-badge {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,59,92,0.12); border: 1px solid rgba(255,59,92,0.35);
  border-radius: var(--radius-pill); padding: 4px 10px;
  font-size: 10px; font-weight: 700; letter-spacing: 2px; color: #FF3B5C;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #FF3B5C; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:0.3; transform:scale(0.6); } }
.header-time { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--accent-cyan); letter-spacing: 1px; }

/* ===== MAIN ===== */
.main-content { flex: 1; padding: 14px 14px 0; display: flex; flex-direction: column; gap: 12px; }

/* ===== GLASS CARD ===== */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-card);
  backdrop-filter: blur(16px);
  padding: 16px;
  position: relative; overflow: hidden;
}
.glass-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
}

/* ===== TIMER TABS ===== */
.timer-section { padding: 0; }
.timer-tabs {
  display: flex; gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-pill); padding: 5px;
}
.timer-tab {
  flex: 1; border: none; cursor: pointer;
  border-radius: var(--radius-pill); padding: 9px 4px;
  font-family: var(--font-main); font-size: 12px; font-weight: 600;
  color: var(--text-muted); background: transparent;
  transition: all 0.3s ease; letter-spacing: 0.3px;
}
.timer-tab:hover { color: var(--text-primary); }
.timer-tab.active {
  background: linear-gradient(135deg, #00F5A0, #FFD700, #FF6B2B, #FF3B5C);
  color: #000; font-weight: 800;
  box-shadow: 0 4px 18px rgba(255,107,43,0.35);
}

/* ===== CARD HEADER ===== */
.card-header { display: flex; align-items: center; gap: 7px; margin-bottom: 12px; }
.card-icon { font-size: 13px; color: var(--accent-cyan); display: inline-block; }
.card-icon.spin { animation: spinAnim 3s linear infinite; }
@keyframes spinAnim { to { transform: rotate(360deg); } }
.card-label { font-size: 10px; font-weight: 700; letter-spacing: 2.5px; color: var(--text-muted); text-transform: uppercase; flex: 1; }

/* ===== PERIOD ID ===== */
.period-id {
  font-family: var(--font-mono); font-size: 19px; font-weight: 700;
  letter-spacing: 0.5px; line-height: 1.2; margin-bottom: 14px; word-break: break-all;
}
.gradient-text {
  background: linear-gradient(90deg, #00F5A0, #00D4FF, #FFD700, #FF6B2B, #FF3B5C);
  background-size: 200% auto;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  animation: gradientShift 4s linear infinite;
}
@keyframes gradientShift { 0% { background-position: 0% center; } 100% { background-position: 200% center; } }

/* ===== COUNTDOWN ===== */
.countdown-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.07); overflow: hidden; margin-bottom: 10px; }
.countdown-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #00F5A0, #FFD700); width: 100%; transition: width 1s linear; }
.countdown-timer { display: flex; align-items: baseline; gap: 8px; }
.timer-num { font-family: var(--font-mono); font-size: 38px; font-weight: 700; color: var(--text-primary); text-shadow: 0 0 20px rgba(0,212,255,0.5); transition: color 0.3s; }
.timer-num.urgent { color: #FF3B5C; text-shadow: 0 0 20px rgba(255,59,92,0.8); animation: shake 0.4s ease infinite; }
.timer-label { font-size: 11px; font-weight: 500; color: var(--text-muted); letter-spacing: 1px; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ===== LAST RESULT ===== */
.result-row { display: flex; align-items: center; gap: 18px; }
.result-number {
  font-family: var(--font-mono); font-size: 72px; font-weight: 900; line-height: 1;
  transition: all 0.3s;
}
.result-num-green {
  background: linear-gradient(135deg, #00F5A0, #00D4FF);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(0,245,160,0.5));
}
.result-num-red {
  background: linear-gradient(135deg, #FF3B5C, #FF6B2B);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(255,59,92,0.5));
}
.result-num-violet {
  filter: drop-shadow(0 0 18px rgba(191,95,255,0.5));
}
.result-badges { display: flex; flex-direction: column; gap: 8px; }
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== BADGES ===== */
.color-badge, .size-badge {
  padding: 5px 14px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;
  display: inline-flex; align-items: center;
}
.color-badge.green { background: rgba(0,245,160,0.12); border: 1.5px solid rgba(0,245,160,0.45); color: #00F5A0; box-shadow: 0 0 10px rgba(0,245,160,0.15); }
.color-badge.red   { background: rgba(255,59,92,0.12);  border: 1.5px solid rgba(255,59,92,0.45);  color: #FF3B5C; box-shadow: 0 0 10px rgba(255,59,92,0.15); }
.color-badge.violet{ background: rgba(191,95,255,0.12); border: 1.5px solid rgba(191,95,255,0.45); color: #BF5FFF; box-shadow: 0 0 10px rgba(191,95,255,0.15); }
.size-badge { background: rgba(255,255,255,0.07); border: 1.5px solid rgba(255,255,255,0.14); color: var(--text-primary); }
.size-badge.big { border-color: rgba(0,212,255,0.4); color: var(--accent-cyan); }
.size-badge.sma { border-color: rgba(255,215,0,0.4); color: var(--accent-yellow); }

/* ===== STATS CARD ===== */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-item { display: flex; flex-direction: column; gap: 5px; }
.stat-label-row { display: flex; align-items: center; gap: 6px; }
.stat-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.stat-dot.green { background: #00F5A0; box-shadow: 0 0 5px #00F5A0; }
.stat-dot.red   { background: #FF3B5C; box-shadow: 0 0 5px #FF3B5C; }
.stat-dot.big   { background: #00D4FF; box-shadow: 0 0 5px #00D4FF; }
.stat-dot.sma   { background: #FFD700; box-shadow: 0 0 5px #FFD700; }
.stat-name { font-size: 11px; font-weight: 600; color: var(--text-muted); flex: 1; }
.stat-pct { font-size: 12px; font-weight: 700; font-family: var(--font-mono); }
.green-text { color: #00F5A0; }
.red-text   { color: #FF3B5C; }
.big-text   { color: #00D4FF; }
.sma-text   { color: #FFD700; }
.stat-bar-bg { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.07); overflow: hidden; }
.stat-bar { height: 100%; border-radius: 3px; width: 0%; transition: width 0.6s ease; }
.green-bar { background: linear-gradient(90deg, #00F5A0, #00D4FF); }
.red-bar   { background: linear-gradient(90deg, #FF3B5C, #FF6B2B); }
.big-bar   { background: linear-gradient(90deg, #00D4FF, #7B68EE); }
.sma-bar   { background: linear-gradient(90deg, #FFD700, #FF6B2B); }

/* ===== STREAK BADGE ===== */
.streak-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  text-transform: uppercase;
}
.streak-green { background: rgba(0,245,160,0.12); border: 1px solid rgba(0,245,160,0.3); color: #00F5A0; }
.streak-red   { background: rgba(255,59,92,0.12);  border: 1px solid rgba(255,59,92,0.3);  color: #FF3B5C; }

/* ===== LEGEND ===== */
.legend-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.legend-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.leg-txt { font-size: 9px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.5px; }

/* ===== NUMBER BALLS ===== */
.num-ball {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.ball-green {
  background: radial-gradient(circle at 35% 35%, #00F5A0, #00a86b);
  color: #001a0e;
  box-shadow: 0 3px 12px rgba(0,245,160,0.4);
}
.ball-red {
  background: radial-gradient(circle at 35% 35%, #FF3B5C, #c0002a);
  color: #fff;
  box-shadow: 0 3px 12px rgba(255,59,92,0.4);
}
.ball-violet-ring {
  outline: 2.5px solid #BF5FFF;
  outline-offset: 2px;
  box-shadow: 0 0 12px rgba(191,95,255,0.5), 0 3px 12px rgba(0,0,0,0.3);
}

/* ===== TABLE ===== */
.table-section { padding: 0; overflow: hidden; }
.table-header-row {
  display: grid; grid-template-columns: 2.2fr 2fr 0.8fr;
  padding: 11px 14px;
  background: rgba(0,212,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.th { font-size: 9px; font-weight: 700; letter-spacing: 2px; color: var(--accent-cyan); text-transform: uppercase; }
.th-right { text-align: right; }
.table-body { max-height: 360px; overflow-y: auto; }
.table-body::-webkit-scrollbar { width: 3px; }
.table-body::-webkit-scrollbar-track { background: transparent; }
.table-body::-webkit-scrollbar-thumb { background: rgba(0,212,255,0.25); border-radius: 2px; }

.table-row {
  display: grid; grid-template-columns: 2.2fr 2fr 0.8fr;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  align-items: center;
  transition: background 0.2s;
  animation: rowSlideIn 0.35s ease forwards;
}
@keyframes rowSlideIn { from { opacity:0; transform:translateX(-8px); } to { opacity:1; transform:translateX(0); } }
.table-row:nth-child(odd) { background: rgba(255,255,255,0.015); }
.table-row:hover { background: rgba(0,212,255,0.04); }
.table-row.new-row { background: rgba(0,245,160,0.05); border-left: 2px solid var(--accent-green); }

.td-period { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-muted); letter-spacing: 0.2px; line-height: 1.4; }
.td-number-wrap { display: flex; align-items: center; }
.td-color { display: flex; align-items: center; gap: 8px; }
.color-labels { display: flex; flex-direction: column; gap: 2px; }
.color-text { font-size: 11px; font-weight: 600; text-transform: capitalize; }
.color-text.green { color: #00F5A0; }
.color-text.red   { color: #FF3B5C; }
.violet-tag { font-size: 9px; font-weight: 700; color: #BF5FFF; letter-spacing: 1px; text-transform: uppercase; }
.td-bs { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-align: right; }
.td-bs.big { color: var(--accent-cyan); }
.td-bs.sma { color: var(--accent-yellow); }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; align-items: center; justify-content: space-around;
  padding: 10px 20px 20px;
  background: rgba(6,8,16,0.94);
  backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255,255,255,0.07);
  z-index: 200;
}
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: none; cursor: pointer; padding: 6px 20px; border-radius: 14px; transition: all 0.25s ease; }
.nav-btn:hover { background: rgba(255,255,255,0.04); }
.nav-btn.active { background: rgba(0,212,255,0.07); }
.nav-icon { font-size: 20px; filter: grayscale(1) opacity(0.45); transition: all 0.25s; }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: 1px; color: var(--text-muted); transition: all 0.25s; }
.nav-btn.active .nav-icon { filter: none; }
.nav-btn.active .nav-label { color: var(--accent-cyan); }

/* ===== FAB ===== */
.fab {
  position: fixed; bottom: 90px; right: calc(50% - 224px);
  width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #FFD700, #FF6B2B, #FF3B5C, #BF5FFF);
  background-size: 200% 200%; animation: fabGradient 3s ease infinite;
  box-shadow: 0 6px 28px rgba(255,107,43,0.45);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  transition: transform 0.2s, box-shadow 0.2s; z-index: 150;
}
.fab:hover { transform: scale(1.1); box-shadow: 0 8px 38px rgba(255,107,43,0.65); }
.fab:active { transform: scale(0.93); }
@keyframes fabGradient { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.fab-icon { animation: rocketBounce 2s ease-in-out infinite; }
@keyframes rocketBounce { 0%,100% { transform: translateY(0) rotate(-45deg); } 50% { transform: translateY(-4px) rotate(-45deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .period-id { font-size: 15px; }
  .result-number { font-size: 58px; }
  .timer-num { font-size: 30px; }
  .fab { right: 14px; }
  .num-ball { width: 28px; height: 28px; font-size: 12px; }
}