/* ================================================================
   HOISTING ELEVATOR – SimplyJavaScript Game
   Read a snippet, pick the floor: runs fine, undefined, TDZ, or
   not defined at all. Master var/let/const/function hoisting.
   styles.css
   ================================================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0b0f14;
  color: #f0f4f8;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game-wrapper { display: flex; flex-direction: column; height: 100%; width: 100%; position: relative; }

/* ================================================================
   TOP BAR
   ================================================================ */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: rgba(11, 15, 20, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(34, 211, 238, 0.2);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
  z-index: 20;
  gap: 6px 12px;
}

.top-left { display: flex; align-items: center; gap: 14px; min-width: 0; }

.brand {
  font-size: 0.95rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
  letter-spacing: -0.2px;
  white-space: nowrap;
  text-decoration: none;
  transition: opacity 0.15s;
}
.brand:hover { opacity: 0.75; }
.brand-accent { color: #22d3ee; }

.game-controls { display: flex; gap: 6px; align-items: center; }

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.18s, box-shadow 0.18s;
}
.ctrl-btn:hover {
  background: rgba(34, 211, 238, 0.14);
  border-color: rgba(34, 211, 238, 0.45);
  color: #22d3ee;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(34, 211, 238, 0.18);
}
.ctrl-btn:active { transform: translateY(0); box-shadow: none; }
.ctrl-btn svg { width: 14px; height: 14px; fill: currentColor; pointer-events: none; }

.stats { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; flex-shrink: 0; }

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat-value {
  color: #22d3ee;
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 18px;
  text-align: center;
  text-transform: none;
  letter-spacing: 0;
  transition: color 0.3s;
}
.stat-value.timer-low  { color: #fb923c; animation: timer-pulse 1s ease-in-out infinite; }
.stat-value.timer-crit { color: #f87171; animation: timer-pulse 0.5s ease-in-out infinite; }
.stat-value.score-pop  { animation: score-pop 0.4s cubic-bezier(0.34,1.56,0.64,1) both; }

@keyframes timer-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes score-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* ================================================================
   PROGRESS BAR
   ================================================================ */
#progress-bar-container { height: 3px; background: rgba(255, 255, 255, 0.05); flex-shrink: 0; z-index: 10; }
#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22d3ee, #6366f1);
  transition: width 0.5s ease;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.4);
}

/* ================================================================
   GAME CONTENT
   ================================================================ */
#game-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px 18px 32px;
}

#game-stage {
  width: 100%;
  max-width: 680px;
  display: flex;
  gap: 16px;
  align-items: stretch;
}

/* Elevator shaft - tracks overall climb across the whole game (1..totalFloors) */
#shaft {
  flex-shrink: 0;
  width: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#shaft-top-label,
#shaft-bottom-label {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  gap: 3px;
}
#shaft-top-label.is-win { color: #4ade80; text-shadow: 0 0 10px rgba(74, 222, 128, 0.6); }

#shaft-track {
  position: relative;
  flex: 1;
  width: 14px;
  border-radius: 7px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.09) 0px,
    rgba(255, 255, 255, 0.09) 5px,
    transparent 5px,
    transparent 12px
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* The elevator car - climbs on correct answers, drops on wrong ones */
#elevator-car {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 1.4rem;
  line-height: 1;
  transition: top 0.6s cubic-bezier(0.34, 1.4, 0.64, 1), filter 0.3s;
  filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.55));
  pointer-events: none;
  z-index: 2;
}
#elevator-car.car-correct { filter: drop-shadow(0 0 10px rgba(74, 222, 128, 0.9)); }
#elevator-car.car-wrong   { filter: drop-shadow(0 0 10px rgba(248, 113, 113, 0.9)); }
#car-floor-badge {
  margin-top: -2px;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.62rem;
  font-weight: 700;
  color: #22d3ee;
  background: #0b0f14;
  border: 1px solid rgba(34, 211, 238, 0.4);
  border-radius: 8px;
  padding: 0 5px;
}

#main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Answer choices */
#floor-panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* Code card */
.code-card {
  background: #10151c;
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 44px rgba(0,0,0,0.5);
  animation: card-in 0.35s ease both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.code-card.correct-flash { animation: flash-green 0.5s ease; }
.code-card.wrong-flash   { animation: flash-red 0.5s ease; }
@keyframes flash-green { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } 30% { box-shadow: 0 0 0 6px rgba(34,197,94,0.35); } 100% { box-shadow: 0 18px 44px rgba(0,0,0,0.5); } }
@keyframes flash-red   { 0% { box-shadow: 0 0 0 0 rgba(248,113,113,0); } 30% { box-shadow: 0 0 0 6px rgba(248,113,113,0.35); } 100% { box-shadow: 0 18px 44px rgba(0,0,0,0.5); } }

.code-card__top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.code-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.code-dot.red { background: #f87171; }
.code-dot.yellow { background: #fbbf24; }
.code-dot.green { background: #4ade80; }
.code-filename { font-size: 0.72rem; color: rgba(255,255,255,0.4); margin-right: auto; }
#concept-tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  padding: 3px 10px;
  border-radius: 20px;
}

#statement-text {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.92rem;
  line-height: 1.65;
  color: #e2e8f0;
  padding: 18px 18px 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-card__hint {
  font-size: 0.76rem;
  color: rgba(255,255,255,0.4);
  padding: 4px 18px 16px;
}

/* Answer buttons */
.floor-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 12px;
  background: #12181f;
  color: rgba(255,255,255,0.82);
  font-family: 'Inter', sans-serif;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
}
.floor-btn:hover:not(:disabled) {
  border-color: rgba(34, 211, 238, 0.4);
  background: rgba(34, 211, 238, 0.08);
  transform: translateX(3px);
  box-shadow: 0 6px 18px rgba(34, 211, 238, 0.15);
}
.floor-btn:active:not(:disabled) { transform: translateX(0) scale(0.98); }
.floor-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.floor-emoji {
  flex-shrink: 0;
  width: 26px;
  text-align: center;
  font-size: 1.1rem;
}
.floor-label code {
  font-family: 'Fira Code', monospace;
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.82em;
}

/* ================================================================
   FEEDBACK SECTION
   ================================================================ */
#feedback-section {
  width: 100%;
  max-width: 680px;
  background: #10151c;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: card-in 0.3s ease both;
}
#feedback-section.hidden { display: none; }

.fb-header { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 800; }
.fb-icon { font-size: 1.4rem; }
#fb-label.is-correct { color: #4ade80; }
#fb-label.is-wrong   { color: #f87171; }

#feedback-score-gained { font-size: 0.85rem; font-weight: 700; color: #22d3ee; }
#feedback-explanation { font-size: 0.9rem; line-height: 1.6; color: rgba(255,255,255,0.72); }
#feedback-explanation code {
  font-family: 'Fira Code', monospace;
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
}

#next-btn {
  align-self: flex-start;
  margin-top: 6px;
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  color: #0b0f14;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
#next-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(34, 211, 238, 0.35); }
#next-btn:active { transform: translateY(0); }

/* ================================================================
   GAME OVER SCREEN
   ================================================================ */
#gameover-screen {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 12, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
#gameover-screen.hidden { display: none; }

#gameover-content {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(160deg, #10151c, #0b0f14);
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: 22px;
  padding: 38px 32px 32px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  animation: card-in 0.4s ease both;
}

#go-grade {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.2;
  margin-bottom: 8px;
}
#go-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 10px; }
#go-score-val { font-size: 2.1rem; font-weight: 800; color: #f4f4f5; margin-bottom: 6px; }
#go-subtitle { font-size: 0.9rem; color: rgba(255,255,255,0.6); line-height: 1.55; margin-bottom: 22px; }

.go-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 26px; }
.go-stat { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: 12px; padding: 12px 6px; }
.go-stat-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: rgba(255,255,255,0.42); margin-bottom: 4px; }
.go-stat-value { font-size: 1.1rem; font-weight: 800; color: #22d3ee; }

#play-again-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  color: #0b0f14;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 12px;
  transition: transform 0.15s, box-shadow 0.15s;
}
#play-again-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(34, 211, 238, 0.35); }

#back-games-link {
  display: inline-block;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  transition: color 0.15s;
}
#back-games-link:hover { color: #22d3ee; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 620px) {
  #game-stage { gap: 10px; }
  #shaft { width: 40px; }
  #elevator-car { font-size: 1.1rem; }
  #statement-text { font-size: 0.82rem; padding: 14px 14px 4px; }
  .floor-btn { padding: 10px 12px; font-size: 0.8rem; }
  .floor-emoji { width: 20px; font-size: 0.95rem; }
  .stats { gap: 5px; }
  .stat-item { padding: 3px 8px; font-size: 0.65rem; }
}
