@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&family=JetBrains+Mono:wght@600;700&display=swap');

:root {
  --sky-top:    #aee3ff;
  --sky-bottom: #eaf7ff;
  --ink:        #16241c;
  --ink-soft:   #4b6358;
  --card:       #ffffff;
  --line:       #dbe9e0;
  --accent:     #2d9e5f;
  --gold:       #e0a51c;
  --radius:     14px;
  --shadow:     0 6px 24px rgba(20,50,30,0.1);
}

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

body {
  font-family: 'Manrope', sans-serif;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px 32px;
}

/* ---------- HUD ---------- */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

#energy-box {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent);
  white-space: nowrap;
}
#energy-icon { margin-right: 4px; }
#energy-unit { font-size: 0.8rem; color: var(--ink-soft); margin-left: 4px; }

#goal-box {
  flex: 1;
  min-width: 180px;
}
#goal-label { font-size: 0.8rem; color: var(--ink-soft); margin-right: 4px; }
#goal-name  { font-weight: 700; font-size: 0.92rem; }

#goal-bar-track {
  margin-top: 6px;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
#goal-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  transition: width 0.4s ease;
}

/*Tutor */
#instruction {
  text-align: center;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

/* scene */
#scene {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 16px 0;
  height: 480px;
  overflow: hidden;
}

/* Sun */
#sun-wrap {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 90px;
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: transform 0.15s ease;
}
#sun-wrap:hover { transform: translateX(-50%) scale(1.05); }
#sun-wrap.pulse { transform: translateX(-50%) scale(0.92); }

#sun-img {
  width: 100%; height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(224,165,28,0.6));
}
#sun-placeholder {
  font-size: 4rem;
  filter: drop-shadow(0 0 14px rgba(224,165,28,0.7));
}

/* Слой фотонов */
#photon-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
.photon {
  position: absolute;
  color: var(--gold);
  font-size: 1.4rem;
  text-shadow: 0 0 8px rgba(224,165,28,0.9), 0 0 14px rgba(255,255,255,0.6);
  pointer-events: none;
  will-change: transform;
}

/* Cut panel */
#panel-cross-section {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 540px);
  z-index: 3;
  display: flex;
  flex-direction: column;
}

#panel-glass {
  height: 14px;
  background: linear-gradient(180deg, rgba(180,225,255,0.65), rgba(180,225,255,0.15));
  border: 1px solid rgba(120,180,220,0.5);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}

#cells-row {
  display: flex;
  gap: 6px;
  background: #143018;
  padding: 14px 10px;
  border-left: 1px solid rgba(120,180,220,0.5);
  border-right: 1px solid rgba(120,180,220,0.5);
}

.solar-cell {
  position: relative;
  flex: 1;
  height: 70px;
  background: linear-gradient(160deg, #1f4d2c, #0f2a16);
  border: 1px solid #2d6b3d;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.solar-cell.hit {
  transform: scale(1.04);
  box-shadow: 0 0 22px 4px rgba(224,165,28,0.85);
}

.cell-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,235,160,0.9), transparent 70%);
  opacity: 0;
  border-radius: 6px;
}
.cell-flash.flash-active {
  animation: flash-pop 0.35s ease;
}
@keyframes flash-pop {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; }
}

.cell-electron {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.18);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

.flying-electron {
  position: absolute;
  bottom: 50%;
  left: 50%;
  transform: translate(-50%, 0);
  font-size: 0.85rem;
  font-weight: 700;
  color: #9fe8ff;
  text-shadow: 0 0 6px rgba(159,232,255,0.9);
  font-family: 'JetBrains Mono', monospace;
  transition: transform 0.5s ease, opacity 0.5s ease;
  pointer-events: none;
}

#panel-base {
  height: 20px;
  background: linear-gradient(180deg, #5a5a5a, #2e2e2e);
  border-radius: 0 0 6px 6px;
  border: 1px solid #1c1c1c;
  border-top: none;
}

/* Physic hint*/
#physics-note {
  margin-top: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
  box-shadow: var(--shadow);
}
#physics-icon { margin-right: 6px; }

/* Popup */
#goal-overlay, #final-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10,40,25,0.55);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
  transition: opacity 0.3s;
}
#goal-overlay.hidden, #final-overlay.hidden { display: none; }

#goal-box-popup, #final-box-popup {
  background: var(--card);
  border-radius: 20px;
  padding: 36px 30px 28px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25);
  animation: pop-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes pop-in {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

#goal-popup-icon, #final-icon { font-size: 2.8rem; margin-bottom: 12px; }
#goal-popup-title, #final-title {
  font-size: 1.2rem; font-weight: 800; margin-bottom: 10px;
}
#goal-popup-text, #final-text {
  font-size: 0.95rem; color: var(--ink-soft); line-height: 1.55; margin-bottom: 20px;
}

#goal-popup-close {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 26px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
#goal-popup-close:hover { background: #248050; }

/* Mobile */
@media (max-width: 480px) {
  #scene { height: 440px; }
  .solar-cell { height: 56px; }
}
