/* ==========================================================================
   STYLE COMBAT HUD
   ========================================================================== */

@keyframes heartPulse {

  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.15);
  }
}

@keyframes turnGlow {

  0%,
  100% {
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.4);
  }

  50% {
    box-shadow: 0 0 18px rgba(46, 204, 113, 0.8), inset 0 0 4px rgba(255, 255, 255, 0.2);
  }
}

/* Base Panel */
.combat-hud-panel {
  display: none;
  /* Hidden by default */
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto;
  gap: 16px;
  align-items: center;
  height: auto;
  padding: 16px;
  background: var(--window-surface, linear-gradient(180deg, rgba(20, 24, 38, 0.95) 0%, rgba(11, 14, 23, 0.98) 100%));
  border: 1px solid var(--window-border, rgba(245, 158, 11, 0.35));
  border-radius: 16px;
  box-sizing: border-box;
  box-shadow: var(--window-shadow, 0 8px 24px rgba(0, 0, 0, 0.5));
}

/* Combat mode: hide nav sections, show combatHUD */
body.combat-mode #minimapContainer,
body.combat-mode #hudSection,
body.combat-mode #optionsSection {
  display: none !important;
}

/* Show combatHUD when tab is active OR in combat mode */
body.combat-mode #combatHUD,
.combat-hud-panel.mobile-visible {
  display: grid !important;
  flex: 1;
}



/* HP Orb & Badges */
.status-container {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  width: 110px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.heart-orb {
  position: relative;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 3px solid #5f4827;
  background: #180909;
  overflow: hidden;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.6);
  cursor: help;
}

.heart-liquid {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  /* Dynamic */
  background: linear-gradient(0deg, #700000 0%, #c01010 60%, #e74c3c 100%);
  box-shadow: 0 -2px 8px rgba(231, 76, 60, 0.6);
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  animation: heartPulse 3s ease-in-out infinite;
}

.heart-text {
  position: absolute;
  width: 100%;
  text-align: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  font-size: 10px;
  font-weight: bold;
  text-shadow: 0 1px 3px #000, 0 -1px 3px #000;
  pointer-events: none;
  z-index: 10;
  font-family: 'Outfit', 'Inter', sans-serif;
}

.badges {
  position: absolute;
  right: 0px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 15;
}

.badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid #ffd700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: #ffffff;
  text-shadow: 0 1px 2px #000;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  font-family: monospace;
}

.badge-ap {
  background: radial-gradient(circle at 35% 35%, #54a0ff, #2e86de);
}

.badge-mp {
  background: radial-gradient(circle at 35% 35%, #1dd1a1, #10ac84);
}

/* Spell Bar Grid */
.spell-bar {
  display: grid;
  grid-template-rows: 46px; /* 1 row */
  grid-template-columns: repeat(10, 46px);
  grid-auto-flow: row;
  gap: 6px;
  padding: 4px;
  box-sizing: border-box;
  align-content: center;
  justify-content: center;
  height: auto;
  scrollbar-width: thin;
  scrollbar-color: #5f4827 #1c1511;
}

/* Combat Spell Bar Pagination */
.combat-spell-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.combat-spell-page-btn {
  background: var(--window-surface, linear-gradient(180deg, #1c1511 0%, #120e0b 100%));
  border: 1.5px solid var(--window-border, rgba(245, 158, 11, 0.35));
  border-radius: 6px;
  color: var(--window-accent, #f59e0b);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.combat-spell-page-btn:hover:not(:disabled) {
  border-color: var(--window-accent, #f59e0b);
  color: #ffffff;
  background: var(--window-accent-soft, rgba(245, 158, 11, 0.25));
  transform: scale(1.05);
}

.combat-spell-page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.combat-spell-pages {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  margin-left: 4px;
}

.combat-spell-page-dot {
  background: rgba(15, 23, 42, 0.8);
  border: 1.5px solid var(--window-border, rgba(245, 158, 11, 0.35));
  border-radius: 4px;
  color: var(--window-text, #a7977c);
  width: 22px;
  height: 18px;
  font-size: 9px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', 'Inter', sans-serif;
}

.combat-spell-page-dot:hover {
  border-color: var(--window-accent, #f59e0b);
  color: var(--window-accent, #f59e0b);
}

.combat-spell-page-dot.active {
  background: var(--window-accent, #f59e0b);
  border-color: var(--window-accent, #f59e0b);
  color: #0f172a;
  box-shadow: 0 0 8px var(--window-accent-soft, rgba(245, 158, 11, 0.6));
}

.spell-slot {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 6px;
  border: 2px solid var(--window-border, rgba(245, 158, 11, 0.35));
  background: var(--window-surface, linear-gradient(135deg, #2b211a 0%, #140e0b 100%));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s, filter 0.15s;
  flex-shrink: 0;
}

.spell-slot>* {
  pointer-events: none;
}

.spell-slot:hover {
  border-color: var(--window-accent, #f59e0b);
  box-shadow: 0 0 10px var(--window-accent-soft, rgba(245, 158, 11, 0.6));
  filter: brightness(1.15);
  z-index: 10;
}

.spell-slot.is-selected {
  border-color: var(--window-accent, #f59e0b);
  box-shadow: 0 0 14px var(--window-accent, #f59e0b), inset 0 0 6px var(--window-accent-soft, rgba(245, 158, 11, 0.35));
  filter: brightness(1.2);
  z-index: 10;
}

.spell-slot.is-unavailable {
  opacity: 0.55;
  filter: grayscale(0.5);
}

.spell-slot.is-locked {
  opacity: 0.25;
  filter: grayscale(1);
  cursor: not-allowed;
}

/* AP and Hotkey indicators */
.spell-ap {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: #2e86de;
  border: 1px solid #54a0ff;
  color: #ffffff;
  border-radius: 4px;
  padding: 0px 3px;
  font-size: 8px;
  font-weight: bold;
  font-family: monospace;
  z-index: 5;
  text-shadow: 0 0 2px #000;
}

.spell-hotkey {
  position: absolute;
  top: 2px;
  left: 3px;
  color: rgba(255, 222, 159, 0.6);
  font-size: 9px;
  font-weight: bold;
  font-family: monospace;
  z-index: 5;
}

/* Sigil adjustments */
.spell-slot .spellSigil {
  transform: scale(0.65);
}

/* Tooltip Description on Hover */
.spell-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: 250px;
  background: rgba(22, 17, 13, 0.98);
  border: 1.5px solid #d8b46a;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: #ffe2aa;
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 11px;
  line-height: 1.45;
  text-align: left;
  pointer-events: none;
  z-index: 3300;
}

.spell-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #d8b46a transparent transparent transparent;
}

.spell-slot:hover .spell-tooltip {
  display: block;
}

/* Action buttons area */
.action-bar {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  align-items: stretch;
  width: 160px;
}

.pass-turn-btn {
  width: 100%;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--window-border, #f59e0b);
  background: linear-gradient(135deg, var(--window-accent, #f59e0b) 0%, var(--window-accent-hover, #d97706) 100%);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px var(--window-accent-soft, rgba(245, 158, 11, 0.35));
  font-family: 'Outfit', 'Inter', sans-serif;
  text-align: center;
}

.pass-turn-btn:hover:not(:disabled) {
  transform: scale(1.02);
  filter: brightness(1.12);
  box-shadow: 0 6px 18px var(--window-accent-soft, rgba(245, 158, 11, 0.5));
}

.pass-turn-btn.is-active {
  background: linear-gradient(135deg, var(--window-accent, #f59e0b) 0%, var(--window-accent-hover, #d97706) 100%);
  border-color: var(--window-accent, #f59e0b);
  box-shadow: 0 0 18px var(--window-accent-soft, rgba(245, 158, 11, 0.7));
  animation: turnGlow 1.5s ease-in-out infinite;
}

.pass-turn-btn.is-ready {
  background: linear-gradient(135deg, var(--window-accent, #f59e0b) 0%, var(--window-accent-hover, #d97706) 100%);
  border-color: var(--window-border, #f59e0b);
  box-shadow: 0 0 12px var(--window-accent-soft, rgba(245, 158, 11, 0.6));
}

.pass-turn-btn.is-ready:hover:not(:disabled) {
  filter: brightness(1.15);
  box-shadow: 0 0 16px var(--window-accent-soft, rgba(245, 158, 11, 0.8));
}

.pass-turn-btn:disabled {
  background: rgba(30, 41, 59, 0.5);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.3);
  text-shadow: none;
  box-shadow: none;
  cursor: not-allowed;
}

.surrender-btn {
  width: 100%;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #721c24;
  background: linear-gradient(180deg, #c82333 0%, #bd2130 100%);
  color: #f5c6cb;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.surrender-btn:hover {
  background: #bd2130;
  color: #ffffff;
}

/* Spell Central Zone & Description */
.combat-spell-zone {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  height: auto;
  min-width: 530px;
}

.combat-spell-desc-inline {
  height: 48px;
  width: 100%;
  max-width: 680px;
  background: rgba(12, 9, 7, 0.82);
  border: 1.5px solid #5f4827;
  border-radius: 6px;
  padding: 4px 12px;
  box-sizing: border-box;
  color: #ffe2aa;
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.85);
}

.combat-spell-desc-empty {
  text-align: center;
  color: #a7977c;
  font-style: italic;
  font-size: 10.5px;
}

.combat-spell-desc-content-horizontal {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  justify-content: space-between;
}

.spell-desc-header-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.spell-desc-header-inline .spellSigil {
  transform: scale(0.4);
  transform-origin: center;
  margin: -16px;
  flex-shrink: 0;
}

.spell-name-inline {
  font-weight: bold;
  color: #ffd700;
  font-size: 12px;
}

.spell-lvl-inline {
  font-size: 9px;
  color: #a7977c;
}

.spell-stats-inline {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.spell-stat-pill {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 9.5px;
}

.spell-damage-inline {
  color: #a2dd7c;
  font-size: 10px;
  background: rgba(162, 221, 124, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(162, 221, 124, 0.12);
  flex-shrink: 0;
  font-weight: 500;
}

.spell-text-inline {
  color: #dcd3bf;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
  text-align: left;
  margin-left: 8px;
}

.combat-spell-target-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 240px;
  margin-left: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(216, 180, 106, 0.14);
}

.combat-spell-target-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #ffe2aa;
  font-size: 10px;
}

.combat-spell-target-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.combat-spell-target-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.combat-spell-target-outcome {
  margin-left: 0;
}

.close-spell-desc-btn {
  display: none !important;
}

/* ==========================================================================
   RESPONSIVE OVERRIDES (MOBILE & TABLET)
   ========================================================================== */

@media (max-width: 768px) {
  .combatSceneBoardPanel>.combat-hud-panel {
    display: grid !important;
  }

  .combat-hud-panel {
    grid-column: 1;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 8px;
    padding: 8px;
    height: auto !important;
    min-height: 0;
    overflow: hidden !important;
    align-items: center;
    justify-content: stretch;
    border-left: none;
    border-top: 1px solid rgba(216, 180, 106, 0.18);
    border-radius: 14px;
  }

  #combatSpellDesc {
    display: none !important;
  }

  /* Popover flottant mobile quand un sort est sélectionné */
  .combat-hud-panel #combatSpellDesc.combat-spell-desc-visible {
    display: flex !important;
    position: fixed;
    bottom: calc(max(150px, min(26dvh, 200px)) + 12px);
    left: 10px;
    right: 10px;
    width: calc(100% - 20px);
    height: auto;
    min-height: 80px;
    max-height: 140px;
    background: rgba(22, 17, 13, 0.98);
    border: 2px solid var(--ui-gold);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    padding: 12px 14px;
    z-index: 2900;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    overflow-y: auto;
  }

  .combat-spell-desc-content-horizontal {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
    position: relative;
    padding-right: 24px;
  }

  .spell-desc-header-inline {
    width: 100%;
    margin-bottom: 2px;
  }

  .spell-desc-header-inline .spellSigil {
    transform: scale(0.65) !important;
    margin: -6px 4px -6px -4px !important;
  }

  .spell-stats-inline {
    width: 100%;
    flex-wrap: wrap;
    gap: 4px;
  }

  .spell-damage-inline {
    margin: 2px 0;
  }

  .spell-text-inline {
    white-space: normal !important;
    font-size: 10.5px;
    line-height: 1.35;
    margin-left: 0 !important;
    margin-top: 4px;
    width: 100%;
  }

  .close-spell-desc-btn {
    display: inline-flex !important;
    position: absolute;
    top: 0;
    right: 0;
    width: 24px;
    height: 24px;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(216, 180, 106, 0.4) !important;
    color: var(--ui-gold) !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    padding: 0;
    min-height: auto !important;
    box-shadow: none !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    transition: background 0.2s, border-color 0.2s;
  }

  .close-spell-desc-btn:hover {
    background: rgba(255, 255, 255, 0.18) !important;
    border-color: var(--ui-gold) !important;
  }

  .status-container {
    grid-column: 1;
    grid-row: 1;
    width: 70px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-right: 0;
  }

  .heart-orb {
    width: 48px;
    height: 48px;
  }

  .badges {
    right: 0px;
  }

  .badge {
    width: 18px;
    height: 18px;
    font-size: 8px;
  }

  .action-bar {
    grid-column: 2;
    grid-row: 1;
    flex-direction: row;
    width: 100%;
    gap: 8px;
    margin-top: 0;
    align-items: center;
  }

  .pass-turn-btn {
    flex: 2;
    height: 32px;
    font-size: 11px;
  }

  .surrender-btn {
    flex: 1;
    height: 32px;
    font-size: 10px;
  }

  .combat-spell-zone {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: auto;
    min-width: 0;
    min-height: 0;
  }

  .spell-bar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 6px;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    width: 100%;
    height: 46px;
    align-items: center;
    justify-content: flex-start;
    padding: 4px 2px 6px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
  }

  .spell-slot {
    width: 38px;
    height: 38px;
    border-width: 1.5px;
    flex-shrink: 0;
  }

  .spell-slot .spellSigil {
    transform: scale(0.42);
  }

  /* Disable hover tooltips on touch devices, display simple label or handle tap */
  .spell-tooltip {
    display: none !important;
  }
}

/* ==========================================================================
   ADAPTATION DU MOTEUR VISUEL DE SORTS AU HUD DE COMBAT (46px)
   ========================================================================== */

/* Ajustement des variables globales pour la taille mini 46px */
.spell-slot[class*="vkey-"] {
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto !important;
  /* Force l'activation des hovers */
}

/* Forcer le rendu du fond radial propre au sort */
.spell-slot[class*="vkey-"] .spell-inner-frame {
  position: absolute;
  inset: 1.5px;
  border-radius: 4px;
  border: 1.5px solid var(--neon-color, #ffd700);
  background: radial-gradient(circle at center, var(--bg-soft, #151515) 0%, #050505 100%) !important;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  display: block !important;
}

/* Gérer les vagues d'énergie en arrière-plan */
.spell-slot[class*="vkey-"] .spell-energy-waves {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, var(--wave-color, transparent) 15%, transparent 85%) !important;
  filter: blur(3px);
  opacity: 0.65;
  display: block !important;
}

/* REDIMENSIONNEMENT DYNAMIQUE DES ICONES (Adaptation au slot de 46px) */
.spell-slot[class*="vkey-"] .spell-graphic-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  /* Calcule un scale automatique pour que l'icône rentre dans le slot de 46px */
  transform: translate(-50%, -50%) scale(0.65) !important;
  background: linear-gradient(to bottom, #ffffff, var(--core-bright, #fff)) !important;
  filter: drop-shadow(0 0 calc(var(--glow-radius, 12px) * 0.6) var(--neon-color, #fff)) !important;
  display: block !important;
  visibility: visible !important;
}

/* ==========================================================================
   RESPONSIVE MOBILE (Slots à 38px)
   ========================================================================== */
@media (max-width: 768px) {
  .spell-slot[class*="vkey-"] .spell-inner-frame {
    inset: 1px;
    border-width: 1px;
  }

  .spell-slot[class*="vkey-"] .spell-graphic-icon {
    /* Échelle encore plus petite pour le mode mobile à 38px */
    transform: translate(-50%, -50%) scale(0.48) !important;
    filter: drop-shadow(0 0 4px var(--neon-color, #fff)) !important;
  }
}

/* ==========================================================================
   HORIZONTAL TIMELINE WIDGET
   ========================================================================== */
.combat-timeline-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--window-surface, linear-gradient(180deg, rgba(20, 24, 38, 0.95) 0%, rgba(11, 14, 23, 0.98) 100%));
  border: 1px solid var(--window-border, rgba(245, 158, 11, 0.35));
  border-radius: 12px;
  padding: 8px 16px;
  box-sizing: border-box;
  height: 76px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  overflow: hidden;
  position: relative;
  z-index: 100;
  width: 100%;
  box-shadow: var(--window-shadow, 0 4px 14px rgba(0, 0, 0, 0.4));
}

.combat-timeline-bar.collapsed {
  height: 48px;
  padding: 6px 12px;
}

.combat-timeline-bar.collapsed .timeline-bar-track {
  display: none !important;
}

.timeline-bar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border-right: 1px dashed var(--window-border, rgba(245, 158, 11, 0.35));
  padding-right: 12px;
  height: 100%;
}

.timeline-bar-collapse-btn {
  background: var(--window-accent-soft, rgba(245, 158, 11, 0.15));
  border: 1px solid var(--window-border, rgba(245, 158, 11, 0.35));
  border-radius: 4px;
  color: var(--window-accent, #f59e0b);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 6px;
  transition: all 0.2s;
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-bar-collapse-btn:hover {
  background: var(--window-accent-soft, rgba(245, 158, 11, 0.3));
  border-color: var(--window-accent, #f59e0b);
}

.timeline-bar-round {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--window-text, #efe6d2);
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: bold;
}

.timeline-bar-round #combatTimelineRoundText {
  font-size: 16px;
  color: var(--window-accent, #f59e0b);
}

.timeline-bar-track {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-grow: 1;
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
  padding: 4px 2px;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--window-border, rgba(245, 158, 11, 0.35)) rgba(0, 0, 0, 0.2);
}

/* Timeline Cards */
.timeline-card {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  border: 2px solid var(--window-border, rgba(245, 158, 11, 0.35));
  background: var(--window-surface, radial-gradient(circle at center, #261f18 0%, #0d0a07 100%));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  cursor: help;
}

.timeline-card:hover {
  border-color: var(--window-accent, #f59e0b);
  transform: translateY(-2px);
}

.timeline-card.active {
  border-color: var(--window-accent, #f59e0b);
  box-shadow: 0 0 14px var(--window-accent-soft, rgba(245, 158, 11, 0.75)), inset 0 0 4px rgba(255, 255, 255, 0.15);
  transform: scale(1.08);
  z-index: 5;
  animation: activeCardPulse 1.5s infinite alternate;
}

@keyframes activeCardPulse {
  0% {
    box-shadow: 0 0 6px rgba(255, 63, 52, 0.4);
  }
  100% {
    box-shadow: 0 0 14px rgba(255, 63, 52, 0.9);
  }
}

.timeline-card.ko {
  opacity: 0.35;
  filter: grayscale(0.9) brightness(0.5);
  border-color: #2b211a;
}

.timeline-card.can-target {
  cursor: pointer;
}
.timeline-card.can-target:hover {
  border-color: #2ecc71 !important;
  box-shadow: 0 0 12px rgba(46, 204, 113, 0.8), inset 0 0 6px rgba(46, 204, 113, 0.3);
  transform: translateY(-3px) scale(1.05);
}
.timeline-card.out-of-range-target {
  opacity: 0.75;
}

/* Damage Preview Badge on Timeline Card */
.timeline-card-dmg-badge {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 15, 20, 0.95);
  color: #ff4757;
  border: 1px solid #ff4757;
  font-size: 8.5px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 2px 5px rgba(0,0,0,0.7);
  font-family: monospace, sans-serif;
}
.timeline-card-dmg-badge.out-range {
  color: #a4b0be;
  border-color: #747d8c;
  font-size: 8px;
  opacity: 0.8;
}
.timeline-card-dmg-badge.lethal {
  color: #ffffff;
  background: linear-gradient(135deg, #e74c3c, #8e44ad);
  border-color: #f1c40f;
  animation: pulseLethal 0.8s infinite alternate;
}

@keyframes pulseLethal {
  0% { transform: translateX(-50%) scale(1); box-shadow: 0 0 4px #e74c3c; }
  100% { transform: translateX(-50%) scale(1.1); box-shadow: 0 0 10px #f1c40f; }
}

.timeline-card-hover-preview {
  position: absolute;
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
}

/* Left HP bar inside timeline card */
.timeline-card-hp-bar {
  position: absolute;
  left: 2px;
  top: 4px;
  bottom: 4px;
  width: 3.5px;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 1px;
  overflow: hidden;
  z-index: 15;
}

.timeline-card-hp-fill {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  background: #2ecc71;
  transition: height 0.25s ease-out;
}

/* Red turn timer overlay for currently active card */
.timeline-card-time-overlay {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  background: rgba(255, 215, 0, 0.25);
  pointer-events: none;
  z-index: 3;
}

/* Avatar content scaling */
.timeline-card-avatar {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

body.isometric-mode .timeline-card-avatar .charSprite,
body.pixi-entities-mode .timeline-card-avatar .charSprite,
.timeline-card-avatar .charSprite {
  position: absolute !important;
  top: 55% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) scale(0.38) !important;
  transform-origin: center center !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

body.isometric-mode .timeline-card-avatar .monsterEntity,
.timeline-card-avatar .monsterEntity {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  transform: none !important;
  transform-origin: center center !important;
  margin: 0 !important;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}

body.isometric-mode .timeline-card-avatar .monsterEntity .monsterName,
body.isometric-mode .timeline-card-avatar .monsterEntity .monsterJoinCombatBtn,
body.isometric-mode .timeline-card-avatar .monsterEntity .monsterHpBarContainer,
.timeline-card-avatar .monsterEntity .monsterName,
.timeline-card-avatar .monsterEntity .monsterJoinCombatBtn,
.timeline-card-avatar .monsterEntity .monsterHpBarContainer {
  display: none !important;
}

body.isometric-mode .timeline-card-avatar .monsterEntity .monsterSprite,
.timeline-card-avatar .monsterEntity .monsterSprite {
  position: absolute !important;
  top: 52% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) scale(0.58) !important;
  transform-origin: center center !important;
  width: 64px !important;
  height: 64px !important;
  right: auto !important;
  bottom: auto !important;
  margin: 0 !important;
}

body.pixi-entities-mode .timeline-card-avatar .monsterEntity .monsterBody,
body.pixi-entities-mode .timeline-card-avatar .monsterEntity .monsterHead,
body.pixi-entities-mode .timeline-card-avatar .monsterEntity .monsterLimbs,
body.pixi-entities-mode .timeline-card-avatar .monsterEntity .monsterTail,
body.pixi-entities-mode .timeline-card-avatar .monsterEntity .monsterFace,
body.pixi-entities-mode .timeline-card-avatar .monsterEntity .monsterAdornment,
body.pixi-entities-mode .timeline-card-avatar .monsterEntity::before,
body.pixi-entities-mode .timeline-card-avatar .monsterEntity::after {
  display: block !important;
}

/* Boss specific scaling inside timeline cards to prevent cut-offs */
body.isometric-mode .timeline-card-avatar .monsterEntity.is-boss .monsterSprite,
.timeline-card-avatar .monsterEntity.is-boss .monsterSprite {
  transform: translate(-50%, -50%) scale(0.4) !important;
}

/* Timer Badge at bottom */
.hud-timer-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 18px;
  font-weight: 900;
  height: 38px;
  border-radius: 8px;
  box-sizing: border-box;
  color: #ffffff !important;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  box-shadow: 0 4px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: all 0.3s ease;
  margin-bottom: 4px;
}

.hud-timer-badge.is-player-turn {
  background: linear-gradient(135deg, #1e3d29 0%, #0c1c11 100%);
  border: 2px solid #2ecc71;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.4);
}

.hud-timer-badge.is-enemy-turn {
  background: linear-gradient(135deg, #3a1515 0%, #1a0808 100%);
  border: 2px solid #e74c3c;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.3);
}

/* Hide original initiative section on sidebar */
body.combat-mode .combatInitiativeSection {
  display: none !important;
}

/* Responsive tweaks for timeline */
@media (max-width: 768px) {
  .combat-timeline-bar {
    height: 64px;
    padding: 4px 8px;
  }
  .timeline-card {
    width: 40px;
    height: 40px;
  }
  .timeline-card-avatar .charSprite {
    transform: translate(-50%, -50%) scale(0.3);
  }
  body.isometric-mode .timeline-card-avatar .monsterEntity,
  .timeline-card-avatar .monsterEntity {
    transform: none !important;
  }
  body.isometric-mode .timeline-card-avatar .monsterEntity .monsterSprite,
  .timeline-card-avatar .monsterEntity .monsterSprite {
    transform: translate(-50%, -50%) scale(0.44) !important;
  }
  body.isometric-mode .timeline-card-avatar .monsterEntity.is-boss .monsterSprite,
  .timeline-card-avatar .monsterEntity.is-boss .monsterSprite {
    transform: translate(-50%, -50%) scale(0.3) !important;
  }
}

/* Floating Damage Indicators */
.combat-damage-indicator {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: #ff2a2a;
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 38px;
  font-weight: 900;
  text-shadow: 
    -2px -2px 0 #000,  
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0 3px 6px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 1000;
  animation-duration: 1.45s;
  animation-fill-mode: forwards;
  animation-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.combat-damage-indicator.float-up {
  bottom: 80%;
  animation-name: floatUpDamage;
}

.combat-damage-indicator.float-down {
  top: 80%;
  animation-name: floatDownDamage;
}

@keyframes floatUpDamage {
  0% {
    transform: translate(-50%, 0) scale(0.6);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -25px) scale(1.35);
    opacity: 1;
  }
  80% {
    transform: translate(-50%, -50px) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -65px) scale(0.8);
    opacity: 0;
  }
}

@keyframes floatDownDamage {
  0% {
    transform: translate(-50%, 0) scale(0.6);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, 25px) scale(1.35);
    opacity: 1;
  }
  80% {
    transform: translate(-50%, 50px) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, 65px) scale(0.8);
    opacity: 0;
  }
}

/* Instant Hover Damage Preview Card (Desktop) */
.combat-cell-hover-preview {
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #1f1814 0%, #0d0a07 100%);
  border: 1px solid #d8b46a;
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.8), 0 0 8px rgba(216,180,106,0.25);
  pointer-events: none;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 11px;
  color: #efe6d2;
  white-space: nowrap;
  opacity: 0;
  animation: fadeInQuick 0.15s forwards ease-out;
}

@keyframes fadeInQuick {
  to {
    opacity: 1;
    transform: translate(-50%, -4px);
  }
}

.combat-cell-hover-preview .preview-damage-value {
  color: #ff4d4d;
  font-weight: 800;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.combat-cell-hover-preview .preview-hp-change {
  color: #a7977c;
  font-weight: 500;
}

.combat-cell-hover-preview .preview-lethal {
  color: #ffd700;
  font-weight: bold;
  text-shadow: 0 0 4px rgba(255, 215, 0, 0.5);
  font-size: 10px;
  text-transform: uppercase;
  margin-top: 1px;
}

.combat-cell-hover-preview.out-of-range {
  border-color: #ff3333;
  box-shadow: 0 6px 16px rgba(0,0,0,0.8), 0 0 8px rgba(255, 50, 50, 0.2);
}

.combat-cell-hover-preview.out-of-range .preview-damage-value {
  color: #ff3333;
}

.combat-cell-hover-preview .preview-title {
  color: #d8b46a;
  font-weight: bold;
  border-bottom: 1px dashed rgba(216, 180, 106, 0.3);
  padding-bottom: 2px;
  margin-bottom: 4px;
  width: 100%;
  text-align: center;
}

.combat-cell-hover-preview .preview-target-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 2px 0;
}

.combat-cell-hover-preview .preview-target-row:last-child {
  border-bottom: none;
}

.combat-cell-hover-preview .preview-target-name {
  font-weight: bold;
  color: #efe6d2;
}