* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  background-color: #09090b;
  color: #f4f4f5;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
#top-bar {
  flex: 0 0 auto;
  background: rgba(18, 18, 24, 0.95);
  border-bottom: 1px solid #27272a;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 10;
}
.status-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hud-bar-container {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
}
.hud-track {
  position: relative;
  height: 18px;
  border-radius: 9px;
  background: #18181b;
  border: 1px solid #3f3f46;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.hud-fill {
  height: 100%;
  transition: width 0.1s linear;
}
.hud-label {
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 2;
}
#cycle-track {
  width: 140px;
}
#cycle-pin {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  line-height: 1;
  z-index: 3;
  transition: left 0.2s linear;
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.8));
}
#blood-fill {
  background: linear-gradient(90deg, #991b1b, #ef4444);
  width: 50%;
}
#sun-fill {
  background: linear-gradient(90deg, #d97706, #fbbf24);
  width: 100%;
}

/* --- Groupe des 3 Fioles de Quête --- */
.vials-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: rgba(24, 24, 30, 0.7);
  border: 1px solid #3f3f46;
  border-radius: 8px;
}
.vial-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.vial-icon {
  font-size: 13px;
  line-height: 1;
}
.vial-track {
  position: relative;
  width: 74px;
  height: 16px;
  border-radius: 8px;
  background: #141416;
  border: 1px solid #3f3f46;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.vial-fill {
  height: 100%;
  transition: width 0.15s ease-out;
}
.vial-label {
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 2;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: default;
  user-select: none;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.4);
}
#med-badge {
  display: none;
  background: rgba(6, 78, 59, 0.45);
  color: #6ee7b7;
  border: 1px dashed #10b981;
}
@keyframes pulse-fast-forward {
  0%, 100% {
    transform: scale(1);
    border-color: #a855f7;
    box-shadow: 0 0 4px rgba(168, 85, 247, 0.3);
  }
  50% {
    transform: scale(1.03);
    border-color: #d8b4fe;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.7);
  }
}
#fast-forward-badge {
  display: none;
  background: rgba(76, 29, 149, 0.4);
  color: #e9d5ff;
  border: 1px dashed #c084fc;
  animation: pulse-fast-forward 1.2s infinite ease-in-out;
}

/* Bouton Aide compact avec ? rouge */
.btn-help-compact {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #18181b;
  border: 2px solid #ef4444;
  color: #ef4444;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}
.btn-help-compact:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: scale(1.08);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.controls-hint {
  color: #71717a;
  font-size: 12px;
}
.author-credit {
  color: #52525b;
  font-size: 11px;
  font-weight: 400;
  margin-left: 6px;
}
.btn {
  background: #27272a;
  color: #f4f4f5;
  border: 1px solid #3f3f46;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}
.btn:hover {
  background: #3f3f46;
}
.btn-active {
  background: #7c2d12;
  border-color: #ea580c;
  color: #ffedd5;
}
#canvas-container {
  flex: 1 1 auto;
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}
canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

/* Bannière d'interdiction/accès au portail du niveau 2 */
#level-gate-banner {
  position: absolute;
  top: 75px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 18, 24, 0.94);
  border: 2px solid #ef4444;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  display: none;
  z-index: 35;
  box-shadow: 0 4px 25px rgba(0,0,0,0.7);
  text-align: center;
  max-width: 650px;
  line-height: 1.4;
  pointer-events: none;
}

#fallback-warning {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(185, 28, 28, 0.9);
  border: 1px solid #f87171;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  display: none;
  z-index: 20;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
#game-over-screen {
  position: absolute;
  inset: 0;
  background: rgba(10, 5, 8, 0.92);
  backdrop-filter: blur(6px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  color: #f4f4f5;
  text-align: center;
  gap: 16px;
}
#pause-screen {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 12, 0.85);
  backdrop-filter: blur(4px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 45;
  color: #f4f4f5;
  text-align: center;
  gap: 12px;
}
#pause-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fbbf24;
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
}
#game-over-title {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ef4444;
  text-shadow: 0 0 25px rgba(239, 68, 68, 0.6);
}
#game-over-reason {
  font-size: 16px;
  color: #d4d4d8;
  max-width: 480px;
  line-height: 1.5;
}

/* Écran de Victoire Finale */
#victory-screen {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #1e1b4b 0%, #030712 100%);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 55;
  color: #f4f4f5;
  text-align: center;
  padding: 24px;
}
#victory-title {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #fbbf24;
  text-shadow: 0 0 30px rgba(251, 191, 36, 0.6);
  margin-bottom: 10px;
}
.victory-card {
  max-width: 620px;
  background: rgba(24, 24, 32, 0.9);
  border: 1px solid #d97706;
  border-radius: 14px;
  padding: 24px 32px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Écran d'accueil narratif */
#start-screen {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #181124 0%, #07050b 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 70;
  color: #f4f4f5;
  text-align: center;
  gap: 18px;
  padding: 24px;
  cursor: pointer;
  user-select: none;
}
#start-title {
  font-size: 46px;
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #ef4444;
  text-shadow: 0 0 35px rgba(239, 68, 68, 0.7);
}
.start-story-card {
  max-width: 640px;
  background: rgba(24, 24, 32, 0.8);
  border: 1px solid #3f3f46;
  border-radius: 12px;
  padding: 18px 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.story-headline {
  font-size: 16px;
  color: #fbbf24;
  line-height: 1.4;
}
.story-text {
  font-size: 13px;
  color: #d4d4d8;
  line-height: 1.5;
}
.vials-mission-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(15, 15, 20, 0.7);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #27272a;
}
.mission-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #e4e4e7;
}
.mission-item .m-icon {
  font-size: 16px;
}
.survival-rules-box {
  background: rgba(127, 29, 29, 0.25);
  border: 1px solid #dc2626;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: #fecaca;
  line-height: 1.5;
}
.start-instruction {
  font-size: 16px;
  font-weight: 600;
  color: #fde047;
  letter-spacing: 1px;
  margin-top: 6px;
  padding: 10px 22px;
  background: rgba(39, 39, 42, 0.7);
  border: 1px solid #71717a;
  border-radius: 9999px;
  box-shadow: 0 0 20px rgba(253, 224, 71, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.start-instruction:hover {
  transform: scale(1.04);
  background: rgba(63, 63, 70, 0.9);
}
.key-cap {
  background: #18181b;
  border: 1px solid #52525b;
  border-bottom: 2px solid #3f3f46;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-weight: bold;
  color: #fafafa;
}

#help-modal {
  position: absolute;
  inset: 0;
  background: rgba(7, 7, 10, 0.88);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.help-card {
  background: #14141a;
  border: 1px solid #3f3f46;
  border-radius: 12px;
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 28px;
  box-shadow: 0 20px 45px rgba(0,0,0,0.7);
  color: #e4e4e7;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.help-card h2 {
  font-size: 22px;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #27272a;
  padding-bottom: 10px;
}
.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 4px;
}
.help-item {
  background: #1c1c24;
  border: 1px solid #2e2e38;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.5;
}
.help-item strong {
  display: block;
  color: #fafafa;
  font-size: 13px;
  margin-bottom: 4px;
}