/* Reward modal and cards */
#reward-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.reward-modal {
  background: linear-gradient(135deg, #0f0f1a 0%, #1a0f2e 100%);
  border: 2px solid #4a9eff;
  padding: 40px;
  max-width: 800px;
  text-align: center;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(74, 158, 255, 0.3), inset 0 0 20px rgba(74, 158, 255, 0.05);
}

.reward-modal h2 {
  font-size: 32px;
  font-weight: 400;
  margin-bottom: 10px;
  color: #64c8ff;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.reward-subtitle {
  color: #9db4ff;
  margin-bottom: 30px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Rarity pill shown on element cards */
/* NOTE: core rarity-pill visuals have been moved to styles/components.css to make them reusable across panels.
   Keep a small positioning helper here for reward cards when the pill should be absolutely positioned. */

.reward-card .reward-card-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* OLD .reward-card-header rules were using a single-line layout.
   Change to a stacked layout so long names wrap safely and the rarity pill
   sits in the top-right corner of the card. */
.reward-card {
  position: relative; /* allow absolute positioning of rarity pill */
}

/* Make header a vertical stack so heading occupies its own line */
.reward-card .reward-card-header {
  display: block;
  padding-right: 48px; /* reserve space for absolute rarity pill to avoid overlap */
}

/* Ensure the title takes the full width and wraps cleanly */
.reward-card .reward-card-header h3 {
  display: block;
  width: 100%;
  margin: 0 0 8px 0;
  line-height: 1.1;
  word-break: break-word;
  white-space: normal;
}

/* Position the rarity pill in the top-right corner of the card (reward-specific absolute placement) */
.reward-card .rarity-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

/* Visual prominence controlled by --rarity-intensity (0.0..1.0) */
.reward-card[data-rarity="common"] {
  --rarity-intensity: 0.0;
}
.reward-card[data-rarity="uncommon"] {
  --rarity-intensity: 0.5;
}
.reward-card[data-rarity="rare"] {
  --rarity-intensity: 1.0;
}

/* Apply a subtle themed overlay, border and glow to the entire card scaled by --rarity-intensity */
.reward-card {
  /* base variables for card tinting */
  --card-tint-strength: calc(0.08 + 0.32 * var(--rarity-intensity, 0)); /* 0.08..0.4 */
  --card-glow-alpha: calc(0.06 + 0.28 * var(--rarity-intensity, 0));   /* 0.06..0.34 */
  --card-border-alpha: calc(0.06 + 0.34 * var(--rarity-intensity, 0)); /* 0.06..0.4 */

  /* subtle colored overlay (kept dark so text remains readable) */
  background: linear-gradient(135deg,
    rgba(20,20,30, calc(var(--card-tint-strength) * 0.7)) 0%,
    rgba(40,20,60, calc(var(--card-tint-strength))) 100%);

  /* border tinted based on rarity intensity */
  border-color: rgba(74,158,255, var(--card-border-alpha));

  /* glow scaled by rarity intensity */
  box-shadow:
    0 0 calc(10px * var(--rarity-intensity, 0)) rgba(100, 200, 255, var(--card-glow-alpha)),
    inset 0 0 calc(14px * var(--rarity-intensity, 0)) rgba(100, 200, 255, calc(var(--card-glow-alpha) * 0.12));
}

/* Make the rarity-pill itself more opaque and vivid so it stands out from the toned card */
.rarity-pill {
  /* Keep dark text color for contrast on bright pills */
  color: #0b0b0b;
  font-weight: 800;
  text-transform: capitalize;
}

/* Stronger accent for uncommon/rare */
.reward-card[data-rarity="uncommon"] .rarity-pill {
  background: rgba(140, 200, 90, 0.92);
  color: #082000;
  border-color: rgba(110,180,70,0.95);
  box-shadow: 0 4px 10px rgba(110,180,70,0.12);
}
.reward-card[data-rarity="unusual"] .rarity-pill {
  background: rgba(100,180,200,0.94);
  color: #04171a;
  border-color: rgba(80,160,180,0.95);
  box-shadow: 0 4px 10px rgba(80,160,180,0.12);
}
.reward-card[data-rarity="rare"] .rarity-pill {
  background: linear-gradient(90deg, rgba(255,200,80,0.98), rgba(255,120,200,0.92));
  color: #221200;
  border-color: rgba(255,180,70,0.98);
  box-shadow: 0 6px 18px rgba(255,160,60,0.18);
}

/* Rarity-specific pill & card tints for full 13-tier system (mundane -> mythic).
   Cooler / more vibrant colors are applied to the rarest tiers. */
.reward-card[data-rarity="mundane"] .rarity-pill { background: rgba(80,80,80,0.92); color:#f2f2f2; border-color: rgba(100,100,100,0.95); box-shadow:0 4px 8px rgba(0,0,0,0.25);}
.reward-card[data-rarity="common"] .rarity-pill { background: linear-gradient(90deg, rgba(160,120,80,0.96), rgba(140,100,60,0.92)); color:#fff6ea; border-color: rgba(160,140,120,0.96); box-shadow:0 4px 10px rgba(0,0,0,0.22);}
.reward-card[data-rarity="uncommon"] .rarity-pill { /* vivid green */ background: linear-gradient(90deg, #7ad06a, #4fb24a); color:#052004; border-color: rgba(60,150,60,0.95); box-shadow: 0 6px 14px rgba(80,180,90,0.12); }
.reward-card[data-rarity="unusual"] .rarity-pill { /* teal */ background: linear-gradient(90deg, #57d1d6, #2aa6b0); color:#041a1a; border-color: rgba(40,160,170,0.95); box-shadow:0 6px 14px rgba(40,160,170,0.12); }
.reward-card[data-rarity="rare"] .rarity-pill { /* bold gold */ background: linear-gradient(90deg, #ffd56b, #ffb84a); color:#2a1400; border-color: rgba(255,170,60,0.98); box-shadow: 0 8px 18px rgba(255,150,40,0.18); }
.reward-card[data-rarity="prestigious"] .rarity-pill { background: linear-gradient(90deg, #b88ef0, #8a63d9); color:#10021b; border-color: rgba(150,110,220,0.98); box-shadow:0 6px 16px rgba(140,100,220,0.14); }
.reward-card[data-rarity="exotic"] .rarity-pill { background: linear-gradient(90deg, #3fe0c9, #2aa6ff); color:#002025; border-color: rgba(60,180,200,0.96); box-shadow:0 6px 14px rgba(60,170,200,0.12); }
.reward-card[data-rarity="outstanding"] .rarity-pill { background: linear-gradient(90deg, #7fb7ff, #9f6fff); color:#040922; border-color: rgba(120,140,240,0.96); box-shadow:0 8px 18px rgba(120,110,230,0.16); }
.reward-card[data-rarity="exceptional"] .rarity-pill { background: linear-gradient(90deg, #5ef1ff, #8ad0ff); color:#021428; border-color: rgba(90,200,255,0.96); box-shadow:0 8px 20px rgba(90,170,230,0.18); }
.reward-card[data-rarity="legendary"] .rarity-pill { background: linear-gradient(90deg, #6ff0ff, #8fe8ff); color:#041226; border-color: rgba(120,220,255,0.98); box-shadow: 0 8px 22px rgba(120,200,255,0.22); }
.reward-card[data-rarity="wondrous"] .rarity-pill { background: linear-gradient(90deg, #9ee6ff, #c58bff); color:#08051a; border-color: rgba(160,140,255,0.98); box-shadow: 0 10px 26px rgba(180,140,255,0.2); }
.reward-card[data-rarity="supernal"] .rarity-pill { background: linear-gradient(90deg, #6ff5d6, #85f0ff); color:#032026; border-color: rgba(100,220,255,0.99); box-shadow: 0 10px 28px rgba(100,220,255,0.22); }
.reward-card[data-rarity="mythic"] .rarity-pill { background: linear-gradient(90deg, #ff8ad6, #ffd36b); color:#13020f; border-color: rgba(255,200,120,1); box-shadow: 0 12px 36px rgba(255,160,200,0.26); }

.reward-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.reward-card {
  background: linear-gradient(135deg, #1a1a25 0%, #2a1a4e 100%);
  border: 2px solid #4a9eff;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 15px rgba(74, 158, 255, 0.15);
}

/* New: essence-card specific visuals that scale with offered amount */
.reward-card.essence-card {
  /* base look; intensity controlled by --essence-intensity (0.2 - 1.0) */
  --essence-intensity: 0.2;
}

.reward-card:hover {
  border-color: #64c8ff;
  transform: translateY(-5px);
  box-shadow: 0 0 25px rgba(100, 200, 255, 0.3);
}

.reward-card-color {
  width: 100%;
  height: 60px;
  margin-bottom: 15px;
  border: 1px solid #333;
  background-size: cover;
  background-position: center;
}

.reward-card-color.default-bg {
  background: #222;
}

.reward-card.essence-card {
  /* subtle color shift and stronger glow when intensity grows */
  background: linear-gradient(135deg,
    rgba(30, 10, 25, calc(0.8 * var(--essence-intensity))) 0%,
    rgba(40, 12, 48, calc(0.9 * var(--essence-intensity))) 100%);
  border-color: rgba(100, 158, 255, calc(0.9 * var(--essence-intensity)));
  box-shadow:
    0 0 calc(12px * var(--essence-intensity)) rgba(100, 200, 255, calc(0.18 * var(--essence-intensity))),
    inset 0 0 calc(18px * var(--essence-intensity)) rgba(100, 200, 255, calc(0.06 * var(--essence-intensity)));
}

.reward-card-small-desc {
  font-size: 12px;
  color: #aaa;
  margin-bottom: 12px;
}

.reward-card-properties {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.reward-card-property-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #ddd;
  gap: 8px;
}

.reward-card-property-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.85;
  flex-shrink: 0;
}

.reward-card-property-name {
  text-transform: capitalize;
}

.reward-card-property-value {
  font-weight: 600;
  color: #fff;
}

.reward-card-essence-amount {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #eaf8ff;
}

.reward-card-essence-amount .essence-amt {
  color: #fff;
  text-shadow: 0 0 8px rgba(100,200,255, calc(0.6 * var(--essence-intensity)));
}

.reward-card h3 {
  font-size: 20px;
  font-weight: 400;
  margin-bottom: 10px;
  color: #64c8ff;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Responsive tweaks for the reward modal */
@media (max-width: 1024px) {
  .reward-modal { padding: 30px; max-width: 700px; }
  .reward-modal h2 { font-size: 26px; }
  .reward-choices { gap: 15px; }
  .reward-card { padding: 15px; }
  .reward-card h3 { font-size: 18px; }
}

@media (max-width: 768px) {
  #reward-overlay { padding: 10px; }
  .reward-modal { padding: 20px; max-width: 100%; width: 100%; }
  .reward-modal h2 { font-size: 22px; margin-bottom: 8px; }
  .reward-choices { 
    grid-template-columns: repeat(2, 1fr); /* 2 columns for elements side-by-side */
    gap: 12px; 
  }
  .reward-card { padding: 12px; }
  .reward-card h3 { font-size: 16px; margin-bottom: 8px; }
  .reward-card-color { height: 50px; margin-bottom: 12px; }
  
  /* ME card spans full width (2 columns) on mobile */
  .reward-choices .essence-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  /* Show element choices side-by-side on very small screens, but ensure the essence card spans both columns */
  .reward-choices { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .reward-card { padding: 10px; }
  .reward-card h3 { font-size: 14px; }
  .reward-card-color { height: 40px; }
  /* The rule .reward-choices .essence-card is now handled by the 768px media query */

  /* Added spacing adjustments for very small screens */
  .reward-choices {
    margin-top: 10px;
  }

  .reward-subtitle {
    margin-bottom: 10px;
  }
}