:root {
    --font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    --color-text: #f0f0f0;
    --color-bg: #1e1e1e;
    --color-bg-pattern: #1e1e1e;
    --color-builder-bg: rgba(0, 0, 0, 0.5);
    --color-field-border: #666;
    --color-field-bg: #2c2c2c;
    --color-field-text: #f0f0f0;
    --color-label: #ddd;
  --color-button-bg: #3c3c3c;
    --color-button-hover: #5c5c5c;
    --color-button-border: #444;
    --color-heading-bg: rgba(80, 80, 80, 0.3);
    --color-heading-border: #555;
    --color-row-border: #333;
    --color-hover-row: rgba(255, 255, 255, 0.07);
    --color-difficulty-bg: #444;
    --color-difficulty-text: #fff;
    --color-modal-bg: rgba(0, 0, 0, 0.4);
    --color-modal-content-bg: #1e1e1e;
    --color-modal-close: #aaa;
    --color-modal-close-hover: #fff;
    --color-modal-input-border: #666;
    --color-modal-input-bg: #2c2c2c;
    --color-modal-input-text: #f0f0f0;
    --color-dead: #888;
    --color-staggered: #ff6600;
    --color-bloodied: #cc0000;
    --color-untouched: #9adf9a;
    --color-injured: #ffd24d;
  }
  
  html,
  body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    color: var(--color-text);
  }
  html {
    background: var(--color-bg) url("images/dragon-scale-bg.png") repeat;
    background-size: 5%;
  }
  .img{
    width: 2rem;
    height: 2rem;
    background-size: contain;
  }
  
  #appContainer {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: var(--color-bg) url("images/dragon-scale-bg.png") repeat;
    background-size: 5%;
  }
  
  #buildEncounterScreen {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 1000px;
    min-width: 800px;
    width: 100%;
    padding: 20px;
    background-color: var(--color-builder-bg);
    border-radius: 8px;
    box-sizing: border-box;
    transition: transform 0.5s ease;
    z-index: 10;
  }
  
  #combatTrackerScreen {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(250%);
    max-width: 1000px;
    min-width: 800px;
    width: 100%;
    padding: 20px;
    background-color: var(--color-builder-bg);
    border-radius: 8px;
    box-sizing: border-box;
    transition: transform 0.5s ease;
    z-index: 20;
  }
  
  #combatantHeadingRow,
  .combatantRow.headingRow {
    display: flex;
    align-items: center;
    font-weight: bold;
    background-color: var(--color-heading-bg);
    border-bottom: 1px solid var(--color-heading-border);
    padding: 8px 0;
  }
  
  #combatantList {
    margin-bottom: 10px;
  }
  
  .combatantRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-row-border);
    padding: 0.5rem 0;
    transition: background-color 0.2s ease;
  }
  .combatantRow:hover {
    background-color: var(--color-hover-row);
  }
  
  .field {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    margin: 0 4px;
  }
  .field label {
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: var(--color-label);
  }
  
  .field input[type="text"],
  .field input[type="color"],
  .field select {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 6px;
    border: 1px solid var(--color-field-border);
    background-color: var(--color-field-bg);
    color: var(--color-field-text);
    font-size: 0.9rem;
  }
  .field select option {
    color: var(--color-field-text) !important;
  }
  .field input[type="color"] {
    color: transparent;
    text-indent: -9999px;
  }
  .field input[type="text"]:focus,
  .field select:focus,
  .field input[type="color"]:focus {
    outline: none;
    border-color: #aaa;
  }
  .field input[type="checkbox"] {
    margin-top: 6px;
    width: 18px;
    height: 18px;
    cursor: pointer;
  }
  
  .copyButtonField,
  .removeButtonField {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .copyButton,
  .removeButton,
  .newRowButton {
    background: url("images/remove.png") no-repeat center;
    background-size: contain;
    border: none;
    width: 32px;
    height: 32px;
    cursor: pointer;
    text-indent: -9999px;
    overflow: hidden;
  }
  .copyButton:hover,
  .removeButton:hover,
  .newRowButton:hover {
    filter: brightness(1.2);
  }
  .copyButton {
    background-image: url("images/copy.png");
  }
  .removeButton {
    background-image: url("images/remove.png");
  }
  .newRowButton {
    background-image: url("images/add.png");
    margin-right: 8px;
  }
  
  #newRowContainer {
    text-align: right;
    margin-top: 10px;
  }

  #globalButtons {
    display: flex;
    align-items: center;
    margin-top: 10px;
    justify-content: space-between;
}

.leftGroup, .rightGroup {
    display: flex;
    align-items: center;
}

.controlBtn {
    margin-left: 8px;
    padding: 6px 12px;
    border: none;
    background-color: transparent;
    color: transparent;
    font-size: 0;
    border-radius: 4px;
    cursor: pointer;
    transition: filter 0.2s ease;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 2.5rem;
    height: 2.5rem;
}

#savePresetButton {
    background-image: url("images/save.png");
}

#loadPresetButton {
    background-image: url("images/load.png");
}

#startCombatButton {
    background-image: url("images/roll.png");
}

#addRowButton {
    background-image: url("images/add.png");
}

.controlBtn:hover {
    filter: brightness(1.2);
}

  
  
  .typeField, .typeCell { width: 3rem; padding-left: 0.25rem; }
  .nameField, .nameCell { width: 8rem; padding-left: 0.25rem; }
  .sharesInitiativeField { width: 2.5rem; padding-left: 0.25rem; }
  .initiativeField { width: 3rem; padding-left: 0.25rem; }
  .sharedInitiativeField { width: 5rem; padding-left: 0.25rem; }
  .hitPointsField, .hpCell { width: 5rem; padding-left: 0.25rem; }
  .maxHPCell { width: 5rem; padding-left: 0.25rem; }
  .acField, .acCell { width: 3rem; padding-left: 0.25rem; }
  .colourSelectorField { width: 7.5rem; padding-left: 0.25rem; }
  .copyButtonField, .removeButtonField { width: 2.5rem; padding-left: 0.25rem; }
  .addCondCell, .addDmgCell, .killRevCell { width: 3rem; padding-left: 0.25rem; }
  .otherField { flex: 1; }
  
  .trackerRow {
    display: flex;
    align-items: center;
    padding: 5px;
    border-bottom: 1px solid var(--color-row-border);
    width: 100%;
  }
  .typeCell { flex: 0 0 3rem; }
  .nameCell { flex: 0 0 8rem; }
  .maxHPCell { flex: 0 0 5rem; }
  .hpCell { flex: 0 0 5rem; }
  .acCell { flex: 0 0 3rem; }
  .condCell { flex: 1 1 auto; min-width: 21rem; }
  .addCondCell { flex: 0 0 3rem; }
  .addDmgCell { flex: 0 0 3rem; }
  .killRevCell { flex: 0 0 3rem; }
  .removeCell { flex: 0 0 3rem; }
  
  .trackerBtn, .controlBtn {
    cursor: pointer;
    padding: 0;
    margin: 0.5rem;
  }
  
  #combatControls {
    text-align: center;
    display: flex;
    margin: 10px 0 0 0;
  }
  
  #difficultyBar {
    text-align: center;
    padding: 5px;
    background-color: var(--color-difficulty-bg);
    color: var(--color-difficulty-text);
    margin-top: 10px;
  }
  
  .swipe-out-left { transform: translateX(-100%); }
  .swipe-in-right { transform: translateX(0%); }
  .swipe-out-right { transform: translateX(100%); }
  .swipe-in-left { transform: translateX(0%); }
  
  .activeRow {
    animation: pulse 2s infinite;
    background-color: transparent;
  }
  @keyframes pulse {
    0% {
      box-shadow: inset 0 0 5px 2px var(--pulse-color, rgba(255, 255, 255, 0.2));
    }
    50% {
      box-shadow: inset 0 0 15px 2px var(--pulse-color, rgba(255, 255, 255, 0.6));
    }
    100% {
      box-shadow: inset 0 0 5px 2px var(--pulse-color, rgba(255, 255, 255, 0.2));
    }
  }
  .currentTurn {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: var(--color-modal-bg);
  }
  .modal-content {
    background-color: var(--color-modal-content-bg);
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 400px;
    border-radius: 8px;
    box-sizing: border-box;
  }

  .modal-title {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--color-text);
  }
  .modal-body {
    margin-bottom: 20px;
    color: var(--color-text);
  }
  .modal-footer {
    text-align: right;
  }
  .modal-footer .controlBtn {
    display: inline-block;
    margin: 0;
    padding: 0;
    cursor: pointer;
  }
  .modal-body input[type="text"],
  .modal-body input[type="number"],
  .modal-body select {
    width: 100%;
    box-sizing: border-box;
    padding: 6px;
    margin-bottom: 10px;
    border: 1px solid var(--color-modal-input-border);
    background-color: var(--color-modal-input-bg);
    color: var(--color-modal-input-text);
    font-size: 1rem;
  }
  .modal-checkbox-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 6px;
  }
  .modal-checkbox-row label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--color-text);
  }
  .modal-checkbox-row input[type="checkbox"] {
    accent-color: var(--color-untouched);
  }
  #customConditionField {
    display: none;
  }
  
  .trackerCell.condCell sup.removeCond {
    cursor: pointer;
  }
  .trackerCell.condCell {
    cursor: default;
  }
  
  .hpStatus.dead {
    color: var(--color-dead);
  }
  .hpStatus.staggered {
    color: var(--color-staggered);
  }
  .hpStatus.bloodied {
    color: var(--color-bloodied);
  }
  .hpStatus.injured {
    color: var(--color-injured);
  }
  .hpStatus.statusPulse {
    display: inline-block;
    transform-origin: center;
    animation: hpStatusPulse 0.6s ease-in-out 1;
  }
  @keyframes hpStatusPulse {
    0% { transform: scale(1); }
    25% { transform: scale(3); }
    50% { transform: scale(1); }
    75% { transform: scale(3); }
    100% { transform: scale(1); }
  }
  #fireworksCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 150;
    pointer-events: none;
  }
  
  #difficultyBarContainer {
    position: fixed;
    bottom: -5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1000px;
    z-index: 50;
  }
  .barBox {
    width: 100%;
    height: 2rem;
  }
  .barEmpty {
    position: relative;
    width: calc(100% - 2rem);
    height: 100%;
    margin: 0 auto;
    background-color: var(--color-bg);
    border-radius: 1rem;
    padding: 0 1rem;
    box-shadow: 0 0 0.5rem black inset;
  }
  .barLine {
    width: calc(100% - 2rem);
    height: 0.125rem;
    border-radius: 0.125rem;
    position: absolute;
    top: 0.9375rem;
    left: 1rem;
    box-shadow: 0 0 1rem white;
    background: linear-gradient(90deg,
              rgba(87,199,133,1) 5%,
              rgba(173,212,92,1) 20%,
              rgba(237,221,83,1) 35%,
              rgba(255,195,0,1) 50%,
              rgba(255,141,26,1) 65%,
              rgba(255,87,51,1) 80%,
              rgba(199,0,57,1) 95%);
  }
  .balanceBar {
    position: absolute;
    top: 0.5rem;
    left: 0;
    width: 0%;
    height: 1rem;
    background-color: rgba(255,255,255,0.1);
    border-radius: 1rem;
  }
  .slider {
    position: relative;
    height: 100%;
    width: 100%;
    margin: auto;
  }
  #currentBalance {
    position: absolute;
    top: 0;
    left: 50%;
    width: 5rem;
    height: 5rem;
    background: url("images/marker.png") no-repeat center;
    background-size: contain;
    transform: translate(-50%, -50%);
    cursor: pointer;
  }
  
  #staticTrackerWrapper {
    width: 800px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: top;
    min-height: 80vh; /* adjust to vertically center if desired */
    transform: translateX(250%);
    transition: transform 0.5s ease;
  }
  #staticTrackerWrapper.tracker-in {
    transform: translateX(0%);
  }

  #staticTracker{
    width:100%;
    background-color: var(--color-builder-bg);
  }
  
  .staticTrackerHeader {
    display: flex;
    border-bottom: 2px solid #555;
    padding: 0.5rem;
    font-weight: bold;
  }
  
  .staticTrackerRow {
    display: flex;
    padding: 0.5rem;
    border-bottom: 1px solid #333;
    align-items: center;
  }
  
  .staticTypeCell,.headerType{ flex: 1; }
  .staticNameCell,.headerName{flex: 3;}
  .staticACCell, .headerAC { flex: 3; }
  .staticCondCell,.headerConditions {flex: 6;}
  
  /* Highlight current turn row using the combatant’s colour */
  .currentTurn {
    background-color: rgba(255,255,255,0.1);
    /* Alternatively, you can set an inline style using the combatant’s colour */
  }
  
  #staticDifficultyBar {
    width: 800px;
    transform: translateY(-33%) translateX(0%);
  }
  
  #staticRoundInfo {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    transform: translateX(-50%);
    text-align: center;
    color: #fff;
    pointer-events: none;
    line-height: 1.3;
    z-index: 120;
  }
  #staticRoundLine,
  #staticRoundSpacer,
  #staticRoundTime {
    font-size: 1.1rem;
  }

  /* Keep the existing table layout reachable on narrow screens. */
  @media (max-width: 800px) {
    #buildEncounterScreen,
    #combatTrackerScreen {
      min-width: 0;
      width: 100%;
      padding: 12px;
      max-height: calc(100dvh - 40px);
      overflow: auto;
    }
    #combatantHeadingRow,
    #combatantList,
    #globalButtons {
      min-width: 760px;
    }
    .trackerRow {
      min-width: 960px;
      box-sizing: border-box;
    }
    .modal-content {
      width: min(400px, calc(100% - 24px));
    }
    #staticTrackerWrapper {
      width: 100%;
      overflow: auto;
      align-items: flex-start;
      min-height: 0;
      padding-bottom: 8rem;
    }
    #staticTracker,
    #staticDifficultyBar {
      min-width: 800px;
    }
  }
  

