/* Unburnt Styling Sheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@400;600;800;900&display=swap');

:root {
  --bg-dark: #0e0805;
  --bg-darker: #050302;
  --primary: #ff5722;
  /* Sunset Orange */
  --primary-glow: rgba(255, 87, 34, 0.4);
  --secondary: #ffc107;
  /* Warm Gold */
  --secondary-glow: rgba(255, 193, 7, 0.3);
  --accent: #d84315;
  /* Clay Red */
  --text-light: #f7f1eb;
  --text-muted: #bdaea2;
  --parchment: #f2e5d5;
  --parchment-dark: #3a2618;
  --glass-bg: rgba(20, 12, 7, 0.85);
  --glass-border: rgba(255, 193, 7, 0.15);
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-light);
  font-family: var(--font-body);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  /* African-inspired geometric subtle grid background pattern */
  background-image:
    radial-gradient(var(--bg-dark) 40%, transparent 40%),
    repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255, 87, 34, 0.02) 10px, rgba(255, 87, 34, 0.02) 20px),
    repeating-linear-gradient(-45deg, transparent, transparent 10px, rgba(255, 193, 7, 0.02) 10px, rgba(255, 193, 7, 0.02) 20px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
}

/* Master Game Container */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1200px;
  max-height: 800px;
  aspect-ratio: 3/2;
  background-color: var(--bg-darker);
  border: 4px solid var(--accent);
  border-image: linear-gradient(135deg, var(--accent), var(--secondary), var(--primary)) 1;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 40px var(--primary-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top Navigation Bar / HUD */
header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background: rgba(10, 6, 4, 0.9);
  border-bottom: 2px solid rgba(255, 87, 34, 0.2);
  z-index: 200;
  /* Must be above canvas overlays (z-index 100) */
  flex-shrink: 0;
}

.logo-section h1 {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 2px;
  background: linear-gradient(to right, var(--secondary), var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 5px rgba(255, 87, 34, 0.3));
}

.logo-section p {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 3px;
  margin-top: -2px;
}

.hud-section {
  display: flex;
  gap: 30px;
  align-items: center;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.hud-value {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 20px;
  color: var(--secondary);
}

.hud-lives {
  display: flex;
  gap: 8px;
}

.shield-life {
  width: 24px;
  height: 24px;
  background-size: contain;
  background-repeat: no-repeat;
  transition: transform 0.3s ease, filter 0.3s ease;
}

/* Custom SVG Shield for Life indicators */
.shield-life.active {
  filter: drop-shadow(0 0 4px var(--primary));
}

.shield-life.lost {
  filter: grayscale(1) opacity(0.2);
  transform: scale(0.8) rotate(15deg);
}

/* Interactive Sound & Back buttons */
.btn-icon {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.05);
}

/* Gameplay Main Canvas Area */
#canvas-container {
  position: relative;
  flex: 1;
  width: 100%;
  background: url('./images/bg.jpg') center/cover no-repeat;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Input Area (Visual Display Overlay) */
#input-overlay {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  text-align: center;
  z-index: 5;
}

#typed-buffer {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 26px;
  color: var(--text-light);
  letter-spacing: 2px;
  min-height: 42px;
  padding: 8px 24px;
  background: rgba(14, 8, 5, 0.9);
  border: 1.5px solid var(--primary);
  border-radius: 24px;
  box-shadow: 0 0 15px rgba(255, 87, 34, 0.2), inset 0 0 10px rgba(0, 0, 0, 0.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#typed-buffer.active {
  border-color: var(--secondary);
  box-shadow: 0 0 20px var(--secondary-glow);
}

#typed-buffer.error {
  border-color: #f44336;
  box-shadow: 0 0 20px rgba(244, 67, 54, 0.4);
  animation: shake-small 0.15s ease-in-out;
}

/* ─── Typing Buffer Word Preview & Highlighting ─── */
.buf-typed {
  color: var(--secondary); /* glowing warm gold */
  text-shadow: 0 0 12px rgba(255, 193, 7, 0.7);
  font-weight: 900;
  letter-spacing: 2px;
}

.buf-untyped {
  color: rgba(255, 255, 255, 0.32);
  font-weight: 700;
  letter-spacing: 2px;
}

.buf-powerup .buf-typed {
  color: #64b5f6;
  text-shadow: 0 0 14px rgba(100, 181, 246, 0.85);
}

.buf-powerup .buf-untyped {
  color: rgba(144, 202, 249, 0.36);
}

.buf-hint {
  font-size: 11px;
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffab91;
  background: rgba(255, 87, 34, 0.22);
  border: 1px solid rgba(255, 87, 34, 0.45);
  border-radius: 12px;
  padding: 2px 8px;
  margin-left: 12px;
  display: inline-flex;
  align-items: center;
  box-shadow: 0 0 8px rgba(255, 87, 34, 0.3);
  animation: pulse-hint 1.8s infinite ease-in-out;
}

@keyframes pulse-hint {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* Screen Shake Animation on Damage */
.shake-screen {
  animation: screen-shake 0.4s ease-out;
}

@keyframes screen-shake {
  0% {
    transform: translate(1px, 1px) rotate(0deg);
  }

  10% {
    transform: translate(-1px, -2px) rotate(-1deg);
  }

  20% {
    transform: translate(-3px, 0px) rotate(1deg);
  }

  30% {
    transform: translate(0px, 2px) rotate(0deg);
  }

  40% {
    transform: translate(1px, -1px) rotate(1deg);
  }

  50% {
    transform: translate(-1px, 2px) rotate(-1deg);
  }

  60% {
    transform: translate(-3px, 1px) rotate(0deg);
  }

  75% {
    transform: translate(2px, 1px) rotate(-1deg);
  }

  90% {
    transform: translate(-1px, -1px) rotate(1deg);
  }

  100% {
    transform: translate(0px, 0px) rotate(0deg);
  }
}

@keyframes shake-small {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  75% {
    transform: translateX(4px);
  }
}

/* Modals & Screens Overlays (Glassmorphic) */
.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(12px) saturate(130%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding: 20px;
  overflow-y: auto;
}

.screen-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Card Styling for Modals */
.overlay-card {
  width: 100%;
  max-width: 650px;
  background: rgba(30, 18, 10, 0.95);
  border: 2px solid var(--glass-border);
  border-radius: 12px;
  padding: 24px 30px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 193, 7, 0.05);
  position: relative;
  overflow: hidden;
}

/* African Tribal Border decoration on Overlay Cards */
.overlay-card::before,
.overlay-card::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 8px;
  background-image: repeating-linear-gradient(90deg,
      var(--primary) 0px, var(--primary) 10px,
      var(--secondary) 10px, var(--secondary) 20px,
      var(--accent) 20px, var(--accent) 30px);
}

.overlay-card::before {
  top: 0;
}

.overlay-card::after {
  bottom: 0;
}

/* Menu Specific Layout */
.menu-title-logo {
  font-family: var(--font-heading);
  font-size: 68px;
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1;
  background: linear-gradient(135deg, var(--secondary), var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.menu-subtitle {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 6px;
  color: var(--text-muted);
  margin-bottom: 40px;
}

.menu-description {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  max-width: 500px;
  margin: 0 auto 40px auto;
}

.btn-container {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: var(--text-light);
  border: none;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 16px 36px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 15px rgba(216, 67, 21, 0.4);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(255, 87, 34, 0.6);
  filter: brightness(1.1);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-light);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 14px 28px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--secondary);
  color: var(--secondary);
}

/* ─── Category Selector Grid ─── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.category-card {
  background: rgba(14, 8, 5, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 11px 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  text-align: left;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--cat-color, var(--primary));
  border-radius: 10px 0 0 10px;
  transition: width 0.3s ease;
}

.category-card:hover {
  border-color: var(--cat-color, var(--primary));
  background: rgba(255, 255, 255, 0.03);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.category-card:hover::before {
  width: 6px;
}

.category-icon {
  font-size: 20px;
  margin-bottom: 4px;
  display: block;
}

.category-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 14.5px;
  color: var(--text-light);
  margin-bottom: 2px;
}

.category-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 6px;
}

.category-progress {
  font-size: 9.5px;
  color: var(--cat-color, var(--primary));
  font-weight: 600;
  letter-spacing: 0.5px;
}

.category-card.coming-soon {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.category-card.coming-soon:hover {
  transform: none;
  border-color: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

/* ─── Level Selector Grid ─── */
.level-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.level-card {
  background: rgba(14, 8, 5, 0.8);
  border: 1.5px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  text-align: left;
}

.level-card:hover {
  border-color: var(--primary);
  background: rgba(255, 87, 34, 0.05);
  transform: translateY(-2px);
}

.level-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.level-card.locked:hover {
  transform: none;
  border-color: rgba(255, 255, 255, 0.05);
  background: rgba(14, 8, 5, 0.8);
}

.level-num {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 14px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.level-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 18px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.level-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.level-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 6px;
  border-radius: 3px;
}

.level-badge.unlocked {
  background: rgba(76, 175, 80, 0.15);
  color: #4CAF50;
  border: 0.5px solid rgba(76, 175, 80, 0.3);
}

.level-badge.complete {
  background: rgba(255, 193, 7, 0.15);
  color: var(--secondary);
  border: 0.5px solid rgba(255, 193, 7, 0.3);
}

/* History Story Unlock Modal Layout (Ancient Parchment Scroll) */
.history-layout {
  display: flex;
  gap: 28px;
  text-align: left;
  max-width: 820px;
  width: 95%;
  background: linear-gradient(135deg, #f7ebd0 0%, #ecd2a4 35%, #e1c087 70%, #d2ad6d 100%);
  border: 4px double #783d16;
  border-radius: 10px;
  padding: 32px 35px;
  box-shadow: inset 0 0 45px rgba(85, 42, 10, 0.45), 0 25px 65px rgba(0, 0, 0, 0.95);
  position: relative;
  overflow: hidden;
}

/* Wooden Scroll Roller Tops/Bottoms */
.history-layout::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: linear-gradient(to right, #381a07, #783d16 20%, #a25824 50%, #783d16 80%, #381a07);
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.history-layout::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: linear-gradient(to right, #381a07, #783d16 20%, #a25824 50%, #783d16 80%, #381a07);
  box-shadow: 0 -2px 5px rgba(0,0,0,0.5);
}

.history-artwork-col {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.history-image-frame {
  width: 100%;
  height: 290px;
  border: 3px solid #783d16;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 12px 24px rgba(45, 20, 5, 0.5);
  background-color: #2b1709;
  position: relative;
}

.history-image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-image-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #783d16;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 14px;
  text-align: center;
  padding: 20px;
  background: radial-gradient(circle, rgba(120, 61, 22, 0.15) 0%, rgba(30, 15, 5, 0.6) 100%);
}

.history-text-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 15px;
}

/* Custom Scrollbar for Story reading on Parchment */
.history-text-col::-webkit-scrollbar {
  width: 7px;
}

.history-text-col::-webkit-scrollbar-track {
  background: rgba(120, 61, 22, 0.1);
  border-radius: 4px;
}

.history-text-col::-webkit-scrollbar-thumb {
  background: #8b4513;
  border-radius: 4px;
}

.history-header {
  border-bottom: 2px solid rgba(120, 61, 22, 0.25);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.history-pre {
  font-size: 11px;
  color: #8b0000;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  font-weight: 800;
  margin-bottom: 4px;
}

.history-title {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 900;
  color: #2b1404;
  line-height: 1.25;
}

.history-body {
  font-size: 15px;
  line-height: 1.8;
  color: #381e09;
  margin-bottom: 25px;
  white-space: pre-line;
  font-weight: 500;
}

.history-actions {
  display: flex;
  justify-content: flex-end;
  gap: 15px;
  margin-top: auto;
}

/* Instructions HUD / Box */
.level-intro-screen {
  text-align: center;
  max-width: 580px;
  width: 100%;
  padding: 22px 30px !important;
}

.intro-badge {
  color: var(--secondary);
  border: 1px solid var(--secondary);
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 2px;
  display: inline-block;
  margin-bottom: 10px;
}

.intro-title {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 800;
  color: var(--text-light);
  margin-bottom: 14px;
}

.intro-desc {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}

/* Game Over / Game Won Overlays */
.result-title {
  font-family: var(--font-heading);
  font-size: 48px;
  font-weight: 900;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.result-title.lose {
  color: #ff5722;
  text-shadow: 0 0 10px rgba(255, 87, 34, 0.3);
}

.result-title.win {
  color: #ffc107;
  text-shadow: 0 0 10px rgba(255, 193, 7, 0.3);
}

.result-subtitle {
  color: var(--text-muted);
  font-size: 16px;
  margin-bottom: 30px;
}

.stat-row {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 40px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 15px 25px;
  min-width: 120px;
}

.stat-num {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 26px;
  color: var(--secondary);
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* Style for missing/unburnt words preview in level intro screen */
.scroll-missing-word {
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 1.5px;
  text-shadow: 0 0 5px var(--primary-glow);
  background: rgba(255, 87, 34, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
  border-bottom: 1px dashed var(--primary);
  display: inline-block;
  line-height: 1.2;
}

/* ─── Endless Mode Banner & High Score Challenge ─── */
.endless-banner {
  background: linear-gradient(135deg, rgba(34, 15, 8, 0.95), rgba(18, 8, 4, 0.96));
  border: 1.5px solid rgba(255, 110, 64, 0.45);
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-align: left;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(255, 87, 34, 0.08);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.endless-banner::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 5px;
  background: linear-gradient(to bottom, #ff9100, #ff3d00);
  border-radius: 12px 0 0 12px;
  transition: width 0.3s ease;
}

.endless-banner:hover {
  transform: translateY(-2px);
  border-color: #ff9100;
  box-shadow: 0 12px 30px rgba(255, 87, 34, 0.25), inset 0 0 30px rgba(255, 87, 34, 0.15);
}

.endless-banner:hover::before {
  width: 7px;
}

.endless-banner-content {
  flex: 1;
}

.endless-badge {
  display: inline-block;
  font-size: 9.5px;
  font-family: var(--font-heading);
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ffab91;
  background: rgba(255, 87, 34, 0.18);
  border: 1px solid rgba(255, 87, 34, 0.35);
  padding: 2px 7px;
  border-radius: 15px;
  margin-bottom: 4px;
}

.endless-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.endless-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 6px;
}

.endless-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #ffd54f;
  font-weight: 600;
}

.endless-meta strong {
  color: #fff;
  font-weight: 800;
}

.endless-meta .dot-sep {
  color: rgba(255, 255, 255, 0.3);
}

.endless-btn {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 1px;
  padding: 12px 22px;
  white-space: nowrap;
  background: linear-gradient(135deg, #d84315, #ff5722);
  border: none;
  box-shadow: 0 4px 15px rgba(255, 87, 34, 0.4);
  cursor: pointer;
  border-radius: 6px;
  color: #fff;
  transition: all 0.25s ease;
}

.endless-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(255, 87, 34, 0.65);
  filter: brightness(1.1);
}

/* ─── Main Menu Layout (Desktop Default) ─── */
#screen-main-menu {
  background: none;
  padding: 0;
  position: relative;
  overflow: hidden;
}

#menu-bg {
  position: absolute;
  inset: 0;
  background: url('images/menu_bg.jpg') center/cover no-repeat;
  z-index: 0;
  transition: opacity 0.4s ease;
}

#menu-gradient-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10, 4, 2, 0.75) 0%, rgba(10, 4, 2, 0.2) 60%, transparent 100%);
  z-index: 1;
}

#menu-content-box {
  position: absolute;
  bottom: 12%;
  left: 6%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}

.menu-hero-title {
  font-family: var(--font-heading);
  font-size: 80px;
  font-weight: 900;
  color: #ff5722;
  margin: 0;
  margin-bottom: -15px;
  letter-spacing: 4px;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 0 8px 24px rgba(0, 0, 0, 0.8);
}

.menu-hero-subtitle {
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(255, 230, 200, 0.85);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  margin: 0;
}

.menu-start-btn {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #c62828, #ff5722);
  border: none;
  padding: 14px 48px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(200, 40, 0, 0.6), 0 0 0 2px rgba(255, 87, 34, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.menu-start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(255, 87, 34, 0.8), 0 0 0 2px rgba(255, 193, 7, 0.4);
}

/* ─── Custom On-Screen Virtual Keyboard (Mobile & Touch) ─── */
#virtual-keyboard {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 8px 6px 14px 6px;
  background: linear-gradient(to top, rgba(12, 6, 3, 0.98) 0%, rgba(22, 10, 5, 0.94) 100%);
  border-top: 1.5px solid rgba(255, 193, 7, 0.35);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 120;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.kb-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.kb-key {
  flex: 1;
  max-width: 42px;
  height: 44px;
  background: rgba(32, 16, 10, 0.92);
  border: 1px solid rgba(255, 193, 7, 0.35);
  border-radius: 7px;
  color: #f7f1eb;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: transform 0.08s ease, background-color 0.08s ease, border-color 0.08s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.kb-key:active, .kb-key.kb-pressed {
  transform: scale(0.92);
  background: linear-gradient(135deg, #d84315, #ff5722);
  border-color: #ffd54f;
  box-shadow: 0 0 14px rgba(255, 87, 34, 0.85);
  color: #fff;
}

.kb-key.kb-action {
  flex: 1.4;
  max-width: 52px;
  background: rgba(48, 20, 12, 0.95);
  border-color: rgba(255, 87, 34, 0.55);
  color: #ffc107;
  font-size: 18px;
}

.kb-key.kb-enter {
  color: #ffd54f;
  font-size: 19px;
}

/* ─── Mobile Responsiveness (Phones & Touch Devices) ─── */
@media (max-width: 768px) {
  body {
    padding: 0;
  }

  #game-container {
    width: 100vw;
    height: 100vh;
    height: -webkit-fill-available;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    aspect-ratio: auto;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }

  header {
    padding: 6px 12px;
  }

  .logo-section h1 {
    font-size: 17px;
    letter-spacing: 1px;
  }

  .logo-section p {
    font-size: 8px;
    letter-spacing: 1px;
  }

  .hud-section {
    gap: 10px;
  }

  .hud-value {
    font-size: 15px;
  }

  .hud-label {
    font-size: 8.5px;
  }

  /* Mobile Start Screen: Crimson Glow Atmosphere */
  #menu-bg {
    background: radial-gradient(circle at 50% 32%, #5c1808 0%, #300c04 45%, #100401 100%) !important;
  }

  #menu-gradient-overlay {
    background: radial-gradient(circle at 50% 50%, rgba(255, 87, 34, 0.15) 0%, transparent 70%) !important;
  }

  #menu-content-box {
    left: 50% !important;
    bottom: 20% !important;
    transform: translateX(-50%) !important;
    align-items: center !important;
    text-align: center !important;
    width: 90% !important;
    gap: 16px !important;
  }

  .menu-hero-title {
    font-size: 50px !important;
    letter-spacing: 2px !important;
    margin-bottom: -6px !important;
    text-align: center !important;
  }

  .menu-hero-subtitle {
    font-size: 11px !important;
    letter-spacing: 2.5px !important;
    text-align: center !important;
  }

  .menu-start-btn {
    padding: 14px 56px !important;
    font-size: 18px !important;
    width: auto !important;
    box-shadow: 0 6px 24px rgba(255, 87, 34, 0.65) !important;
  }

  /* Zoomed-out cobblestone background texture for gameplay */
  #canvas-container {
    background: url('./images/bg.jpg') center/240px repeat !important;
  }

  /* Lifted floating responsive virtual keyboard with clear generous space below */
  #virtual-keyboard {
    bottom: max(60px, calc(40px + env(safe-area-inset-bottom, 20px))) !important;
    left: 4px !important;
    right: 4px !important;
    width: calc(100% - 8px) !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255, 193, 7, 0.45) !important;
    padding: 7px 4px 8px 4px !important;
    gap: 3.5px !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.95), 0 0 12px rgba(255, 87, 34, 0.25) !important;
  }

  .kb-row {
    gap: 2.5px !important;
  }

  .kb-key {
    height: 38px !important;
    max-width: 38px !important;
    font-size: 14.5px !important;
    border-radius: 6px !important;
  }

  .kb-key.kb-action {
    height: 38px !important;
    max-width: 48px !important;
    font-size: 16px !important;
  }

  /* Input buffer positioned cleanly above elevated virtual keyboard */
  #input-overlay {
    bottom: 206px !important;
  }

  #typed-buffer {
    font-size: 16px !important;
    padding: 4px 14px !important;
    min-height: 32px !important;
    border-radius: 18px !important;
    border: 1.5px solid #ffc107 !important;
    background: rgba(14, 8, 5, 0.94) !important;
    box-shadow: 0 0 16px rgba(255, 193, 7, 0.35) !important;
  }

  .category-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    max-height: 48vh;
    overflow-y: auto;
  }

  .level-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    max-height: 52vh;
    overflow-y: auto;
  }

  .overlay-card {
    padding: 14px 16px;
    width: 95%;
    max-height: 94%;
    overflow-y: auto;
  }

  .menu-title-logo {
    font-size: 26px;
  }

  .endless-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
  }

  .endless-btn {
    width: 100%;
    text-align: center;
    padding: 10px 16px;
  }

  /* Result screen stat row grid fix (prevents stats cutting off) */
  .stat-row {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
    margin-bottom: 20px !important;
    width: 100% !important;
  }

  .stat-box {
    min-width: 0 !important;
    padding: 8px 3px !important;
  }

  .stat-num {
    font-size: 19px !important;
  }

  .stat-label {
    font-size: 8.5px !important;
    letter-spacing: 0.5px !important;
  }

  .result-title {
    font-size: 26px !important;
    margin-bottom: 6px !important;
  }

  .result-subtitle {
    font-size: 12.5px !important;
    margin-bottom: 16px !important;
    line-height: 1.35 !important;
  }
}