/* ===== CSS Variables ===== */
:root {
  --red-dark:   #5a0000;
  --red-mid:    #8b0000;
  --red-bright: #cc1111;
  --red-blood:  #990000;
  --red-glow:   #ff2020;
  --dark-bg:    #0a0000;
  --card-bg:    #080808;
  --card-border:#2a0808;
  --text-main:  #e8ddd0;
  --text-dim:   #7a6a60;
  --gold:       #c8a44a;
  --slot-empty: #3a1010;
  --slot-glow:  rgba(200,30,30,0.5);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; min-height: 100vh;
  overflow-x: hidden;
  font-family: 'Special Elite', serif;
  background: var(--dark-bg);
  color: var(--text-main);
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Ccircle cx='10' cy='10' r='4' fill='%23cc1111'/%3E%3C/svg%3E") 10 10, crosshair;
}

/* ===== Background Layers ===== */
.bg-layer { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

.bg-noise {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.35;
  mix-blend-mode: overlay;
}

.bg-vignette {
  background: radial-gradient(ellipse at 50% 50%,
    transparent 20%,
    rgba(0,0,0,0.5) 60%,
    rgba(0,0,0,0.92) 100%);
}

/* Animated gradient background */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse at 20% 50%, #3a0000 0%, transparent 50%),
    radial-gradient(ellipse at 80% 30%, #1a0000 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, #200505 0%, transparent 60%),
    #050000;
  animation: bgShift 12s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0%   { filter: hue-rotate(0deg) brightness(1); }
  50%  { filter: hue-rotate(-10deg) brightness(0.85); }
  100% { filter: hue-rotate(5deg) brightness(1.05); }
}

.bg-fog {
  background: radial-gradient(ellipse, rgba(120,0,0,0.08) 0%, transparent 70%);
  animation: fogMove 20s ease-in-out infinite;
  width: 150%; height: 150%;
}
#fog2 {
  animation-delay: -10s;
  animation-duration: 25s;
  background: radial-gradient(ellipse, rgba(80,0,0,0.06) 0%, transparent 70%);
}
@keyframes fogMove {
  0%   { transform: translate(-20%, -20%) scale(1); }
  50%  { transform: translate(10%, 10%) scale(1.2); }
  100% { transform: translate(-20%, -20%) scale(1); }
}

/* ===== Blood Drips ===== */
.blood-drips {
  position: fixed; top: 0; left: 0; width: 100%; z-index: 10;
  pointer-events: none;
  display: flex; gap: 0; align-items: flex-start;
}

.drip {
  width: 6px;
  background: linear-gradient(to bottom, #8b0000, #cc1111, #440000);
  border-radius: 0 0 50% 50%;
  animation: drip var(--drip-dur, 4s) ease-in var(--drip-delay, 0s) infinite;
  margin-right: var(--drip-gap, 30px);
}

@keyframes drip {
  0%   { height: 0; opacity: 0; }
  10%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { height: var(--drip-h, 80px); opacity: 0; }
}

/* ===== Header ===== */
.header {
  position: relative; z-index: 20;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1.2rem 2rem 0.5rem;
}

.lives-label {
  font-family: 'Oswald', sans-serif;
  font-weight: 700; letter-spacing: 0.1em;
  font-size: 0.85rem; color: var(--red-bright);
  display: block; margin-bottom: 0.4rem;
  text-shadow: 0 0 8px var(--red-bright);
}

.hearts {
  display: flex; gap: 0.35rem; flex-wrap: wrap;
}

.heart {
  font-size: 2.4rem;
  filter: drop-shadow(0 0 6px #cc0000);
  transition: all 0.3s ease;
  animation: heartbeat 2s ease-in-out infinite;
}

.heart.broken {
  filter: drop-shadow(0 0 4px #440000) grayscale(0.4) brightness(0.5);
  animation: shatter 0.5s ease forwards;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}

@keyframes shatter {
  0%   { transform: scale(1) rotate(0deg); opacity: 1; }
  30%  { transform: scale(1.3) rotate(-15deg); opacity: 1; }
  60%  { transform: scale(0.7) rotate(20deg); opacity: 0.6; }
  100% { transform: scale(0) rotate(-30deg); opacity: 0; }
}

.score-section {
  text-align: right;
}
.score-label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.75rem; letter-spacing: 0.15em;
  color: var(--text-dim); display: block;
}
.score-value {
  font-family: 'Creepster', cursive;
  font-size: 2.5rem; color: var(--gold);
  text-shadow: 0 0 12px rgba(200,164,74,0.6);
  line-height: 1;
}

/* ===== Main ===== */
.main {
  position: relative; z-index: 20;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 1rem 2rem;
  min-height: calc(100vh - 100px);
  justify-content: center;
  gap: 1.5rem;
}

.game-title {
  font-family: 'Creepster', cursive;
  font-size: clamp(2.5rem, 6vw, 4rem);
  color: var(--red-bright);
  text-shadow: 0 0 20px var(--red-glow), 0 0 60px rgba(200,0,0,0.3), 2px 2px 0 #000;
  letter-spacing: 0.04em;
  animation: titleFlicker 6s ease-in-out infinite;
}

@keyframes titleFlicker {
  0%, 95%, 100% { opacity: 1; text-shadow: 0 0 20px var(--red-glow), 0 0 60px rgba(200,0,0,0.3), 2px 2px 0 #000; }
  96%            { opacity: 0.7; text-shadow: none; }
  97%            { opacity: 1; }
  98%            { opacity: 0.5; }
}

/* ===== Clue Card ===== */
.card {
  position: relative;
  width: min(700px, 92vw);
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 6px;
  padding: 2.5rem 3rem;
  box-shadow:
    0 0 0 1px #1a0000,
    0 0 40px rgba(100,0,0,0.4),
    inset 0 0 60px rgba(0,0,0,0.8);
  animation: cardPulse 8s ease-in-out infinite;
}

@keyframes cardPulse {
  0%, 100% { box-shadow: 0 0 0 1px #1a0000, 0 0 40px rgba(100,0,0,0.4), inset 0 0 60px rgba(0,0,0,0.8); }
  50%       { box-shadow: 0 0 0 1px #3a0000, 0 0 70px rgba(160,0,0,0.5), inset 0 0 60px rgba(0,0,0,0.8); }
}

/* Corner decorations */
.card-corner {
  position: absolute;
  width: 22px; height: 22px;
  border-color: var(--red-mid);
  border-style: solid;
}
.card-corner.tl { top: -1px; left: -1px;  border-width: 3px 0 0 3px; }
.card-corner.tr { top: -1px; right: -1px; border-width: 3px 3px 0 0; }
.card-corner.bl { bottom: -1px; left: -1px;  border-width: 0 0 3px 3px; }
.card-corner.br { bottom: -1px; right: -1px; border-width: 0 3px 3px 0; }

.clue-text {
  font-family: 'Special Elite', serif;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  line-height: 1.7;
  text-align: center;
  color: var(--text-main);
  margin-bottom: 2rem;
  min-height: 4rem;
}

/* ===== Letter Slots ===== */
.letter-slots {
  display: flex; flex-wrap: wrap;
  justify-content: center; gap: 0.5rem;
}

.slot-group {
  display: flex; gap: 0.3rem; align-items: flex-end;
}

.slot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 48px;
  border-bottom: 3px solid var(--red-blood);
  font-family: 'Oswald', sans-serif;
  font-size: 1.4rem; font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
  position: relative;
}

.slot.revealed {
  color: var(--red-glow);
  border-bottom-color: var(--red-bright);
  text-shadow: 0 0 8px var(--red-glow);
  animation: revealLetter 0.4s ease;
}

.slot.space {
  border-bottom: none;
  width: 20px;
}

@keyframes revealLetter {
  0%   { transform: translateY(-10px) scale(1.3); opacity: 0; }
  60%  { transform: translateY(2px); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* ===== Wrong Letters ===== */
.wrong-section {
  font-family: 'Oswald', sans-serif;
  font-size: 0.9rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}
.wrong-label { color: var(--red-mid); margin-right: 0.5rem; }
.wrong-letters {
  color: #ff4444;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

/* ===== Keyboard ===== */
.keyboard {
  display: flex; flex-direction: column;
  align-items: center; gap: 0.4rem;
  width: 100%;
}

.key-row {
  display: flex; gap: 0.3rem; justify-content: center; flex-wrap: wrap;
}

.key {
  width: clamp(32px, 5.5vw, 44px);
  height: clamp(38px, 6vw, 50px);
  background: linear-gradient(135deg, #1a0505 0%, #0d0000 100%);
  border: 1px solid #3a1010;
  border-bottom: 3px solid #5a1515;
  border-radius: 5px;
  color: var(--text-main);
  font-family: 'Oswald', sans-serif;
  font-size: clamp(0.75rem, 1.8vw, 1rem);
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.key::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.04), transparent);
  pointer-events: none;
}

.key:hover:not(:disabled) {
  background: linear-gradient(135deg, #3a0505 0%, #200000 100%);
  border-color: var(--red-mid);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(150,0,0,0.5);
}

.key:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.key:disabled {
  cursor: not-allowed;
  opacity: 0.25;
  transform: none;
}

.key.correct {
  background: linear-gradient(135deg, #1a4a0a, #0d2005) !important;
  border-color: #3a8020 !important;
  border-bottom-color: #5ab030 !important;
  color: #6dff30 !important;
  text-shadow: 0 0 6px #4ddf10;
  opacity: 1 !important;
}

.key.wrong {
  background: linear-gradient(135deg, #3a0000, #1a0000) !important;
  border-color: #600000 !important;
  color: #5a2020 !important;
  opacity: 0.4 !important;
}

/* ===== Overlays ===== */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}
.overlay.active { display: flex; }

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

.overlay-box {
  position: relative;
  background: #080000;
  border: 2px solid var(--red-mid);
  border-radius: 8px;
  padding: 2.5rem 3rem;
  max-width: 460px; width: 90%;
  text-align: center;
  box-shadow: 0 0 80px rgba(150,0,0,0.6), inset 0 0 40px rgba(0,0,0,0.8);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0%   { transform: scale(0.7) rotate(-3deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.overlay-icon { font-size: 3.5rem; margin-bottom: 0.75rem; }
.overlay-title {
  font-family: 'Creepster', cursive;
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  text-shadow: 0 0 20px currentColor;
}

.win-box .overlay-title  { color: var(--gold); }
.lose-box .overlay-title { color: var(--red-bright); }
.gameover-box .overlay-title { color: var(--red-bright); animation: titleFlicker 1.5s infinite; }

.overlay-msg {
  font-family: 'Special Elite', serif;
  font-size: 1rem; line-height: 1.6;
  color: var(--text-dim); margin-bottom: 1.5rem;
}

.score-final {
  font-family: 'Oswald', sans-serif;
  font-size: 1.2rem; color: var(--gold);
  margin-bottom: 1.5rem;
  text-shadow: 0 0 10px rgba(200,164,74,0.5);
}

.btn-next {
  background: linear-gradient(135deg, var(--red-dark), #200000);
  border: 1px solid var(--red-mid);
  border-bottom: 3px solid var(--red-bright);
  color: #fff;
  font-family: 'Oswald', sans-serif;
  font-size: 1rem; font-weight: 600;
  letter-spacing: 0.1em;
  padding: 0.75rem 2rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.btn-next:hover {
  background: linear-gradient(135deg, var(--red-mid), #350000);
  box-shadow: 0 0 20px rgba(200,0,0,0.5);
  transform: translateY(-2px);
}

/* ===== Shake animation for wrong answer ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-8px) rotate(-1deg); }
  30%  { transform: translateX(8px)  rotate(1deg); }
  45%  { transform: translateX(-6px); }
  60%  { transform: translateX(6px); }
  75%  { transform: translateX(-3px); }
  90%  { transform: translateX(3px); }
}

.shake { animation: shake 0.5s ease; }

/* ===== Progress indicator ===== */
.progress-bar-wrap {
  width: min(700px, 92vw);
  height: 3px;
  background: #1a0000;
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(to right, var(--red-mid), var(--red-bright));
  transition: width 0.6s ease;
  box-shadow: 0 0 6px var(--red-glow);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .card { padding: 1.5rem 1.2rem; }
  .slot { width: 30px; height: 40px; font-size: 1.1rem; }
  .key { width: 28px; height: 34px; font-size: 0.7rem; }
  .header { padding: 0.8rem 1rem 0.3rem; }
  .heart { font-size: 1.8rem; }
}
