/* ============================================
   UpTree · $UPTREE — Stylesheet v2
   Dark cyber minimalism · Glassmorphism · Neon green accents
   + Recent Waters feed · Streamer toggle · Milestone roadmap · Share modal
   ============================================ */

:root {
  --bg-primary: #050505;
  --bg-secondary: #0A0A0A;
  --card-bg: rgba(15, 15, 15, 0.65);
  --card-bg-hover: rgba(20, 22, 20, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-glow: rgba(0, 255, 102, 0.25);
  --text-primary: #E8E8E8;
  --text-secondary: #888888;
  --text-muted: #555555;
  --accent: #00FF66;
  --accent-dim: rgba(0, 255, 102, 0.3);
  --accent-glow: rgba(0, 255, 102, 0.6);
  --accent-red: #FF4444;
  --glass-blur: 14px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-display);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  position: relative;
}
input { font-family: var(--font-display); }
button { font-family: var(--font-display); cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ===== CANVAS ===== */
#tree-canvas, #ripple-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0; display: block;
}
#ripple-canvas { z-index: 1; pointer-events: none; }

/* ===== TOP BAR ===== */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px;
  background: linear-gradient(180deg, rgba(5,5,5,0.85) 0%, rgba(5,5,5,0) 100%);
  pointer-events: none;
}
.top-bar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1a1a1a, #0a0a0a);
  border: 1px solid var(--card-border); position: relative; flex-shrink: 0;
}
.brand-mark::before {
  content: ''; position: absolute; inset: 8px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.4; border-radius: 50%; filter: blur(3px);
}
.brand-mark::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 4px; height: 4px; background: var(--accent); border-radius: 50%;
  transform: translate(-50%, -50%); box-shadow: 0 0 8px var(--accent-glow);
}
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-name { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.brand-ticker { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); letter-spacing: 0.05em; }

.tagline { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.top-actions { display: flex; align-items: center; gap: 10px; }

.ca-bar {
  display: flex; align-items: center;
  background: var(--card-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.ca-bar:focus-within { border-color: var(--card-border-glow); box-shadow: 0 0 12px rgba(0,255,102,0.08); }
.ca-bar input {
  width: 140px; padding: 8px 12px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary);
  background: transparent; border: none; outline: none;
}
.ca-bar input::placeholder { color: var(--text-muted); }
.ca-copy-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 8px 14px; font-size: 12px; font-weight: 500;
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
  border-left: 1px solid var(--card-border);
  transition: all 0.2s var(--ease);
}
.ca-copy-btn:hover { background: var(--accent-dim); color: var(--accent); }
.ca-copy-btn.copied { background: var(--accent); color: #000; }

.social-nav { display: flex; gap: 2px; }
.nav-link {
  padding: 8px 12px; font-size: 12px; font-weight: 500;
  color: var(--text-secondary); border-radius: var(--radius-sm);
  transition: all 0.2s var(--ease); white-space: nowrap;
}
.nav-link:hover { color: var(--accent); background: rgba(0,255,102,0.06); }

/* ===== ICON BUTTONS (audio + streamer) ===== */
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  color: var(--text-secondary);
  background: var(--card-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--accent); border-color: var(--card-border-glow); box-shadow: 0 0 12px rgba(0,255,102,0.1); }
.icon-btn.active { color: var(--accent); border-color: var(--accent-dim); background: rgba(0,255,102,0.08); }

/* ===== HUD CARD (enhanced glassmorphism + hover elevation) ===== */
.hud-card {
  position: fixed; top: 72px; right: 20px; z-index: 10;
  width: 280px; padding: 18px 20px;
  background: var(--card-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transition: all 0.4s var(--ease-out);
}
.hud-card:hover {
  border-color: var(--card-border-glow);
  box-shadow: 0 12px 48px rgba(0,0,0,0.5), 0 0 20px rgba(0,255,102,0.08);
  transform: translateY(-2px);
}

.hud-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.hud-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; color: var(--text-muted); }
.hud-stage {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--accent);
  padding: 2px 8px; border-radius: 4px;
  background: rgba(0,255,102,0.08); border: 1px solid rgba(0,255,102,0.15);
  letter-spacing: 0.05em;
}
.hud-mc {
  font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15;
  margin-bottom: 14px; font-variant-numeric: tabular-nums;
}
.hud-row { display: flex; gap: 16px; margin-bottom: 14px; }
.hud-stat { display: flex; flex-direction: column; gap: 2px; }
.hud-stat-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; color: var(--text-muted); }
.hud-stat-value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hud-stat-value.positive { color: var(--accent); }
.hud-stat-value.negative { color: var(--accent-red); }
.hud-progress-wrap { margin-top: 4px; }
.hud-progress-track {
  position: relative; height: 6px;
  background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden;
}
.hud-progress-fill {
  position: absolute; top: 0; left: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, rgba(0,255,102,0.4), var(--accent));
  border-radius: 3px; transition: width 0.6s var(--ease-out);
  box-shadow: 0 0 12px var(--accent-glow);
}
.hud-progress-milestones { position: absolute; inset: 0; }
.hud-milestone-dot {
  position: absolute; top: -2px; width: 2px; height: 10px;
  background: rgba(255,255,255,0.15); border-radius: 1px;
}
.hud-progress-label {
  display: flex; justify-content: space-between; margin-top: 6px;
  font-size: 10px; color: var(--text-muted);
}
.hud-progress-label span:last-child { color: var(--text-secondary); font-weight: 500; }
.hud-status {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--card-border);
  font-family: var(--font-mono); font-size: 10px; color: var(--text-muted);
  text-align: center; letter-spacing: 0.03em;
}
.hud-status.live { color: var(--accent); }
.hud-status.live::before { content: '●'; margin-right: 4px; animation: pulse-dot 1.5s infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ===== RECENT WATERS ACTIVITY FEED ===== */
.activity-feed {
  position: fixed; bottom: 160px; left: 20px; z-index: 10;
  width: 260px;
  background: var(--card-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.4s var(--ease-out);
}
.activity-feed:hover {
  border-color: var(--card-border-glow);
  box-shadow: 0 0 20px rgba(0,255,102,0.06);
}
.activity-feed-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--card-border);
}
.activity-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  animation: pulse-dot 1.5s infinite;
}
.activity-list { list-style: none; max-height: 200px; overflow: hidden; }
.activity-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  animation: fade-in 0.3s var(--ease-out);
}
.activity-item:last-child { border-bottom: none; }
.activity-emoji { font-size: 12px; flex-shrink: 0; }
.activity-name { color: var(--text-primary); font-weight: 500; font-family: var(--font-mono); }
.activity-action { color: var(--text-muted); }
.activity-amount { color: var(--accent); font-weight: 600; font-family: var(--font-mono); margin-left: auto; }
.activity-time { color: var(--text-muted); font-size: 10px; }
.activity-item.slide-in { animation: slide-in 0.4s var(--ease-out); }
@keyframes slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; } to { opacity: 1; }
}

/* ===== MILESTONE ROADMAP BAR ===== */
.roadmap-bar {
  position: fixed; bottom: 96px; left: 50%; z-index: 10;
  transform: translateX(-50%);
  width: 90%; max-width: 640px;
  background: var(--card-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 20px 12px;
  transition: all 0.4s var(--ease-out);
}
.roadmap-bar:hover {
  border-color: var(--card-border-glow);
  box-shadow: 0 0 20px rgba(0,255,102,0.06);
}
.roadmap-track {
  position: relative; height: 3px;
  background: rgba(255,255,255,0.05); border-radius: 2px;
  margin-bottom: 14px; overflow: hidden;
}
.roadmap-fill {
  position: absolute; top: 0; left: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, rgba(0,255,102,0.3), var(--accent));
  border-radius: 2px; transition: width 0.6s var(--ease-out);
  box-shadow: 0 0 8px var(--accent-glow);
}
.roadmap-milestones {
  display: flex; justify-content: space-between;
}
.milestone-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  position: relative; opacity: 0.35;
  transition: opacity 0.4s var(--ease), transform 0.3s var(--ease);
}
.milestone-item.reached { opacity: 1; }
.milestone-item.reached .milestone-emoji { filter: drop-shadow(0 0 4px var(--accent-glow)); }
.milestone-item:not(.reached) .milestone-emoji { filter: grayscale(1); }
.milestone-emoji { font-size: 16px; line-height: 1; transition: filter 0.4s var(--ease); }
.milestone-label { font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--text-primary); }
.milestone-name { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.milestone-item.reached .milestone-label { color: var(--accent); }

/* ===== ACTION AREA ===== */
.action-area {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 24px 20px 28px;
  background: linear-gradient(0deg, rgba(5,5,5,0.85) 0%, rgba(5,5,5,0) 100%);
  pointer-events: none;
}
.action-area > * { pointer-events: auto; }

.water-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 36px; font-size: 16px; font-weight: 600;
  color: #000; background: var(--accent); border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,255,102,0.3), 0 0 0 1px rgba(0,255,102,0.5);
  transition: all 0.25s var(--ease); position: relative; overflow: hidden;
}
.water-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 32px rgba(0,255,102,0.45), 0 0 0 1px rgba(0,255,102,0.6);
}
.water-btn:active { transform: translateY(0) scale(0.98); }
.water-btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: translateX(-100%); transition: transform 0.6s var(--ease);
}
.water-btn:hover::before { transform: translateX(100%); }
.water-btn-icon { display: flex; align-items: center; }

.share-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px; font-size: 13px; font-weight: 500;
  color: var(--text-primary);
  background: var(--card-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--card-border); border-radius: var(--radius);
  transition: all 0.2s var(--ease);
}
.share-btn:hover { border-color: var(--accent-dim); color: var(--accent); transform: translateY(-1px); }

/* ===== SHARE MODAL ===== */
.share-modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s var(--ease);
}
.share-modal-backdrop.show { display: flex; opacity: 1; }
.share-modal {
  position: relative;
  width: 90%; max-width: 500px;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border-glow);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 32px rgba(0,255,102,0.1);
  padding: 24px; animation: modal-in 0.35s var(--ease-out);
}
@keyframes modal-in { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.share-modal-close {
  position: absolute; top: 12px; right: 16px;
  font-size: 24px; color: var(--text-muted);
  transition: color 0.2s var(--ease);
}
.share-modal-close:hover { color: var(--text-primary); }
.share-modal-header { margin-bottom: 16px; }
.share-modal-title { font-size: 18px; font-weight: 600; display: block; }
.share-modal-sub { font-size: 12px; color: var(--text-muted); }
.share-preview-canvas {
  width: 100%; border-radius: var(--radius); margin-bottom: 14px;
  border: 1px solid var(--card-border);
}
.share-modal-text {
  font-size: 12px; font-family: var(--font-mono); color: var(--text-secondary);
  background: rgba(255,255,255,0.03); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  white-space: pre-wrap; line-height: 1.5; margin-bottom: 14px;
  max-height: 100px; overflow-y: auto;
}
.share-modal-actions { display: flex; gap: 10px; }
.share-post-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px; font-size: 14px; font-weight: 600;
  color: #fff; background: #000; border: 1px solid #333;
  border-radius: var(--radius); transition: all 0.2s var(--ease); flex: 1;
  justify-content: center;
}
.share-post-btn:hover { background: #111; border-color: var(--accent); color: var(--accent); }
.share-copy-btn {
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.04); border: 1px solid var(--card-border);
  border-radius: var(--radius); transition: all 0.2s var(--ease);
}
.share-copy-btn:hover { color: var(--accent); border-color: var(--accent-dim); }

/* ===== DEBUG DRAWER ===== */
.debug-drawer {
  position: fixed; bottom: 0; left: 0; z-index: 20;
  display: flex; align-items: flex-end;
}
.debug-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin: 0 0 16px 16px;
  color: var(--text-muted);
  background: var(--card-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  transition: all 0.2s var(--ease); flex-shrink: 0;
}
.debug-toggle:hover, .debug-toggle.active { color: var(--accent); border-color: var(--accent-dim); }
.debug-content {
  max-height: 0; overflow: hidden;
  background: var(--card-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--card-border); border-radius: var(--radius);
  margin: 0 0 16px 8px; padding: 0 18px;
  transition: max-height 0.4s var(--ease), padding 0.4s var(--ease);
  width: 300px;
}
.debug-content.open { max-height: 200px; padding: 18px; }
.debug-title { font-size: 12px; font-weight: 600; margin-bottom: 12px; color: var(--text-secondary); }
.debug-sliders label { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
.debug-sliders label span:first-child { flex: 1; }
.debug-sliders label span:last-child { font-family: var(--font-mono); color: var(--accent); width: 32px; text-align: right; }
.stage-slider { accent-color: var(--accent); width: 100%; }
.debug-hint { font-size: 10px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }
.debug-checkbox { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary); margin-top: 10px; cursor: pointer; }
.debug-checkbox input { accent-color: var(--accent); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 180px; left: 50%; z-index: 100;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px; font-size: 13px; font-weight: 500;
  color: var(--text-primary);
  background: rgba(15,15,15,0.9);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--accent-dim); border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,255,102,0.15);
  opacity: 0; pointer-events: none;
  transition: all 0.3s var(--ease-out);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== OVERLAY MODE (overlay.html) ===== */
body.overlay-mode {
  background: transparent !important;
}
body.overlay-mode #top-bar,
body.overlay-mode .action-area,
body.overlay-mode .debug-drawer,
body.overlay-mode .activity-feed,
body.overlay-mode .roadmap-bar {
  display: none !important;
}
body.overlay-mode .hud-card {
  position: fixed; bottom: 20px; right: 20px; top: auto;
  width: 240px; padding: 14px 16px;
}
body.overlay-mode .hud-card .hud-mc { font-size: 24px; }
body.overlay-mode .hud-card .hud-status { display: none; }
body.overlay-mode .toast { bottom: 140px; }

/* ===== STREAMER MODE (toggleable) ===== */
body.streamer-mode {
  background: transparent !important;
}
body.streamer-mode #top-bar,
body.streamer-mode .action-area,
body.streamer-mode .debug-drawer,
body.streamer-mode .activity-feed,
body.streamer-mode .roadmap-bar {
  display: none !important;
}
body.streamer-mode .hud-card {
  position: fixed; bottom: 20px; right: 20px; top: auto;
  width: 240px; padding: 14px 16px;
}
body.streamer-mode .hud-card .hud-mc { font-size: 24px; }
body.streamer-mode .toast { bottom: 140px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .top-bar { flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
  .tagline { display: none; }
  .ca-bar input { width: 90px; font-size: 11px; }
  .ca-copy-btn span { display: none; }
  .nav-link { padding: 6px 8px; font-size: 11px; }

  .hud-card { top: auto; bottom: 260px; left: 14px; right: 14px; width: auto; padding: 14px 16px; }
  .hud-mc { font-size: 26px; }

  .activity-feed { width: calc(50% - 20px); max-width: 200px; bottom: 300px; left: 14px; }
  .activity-item { font-size: 10px; padding: 5px 10px; }
  .activity-name { font-size: 10px; }
  .activity-amount { font-size: 10px; }

  .roadmap-bar { width: calc(100% - 28px); bottom: 100px; padding: 10px 14px 8px; }
  .milestone-emoji { font-size: 14px; }
  .milestone-label { font-size: 9px; }
  .milestone-name { display: none; }

  .action-area { padding: 16px 14px 20px; gap: 10px; }
  .water-btn { padding: 12px 28px; font-size: 15px; width: 100%; max-width: 340px; justify-content: center; }
  .share-btn { font-size: 12px; padding: 8px 16px; }

  .debug-drawer { display: none; }
  .toast { bottom: 200px; }
}

@media (max-width: 480px) {
  .top-actions { flex: 1; justify-content: flex-end; }
  .social-nav { display: none; }
  .ca-bar { flex: 1; max-width: 140px; }
  .ca-bar input { width: 100%; }
  .hud-card { bottom: 240px; padding: 12px 14px; }
  .hud-mc { font-size: 22px; }
  .activity-feed { width: calc(100% - 28px); max-width: 280px; bottom: 320px; }
  .share-modal { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
