/* ============================================================
   Power Grid Microworld — styles.css
   ============================================================ */

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #2d5a27, #4a7c59);
  color: #ffffff;
  overflow: hidden;
}



/* ============================================================
   Start Screen
   ============================================================ */
#start-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 24px;
}

#start-screen h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  text-shadow: 2px 2px 6px rgba(0,0,0,0.4);
  margin: 0 0 8px 0;
  text-align: center;
}

#start-screen p {
  font-size: 1.2rem;
  margin: 0;
}

#start-screen form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

input[type="text"] {
  padding: 14px 18px;
  font-size: 1.1rem;
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  min-width: 220px;
}

button[type="submit"] {
  padding: 14px 32px;
  font-size: 1.1rem;
  background: linear-gradient(135deg, #4CAF50, #45a049);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}

/* ============================================================
   Welcome Flash
   ============================================================ */
#welcome-flash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  pointer-events: none;
}

#welcome-flash h1 {
  font-size: clamp(2rem, 7vw, 4rem);
  text-align: center;
  text-shadow: 2px 2px 8px rgba(0,0,0,0.7);
  padding: 0 24px;
}

/* ============================================================
   Game Screen wrapper
   ============================================================ */
#game-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Level Select
   ============================================================ */
#level-select-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
}

.level-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 540px;
}

.level-select-title {
  text-align: center;
  margin-bottom: 16px;
}

.level-select-title h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  margin: 0 0 8px 0;
  text-shadow: 2px 2px 6px rgba(0,0,0,0.4);
}

.level-select-title h2 {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  margin: 0;
  opacity: 0.85;
}

.level-btn {
  width: 100%;
  padding: 20px 32px;
  font-size: 1.2rem;
  background: linear-gradient(135deg, #4CAF50, #45a049);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  text-align: left;
}

.level-btn:hover:not(:disabled) {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.level-btn.locked {
  background: #555;
  cursor: not-allowed;
  opacity: 0.65;
}

.level-btn.completed {
  background: #1b4332;
  cursor: default;
  opacity: 0.7;
}

.level-btn.completed::after {
  content: " ✓ Completed";
  display: block;
  font-size: 0.78rem;
  opacity: 0.75;
  margin-top: 4px;
  font-family: monospace;
}

/* ============================================================
   Level Screen
   ============================================================ */
#level-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


/* ---- Header bar ---- */
.level-header {
  flex: 0 0 auto;
  height: 68px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.15);
  flex-wrap: nowrap;
}

.level-header h2 {
  margin: 0;
  font-size: clamp(0.9rem, 2vw, 1.3rem);
  white-space: nowrap;
}

.level-header-budget {
  font-size: clamp(0.75rem, 1.5vw, 1rem);
  font-family: monospace;
  background: rgba(147,183,153,0.3);
  padding: 6px 14px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.3s;
}

/* Flash red when over budget */
.level-header-budget.over-budget {
  background: rgba(220, 50, 50, 0.6);
  animation: budgetPulse 0.8s ease-in-out infinite alternate;
}

@keyframes budgetPulse {
  from { background: rgba(220,50,50,0.5); }
  to   { background: rgba(220,50,50,0.85); }
}

.level-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: 100%;
}

#results-summary-btn {
  display: block;
  margin: 16px auto 0;
}


.level-row .level-btn {
  flex: 1;
}

.redo-level-btn {
  padding: 0 20px;
  font-size: 1rem;
  background: #1b4332;
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  opacity: 0.7;
}

.redo-level-btn:hover {
  opacity: 0.88;
  transform: translateY(-2px);
}


/* ---- Year controls ---- */
#year-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.2);
  padding: 6px 14px;
  border-radius: 8px;
}

#year-controls button {
  padding: 6px 12px;
  font-size: 0.95rem;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 6px;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

#year-controls button:hover:not(:disabled) {
  background: rgba(255,255,255,0.35);
}

#year-controls button:disabled {
  opacity: 0.4;
  cursor: default;
}

.year-label {
  font-size: 1.15rem;
  font-family: monospace;
  font-weight: bold;
  min-width: 50px;
  text-align: center;
}

/* ---- Timer + Pause ---- */
.timer-pause {
  display: flex;
  gap: 12px;
  align-items: center;
}

#timer {
  font-size: 1.2rem;
  font-family: monospace;
  background: rgba(0,0,0,0.3);
  padding: 6px 14px;
  border-radius: 8px;
}

.timer-pause button {
  padding: 8px 16px;
  font-size: 1rem;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 8px;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

.timer-pause button:hover {
  background: rgba(255,255,255,0.35);
}

/* ---- Content area ---- */
#level-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: row;
  gap: 10px;
  padding: 10px;
  overflow: hidden;
}


:fullscreen #level-screen {
  width: 100vw;
  height: 100vh;
  overflow: auto;
}

:fullscreen .level-header {
  position: sticky;
  top: 0;
  z-index: 10;
}



/* ============================================================
   Goals Panel (top-right)
   ============================================================ */
#goals-panel {
  flex: 1 1 0;
  overflow-y: auto;
  background: rgba(45, 110, 65, 0.88);
  border: 2px solid rgba(255,255,255,0.22);
  border-radius: 14px;
  backdrop-filter: blur(16px);
  padding: 14px 16px;
}


#goals-panel h3 {
  margin: 0 0 10px 0;
  font-size: 1rem;
  color: #eaffea;
  text-align: left;
}

.goal {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  column-gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  font-size: 0.88rem;
  line-height: 1.4;
}

.goal:last-child { border-bottom: none; }

.goal-progress {
  font-family: 'Courier New', monospace;
  font-size: 0.84rem;
  white-space: nowrap;
  text-align: right;
  color: rgba(255,255,255,0.9);
}

.goal-status {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  font-weight: bold;
  min-width: 20px;
  text-align: center;
  padding: 1px 4px;
  border-radius: 3px;
}

.goal-status.complete   { color: #00e676; background: rgba(0,0,0,0.3); }
.goal-status.incomplete { color: #ff5252; background: rgba(0,0,0,0.3); }

/* ============================================================
   Energy Table (top-left, scrollable)
   ============================================================ */
#energy-table-wrap {
  flex: 2 1 auto;
  min-height: 0;
  overflow-x: hidden;   /* no horizontal scroll */
  overflow-y: auto;   /* no vertical scroll on the wrap itself */
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.22);
  border-radius: 14px;
  backdrop-filter: blur(12px);
  padding: 10px;
}


#energy-table {
  width: 100%;
  border-collapse: collapse;
  color: #fff;
  font-size: 0.85rem;
}

#energy-table caption {
  caption-side: top;
  text-align: left;
  padding: 4px 4px 10px 4px;
  font-weight: 700;
  font-size: 1rem;
}


#energy-table td {
  padding: 9px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  vertical-align: middle;
  white-space: nowrap;
}

#energy-table thead th {
  padding: 9px 10px;
  vertical-align: middle;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: rgba(30, 60, 40, 1); 
  backdrop-filter: blur(10px);
  z-index: 2;
  text-align: left;
  position: sticky;

}

#energy-table tfoot td {
  background: rgba(0,0,0,0.18);
  font-weight: 700;
}

#energy-table .cap-value,
#energy-table .units-value {
  font-family: monospace;
}

#energy-table td.adjust { white-space: nowrap; }

.step {
  padding: 5px 10px;
  margin: 0 3px;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.step:hover { background: rgba(255,255,255,0.3); }

/* ---- Charts section ---- */
#charts-section {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: row;
  gap: 10px;
  overflow: hidden;
  /* remove margin-top, flex-wrap, padding-top, border-top */
}

.chart-box {
  flex: 1;
  min-width: 280px;
  background: rgba(255,255,255,0.07);
  padding: 14px;
  border-radius: 10px;
}

.chart-box h4 {
  margin: 0 0 10px 0;
  text-align: center;
  color: #fff;
  font-size: 0.92rem;
}

/* ============================================================
   Investment Panel (bottom-right)
   ============================================================ */
#investment-panel {

  min-height: 0;
  flex: 1 1 0;
  overflow-y: auto;
  background: rgba(45, 110, 65, 0.88);
  border: 2px solid rgba(99,145,114,0.8);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  padding: 14px;
  justify-content: flex-end;   /* push content to the bottom half */

}
#investment-panel h4 {
  margin: 0 0 10px 0;
  text-align: left;
  font-size: 1rem;
}

.invest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin: 8px 0;
  background: rgba(0,0,0,0.12);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  transition: background 0.2s;
  font-size: 0.88rem;
}

.invest-item:hover { background: rgba(0,0,0,0.22); }

.invest-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #00e676;
  flex: 0 0 auto;
  cursor: pointer;
}

/* ============================================================
   Pause Overlay
   ============================================================ */
#pause-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.pause-panel {
  background: linear-gradient(135deg, #4a7c59, #2d5a27);
  padding: 40px 48px;
  border-radius: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pause-panel h2 { margin: 0 0 8px 0; }

.pause-panel button {
  padding: 12px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  min-width: 180px;
  transition: opacity 0.2s;
}

.pause-panel button:hover { opacity: 0.88; }

#resume-btn { background: #4CAF50; color: white; }
#reset-btn  { background: #ff9800; color: white; }
#exit-btn   { background: #f44336; color: white; }

/* ============================================================
   Level Complete Overlay
   ============================================================ */
#level-complete-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.level-complete-card {
  width: min(520px, 92vw);
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.25);
  backdrop-filter: blur(16px);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.level-complete-card h2 {
  margin: 0 0 12px 0;
  font-size: 1.8rem;
}

.level-complete-card p {
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0 0 20px 0;
}

.level-complete-card button {
  margin: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  transition: opacity 0.2s;
}


.level-complete-card button:hover { opacity: 0.85; }
.level-complete-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

#view-level-btn, #next-level-btn, #redo-btn, #close-level-complete-btn     
{ background: #4CAF50; color: white; }

.btn-best-time, .btn-best-budget {
  display: block;
  font-size: 0.78rem;
  opacity: 0.75;
  margin-top: 4px;
  font-family: monospace;
}

/* i beg to get dynamiic sizing */
 
.game-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 75%;
  min-width: 60;
  max-width:75;
  min-height: 0;
  overflow: hidden;
}

.game-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 calc(25% - 10px);  /* 25% minus the gap */
  min-height: 0;
  min-width: 20;                 /* was "10" — invalid */
  max-width: 25;
  overflow: hidden;
  
}

.game-left          { display: flex; flex-direction: column; overflow: hidden; }
#energy-table-wrap  { flex: 2 1 0; min-height: 0; overflow: auto; }
#charts-section     { flex: 1 1 0; min-height: 0; overflow: hidden; }

.chart-box {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  background: rgba(255,255,255,0.07);
  padding: 10px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#fuelChart-box {
  flex: 0.65 1 0;    /* smaller than the other two */
}

.units-divested { color: #ff6b6b; }

/* Investment effect tags */
.inv-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-family: monospace;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.inv-tag--demand-down {
  background: rgba(64, 145, 108, 0.35);
  border: 1px solid rgba(82, 183, 136, 0.6);
  color: #b7e4c7;
}

.inv-tag--demand-up {
  background: rgba(255, 152, 0, 0.25);
  border: 1px solid rgba(255, 152, 0, 0.55);
  color: #ffe0a3;
}

.inv-tag--gge {
  background: rgba(100, 180, 255, 0.18);
  border: 1px solid rgba(100, 180, 255, 0.45);
  color: #b3d9ff;
}

.inv-tag--gge-up {
  background: rgba(255, 80, 50, 0.22);
  border: 1px solid rgba(255, 80, 50, 0.55);
  color: #ffbdad;
}

.inv-tag--budget {
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid rgba(255, 215, 0, 0.5);
  color: #fff0a0;
}
/* ============================================================
   Level Intro Overlay
   ============================================================ */
#level-intro-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#level-intro-overlay.visible {
  display: flex;
}

.intro-card {
  background: linear-gradient(160deg, #183425 0%, #0d1f16 100%);
  border: 1px solid rgba(82, 183, 136, 0.30);
  border-radius: 16px;
  padding: 36px 40px 32px;
  max-width: 660px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 28px 70px rgba(0,0,0,0.65), inset 0 1px 0 rgba(255,255,255,0.05);
  scrollbar-width: thin;
  scrollbar-color: #52b788 transparent;
}
.intro-card::-webkit-scrollbar { width: 5px; }
.intro-card::-webkit-scrollbar-thumb { background: #52b788; border-radius: 4px; }

/* Badge + heading */
.intro-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #52b788;
  background: rgba(82,183,136,0.12);
  border: 1px solid rgba(82,183,136,0.28);
  border-radius: 20px;
  padding: 3px 13px;
  margin-bottom: 12px;
}

.intro-card h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 5px;
  color: #fff;
  line-height: 1.2;
}

.intro-tagline {
  font-size: 0.92rem;
  color: rgba(255,255,255,0.50);
  margin: 0 0 26px;
  font-style: italic;
}

.intro-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 18px 0;
}

/* Sections */
.intro-section { margin-bottom: 16px; }

.intro-section-heading {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: #52b788;
  margin-bottom: 6px;
}

.intro-section p {
  font-size: 0.875rem;
  line-height: 1.68;
  color: rgba(255,255,255,0.80);
  margin: 0 0 5px;
}
.intro-section p:last-child { margin-bottom: 0; }

/* NEW tag */
.intro-new {
  display: inline-block;
  font-size: 0.60rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: #e9c46a;
  color: #111;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 5px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* Mechanic cards grid */
.intro-mechanics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 6px;
}

.intro-mech {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 9px;
  padding: 11px 13px;
}

.intro-mech-icon { font-size: 1.2rem; margin-bottom: 4px; }
.intro-mech-label { font-size: 0.78rem; font-weight: 600; color: #fff; margin-bottom: 2px; }
.intro-mech-desc  { font-size: 0.74rem; color: rgba(255,255,255,0.58); line-height: 1.44; }

/* Checkpoint chips */
.intro-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.intro-chip {
  background: rgba(82,183,136,0.14);
  border: 1px solid rgba(82,183,136,0.35);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.80rem;
  font-weight: 600;
  color: #a8d5b5;
}

/* Warning box */
.intro-warning {
  background: rgba(230,57,70,0.11);
  border: 1px solid rgba(230,57,70,0.32);
  border-radius: 9px;
  padding: 11px 15px;
  margin-top: 8px;
}
.intro-warning .intro-section-heading { color: #e6646e; }
.intro-warning p { color: rgba(255,195,195,0.88) !important; margin: 0 !important; }

/* Start button */
.intro-start-btn {
  display: block;
  width: 100%;
  margin-top: 26px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #52b788 0%, #2d6a4f 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  box-shadow: 0 4px 18px rgba(82,183,136,0.28);
}
.intro-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(82,183,136,0.42);
}



/* achievements stuff */
.achievement-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  gap: 12px;
  margin-top: 12px;
}


.achievement-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 80px;
  text-align: center;
}


.achievement-circle {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
}

.achievement-circle.earned {
  background: #52b788;
  opacity: 1;
}

.achievement-circle.locked {
  background: #2d3a2e;
  opacity: 0.8;
}

.achievement-circle:hover .achievement-tooltip {
  display: block;
}
.achievement-circle.locked {
  background: #2d3a2e;
  opacity: 0.4;
}

.achievement-circle.locked:hover {
  opacity: 1;
}

.achievement-circle.locked:hover .achievement-tooltip {
  opacity: 1;
  color: #fff;
}

.achievement-tooltip {
  display: none;
  position: absolute;
  bottom: 60px;          /* appears above the icon */
  left: 50%;
  transform: translateX(-50%);
  background: #0a1f14;
  color: #fff;
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 6px;
  width: 160px;
  text-align: center;
  z-index: 9999;
  pointer-events: none;
  white-space: normal;
}


.achievement-label {
  font-size: 0.75rem;
  color: #ccc;
  margin-top: 2px;
}
