/* ==========================================================================
   ZOMBIE ESCAPE — HORROR ADRENALINE & ACTION TYPING ADVENTURE
   ========================================================================== */

:root {
  --escape-cyan: #00f0ff;
  --escape-emerald: #10b981;
  --escape-crimson: #ef4444;
  --escape-amber: #f59e0b;
  --escape-purple: #a855f7;
  --escape-blood: #dc2626;
  --escape-bg: #060a14;
}

body.escape-body {
  background: radial-gradient(circle at 50% 20%, #0d172e 0%, #040711 100%);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* Screen Shake Effect Container */
.escape-screen-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: transform 0.05s ease;
  position: relative;
  overflow: visible;
}

.escape-screen-wrapper.shake {
  animation: screenShake 0.35s cubic-bezier(.36,.07,.19,.97) both;
}

.escape-screen-wrapper.heavy-shake {
  animation: heavyScreenShake 0.45s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes screenShake {
  10%, 90% { transform: translate3d(-4px, 0, 0); }
  20%, 80% { transform: translate3d(5px, 2px, 0); }
  30%, 50%, 70% { transform: translate3d(-7px, -3px, 0); }
  40%, 60% { transform: translate3d(7px, 2px, 0); }
}

@keyframes heavyScreenShake {
  0% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-12px, -8px, 0) rotate(-1deg); }
  30% { transform: translate3d(14px, 6px, 0) rotate(1.5deg); }
  45% { transform: translate3d(-10px, 8px, 0) rotate(-1deg); }
  60% { transform: translate3d(8px, -6px, 0); }
  75% { transform: translate3d(-4px, 2px, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

/* Blood Splatter Overlay on Screen */
.blood-splatter-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5000;
  opacity: 0;
  background: radial-gradient(circle, transparent 40%, rgba(185, 28, 28, 0.4) 80%, rgba(153, 27, 27, 0.85) 100%);
  transition: opacity 0.1s ease-out;
}

.blood-splatter-overlay.slash {
  opacity: 1;
  animation: bloodSplatterFade 0.75s ease-out forwards;
}

@keyframes bloodSplatterFade {
  0% { opacity: 1; transform: scale(1.05); }
  50% { opacity: 0.85; }
  100% { opacity: 0; transform: scale(1); }
}

/* Danger Vignette Overlay */
.danger-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4000;
  box-shadow: inset 0 0 100px rgba(239, 68, 68, 0);
  transition: box-shadow 0.3s ease;
}

.danger-vignette.active {
  box-shadow: inset 0 0 95px rgba(239, 68, 68, 0.75);
  animation: vignettePulse 0.6s infinite alternate;
}

@keyframes vignettePulse {
  0% { box-shadow: inset 0 0 70px rgba(239, 68, 68, 0.45); }
  100% { box-shadow: inset 0 0 120px rgba(239, 68, 68, 0.9); }
}

/* Sudden Ambush Alert Flash */
.ambush-banner {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(220, 38, 38, 0.95);
  border: 3px solid #fff;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  padding: 0.5rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.9), inset 0 0 20px rgba(0, 0, 0, 0.5);
  letter-spacing: 2px;
  text-transform: uppercase;
  z-index: 3000;
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.ambush-banner.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  animation: ambushStrobe 0.4s infinite alternate;
}

@keyframes ambushStrobe {
  0% { background: rgba(220, 38, 38, 0.95); }
  100% { background: rgba(245, 158, 11, 0.95); }
}

.escape-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.3rem 0.85rem 0.6rem 0.85rem;
  width: 100%;
  box-sizing: border-box;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* ==========================================================================
   TOP ESCAPE HUD
   ========================================================================== */
.escape-top-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: rgba(13, 20, 36, 0.92);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.85rem;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 240, 255, 0.1);
  flex-shrink: 0;
}

.escape-hud-left, .escape-hud-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.escape-hud-center {
  text-align: center;
  flex: 1;
}

.escape-header-level-title {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.2;
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}

.escape-world-tag {
  font-size: 0.74rem;
  color: var(--escape-cyan);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Health Bar */
.escape-health-box {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(239, 68, 68, 0.45);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.25);
}

.escape-health-bar {
  width: 85px;
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.escape-health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444, #f87171);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
  transition: width 0.2s ease-out;
}

/* ==========================================================================
   CANVAS STAGE & CINEMATIC HORROR ARENA
   ========================================================================== */
.escape-stage-arena {
  background: #060912;
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 35px rgba(0, 0, 0, 0.85), inset 0 0 50px rgba(0, 0, 0, 0.8);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.escape-objective-banner {
  background: linear-gradient(90deg, rgba(6, 11, 22, 0.95) 0%, rgba(13, 22, 42, 0.95) 100%);
  border-bottom: 1px solid rgba(0, 240, 255, 0.3);
  padding: 0.35rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-display);
}

.escape-radio-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--escape-amber);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.escape-objective-text {
  font-size: 0.92rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.4px;
}

/* Threat Distance & Danger Radar */
.escape-threat-container {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.escape-threat-proximity {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--escape-crimson);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  animation: proximityBlink 0.6s infinite alternate;
}

@keyframes proximityBlink {
  0% { opacity: 0.7; }
  100% { opacity: 1; text-shadow: 0 0 8px rgba(239, 68, 68, 0.8); }
}

.escape-threat-bar {
  width: 110px;
  height: 7px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.escape-threat-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
  transition: width 0.05s linear;
}

/* Canvas Viewport */
.escape-canvas {
  width: 100%;
  height: 190px;
  display: block;
}

/* Floating Action Text Container over canvas */
.escape-floating-text-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-action-text {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.25rem;
  color: #fff;
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.95), 0 2px 5px #000;
  pointer-events: none;
  animation: floatUpFade 0.75s ease-out forwards;
}

@keyframes floatUpFade {
  0% { transform: translateY(0) scale(0.7); opacity: 0; }
  25% { transform: translateY(-15px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-45px) scale(1); opacity: 0; }
}

/* ==========================================================================
   TELEMETRY HUD STRIP
   ========================================================================== */
.escape-telemetry-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  flex-shrink: 0;
}

.escape-stat-card {
  background: rgba(13, 20, 36, 0.88);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.escape-stat-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.escape-stat-val {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.25rem;
  line-height: 1;
}

/* ==========================================================================
   TYPING CONSOLE (PROMINENT, BIG & CRYSTAL CLEAR)
   ========================================================================== */
.escape-console-card {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(8, 14, 28, 0.98) 100%);
  border: 2px solid rgba(0, 240, 255, 0.4);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.85rem;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7), 0 0 25px rgba(0, 240, 255, 0.15);
  position: relative;
  flex-shrink: 0;
}

.escape-console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.escape-typing-box {
  background: rgba(4, 8, 18, 0.98);
  border: 2px solid rgba(0, 240, 255, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  min-height: 68px;
  height: auto;
  box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.65rem;
  line-height: 2.2rem;
  letter-spacing: 0.5px;
  position: relative;
  cursor: text;
  outline: none;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.escape-typing-box:focus-within, .escape-typing-box.focused {
  border-color: var(--escape-cyan);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.4);
}

#escapeTextDisplay {
  width: 100%;
  text-align: center;
  white-space: normal;
  word-break: break-word;
}

/* Keystroke Highlight Styling — High Contrast & Brightness */
.char-correct {
  color: var(--escape-emerald);
  font-weight: 800;
  text-shadow: 0 0 12px rgba(16, 185, 129, 0.85);
}

.char-current {
  color: #ffffff;
  font-weight: 900;
  background: rgba(0, 240, 255, 0.5);
  border-bottom: 4px solid var(--escape-cyan);
  box-shadow: 0 0 16px var(--escape-cyan);
  border-radius: 4px;
  padding: 0 3px;
  animation: cursorPulse 0.8s infinite;
}

@keyframes cursorPulse {
  0%, 100% { background: rgba(0, 240, 255, 0.45); }
  50% { background: rgba(0, 240, 255, 0.8); box-shadow: 0 0 20px var(--escape-cyan); }
}

.char-pending {
  color: #f1f5f9;
  font-weight: 700;
  opacity: 0.92;
}

/* ==========================================================================
   COUNTDOWN OVERLAY
   ========================================================================== */
.escape-countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 6000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.escape-countdown-overlay.active {
  opacity: 1;
  visibility: visible;
}

.escape-countdown-number {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 6rem;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 45px var(--escape-cyan);
  animation: countdownPop 0.85s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.escape-countdown-sub {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--escape-cyan);
  letter-spacing: 2px;
  margin-top: 0.5rem;
  text-transform: uppercase;
}

/* ==========================================================================
   30-LEVEL SELECTOR GRID MODAL
   ========================================================================== */
.escape-levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 0.5rem;
  max-height: 55vh;
  overflow-y: auto;
  padding: 0.5rem 0.2rem;
}

.escape-level-card-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.55rem 0.3rem;
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.escape-level-card-btn:hover:not(:disabled), .escape-level-card-btn.current {
  background: rgba(0, 240, 255, 0.25);
  border-color: var(--escape-cyan);
  transform: scale(1.06);
  box-shadow: 0 0 15px var(--escape-cyan);
}

.escape-level-card-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.escape-level-stars {
  font-size: 0.65rem;
  color: var(--escape-amber);
  letter-spacing: 1px;
}

/* ==========================================================================
   ADVANCED RESPONSIVE DESIGN & BROWSER WINDOW ADAPTABILITY
   ========================================================================== */

/* Laptops & Medium Screens (1024px - 1366px) */
@media (max-width: 1366px) {
  .escape-container {
    padding: 0.35rem 0.8rem 0.5rem 0.8rem;
    gap: 0.4rem;
  }
  .escape-canvas {
    height: 180px;
  }
  .escape-typing-box {
    font-size: 1.45rem;
    line-height: 2rem;
    min-height: 58px;
    padding: 0.45rem 0.8rem;
  }
  .escape-stat-val {
    font-size: 1.4rem;
  }
}

/* Tablets (768px - 1024px) */
@media (max-width: 1024px) {
  .escape-top-hud {
    padding: 0.35rem 0.6rem;
  }
  .escape-header-level-title {
    font-size: 0.95rem;
  }
  .escape-canvas {
    height: 160px;
  }
  .escape-telemetry-hud {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
  }
  .escape-stat-card {
    padding: 0.4rem 0.5rem;
  }
  .escape-stat-label {
    font-size: 0.62rem;
  }
  .escape-stat-val {
    font-size: 1.2rem;
  }
  .escape-typing-box {
    font-size: 1.3rem;
    line-height: 1.8rem;
    min-height: 52px;
  }
}

/* Small Tablets & Mobile Landscape (576px - 767px) */
@media (max-width: 767px) {
  .escape-telemetry-hud {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }
  .escape-stage-arena {
    height: 170px;
    min-height: 170px;
  }
  .escape-canvas {
    height: 170px;
    min-height: 170px;
    display: block;
    width: 100%;
  }
  .escape-typing-box {
    font-size: 1.25rem;
    line-height: 1.7rem;
    min-height: 48px;
    padding: 0.45rem 0.7rem;
  }
  .escape-objective-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  .escape-objective-text {
    font-size: 0.75rem;
  }
}

/* Small Mobile Phones (< 576px) */
@media (max-width: 575px) {
  .escape-container {
    padding: 0.2rem 0.35rem;
    gap: 0.25rem;
  }
  .escape-top-hud {
    padding: 0.2rem 0.35rem;
    gap: 0.25rem;
  }
  .escape-header-level-title {
    font-size: 0.82rem;
  }
  .escape-world-tag {
    font-size: 0.65rem;
  }
  .escape-stage-arena {
    height: 150px;
    min-height: 150px;
  }
  .escape-canvas {
    height: 150px;
    min-height: 150px;
    display: block;
    width: 100%;
  }
  .escape-typing-box {
    font-size: 1.15rem;
    line-height: 1.55rem;
    min-height: 46px;
    padding: 0.4rem 0.6rem;
  }
  .escape-console-header {
    font-size: 0.65rem;
  }
  .escape-stat-card {
    padding: 0.25rem 0.35rem;
  }
  .escape-stat-label {
    font-size: 0.58rem;
  }
  .escape-stat-val {
    font-size: 1.05rem;
  }
}

/* HIDE REDUNDANT VIRTUAL KEYBOARD ON MOBILE & TOUCH SCREENS */
@media (max-width: 900px), (pointer: coarse) {
  .tp-keyboard-wrapper,
  #visualKeyboardContainer,
  .virtual-keyboard {
    display: none !important;
  }
}

/* ==========================================================================
   MOBILE KEYBOARD ACCESSIBILITY & INPUT BRIDGE
   ========================================================================== */
.escape-mobile-input {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  height: 48px;
  opacity: 0.01;
  z-index: 90;
  font-size: 16px !important; /* Prevents iOS auto-zoom */
  pointer-events: auto;
  border: none;
  background: transparent;
  color: transparent;
  outline: none;
}

.escape-mobile-summon-btn {
  display: none;
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 240, 255, 0.25);
  border: 1px solid var(--escape-cyan);
  border-radius: 20px;
  padding: 0.45rem 1.25rem;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.35);
  z-index: 85;
  pointer-events: auto;
  cursor: pointer;
  animation: pulseButton 1.5s infinite alternate;
}

@media (max-width: 768px), (pointer: coarse) {
  .escape-mobile-summon-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }
}
