/* Energy Empire - Main Styles */

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

:root {
  /* Color Palette - Energy Empire Theme */
  --bg-dark: #0d0d1a;
  --bg-darker: #080810;
  --bg-panel: rgba(12, 12, 28, 0.97);
  --bg-panel-hover: rgba(20, 20, 45, 0.98);
  --bg-panel-active: rgba(30, 30, 60, 0.95);
  --text-primary: #f0f0ff;
  --text-secondary: #9898c8;
  --text-muted: #5858a0;
  --accent-yellow: #ffd700;
  --accent-gold: #ffaa00;
  --accent-orange: #ff6b35;
  --accent-blue: #00d4ff;
  --accent-cyan: #00ffcc;
  --accent-green: #00ff88;
  --accent-purple: #9b59b6;
  --accent-pink: #ff69b4;
  --accent-red: #ff4757;
  --border-color: #2a2a55;
  --border-glow: #4a4a8a;
  --glow-color: rgba(255, 215, 0, 0.4);
  --glow-blue: rgba(0, 212, 255, 0.4);
  --glow-purple: rgba(155, 89, 182, 0.4);

  /* Gradients */
  --gradient-gold: linear-gradient(135deg, #ffd700 0%, #ffaa00 50%, #ff8c00 100%);
  --gradient-blue: linear-gradient(135deg, #00d4ff 0%, #0088ff 50%, #0066cc 100%);
  --gradient-purple: linear-gradient(135deg, #9b59b6 0%, #8e44ad 50%, #6c3483 100%);
  --gradient-green: linear-gradient(135deg, #00ff88 0%, #00cc6a 50%, #00994d 100%);
  --gradient-dark: linear-gradient(180deg, #1a1a2e 0%, #0d0d1a 100%);

  /* Spacing Scale */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 50%;

  /* Animation Durations */
  --duration-fast: 0.15s;
  --duration-normal: 0.3s;
  --duration-slow: 0.5s;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow-blue: 0 0 15px var(--glow-blue);
  --shadow-glow-green: 0 0 15px rgba(0, 255, 136, 0.4);
  --shadow-glow-yellow: 0 0 15px var(--glow-color);
  --shadow-glow-purple: 0 0 15px var(--glow-purple);

  /* Z-Index Layers */
  --z-background: -10;
  --z-content: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 500;
  --z-modal-backdrop: 900;
  --z-modal: 1000;
  --z-toast: 1100;
  --z-tooltip: 1200;

  /* Responsive Breakpoints (for reference) */
  --breakpoint-mobile: 480px;
  --breakpoint-tablet: 768px;
  --breakpoint-desktop: 1024px;
  --breakpoint-wide: 1440px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* Game Container - Phaser Canvas */
#game-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - 100px); /* Leave space for ad footer */
  z-index: 1;
}

#game-container canvas {
  display: block;
}

/* UI Overlay - DOM Elements */
#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - 100px); /* Leave space for ad footer */
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

/* Stats Bar */
#stats-bar {
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(15, 15, 35, 0.98) 0%, rgba(10, 10, 25, 0.95) 100%);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--border-color);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 215, 0, 0.1) inset;
}

.stats-section {
  display: flex;
  gap: 30px;
  align-items: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent-yellow);
  text-shadow: 0 0 15px var(--glow-color), 0 0 30px rgba(255, 215, 0, 0.2);
  letter-spacing: 0.5px;
}

#wps-value {
  color: var(--accent-blue);
  text-shadow: 0 0 15px var(--glow-blue), 0 0 30px rgba(0, 212, 255, 0.2);
}

/* Primary stats highlight */
#watts-display .stat-value {
  font-size: 30px;
  background: var(--gradient-gold);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
}

.header-btn {
  background: linear-gradient(180deg, var(--bg-panel-hover) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-btn:hover {
  background: linear-gradient(180deg, var(--bg-panel-active) 0%, var(--bg-panel-hover) 100%);
  color: var(--text-primary);
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px var(--glow-blue);
}

/* Main Content Layout */
#main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  grid-template-rows: 1fr;
  gap: 0;
  padding-bottom: 100px; /* Space for ad footer */
  overflow: hidden;
  min-height: 0;
}

/* Side Panels */
.side-panel {
  pointer-events: auto;
  background: linear-gradient(180deg, var(--bg-panel) 0%, rgba(8, 8, 20, 0.98) 100%);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
  height: 100%;
  overflow: hidden;
}

#upgrade-panel {
  border-left: none;
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.4);
}

#building-panel {
  border-right: none;
  box-shadow: -4px 0 30px rgba(0, 0, 0, 0.4);
}

.panel-title {
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--accent-yellow);
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, rgba(255, 215, 0, 0.08) 0%, rgba(0, 0, 0, 0.3) 100%);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  min-height: 0;
}

/* Game Area (Center - clicks pass through) */
#game-area {
  position: relative;
  /* Clicks pass through to canvas */
}

#click-feedback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

/* Scrollbar Styling */
.panel-content::-webkit-scrollbar {
  width: 8px;
}

.panel-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

.panel-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent-blue);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
}

.modal.hidden {
  display: none;
  opacity: 0;
}

.modal-content {
  background: linear-gradient(135deg, var(--bg-panel) 0%, rgba(30, 30, 50, 0.98) 100%);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 30px 40px;
  min-width: 400px;
  max-width: 500px;
  text-align: center;
  animation: modalSlideIn 0.3s ease-out;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 191, 255, 0.1);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-content h2 {
  margin-bottom: 20px;
  color: var(--accent-yellow);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 15px 0;
  padding: 10px 0;
}

.setting-btn {
  background: var(--bg-panel-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.setting-btn:hover {
  border-color: var(--accent-blue);
}

.setting-btn.danger {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.setting-btn.danger:hover {
  background: var(--accent-red);
  color: white;
}

.close-btn {
  margin-top: 20px;
  background: var(--accent-blue);
  border: none;
  color: white;
  padding: 12px 30px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: #0099cc;
}

/* Offline Modal */
.offline-earnings {
  font-size: 20px;
  color: var(--accent-yellow);
  margin: 20px 0;
}

.collect-btn {
  background: linear-gradient(180deg, var(--accent-yellow) 0%, var(--accent-orange) 100%);
  border: none;
  color: #1a1a2e;
  padding: 15px 40px;
  border-radius: 6px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.collect-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px var(--glow-color);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

select {
  background: var(--bg-panel-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

/* ========================================
   SIDEBAR LAYOUT ADJUSTMENTS
   ======================================== */

/* Adjust UI overlay when sidebar is active */
body.sidebar-active #ui-overlay {
  margin-left: 240px;
  width: calc(100% - 240px);
  transition: margin-left 0.3s ease, width 0.3s ease;
}

body.sidebar-active.sidebar-collapsed #ui-overlay {
  margin-left: 56px;
  width: calc(100% - 56px);
}

/* Adjust game container similarly */
body.sidebar-active #game-container {
  margin-left: 240px;
  width: calc(100% - 240px);
  transition: margin-left 0.3s ease, width 0.3s ease;
}

body.sidebar-active.sidebar-collapsed #game-container {
  margin-left: 56px;
  width: calc(100% - 56px);
}

/* Mobile - no sidebar offset */
@media (max-width: 768px) {
  body.sidebar-active #ui-overlay,
  body.sidebar-active.sidebar-collapsed #ui-overlay,
  body.sidebar-active #game-container,
  body.sidebar-active.sidebar-collapsed #game-container {
    margin-left: 0;
    width: 100%;
  }
}

/* ========================================
   HIDE OLD HEADER BUTTONS (Sidebar replaces them)
   ======================================== */

body.sidebar-active #stats-bar .header-btn.skill-tree,
body.sidebar-active #stats-bar .header-btn.managers,
body.sidebar-active #stats-bar .header-btn.seasons,
body.sidebar-active #stats-bar .header-btn.achievements,
body.sidebar-active #stats-bar .header-btn.pet,
body.sidebar-active #stats-bar .header-btn.minigames,
body.sidebar-active #stats-bar .header-btn.statistics,
body.sidebar-active #stats-bar .header-btn.challenges,
body.sidebar-active #stats-bar .header-btn.milestones,
body.sidebar-active #stats-bar .header-btn.quests,
body.sidebar-active #stats-bar .header-btn.singularity,
body.sidebar-active #stats-bar .header-btn.dark-forge,
body.sidebar-active #stats-bar .header-btn.sacrifice,
body.sidebar-active #stats-bar .header-btn.artifacts,
body.sidebar-active #stats-bar .header-btn.mastery,
body.sidebar-active #stats-bar .header-btn.ascension,
body.sidebar-active #stats-bar .header-btn.endless,
body.sidebar-active #stats-bar .header-btn.prestige,
body.sidebar-active #stats-bar .header-btn.forge,
body.sidebar-active #stats-bar .header-btn.perks,
body.sidebar-active #stats-bar #save-btn,
body.sidebar-active #stats-bar #settings-btn {
  display: none !important;
}

/* Keep the essential stats visible */
body.sidebar-active #stats-bar {
  padding: 10px 20px;
}

body.sidebar-active #stats-bar .stats-right {
  gap: 15px;
}
