/* ================================================================
   REGEX RUSH – SimplyJavaScript Game
   Tap the falling strings that match the pattern; let the rest fall.
   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: #0a0f0a;
  color: #f0f4f0;
  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(10, 15, 10, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(163, 230, 53, 0.2);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
  z-index: 30;
  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: #a3e635; }

.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(163, 230, 53, 0.14);
  border-color: rgba(163, 230, 53, 0.45);
  color: #a3e635;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(163, 230, 53, 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: #a3e635;
  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.life-lost { animation: life-pulse 0.5s ease; }
.stat-value.score-pop { animation: score-pop 0.4s cubic-bezier(0.34,1.56,0.64,1) both; }

@keyframes life-pulse { 0%,100% { color: #a3e635; } 40% { color: #f87171; transform: scale(1.3); } }
@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, #a3e635, #22d3ee);
  transition: width 0.5s ease;
  box-shadow: 0 0 8px rgba(163, 230, 53, 0.4);
}

/* ================================================================
   GAME CONTENT
   ================================================================ */
#game-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 18px 20px;
  gap: 12px;
  min-height: 0;
}

/* Pattern bar */
#pattern-bar {
  width: 100%;
  max-width: 720px;
  background: #10160f;
  border: 1px solid rgba(163, 230, 53, 0.25);
  border-radius: 12px;
  padding: 12px 18px;
  flex-shrink: 0;
}
#pattern-code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: #a3e635;
  margin-bottom: 4px;
}
#pattern-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
}
#concept-tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(34, 211, 238, 0.16);
  color: #67e8f9;
  padding: 3px 10px;
  border-radius: 20px;
}

/* Falling arena */
#arena {
  position: relative;
  width: 100%;
  max-width: 720px;
  flex: 1;
  min-height: 280px;
  background: #0d130c;
  border: 1px solid rgba(163, 230, 53, 0.18);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
}
#arena::after {
  /* danger strip near the bottom edge */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10%;
  background: linear-gradient(to top, rgba(248, 113, 113, 0.14), transparent);
  pointer-events: none;
}
#arena.arena-shake { animation: arena-shake 0.4s ease; }
@keyframes arena-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Falling chips */
.chip {
  position: absolute;
  top: -48px;
  transform: translateX(-50%);
  padding: 9px 14px;
  border-radius: 10px;
  background: #182018;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #eafbe6;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.15s, border-color 0.15s;
  z-index: 1;
}
.chip:hover { border-color: rgba(163, 230, 53, 0.5); box-shadow: 0 4px 18px rgba(163, 230, 53, 0.2); }
.chip.chip-hit-correct {
  animation: chip-pop-correct 0.35s ease forwards;
  pointer-events: none;
}
.chip.chip-hit-wrong {
  animation: chip-pop-wrong 0.35s ease forwards;
  pointer-events: none;
}
.chip.chip-missed {
  animation: chip-pop-wrong 0.35s ease forwards;
  pointer-events: none;
}
@keyframes chip-pop-correct {
  0% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) scale(1.5); opacity: 0; }
}
@keyframes chip-pop-wrong {
  0% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.6); opacity: 0; }
}

/* Floating score/penalty popup */
.pop-float {
  position: absolute;
  transform: translateX(-50%);
  font-family: 'Fira Code', 'Consolas', monospace;
  font-weight: 800;
  font-size: 0.95rem;
  pointer-events: none;
  animation: pop-float-up 0.7s ease forwards;
  z-index: 2;
}
.pop-float.is-good { color: #a3e635; text-shadow: 0 0 10px rgba(163, 230, 53, 0.6); }
.pop-float.is-bad  { color: #f87171; text-shadow: 0 0 10px rgba(248, 113, 113, 0.6); }
@keyframes pop-float-up {
  0%   { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -46px); }
}

/* ================================================================
   LEVEL COMPLETE PANEL
   ================================================================ */
#level-complete {
  width: 100%;
  max-width: 720px;
  background: #10160f;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  animation: card-in 0.3s ease both;
}
#level-complete.hidden { display: none; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.lc-header { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; font-weight: 800; }
#lc-icon { font-size: 1.3rem; }
#lc-tally { font-size: 0.85rem; font-weight: 700; color: #a3e635; }
#lc-explanation { font-size: 0.88rem; line-height: 1.55; color: rgba(255,255,255,0.7); }
#lc-explanation code {
  font-family: 'Fira Code', monospace;
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
}

#next-level-btn {
  align-self: flex-start;
  margin-top: 4px;
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #a3e635, #22d3ee);
  color: #0a0f0a;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
#next-level-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(163, 230, 53, 0.35); }
#next-level-btn:active { transform: translateY(0); }

/* ================================================================
   GAME OVER SCREEN
   ================================================================ */
#gameover-screen {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 6, 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, #10160f, #0a0f0a);
  border: 1px solid rgba(163, 230, 53, 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, #a3e635, #22d3ee);
  -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: #a3e635; }

#play-again-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #a3e635, #22d3ee);
  color: #0a0f0a;
  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(163, 230, 53, 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: #a3e635; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 600px) {
  #pattern-code { font-size: 0.95rem; }
  #pattern-info { font-size: 0.74rem; }
  .chip { padding: 7px 11px; font-size: 0.76rem; }
  #arena { min-height: 240px; }
  .stats { gap: 5px; }
  .stat-item { padding: 3px 8px; font-size: 0.65rem; }
}
