/* ══════════════════════════════════════════════════════════
   South Park Theme — HangMan v2
   ══════════════════════════════════════════════════════════ */

:root {
  --sky: #87CEEB;
  --snow: #F0F4FF;
  --mountain: #C8D8E8;
  --mountain-dark: #9BABB8;
  --wood: #8B4513;
  --orange: #FF6B35;
  --green: #4CAF50;
  --red: #E74C3C;
  --yellow: #FFD700;
  --purple: #9B59B6;
  --blue: #3498DB;
  --dark: #2D2D2D;
  --card-bg: rgba(255, 255, 255, 0.92);
}

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

body {
  font-family: 'Nunito', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--dark);
  position: relative;
}

/* ── Background ──────────────────────────────────────── */

.bg-sky {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, var(--sky) 0%, #B8E2F2 60%, var(--snow) 100%);
  z-index: -3;
}

.bg-mountains {
  position: fixed; bottom: 80px; left: 0; right: 0; height: 300px;
  z-index: -2;
}

.mountain {
  position: absolute; bottom: 0;
  width: 0; height: 0;
  border-style: solid;
}

.m1 {
  left: -10%; 
  border-width: 0 200px 250px 200px;
  border-color: transparent transparent var(--mountain) transparent;
}
.m2 {
  left: 30%; 
  border-width: 0 300px 300px 300px;
  border-color: transparent transparent var(--mountain-dark) transparent;
}
.m3 {
  right: -5%; 
  border-width: 0 250px 220px 250px;
  border-color: transparent transparent var(--mountain) transparent;
}

/* Snow caps */
.mountain::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border-style: solid;
}

.m1::after {
  top: -250px; left: -40px;
  border-width: 0 40px 50px 40px;
  border-color: transparent transparent #fff transparent;
}
.m2::after {
  top: -300px; left: -60px;
  border-width: 0 60px 70px 60px;
  border-color: transparent transparent #fff transparent;
}
.m3::after {
  top: -220px; left: -50px;
  border-width: 0 50px 55px 50px;
  border-color: transparent transparent #fff transparent;
}

.bg-snow {
  position: fixed; bottom: 0; left: 0; right: 0; height: 80px;
  background: var(--snow);
  border-top: 3px solid #D0DCE8;
  z-index: -1;
  border-radius: 50% 50% 0 0 / 30px 30px 0 0;
}

/* ── Container ──────────────────────────────────────── */

.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  position: relative;
  z-index: 1;
}

/* ── Header ─────────────────────────────────────────── */

header {
  text-align: center;
  margin-bottom: 16px;
}

header h1 {
  font-family: 'Fredoka One', cursive;
  font-size: 2.4rem;
  color: var(--dark);
  text-shadow: 2px 2px 0 var(--yellow);
  margin-bottom: 6px;
}

.category-badge {
  display: inline-block;
  background: var(--purple);
  color: #fff;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ── Game Area ──────────────────────────────────────── */

.game-area {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.gallows-container {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.gallows-container svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* ── Word Letters ───────────────────────────────────── */

.word-display {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.word-letters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.letter-slot {
  width: 40px;
  height: 48px;
  border-bottom: 3px solid var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  font-size: 1.6rem;
  color: var(--dark);
  transition: all 0.3s ease;
}

.letter-slot.revealed {
  border-bottom-color: var(--green);
  color: var(--green);
  animation: popIn 0.3s ease;
}

.letter-slot.lost {
  border-bottom-color: var(--red);
  color: var(--red);
}

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Lives ──────────────────────────────────────────── */

.lives-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.lives-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--dark);
}

.hearts {
  display: flex;
  gap: 4px;
}

.heart {
  font-size: 1.3rem;
  transition: all 0.3s ease;
}

.heart.lost {
  filter: grayscale(1);
  opacity: 0.3;
  transform: scale(0.8);
}

/* ── Keyboard ───────────────────────────────────────── */

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.keyboard-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.keyboard button {
  width: 42px;
  height: 48px;
  border: none;
  border-radius: 10px;
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 3px 0 #2475A0;
}

.keyboard button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #2475A0;
}

.keyboard button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #2475A0;
}

.keyboard button:disabled {
  cursor: default;
  transform: none;
}

.keyboard button.correct {
  background: var(--green);
  box-shadow: 0 3px 0 #388E3C;
}

.keyboard button.wrong {
  background: var(--red);
  box-shadow: 0 3px 0 #C0392B;
  opacity: 0.5;
}

.keyboard button.used {
  background: #BDC3C7;
  box-shadow: 0 3px 0 #95A5A6;
  opacity: 0.4;
}

/* ── Actions ────────────────────────────────────────── */

.actions {
  text-align: center;
}

.btn-reset {
  padding: 10px 28px;
  border: none;
  border-radius: 12px;
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  color: #fff;
  background: var(--orange);
  box-shadow: 0 3px 0 #C45220;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reset:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #C45220;
}

.btn-primary {
  padding: 12px 36px;
  border: none;
  border-radius: 12px;
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem;
  color: #fff;
  background: var(--green);
  box-shadow: 0 4px 0 #388E3C;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #388E3C;
}

/* ── Overlay ────────────────────────────────────────── */

.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

.overlay-content {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  animation: slideUp 0.4s ease;
}

.overlay-emoji {
  font-size: 4rem;
  margin-bottom: 12px;
}

#overlayTitle {
  font-family: 'Fredoka One', cursive;
  font-size: 1.8rem;
  margin-bottom: 8px;
}

#overlayWord {
  font-size: 1.1rem;
  color: #666;
  margin-bottom: 24px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 480px) {
  header h1 { font-size: 1.8rem; }
  .letter-slot { width: 30px; height: 36px; font-size: 1.2rem; }
  .keyboard button { width: 32px; height: 38px; font-size: 0.9rem; }
  .gallows-container svg { width: 150px; height: 165px; }
  .overlay-content { padding: 28px 24px; margin: 0 16px; }
}
