/* File: /webapp/style.css */
/* PWA Styles for MindTrack - Enhanced with Recovery Features */

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

:root {
  --primary: #0066cc;
  --primary-dark: #0052a3;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg-dark: #0f0f0f;
  --bg-light: #1a1a1a;
  --surface: #262626;
  --surface-hover: #2d2d2d;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --border: #374151;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
  --bg-dark: #ffffff;
  --bg-light: #f9fafb;
  --surface: #ffffff;
  --surface-hover: #f3f4f6;
  --text: #111827;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --border: #e5e7eb;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  transition: var(--transition);
}

/* NEW: Crash Mode */
body.crash-mode {
  background: #0a0a0a;
}

body.crash-mode .app-container {
  opacity: 0.7;
}

body.crash-mode .session-badge {
  background: var(--warning);
  animation: gentlePulse 3s ease-in-out infinite;
}

@keyframes gentlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Install Banner */
.install-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  color: white;
  padding: 0.75rem 1rem;
  z-index: 1000;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.install-banner.show { transform: translateY(0); }
.install-banner.hidden { display: none; }

.install-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-small {
  padding: 0.375rem 1rem;
  background: white;
  color: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
}

.btn-text {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  text-decoration: underline;
}

/* App Container */
.app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.app-header {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.back-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.25rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
}

.back-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--primary);
  transform: scale(1.05);
}

.app-title {
  font-size: 1.5rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary), var(--success));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--surface-hover);
  transform: scale(1.05);
}

/* NEW: Energy Status Section */
.energy-status {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.energy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.energy-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}

.energy-percentage {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--success);
}

.energy-battery {
  height: 1.5rem;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.battery-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #059669);
  transition: width 0.5s ease, background 0.5s ease;
  border-radius: var(--radius-sm);
}

.energy-message {
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
}

/* NEW: Crash Prediction Display */
.crash-prediction {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  margin-top: 1rem;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--primary);
}

.crash-prediction.prediction-urgent {
  border-left-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.crash-prediction.prediction-warning {
  border-left-color: var(--warning);
  background: rgba(245, 158, 11, 0.1);
}

.crash-prediction.prediction-ok {
  border-left-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.prediction-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.prediction-content {
  flex: 1;
  min-width: 0;
}

.prediction-text {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.prediction-time {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Timer Section */
.timer-section {
  text-align: center;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 2rem;
  position: relative;
}

.session-badge {
  display: inline-block;
  padding: 0.375rem 1rem;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
}

.session-badge.break { background: var(--success); }
.session-badge.recovery { background: var(--warning); }

.timer-display {
  font-size: 5rem;
  font-weight: 200;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.timer-display.pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.timer-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  width: 0%;
  transition: width 1s linear;
  border-radius: 2px;
}

.session-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.info-item {
  text-align: center;
}

.info-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
}

.info-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* NEW: Recovery Section */
.recovery-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

.recovery-section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.recovery-display {
  margin-bottom: 1rem;
}

.recovery-time {
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--warning);
  margin-bottom: 0.25rem;
}

.recovery-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.recovery-suggestion {
  font-size: 0.9375rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

/* Controls */
.controls-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.btn {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:hover:not(:disabled) {
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: white;
}

.btn-warning:hover:not(:disabled) {
  background: #ea8f0a;
}

.btn-recovery {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.btn-recovery:hover:not(:disabled) {
  background: #059669;
}

.btn-icon {
  font-size: 1.125rem;
}

/* Quick Sessions */
.quick-sessions {
  margin-bottom: 2rem;
}

.quick-sessions h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.quick-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quick-btn {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}

.quick-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Voice Indicator */
.voice-indicator {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: var(--transition);
}

.voice-indicator.listening {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(0, 102, 204, 0.3);
}

.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.voice-indicator.listening .voice-dot {
  background: var(--primary);
  animation: voicePulse 1.5s ease-in-out infinite;
}

@keyframes voicePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.7; }
}

.voice-text {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Quote Section */
.quote-section {
  text-align: center;
  padding: 1.5rem;
  margin-bottom: 2rem;
  font-style: italic;
  color: var(--text-muted);
}

/* Modal */
.modal {
  display: none !important;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  padding: 1rem;
  overflow-y: auto;
  /* Safari fixes */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.modal.active {
  display: flex !important;
  /* Safari flex fixes */
  display: -webkit-flex !important;
  -webkit-align-items: center;
  -webkit-justify-content: center;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 1.5rem;
}

.setting-group {
  margin-bottom: 1.5rem;
}

.setting-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text);
}

.setting-group input[type="range"] {
  width: 100%;
  margin-bottom: 0.25rem;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

/* NEW: Intensity Modal Styles */
.intensity-buttons {
  display: grid;
  gap: 1rem;
}

.intensity-btn {
  padding: 1.25rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.intensity-btn:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.intensity-icon {
  font-size: 2rem;
}

.intensity-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.intensity-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.25rem;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* NEW: Energy Stats */
.energy-stats {
  background: var(--bg-light);
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 2rem;
}

.energy-stats h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-actions {
  display: flex;
  gap: 1rem;
}

/* Voice Help */
.voice-help {
  margin-bottom: 2rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid var(--border);
}

.voice-help summary {
  cursor: pointer;
  font-weight: 500;
}

.voice-help ul {
  margin-top: 1rem;
  margin-left: 1.5rem;
  color: var(--text-muted);
}

.voice-help li {
  margin-bottom: 0.5rem;
}

/* Keyboard shortcut styling */
kbd {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  font-family: monospace;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Footer */
.app-footer {
  padding: 2rem 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--text);
}

.footer-note {
  margin-top: 0.5rem;
  color: var(--text-dim);
}

/* NEW: Undo Bar */
.undo-bar {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: bottom 0.3s ease;
  z-index: 2000;
  max-width: 90%;
}

.undo-bar.show {
  bottom: 2rem;
}

.undo-message {
  color: var(--text);
  font-size: 0.9375rem;
}

.undo-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.undo-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.undo-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.undo-close:hover {
  color: var(--text);
}


/* Responsive */
@media (max-width: 640px) {
  .timer-display {
    font-size: 3.5rem;
  }
  
  .controls-section {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    padding: 1rem;
    border-top: 2px solid var(--border);
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
  }
  
  .btn {
    min-height: 56px; /* Better tap target for mobile */
    font-size: 0.875rem;
  }
  
  /* Crash button full width on mobile */
  #crashBtn {
    grid-column: 1 / -1;
    background: var(--danger);
    border-color: var(--danger);
    font-size: 1rem;
    min-height: 60px;
  }
  
  /* Quick recovery also full width */
  #quickRecoveryBtn {
    grid-column: 1 / -1;
  }
  
  /* Add padding to bottom of app container so content isn't hidden */
  .app-container {
    padding-bottom: 200px; /* Space for fixed controls */
  }
  
  .session-info {
    gap: 0.5rem;
  }
  
  .voice-indicator {
    left: 1rem;
    bottom: 1rem;
    padding: 0.5rem 1rem;
  }
  
  .stat-grid {
    grid-template-columns: 1fr;
  }
  
  /* Make crash prediction more compact on mobile */
  .crash-prediction {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
  
  .prediction-icon {
    font-size: 2rem;
  }
}

/* PWA Standalone Mode */
@media (display-mode: standalone) {
  .install-banner {
    display: none !important;
  }
  
  .footer-note {
    display: none;
  }
}

/* Safe Areas for iPhone */
@supports (padding: env(safe-area-inset-top)) {
  .app-header {
    padding-top: calc(1.5rem + env(safe-area-inset-top));
  }
  
  .app-footer {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
}
/* ========================================
   AUTH MODAL STYLES
   ======================================== */

/* Auth Modal Layout */
.auth-modal {
  max-width: 440px;
  padding: 2.5rem;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h2 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
}

.auth-header p {
  color: var(--text-light);
  margin: 0;
  font-size: 0.9375rem;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2rem;
  gap: 0.5rem;
}

.auth-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-light);
  transition: all 0.2s;
  font-family: inherit;
}

.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.auth-tab:hover {
  color: var(--text);
}

/* Auth Forms */
.auth-form {
  display: flex;
  flex-direction: column;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-help {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-lighter);
}

.btn-block {
  width: 100%;
}

/* Google Sign In Button */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-google:hover {
  background: var(--bg-light);
  border-color: var(--accent);
}

/* Auth Divider */
.auth-divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  color: var(--text-lighter);
  font-size: 0.875rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-divider span {
  padding: 0 1rem;
}

/* Auth Footer */
.auth-footer {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-lighter);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Link Button */
.link-button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

/* Auth Success State */
.auth-success {
  text-align: center;
  padding: 2rem 0;
}

.success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: var(--success);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
}

.auth-success h3 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.auth-success p {
  color: var(--text-light);
  margin: 0;
}

/* Auth Loading State */
.auth-loading {
  text-align: center;
  padding: 3rem 0;
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* User Dropdown */
.user-dropdown {
  position: relative;
}

.user-menu-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.9375rem;
  font-family: inherit;
  transition: all 0.2s;
}

.user-menu-button:hover {
  background: var(--bg-light);
  border-color: var(--accent);
}

.user-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 240px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 1000;
}

.user-menu-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tier-badge {
  padding: 0.25rem 0.5rem;
  background: var(--bg-light);
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.tier-badge.plus {
  background: var(--accent-light);
  color: var(--accent);
}

.user-menu-items {
  padding: 0.5rem;
}

.user-menu-items button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem;
  background: none;
  border: none;
  border-radius: 0.375rem;
  text-align: left;
  cursor: pointer;
  font-size: 0.9375rem;
  font-family: inherit;
  transition: background 0.2s;
}

.user-menu-items button:hover {
  background: var(--bg-light);
}

/* Responsive Auth Styles */
@media (max-width: 640px) {
  .auth-modal {
    padding: 2rem 1.5rem;
  }
}

/* ========================================
   ONBOARDING STYLES
   ======================================== */

.onboarding-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
}

.onboarding-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  padding: 3rem 2rem 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.onboarding-skip {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.2s;
}

.onboarding-skip:hover {
  color: var(--text);
}

.onboarding-screen {
  text-align: center;
  animation: fadeIn 0.4s ease;
}

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

.onboarding-visual {
  margin-bottom: 2rem;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Screen 1: Burst Visual */
.burst-visual {
  position: relative;
  width: 200px;
  height: 140px;
}

.burst-wave {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 60px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--success));
  border-radius: 30px 30px 0 0;
  transform: translateX(-50%);
  opacity: 0;
  animation: burstPulse 3s ease-in-out infinite;
}

.burst-wave:nth-child(1) {
  animation-delay: 0s;
  transform: translateX(-80px);
}

.burst-wave:nth-child(2) {
  animation-delay: 0.6s;
  height: 120px;
}

.burst-wave:nth-child(3) {
  animation-delay: 1.2s;
  transform: translateX(30px);
  height: 90px;
}

@keyframes burstPulse {
  0%, 100% {
    opacity: 0;
    transform: translateX(-50%) scaleY(0.3);
  }
  20%, 80% {
    opacity: 0.8;
    transform: translateX(-50%) scaleY(1);
  }
}

/* Screen 2: Battery Visual */
.battery-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.battery-shell {
  width: 140px;
  height: 70px;
  border: 4px solid var(--border);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background: var(--background);
}

.battery-shell::before {
  content: '';
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 30px;
  background: var(--border);
  border-radius: 0 4px 4px 0;
}

.battery-level {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(135deg, var(--success), var(--primary));
  animation: batteryDrain 4s ease-in-out infinite;
}

@keyframes batteryDrain {
  0% {
    width: 100%;
  }
  50% {
    width: 30%;
  }
  100% {
    width: 100%;
  }
}

.task-costs {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.task-item {
  background: var(--bg-dark);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  animation: taskAppear 1s ease forwards;
}

.task-item:nth-child(1) {
  animation-delay: 0.5s;
}

.task-item:nth-child(2) {
  animation-delay: 1.5s;
}

.task-item:nth-child(3) {
  animation-delay: 2.5s;
}

@keyframes taskAppear {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Screen 3: Crash Button Visual */
.crash-visual {
  position: relative;
  display: inline-block;
}

.crash-btn-demo {
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: default;
  box-shadow: 0 4px 15px rgba(238, 90, 111, 0.4);
}

.crash-icon {
  font-size: 1.5rem;
}

.glow-effect {
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border-radius: var(--radius);
  background: radial-gradient(circle, rgba(238, 90, 111, 0.3), transparent 70%);
  animation: glowPulse 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes glowPulse {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.1);
  }
}

.onboarding-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.onboarding-text {
  color: var(--text-muted);
  font-size: 1.125rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.onboarding-btn {
  width: 100%;
  max-width: 280px;
  padding: 1rem 2rem;
  font-size: 1rem;
  margin: 0 auto 2rem;
  display: block;
}

.onboarding-dots {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.onboarding-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s;
}

.onboarding-dots .dot.active {
  background: var(--primary);
  width: 24px;
  border-radius: 4px;
}

/* Responsive Onboarding */
@media (max-width: 640px) {
  .onboarding-content {
    padding: 2rem 1.5rem 1.5rem;
  }

  .onboarding-visual {
    min-height: 160px;
  }

  .burst-visual {
    width: 160px;
    height: 120px;
  }

  .onboarding-title {
    font-size: 1.5rem;
  }

  .onboarding-text {
    font-size: 1rem;
  }

  .crash-btn-demo {
    padding: 0.875rem 1.5rem;
    font-size: 0.9375rem;
  }
}

/* Support for swipe gestures on mobile */
@media (hover: none) and (pointer: coarse) {
  .onboarding-content {
    touch-action: pan-x;
  }
}

/* ========================================
   ENERGY EXPLAINER STYLES
   ======================================== */

.energy-info-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.energy-info-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.energy-info-btn:active {
  transform: scale(0.95);
}

.energy-explanation {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.energy-cost-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.energy-cost-item:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cost-icon {
  font-size: 2rem;
  flex-shrink: 0;
  width: 50px;
  text-align: center;
}

.cost-details {
  flex: 1;
  min-width: 0;
}

.cost-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.cost-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.cost-multiplier {
  font-weight: 600;
  font-size: 1rem;
  color: var(--primary);
  white-space: nowrap;
  padding: 0.375rem 0.75rem;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
}

/* Responsive Energy Explainer */
@media (max-width: 640px) {
  .energy-cost-item {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }

  .cost-icon {
    width: 100%;
  }

  .cost-multiplier {
    width: 100%;
  }
}

/* ========================================
   ENERGY GRAPH STYLES
   ======================================== */

.energy-graph-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.energy-graph-section h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: var(--text);
}

#energyGraphContainer {
  position: relative;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  margin-bottom: 1rem;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#energyGraph {
  max-width: 100%;
  height: auto;
  display: block;
}

.graph-placeholder {
  text-align: center;
  padding: 2rem 1rem;
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.graph-placeholder p {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.placeholder-subtext {
  font-size: 0.875rem;
  color: var(--text-lighter);
  max-width: 300px;
  margin: 0 auto;
}

.energy-insight {
  background: linear-gradient(135deg, var(--accent-light), var(--bg-light));
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
}

.energy-insight:empty {
  display: none;
}

/* Responsive Energy Graph */
@media (max-width: 640px) {
  #energyGraphContainer {
    padding: 1rem;
  }

  #energyGraph {
    width: 100%;
  }

  .placeholder-icon {
    font-size: 2.5rem;
  }

  .graph-placeholder p {
    font-size: 0.9375rem;
  }
}

/* ========================================
   CRASH BUTTON TUTORIAL
   ======================================== */

.crash-tutorial {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
  animation: tutorialFadeIn 0.5s ease;
}

@keyframes tutorialFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.crash-tutorial.fade-out {
  animation: tutorialFadeOut 0.5s ease forwards;
}

@keyframes tutorialFadeOut {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
}

.tutorial-pointer {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 30px solid var(--primary);
  margin-bottom: 10px;
  animation: pointerBounce 1.5s ease-in-out infinite;
}

@keyframes pointerBounce {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-10px);
  }
}

.tutorial-tooltip {
  background: var(--primary);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 102, 204, 0.3);
  min-width: 280px;
  max-width: 320px;
  text-align: center;
  animation: tooltipPulse 2s ease-in-out infinite;
}

@keyframes tooltipPulse {
  0%, 100% {
    box-shadow: 0 8px 24px rgba(0, 102, 204, 0.3);
  }
  50% {
    box-shadow: 0 8px 32px rgba(0, 102, 204, 0.5);
  }
}

.tutorial-tooltip p {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: white;
}

.tutorial-tooltip p:first-child {
  margin-bottom: 0.5rem;
}

.tutorial-tooltip strong {
  color: white;
  font-weight: 600;
}

/* Mobile positioning for crash tutorial */
@media (max-width: 640px) {
  .crash-tutorial {
    position: fixed;
    top: auto;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
  }

  .tutorial-tooltip {
    min-width: 260px;
    max-width: 280px;
    padding: 0.875rem 1.25rem;
  }

  .tutorial-tooltip p {
    font-size: 0.875rem;
  }

  .tutorial-pointer {
    border-left-width: 15px;
    border-right-width: 15px;
    border-bottom-width: 25px;
  }
}

/* ========================================
   COMPLETION CELEBRATION
   ======================================== */

.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.celebration-message {
  text-align: center;
  background: rgba(255, 255, 255, 0.98);
  padding: 2rem 3rem;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: celebrationPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  position: relative;
  z-index: 2;
}

@keyframes celebrationPop {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.celebration-emoji {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: emojiSpin 0.8s ease;
}

@keyframes emojiSpin {
  0% {
    transform: rotate(0deg) scale(0);
  }
  50% {
    transform: rotate(180deg) scale(1.2);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

.celebration-message h2 {
  font-size: 2rem;
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.celebration-message p {
  font-size: 1.125rem;
  margin: 0;
  color: var(--text-muted);
}

.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 1;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--primary);
  top: -10px;
  opacity: 0;
  animation: confettiFall 2.5s linear forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg);
  }
}

.confetti:nth-child(2n) {
  background: #ff6b6b;
  width: 8px;
  height: 8px;
}

.confetti:nth-child(3n) {
  background: #ffd93d;
  width: 6px;
  height: 12px;
}

.confetti:nth-child(4n) {
  background: #6bcf7f;
}

.confetti:nth-child(5n) {
  background: #a78bfa;
  width: 12px;
  height: 6px;
}

/* Responsive celebration */
@media (max-width: 640px) {
  .celebration-message {
    padding: 1.5rem 2rem;
    margin: 0 1rem;
  }

  .celebration-emoji {
    font-size: 3rem;
  }

  .celebration-message h2 {
    font-size: 1.5rem;
  }

  .celebration-message p {
    font-size: 1rem;
  }
}

/* ========================================
   STATS MODAL SECTIONS
   ======================================== */

.stats-section {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.stats-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.stats-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Remove duplicate borders from nested sections */
.stats-section .energy-graph-section {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.stats-section .energy-stats {
  margin-top: 0;
}

/* Adjust stat grid within sections */
.stats-section .stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}

/* Responsive sections */
@media (max-width: 640px) {
  .stats-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
  }

  .stats-section-title {
    font-size: 1.125rem;
  }

  .stats-section .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
  }
}
