/* ================================================================
   SHOOT THE CORRECT ANSWER — SimplyJavaScript Game
   styles.css
   ================================================================ */

/* ── Reset & base ── */
*, *::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: #0d0d0d;
  color: #f0f0f0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Layout ── */
#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: 8px 16px;
  background: #111;
  border-bottom: 2px solid #FFC107;
  flex-shrink: 0;
  z-index: 20;
  gap: 4px 8px;
}

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

.brand {
  font-size: 0.95rem;
  font-weight: 700;
  color: #FFC107;
  letter-spacing: 0.3px;
  white-space: nowrap;
  text-decoration: none;
}
.brand:hover { color: #ffca28; }

/* ── Game controls ── */
.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 #333;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: #aaa;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.8rem;
}
.ctrl-btn:hover {
  border-color: #FFC107;
  color: #FFC107;
  background: rgba(255,193,7,0.08);
}
.ctrl-btn.active {
  border-color: #FFC107;
  color: #FFC107;
}
.ctrl-btn svg { width: 14px; height: 14px; fill: currentColor; pointer-events: none; }

/* ── Stats row ── */
.stats {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: nowrap;
}

.stat-item {
  font-size: 0.78rem;
  color: #999;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.stat-value {
  color: #FFC107;
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 18px;
  text-align: center;
}

#combo-indicator {
  color: #ff9800;
  font-weight: 700;
  font-size: 0.78rem;
  opacity: 0;
  transition: opacity 0.3s;
}
#combo-indicator.visible { opacity: 1; }

/* ── Timer bar ── */
#timer-bar-container {
  height: 3px;
  background: #1a1a1a;
  flex-shrink: 0;
  z-index: 10;
}

#timer-bar {
  height: 100%;
  background: linear-gradient(90deg, #FFC107, #ff9800);
  width: 100%;
  transition: width 0.3s linear;
}
#timer-bar.danger { background: linear-gradient(90deg, #f44336, #ff5722); }

/* urgency pulse when time is running low */
#timer-bar.urgency { animation: timerPulse 0.5s ease-in-out infinite; }
@keyframes timerPulse {
  0%, 100% { opacity: 1; box-shadow: none; }
  50%      { opacity: 0.6; box-shadow: 0 0 10px rgba(244,67,54,0.7); }
}

/* urgency border glow on game area */
#game-area.urgency-glow {
  box-shadow: inset 0 0 40px rgba(244,67,54,0.12);
}

/* ── Question area ── */
#question-area {
  padding: 8px 16px;
  background: #141414;
  text-align: center;
  flex-shrink: 0;
  z-index: 10;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#question-text {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
  max-width: 780px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,193,7,0.12);
  border-radius: 8px;
  padding: 8px 18px;
}

/* ── Progress bar ── */
#progress-bar-container {
  height: 3px;
  background: #1a1a1a;
  flex-shrink: 0;
  z-index: 10;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #66bb6a, #43a047);
  transition: width 0.4s ease;
}

/* ── Feedback toast ── */
#feedback-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  font-size: 1.5rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 150;
  opacity: 0;
  text-shadow: 0 2px 12px rgba(0,0,0,0.7);
  transition: none;
  white-space: nowrap;
}
#feedback-text.show {
  animation: feedbackPop 0.8s ease-out forwards;
}
@keyframes feedbackPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  40%  { transform: translate(-50%, -50%) scale(0.95); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* ── Game area (balloon canvas) ── */
#game-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 100%, #131320 0%, #0a0a0a 80%);
}

/* subtle dev grid */
#game-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,193,7,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,193,7,0.025) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
}

/* ── Balloon ── */
.balloon {
  position: absolute;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.1s ease;
  will-change: transform, bottom;
  pointer-events: auto;
  touch-action: manipulation;
  animation: balloonBob var(--bob-duration, 2.4s) ease-in-out infinite var(--bob-delay, 0s);
}
.balloon:active { transform: scale(0.93); }

/* bobbing / alive animation */
@keyframes balloonBob {
  0%, 100% { margin-top: 0; }
  50%      { margin-top: calc(var(--bob-amount, -6px)); }
}

.balloon-body {
  width: 100%;
  height: 100%;
  border-radius: 50% 50% 50% 50% / 43% 43% 57% 57%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  position: relative;
  box-shadow:
    inset -6px -6px 16px rgba(0,0,0,0.3),
    0 0 18px rgba(255,255,255,0.04),
    0 4px 16px rgba(0,0,0,0.5);
  overflow: hidden;
}

/* shine highlight */
.balloon-body::before {
  content: '';
  position: absolute;
  top: 11%;
  left: 18%;
  width: 32%;
  height: 26%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.32), transparent);
  border-radius: 50%;
  pointer-events: none;
}

/* subtle glow aura */
.balloon-body::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.35;
}

/* balloon knot */
.balloon::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  pointer-events: none;
}

/* balloon string */
.balloon-string {
  position: absolute;
  bottom: -36px;
  left: 50%;
  width: 1px;
  height: 30px;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0.6;
}

.balloon-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  word-break: break-word;
  pointer-events: none;
  z-index: 1;
}

/* ── Balloon colors with glow ── */
.balloon-color-0 .balloon-body { background: linear-gradient(145deg, #ef5350, #c62828); }
.balloon-color-0 .balloon-body::after { box-shadow: 0 0 20px rgba(239,83,80,0.4); }
.balloon-color-0::after { border-top: 9px solid #c62828; }
.balloon-color-0 .balloon-string { background: #c62828; }

.balloon-color-1 .balloon-body { background: linear-gradient(145deg, #42a5f5, #1565c0); }
.balloon-color-1 .balloon-body::after { box-shadow: 0 0 20px rgba(66,165,245,0.4); }
.balloon-color-1::after { border-top: 9px solid #1565c0; }
.balloon-color-1 .balloon-string { background: #1565c0; }

.balloon-color-2 .balloon-body { background: linear-gradient(145deg, #66bb6a, #2e7d32); }
.balloon-color-2 .balloon-body::after { box-shadow: 0 0 20px rgba(102,187,106,0.4); }
.balloon-color-2::after { border-top: 9px solid #2e7d32; }
.balloon-color-2 .balloon-string { background: #2e7d32; }

.balloon-color-3 .balloon-body { background: linear-gradient(145deg, #ab47bc, #6a1b9a); }
.balloon-color-3 .balloon-body::after { box-shadow: 0 0 20px rgba(171,71,188,0.4); }
.balloon-color-3::after { border-top: 9px solid #6a1b9a; }
.balloon-color-3 .balloon-string { background: #6a1b9a; }

/* ── Pop animation ── */
@keyframes pop {
  0%   { transform: scale(1); opacity: 1; }
  30%  { transform: scale(1.25); opacity: 0.7; }
  100% { transform: scale(0); opacity: 0; }
}
.balloon.popped { animation: pop 0.28s ease-out forwards; pointer-events: none; }

.balloon.correct-pop .balloon-body {
  background: linear-gradient(145deg, #4caf50, #1b5e20) !important;
  box-shadow: 0 0 28px rgba(76,175,80,0.65);
}
.balloon.wrong-pop .balloon-body {
  background: linear-gradient(145deg, #f44336, #b71c1c) !important;
  box-shadow: 0 0 28px rgba(244,67,54,0.65);
}

/* shake animation for wrong answer */
.balloon.wrong-pop {
  animation: wrongShake 0.45s ease-out forwards !important;
}
@keyframes wrongShake {
  0%   { transform: translateX(0); opacity: 1; }
  15%  { transform: translateX(-10px) rotate(-4deg); }
  30%  { transform: translateX(10px) rotate(4deg); }
  45%  { transform: translateX(-6px) rotate(-2deg); }
  60%  { transform: translateX(6px) rotate(2deg); }
  75%  { transform: translateX(-2px); opacity: 0.6; }
  100% { transform: translateX(0) scale(0.3); opacity: 0; }
}

/* burst particles */
.burst-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 90;
  animation: burstFly 0.6s ease-out forwards;
}
@keyframes burstFly {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--bx, 30px), var(--by, -30px)) scale(0.3); }
}

/* correct glow flash on game area */
#game-area.correct-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--flash-x, 50%) var(--flash-y, 50%), rgba(76,175,80,0.2), transparent 60%);
  pointer-events: none;
  z-index: 80;
  animation: flashFade 0.5s ease-out forwards;
}
@keyframes flashFade {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Floating score text ── */
.float-text {
  position: absolute;
  font-size: 1.3rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 100;
  animation: floatUp 0.9s ease-out forwards;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-55px) scale(1.2); }
}

/* ── Screen overlays (start, game-over, pause) ── */
.screen-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.screen-overlay.hidden { display: none; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen-overlay:not(.hidden) > * {
  animation: fadeSlideIn 0.4s ease-out both;
}
.screen-overlay:not(.hidden) > *:nth-child(2) { animation-delay: 0.06s; }
.screen-overlay:not(.hidden) > *:nth-child(3) { animation-delay: 0.12s; }
.screen-overlay:not(.hidden) > *:nth-child(4) { animation-delay: 0.18s; }
.screen-overlay:not(.hidden) > *:nth-child(5) { animation-delay: 0.24s; }
.screen-overlay:not(.hidden) > *:nth-child(6) { animation-delay: 0.30s; }

.screen-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #FFC107;
  margin-bottom: 8px;
}

.screen-subtitle {
  font-size: 0.95rem;
  color: #aaa;
  margin-bottom: 28px;
  max-width: 460px;
  line-height: 1.6;
}

.screen-score {
  font-size: 2.8rem;
  font-weight: 800;
  color: #FFC107;
  margin-bottom: 4px;
}

.screen-score-label {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 22px;
}

.screen-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  justify-content: center;
}

.screen-stat { text-align: center; }

.screen-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}

.screen-stat-label {
  font-size: 0.72rem;
  color: #777;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Buttons ── */
.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 12px 32px;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: #FFC107;
  color: #111;
}
.btn-primary:hover {
  background: #ffca28;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(255,193,7,0.3);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: #ccc;
  border: 1.5px solid #444;
}
.btn-secondary:hover {
  border-color: #FFC107;
  color: #FFC107;
}

/* ── Difficulty selector ── */
.difficulty-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  justify-content: center;
}

.diff-btn {
  padding: 9px 20px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 2px solid #3a3a3a;
  border-radius: 6px;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  transition: all 0.2s;
}
.diff-btn:hover { border-color: #FFC107; color: #FFC107; }
.diff-btn.active {
  border-color: #FFC107;
  background: rgba(255,193,7,0.12);
  color: #FFC107;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  #top-bar { padding: 6px 10px; gap: 3px 6px; }
  .top-left { gap: 8px; }
  .brand { font-size: 0.78rem; }
  .ctrl-btn { width: 26px; height: 26px; }
  .ctrl-btn svg { width: 11px; height: 11px; }
  .game-controls { gap: 4px; }
  .stats { gap: 10px; }
  .stat-item { font-size: 0.68rem; }
  .stat-value { font-size: 0.75rem; min-width: 14px; }
  #question-area { padding: 6px 10px; min-height: 40px; }
  #question-text { font-size: 0.88rem; padding: 6px 12px; }
  .balloon-label { font-size: 0.7rem; }
  .screen-title { font-size: 1.35rem; }
  .screen-score { font-size: 2rem; }
  .screen-stats { gap: 16px; }
  .btn { padding: 10px 24px; font-size: 0.82rem; }
  #feedback-text { font-size: 1.2rem; }
}

@media (max-width: 380px) {
  .brand { font-size: 0.7rem; }
  .ctrl-btn { width: 24px; height: 24px; }
  .ctrl-btn svg { width: 10px; height: 10px; }
  .game-controls { gap: 3px; }
  .stats { gap: 8px; }
  .stat-item { font-size: 0.64rem; }
  .stat-value { font-size: 0.7rem; }
  #question-text { font-size: 0.8rem; }
  .balloon-label { font-size: 0.64rem; }
}
