#token-hud .hp-loss-wrap {
  position: absolute;
  left: 75px;
  display: none;
  top: 50%;
  width: 48px;
  text-align: start;
  overflow-y: auto;
}

#token-hud .hp-loss-wrap-col1 {
  transform: translate(-200%, -50%);
}

#token-hud .hp-loss-wrap-col2 {
  transform: translate(-300%, -50%);
}

#token-hud .hp-loss-wrap-col3 {
  transform: translate(-400%, -50%);
}

#token-hud .hp-loss-hud-active {
  display: block;
}

#token-hud .hp-loss-hud-disabled {
  display: none;
}

#token-hud .hud-loss-hp-button-select {
  max-width: 40px;
  background-image: var(--background-image-base);
  padding-top: 0;
  padding-bottom: 0;
  width: max-content;
  margin: 0;
  color: #252424;
}

#token-hud .hp-loss-wrap .hud-loss-hp-button-select {
  padding-left: 8px;
  font-size: 0.9rem;
}

/* HP Gain Styles */
#token-hud .hp-gain-wrap {
  position: absolute;
  left: 75px;
  display: none;
  top: 50%;
  width: 48px;
  text-align: start;
  overflow-y: auto;
}

#token-hud .hp-gain-wrap-col1 {
  transform: translate(-200%, -50%);
}

#token-hud .hp-gain-wrap-col2 {
  transform: translate(-300%, -50%);
}

#token-hud .hp-gain-wrap-col3 {
  transform: translate(-400%, -50%);
}

#token-hud .hp-gain-hud-active {
  display: block;
}

#token-hud .hp-gain-hud-disabled {
  display: none;
}

#token-hud .hud-gain-hp-button-select {
  max-width: 40px;
  background-image: var(--background-image-base);
  padding-top: 0;
  padding-bottom: 0;
  width: max-content;
  margin: 0;
  color: #252424;
}

#token-hud .hp-gain-wrap .hud-gain-hp-button-select {
  padding-left: 8px;
  font-size: 0.9rem;
}

/* Luck/Grit Styles */
#token-hud .luck-grit-wrap {
  position: absolute;
  left: 75px;
  display: none;
  top: 50%;
  width: 80px;
  text-align: start;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(139, 69, 19, 0.5);
  border-radius: 4px;
  padding: 4px 6px;
  transform: translate(-100%, -50%);
}

#token-hud .luck-grit-hud-active {
  display: block;
}

#token-hud .luck-grit-hud-disabled {
  display: none;
}

#token-hud .luck-grit-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0;
}

#token-hud .luck-grit-label {
  flex: 1;
  color: #c9b896;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

#token-hud .luck-grit-btn {
  width: 28px;
  height: 22px;
  padding: 0;
  background: rgba(139, 69, 19, 0.25);
  border: 1px solid rgba(139, 69, 19, 0.4);
  border-radius: 3px;
  color: #d4c5a9;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;

  &:hover {
    background: rgba(139, 69, 19, 0.5);
    border-color: rgba(139, 69, 19, 0.7);
  }
}

/* -------------------------------------------------- */
/* Dice Tray — injected into the Foundry chat sidebar */
/* -------------------------------------------------- */

.lf-dice-tray {
  padding: 6px 8px;
  background:
    linear-gradient(135deg, rgba(245, 232, 200, 0.97) 0%, rgba(238, 222, 185, 0.97) 100%),
    url("/systems/fvtt-lethal-fantasy/assets/ui/lethal_fantasy_background.webp") center / cover;
  border-top: 2px solid rgba(139, 69, 19, 0.5);
  border-bottom: 1px solid rgba(139, 69, 19, 0.25);
  width: 100%;
  box-sizing: border-box;
  pointer-events: all;

  .lf-dt-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
  }

  .lf-dt-label {
    color: #3a2a10;
    font-size: 15px;
    flex-shrink: 0;
    opacity: 0.7;
  }

  .lf-dt-count {
    width: 44px;
    flex-shrink: 0;
    padding: 3px 4px;
    background: rgba(139, 69, 19, 0.15);
    border: 1px solid rgba(139, 69, 19, 0.45);
    border-radius: 4px;
    color: #2a1a08;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;

    option { background: #f5ead0; color: #2a1a08; }

    &:focus {
      outline: none;
      border-color: rgba(139, 69, 19, 0.7);
      box-shadow: 0 0 4px rgba(139, 69, 19, 0.25);
    }
  }

  .lf-dt-dice {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    flex: 1;
  }

  .lf-dt-die-btn {
    padding: 3px 7px;
    background: rgba(139, 69, 19, 0.15);
    border: 1px solid rgba(139, 69, 19, 0.4);
    border-radius: 4px;
    color: #2a1a08;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
    line-height: 1.5;
    letter-spacing: 0.3px;

    &:hover {
      background: rgba(139, 69, 19, 0.35);
      border-color: rgba(139, 69, 19, 0.7);
      color: #5a2a00;
      box-shadow: 0 0 5px rgba(139, 69, 19, 0.3);
      transform: translateY(-1px);
    }

    &:active {
      transform: translateY(0);
      box-shadow: none;
      background: rgba(139, 69, 19, 0.5);
    }
  }

  .lf-dt-explode-label {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    color: rgba(160, 80, 20, 0.7);
    font-size: 14px;
    flex-shrink: 0;
    padding: 3px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;

    &:hover {
      color: rgba(200, 100, 30, 0.9);
      border-color: rgba(139, 69, 19, 0.45);
      background: rgba(139, 69, 19, 0.12);
    }

    input[type="checkbox"] {
      appearance: none;
      width: 0;
      height: 0;
      position: absolute;
      opacity: 0;

      &:checked ~ i {
        color: #cc4400;
        filter: drop-shadow(0 0 4px rgba(200, 80, 0, 0.6));
      }
    }

    &:has(input:checked) {
      color: #cc4400;
      border-color: rgba(139, 69, 19, 0.55);
      background: rgba(139, 60, 10, 0.2);
    }
  }
}

/* Free roll chat card — styled to match regular system roll cards */
.lf-free-roll-card {
  border-radius: 6px;
  overflow: hidden;

  .lf-frc-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: linear-gradient(135deg, rgba(40, 30, 20, 0.7) 0%, rgba(30, 22, 15, 0.9) 100%);
    border-bottom: 2px solid rgba(139, 69, 19, 0.4);

    i { color: #c9b896; font-size: calc(var(--font-size-standard, 14px) * 1.1); }

    .lf-frc-title-text {
      font-size: calc(var(--font-size-standard, 14px) * 0.85);
      color: #c9b896;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .lf-frc-badge {
      display: inline-flex;
      align-items: center;
      padding: 2px 8px;
      background: rgba(139, 69, 19, 0.3);
      border: 1px solid rgba(139, 69, 19, 0.5);
      border-radius: 10px;
      font-size: calc(var(--font-size-standard, 14px) * 0.85);
      font-weight: 600;
      color: #d4c5a9;
    }
  }

  .lf-frc-dice {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(139, 69, 19, 0.3);
    border-top: none;

    .lf-frc-die-chip {
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 3px 8px;
      background: rgba(139, 69, 19, 0.2);
      border: 1px solid rgba(139, 69, 19, 0.3);
      border-radius: 4px;

      .lf-frc-die-type {
        font-size: calc(var(--font-size-standard, 14px) * 0.85);
        font-weight: 600;
        color: #2a2a1a;
        text-transform: uppercase;
      }

      .lf-frc-die-sep {
        color: rgba(0, 0, 0, 0.35);
        font-weight: 300;
        font-size: calc(var(--font-size-standard, 14px) * 0.8);
      }

      .lf-frc-die-val {
        font-weight: bold;
        color: #ffd700;
        font-size: calc(var(--font-size-standard, 14px) * 0.95);

        .lf-dt-explode-icon {
          font-size: 8px;
          color: #ffcc00;
          margin-left: 2px;
          vertical-align: super;
          text-shadow: 0 0 4px rgba(255, 200, 0, 0.8);
        }
      }

      &.lf-frc-max {
        background: rgba(139, 90, 19, 0.35);
        border-color: rgba(200, 116, 42, 0.6);
        .lf-frc-die-val { color: #ff9a40; text-shadow: 0 0 6px rgba(200, 116, 42, 0.6); }
      }

      &.lf-frc-min {
        background: rgba(139, 20, 20, 0.25);
        border-color: rgba(139, 34, 34, 0.5);
        .lf-frc-die-val { color: #ff6b6b; }
      }
    }
  }

  .lf-frc-total-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 10px;
    background: linear-gradient(135deg, rgba(40, 30, 20, 0.6) 0%, rgba(20, 15, 10, 0.8) 100%);
    border: 2px solid rgba(139, 69, 19, 0.5);

    .lf-frc-total-label {
      font-size: calc(var(--font-size-standard, 14px) * 0.85);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      color: #c9b896;
    }

    .lf-frc-total-value {
      font-family: var(--font-primary, serif);
      font-size: calc(var(--font-size-standard, 14px) * 1.6);
      font-weight: bold;
      color: #e8d5a0;
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    }
  }
}
