:root {
  --primary: #00d4ff;
  --primary-dark: #0088aa;
  --accent-glow: #f0a020;
  --accent-neon: #67e8f9;
  --bg-dark: #020806;
  --bg-panel: rgba(2, 14, 18, 0.88);
  --text: #e0f4ff;
  --text-muted: #7da8b8;
  --border: rgba(240, 160, 32, 0.4);
  --success: #00d4ff;
  --danger: #ff4757;
  --warning: #f0a020;
  --shadow-hover: 0 10px 30px rgba(0, 212, 255, 0.22);
  --radius: 14px;
  --font: 'Be Vietnam Pro', 'Roboto', system-ui, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-dark);
}

body.full-page { overflow: hidden; }
body.scroll-page { overflow-y: auto; }

a {
  color: var(--primary);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

/* Mobile/WebView ergonomics */
body{
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#page-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    url('../assets/chip-bg.png') center center / cover no-repeat,
    linear-gradient(180deg, #030a08 0%, #020806 50%, #010504 100%);
  filter: blur(1.5px) brightness(0.88);
  transform: scale(1.03);
}

#page-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(2, 8, 6, 0.4) 0%, rgba(0, 0, 0, 0.55) 50%, rgba(0, 0, 0, 0.78) 100%),
    radial-gradient(ellipse 35% 28% at 58% 30%, rgba(0, 200, 230, 0.06), transparent 70%);
  pointer-events: none;
  filter: none;
}

#circuit-canvas {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0.72;
  filter: blur(0.4px);
}

#grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 212, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240, 160, 32, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.45;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, #000 30%, transparent 85%);
}

#space-dust-overlay,
.video-overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 26%, rgba(0, 212, 255, 0.07), transparent 35%),
    radial-gradient(circle at 20% 80%, rgba(240, 160, 32, 0.05), transparent 30%);
}

.page-wrap {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 12px 14px 90px;
  padding-top: max(44px, calc(12px + var(--sat)));
  padding-bottom: calc(90px + var(--sab));
  padding-left: calc(14px + var(--sal));
  padding-right: calc(14px + var(--sar));
  max-width: 480px;
  margin: 0 auto;
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 40px;
  flex-shrink: 0;
}

.user-greet {
  font-size: 14px;
  font-weight: 500;
}

.user-greet strong { color: var(--accent-glow); }

.btn-logout {
  background: linear-gradient(180deg, #40e8ff, var(--primary-dark));
  color: #021018;
  border: 1px solid rgba(0, 212, 255, 0.45);
  border-radius: 20px;
  padding: 8px 16px;
  min-height: 38px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(0, 212, 255, 0.25);
}

.btn-auth-code {
  background: linear-gradient(180deg, rgba(212,175,55,.35), rgba(120,90,20,.5));
  color: var(--accent-glow);
  border-color: rgba(212,175,55,.55);
  box-shadow: 0 0 14px rgba(212,175,55,.2);
}

.dash-auth-row { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.badge-member {
  background: linear-gradient(90deg, #8b6914, var(--accent-glow));
  color: #1a1000;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
}

.vip-bar-wrap {
  flex: 1;
  min-width: 120px;
}

.vip-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  overflow: hidden;
}

.vip-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary), var(--accent-neon));
  border-radius: 8px;
  transition: width 0.4s;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.35);
}

.vip-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.clock-box {
  text-align: right;
  font-size: 11px;
  color: var(--accent-glow);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
}

/* Ticker */
.ticker-wrap {
  overflow: hidden;
  background: rgba(2, 14, 18, 0.88);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 6px 0;
}

.ticker-track {
  display: flex;
  white-space: nowrap;
  animation: ticker 28s linear infinite;
  font-size: 11px;
  color: var(--accent-glow);
}

@keyframes ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #40e8ff, var(--primary-dark));
  color: #021018;
  border: 1px solid rgba(0, 212, 255, 0.5);
  border-radius: 30px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: var(--shadow-hover);
  transition: transform 0.15s;
}

.btn-primary:hover { transform: scale(1.03); }

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(2, 16, 22, 0.65);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 20px;
  padding: 8px 16px;
  min-height: 38px;
  font-size: 12px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.title-pill {
  text-align: center;
  background: linear-gradient(180deg, #40e8ff, var(--primary-dark));
  color: #041208;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 30px;
  margin: 12px auto;
  max-width: 320px;
  box-shadow: var(--shadow-hover);
  border: 1px solid rgba(0, 212, 255, 0.35);
}

.coin-display {
  font-size: 12px;
  color: var(--accent-glow);
  font-weight: 700;
}

/* Terminal */
.terminal-widget {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 100;
  width: min(280px, calc(100vw - 24px));
  background: rgba(2, 10, 14, 0.92);
  border: 1px solid var(--accent-glow);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 11px;
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.1), 0 0 8px rgba(240, 160, 32, 0.15);
  pointer-events: none;
}

@supports (padding: max(0px)) {
  .terminal-widget{
    left: calc(12px + env(safe-area-inset-left, 0px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

.terminal-widget .term-title {
  color: var(--accent-glow);
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 12px;
}

.terminal-widget .term-line {
  color: var(--primary);
  line-height: 1.45;
  min-height: 16px;
  text-shadow: 0 0 6px rgba(0, 212, 255, 0.35);
}

.terminal-widget .term-cursor {
  display: inline-block;
  width: 7px;
  height: 12px;
  background: var(--primary);
  animation: blink 1s step-end infinite;
  vertical-align: middle;
}

@keyframes blink { 50% { opacity: 0; } }

.tool-mascot {
  position: fixed;
  left: 14px;
  bottom: 78px;
  z-index: 99;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a1820, #020806);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.25);
  pointer-events: none;
}

@supports (padding: max(0px)) {
  .tool-mascot{
    left: calc(14px + env(safe-area-inset-left, 0px));
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.75);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.show { display: flex; }

.modal-box {
  background: #061018;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.modal-box h3 { margin-bottom: 12px; color: var(--primary); }

.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Reduced motion: keep UI readable + save battery */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  #circuit-canvas{opacity:.45;filter:none}
  .ticker-track{animation:none !important; transform:none !important}
}

@media (min-width: 768px) {
  .page-wrap { max-width: 520px; }
}
.section-title-main .btn-primary{
  font-family:Orbitron,"Be Vietnam Pro",sans-serif;
  letter-spacing:.08em;
  text-transform:uppercase;
  font-size:15px;
  text-shadow:0 0 20px rgba(0,212,255,.35);
}
.title-pill{
  font-family:Orbitron,"Be Vietnam Pro",sans-serif;
  letter-spacing:.06em;
  text-shadow:0 2px 12px rgba(0,212,255,.3);
}
.user-greet{font-family:"Be Vietnam Pro",sans-serif;font-size:14px}
.sub-title{text-align:center;color:var(--accent-glow);font-weight:800;font-size:13px;letter-spacing:.1em;margin-bottom:16px}
