/* ============================================
   War Inc Rising Calculator Styles
   ============================================ */

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Theme Variables */
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #2a2a4a;
  --bg-card: #16213e;
  --text-primary: #fff;
  --text-secondary: #aaa;
  --text-muted: #666;
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow-color: rgba(0, 0, 0, 0.3);
  /* Status colors */
  --color-danger: #e74c3c;
  --color-success: #2ecc71;
  --color-warning: #f39c12;
  --color-info: #3498db;
  /* Rarity colors */
  --color-rarity-common: #95a5a6;
  /* Status background colors */
  --color-success-bg: #2d6a4f;
  --color-danger-bg: #9c3535;
  --color-warning-bg: #8a6a4a;
  --color-info-bg: #4a6a8a;
  /* Logo */
  --logo-border: #4a4a8a;
  --logo-glow: rgba(74, 74, 138, 0.5);
}

[data-theme="light"] {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e4e6eb;
  --bg-card: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #555;
  --text-muted: #888;
  --border-color: rgba(0, 0, 0, 0.1);
  --shadow-color: rgba(0, 0, 0, 0.1);
  /* Status background colors - brighter for light bg */
  --color-success-bg: #40916c;
  --color-danger-bg: #c04040;
  --color-warning-bg: #c9a227;
  --color-info-bg: #5c8db5;
  /* Rarity colors - darker for ≥4.5:1 contrast on light bg */
  --color-rarity-common: #7f8c8d;
  /* Logo - Light Theme */
  --logo-border: #6a6aaa;
  --logo-glow: rgba(74, 74, 138, 0.3);
}

/* Light Theme Specific Overrides */
[data-theme="light"] .card {
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .hero-btn {
  background: rgba(0, 0, 0, 0.04);
  color: #333;
}

[data-theme="light"] .hero-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .hero-btn .level {
  color: #1a1a2e;
}

[data-theme="light"] .hero-btn .cards {
  color: #666;
}

[data-theme="light"] .results-card {
  background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .result-label {
  color: #555;
}

[data-theme="light"] .detail-box {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .result-details {
  border-top-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .gem-methods {
  border-top-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .detail-label {
  color: #555;
}

[data-theme="light"] .input-group input {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
  color: #1a1a2e;
}

[data-theme="light"] .input-group input:focus {
  background: #ffffff;
  border-color: #f39c12;
}

[data-theme="light"] .input-group label {
  color: #555;
}

[data-theme="light"] .collapsible-header {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .collapsible-header:hover {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .collapsible-header .title {
  color: #555;
}

[data-theme="light"] .collapsible-content {
  background: rgba(0, 0, 0, 0.02);
  color: #555;
}

[data-theme="light"] .collapsible-content code {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .info-box {
  background: rgba(52, 152, 219, 0.1);
  color: #444;
}

[data-theme="light"] .gem-ref-row {
  background: transparent;
  border-radius: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .gem-method-item:last-child .gem-ref-row {
  border-bottom: none;
}

[data-theme="light"] .gem-ref-row:hover {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .gem-ref-row .method-cost {
  color: #1a1a2e;
}

[data-theme="light"] .gem-ref-row .cost-per {
  color: #555;
}

[data-theme="light"] .gem-ref-row .cost-specific {
  color: #555;
}

[data-theme="light"] .gem-ref-row .cost-total {
  color: #d68910;
}

[data-theme="light"] .method-details-content {
  background: #f8f9fa;
  border-color: rgba(52, 152, 219, 0.2);
}

[data-theme="light"] .method-calc-row .highlight {
  color: #1a1a2e;
}

[data-theme="light"] .merge-table th {
  color: #d68910;
}

[data-theme="light"] .merge-table td {
  color: #333;
}

[data-theme="light"] .merge-table tr:hover td {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .merge-table td,
[data-theme="light"] .comparison-table td {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .comparison-table th {
  color: #d68910;
}

[data-theme="light"] .forge-stones-section {
  background: rgba(243, 156, 18, 0.08);
}

[data-theme="light"] .forge-row {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .forge-value {
  color: #1a1a2e;
}

[data-theme="light"] .forge-popup {
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .wheel-results {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .wheel-result-row .value {
  color: #1a1a2e;
}

[data-theme="light"] .available-gems-input input {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
  color: #1a1a2e;
}

[data-theme="light"] .available-gems-input input:focus {
  background: #ffffff;
}

[data-theme="light"] .available-gems-input label {
  color: #555;
}

[data-theme="light"] .click-hint {
  color: #666;
}

[data-theme="light"] .target-label {
  color: #555;
}

[data-theme="light"] .wheel-input-row label {
  color: #555;
}

[data-theme="light"] .wheel-input-row .input-hint {
  color: #666;
}

[data-theme="light"] .wheel-result-row .label {
  color: #555;
}

/* Light theme wheel calculator - darker orange for better contrast */
[data-theme="light"] .wheel-calc {
  border-color: rgba(184, 134, 11, 0.4);
}

[data-theme="light"] .card-title {
  color: #b8860b;
}

[data-theme="light"] .wheel-input-row input[type="number"] {
  border-color: rgba(184, 134, 11, 0.5);
  background: rgba(184, 134, 11, 0.08);
  color: #8b6914;
}

[data-theme="light"] .wheel-input-row input[type="number"]:focus {
  border-color: #b8860b;
  background: rgba(184, 134, 11, 0.12);
}

[data-theme="light"] .wheel-result-row .value.highlight {
  color: #b8860b;
}

[data-theme="light"] .milestone-badge {
  background: rgba(184, 134, 11, 0.15);
  color: #8b6914;
}

/* Light theme wheel result row separators */
[data-theme="light"] .wheel-result-row {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .wheel-milestones {
  border-top-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .method-calc-row {
  color: #555;
}

[data-theme="light"] .formula-mechanics {
  color: #555;
}

[data-theme="light"] .formula-step {
  color: #555;
}

[data-theme="light"] .method-step {
  color: #444;
}

[data-theme="light"] .method-popup-mechanics {
  color: #555;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  display: flex;
  flex-direction: column;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  min-height: 100vh;
  color: var(--text-primary);
  transition: background 0.3s, color 0.3s;
}

main {
  flex: 1;
}

/* ============================================
   Page-specific beta badge for h1
   ============================================ */
h1 .beta-badge {
  font-size: 0.4em;
  padding: 4px 8px;
  vertical-align: middle;
}

/* ============================================
   Focus Styles for Keyboard Navigation
   ============================================ */
.hero-btn:focus-visible,
.reset-btn:focus-visible,
.reset-all-btn:focus-visible,
.formula-info-btn:focus-visible,
.forge-info-btn:focus-visible,
.formula-popup-close:focus-visible,
.collapsible-header:focus-visible,
.gem-ref-row.clickable:focus-visible {
  outline: 2px solid var(--color-warning);
  outline-offset: 2px;
}

.input-group input:focus-visible,
.available-gems-input input:focus-visible,
.wheel-input-row input:focus-visible,
.target-dropdown-wrapper select:focus-visible {
  outline: 2px solid var(--color-warning);
  outline-offset: 2px;
}

/* ============================================
   Main Container
   ============================================ */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 15px;
}

/* ============================================
   Hero Section Override (inside container)
   ============================================ */
.hero-section {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  background: rgba(255, 255, 255, 0.05);
}

.hero-section .subtitle {
  color: var(--text-secondary);
}

/* ============================================
   Card Styles
   ============================================ */
.card {
  background: rgba(255,255,255,0.05);
  border-radius: 15px;
  padding: 15px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.1em;
  color: #f39c12;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.reset-all-btn {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 0.75em;
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.3);
  color: #e74c3c;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.reset-all-btn:hover {
  background: rgba(231, 76, 60, 0.3);
  border-color: rgba(231, 76, 60, 0.5);
  transform: translateY(-1px);
}

/* ============================================
   Hero Grid for Merge Calculator
   ============================================ */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (min-width: 601px) {
  .hero-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.hero-btn {
  background: rgba(255,255,255,0.08);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hero-btn:hover {
  background: rgba(255,255,255,0.12);
  transform: scale(1.02) translateY(-2px);
}

.hero-btn:active {
  transform: scale(0.98);
}

.hero-btn.selected {
  background: rgba(46, 204, 113, 0.15);
  border-color: rgba(46, 204, 113, 0.6);
}

.hero-btn .level {
  font-size: 1.3em;
  font-weight: bold;
  color: #fff;
}

.hero-btn .cards {
  font-size: 0.7em;
  color: #888;
  margin-top: 2px;
}

.hero-btn.selected .cards {
  color: #2ecc71;
  font-size: 1em;
  font-weight: bold;
}

/* Reset Button */
.reset-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(231, 76, 60, 0.8);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.reset-btn:hover {
  background: rgba(231, 76, 60, 1);
  transform: scale(1.1);
}

.reset-btn:active {
  transform: scale(0.95);
}

.hero-btn.selected .reset-btn {
  display: flex;
}

/* Desktop: smaller reset button */
@media (min-width: 601px) {
  .reset-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
    top: 4px;
    right: 4px;
  }
}

.click-hint {
  text-align: center;
  font-size: 0.8em;
  color: #666;
  margin-top: 12px;
}

/* ============================================
   Target Level Selector
   ============================================ */
.target-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  margin: 15px 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  flex-wrap: wrap;
}

.target-label {
  font-size: 1.1em;
  color: #888;
}

.target-dropdown-wrapper {
  position: relative;
}

.target-dropdown-wrapper select {
  appearance: none;
  padding: 12px 45px 12px 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: #1e2530;
  color: #fff;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.target-dropdown-wrapper select option {
  background: #1e2530;
  color: #fff;
  padding: 10px;
}

.target-dropdown-wrapper select:hover {
  background: #252d3a;
  border-color: rgba(255, 255, 255, 0.2);
}

.target-dropdown-wrapper select:focus {
  outline: none;
  border-color: var(--color-warning);
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.3);
}

.target-dropdown-wrapper::after {
  content: "▼";
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  font-size: 0.7em;
  pointer-events: none;
}

/* Light theme dropdown */
[data-theme="light"] .target-selector {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .target-dropdown-wrapper select {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.15);
  color: #1a1a2e;
}

[data-theme="light"] .target-dropdown-wrapper select option {
  background: #ffffff;
  color: #1a1a2e;
}

[data-theme="light"] .target-dropdown-wrapper select:hover {
  background: #f5f5f5;
  border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .target-dropdown-wrapper::after {
  color: #666;
}

/* ============================================
   Results Card
   ============================================ */
.results-card {
  background: linear-gradient(135deg, #1e2530 0%, #0d1117 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.result-main {
  text-align: center;
  padding: 25px 0;
  position: relative;
}

.result-number {
  font-size: 2.5em;
  font-weight: bold;
  color: var(--text-primary);
  line-height: 1;
}

.result-number.need-more {
  color: var(--color-danger, #e74c3c);
}

.result-number.enough {
  color: var(--color-success, #2ecc71);
}

.result-number.exact {
  color: var(--color-warning, #f39c12);
}

.result-label {
  font-size: 1.1em;
  color: #aaa;
  margin-top: 8px;
}

/* Visually hidden (accessible but not visible) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Formula Info Button */
.formula-info-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(52, 152, 219, 0.2);
  color: #3498db;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.formula-info-btn:hover {
  background: rgba(52, 152, 219, 0.4);
  transform: scale(1.1);
}

/* Formula Popup */
.formula-popup {
  position: absolute;
  top: 50px;
  right: 10px;
  width: min(280px, calc(100vw - 30px));
  background: rgba(20, 20, 30, 0.98);
  border: 1px solid rgba(52, 152, 219, 0.4);
  border-radius: 12px;
  padding: 15px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  /* Animation */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
}

.formula-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.formula-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: #3498db;
  font-size: 0.95em;
}

.formula-popup-close {
  background: none;
  border: none;
  color: #666;
  font-size: 20px;
  cursor: pointer;
  padding: 0 5px;
  line-height: 1;
}

.formula-popup-close:hover {
  color: #e74c3c;
}

.formula-text {
  font-size: 0.85em;
  color: #aaa;
  margin-bottom: 12px;
}

.formula-popup .merge-table {
  margin: 0;
}

.formula-popup .merge-table th,
.formula-popup .merge-table td {
  padding: 5px 8px;
  font-size: 0.85em;
}

/* Light theme */
[data-theme="light"] .formula-info-btn {
  background: rgba(52, 152, 219, 0.15);
}

[data-theme="light"] .formula-info-btn:hover {
  background: rgba(52, 152, 219, 0.3);
}

[data-theme="light"] .formula-popup {
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .formula-text {
  color: #555;
}

/* ============================================
   Result Details Grid
   ============================================ */
.result-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.detail-box {
  text-align: center;
  padding: 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
}

.detail-value {
  font-size: 1.8em;
  font-weight: bold;
  color: #3498db;
}

.detail-label {
  font-size: 0.8em;
  color: #888;
  margin-top: 3px;
}

/* ============================================
   Forge Stones Section
   ============================================ */
.forge-stones-section {
  margin-top: 20px;
  padding: 15px;
  background: rgba(243, 156, 18, 0.1);
  border-radius: 10px;
  border: 1px solid rgba(243, 156, 18, 0.3);
  position: relative;
}

.forge-title {
  font-size: 0.95em;
  color: #f39c12;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.forge-info-btn {
  font-size: 0.85em;
  color: #888;
  cursor: pointer;
  min-width: 28px;
  min-height: 28px;
  padding: 2px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.forge-info-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #f39c12;
}

.forge-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 601px) {
  .forge-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

.forge-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
}

.forge-rarity {
  font-size: 0.85em;
  font-weight: 500;
}

.forge-rarity.mythic { color: #e74c3c; }
.forge-rarity.legendary { color: #f39c12; }
.forge-rarity.epic { color: #9b59b6; }
.forge-rarity.rare { color: #3498db; }
.forge-rarity.common { color: var(--color-rarity-common); }

.forge-value {
  font-weight: bold;
  color: #fff;
}

/* Forge Stones Popup */
.forge-popup {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 10px;
  background: rgba(20, 20, 30, 0.98);
  border: 1px solid rgba(243, 156, 18, 0.4);
  border-radius: 10px;
  padding: 15px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  overflow-x: auto;
  /* Animation */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
}

.forge-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.forge-popup-title {
  font-size: 0.9em;
  color: #f39c12;
  margin-bottom: 12px;
  text-align: center;
}

.forge-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
}

.forge-table th,
.forge-table td {
  padding: 8px;
  text-align: center;
}

.forge-table th {
  color: #888;
  font-weight: normal;
}

.forge-table td:first-child {
  text-align: left;
}

.forge-table td.mythic { color: #e74c3c; }
.forge-table td.legendary { color: #f39c12; }
.forge-table td.epic { color: #9b59b6; }
.forge-table td.rare { color: #3498db; }
.forge-table td.common { color: var(--color-rarity-common); }

.forge-table th.mythic { color: #e74c3c; }
.forge-table th.legendary { color: #f39c12; }
.forge-table th.epic { color: #9b59b6; }
.forge-table th.rare { color: #3498db; }
.forge-table th.common { color: var(--color-rarity-common); }

.forge-table.compact th,
.forge-table.compact td {
  padding: 6px 10px;
  font-size: 0.9em;
}

.forge-table.compact td:first-child {
  font-weight: bold;
  color: #aaa;
}

/* ============================================
   Gem Methods Table
   ============================================ */
.gem-methods {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.gem-methods-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 12px;
}

.gem-methods-title {
  font-size: 1em;
  color: #3498db;
}

.available-gems-input {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: space-between;
}

.available-gems-input label {
  font-size: 0.85em;
  color: #666;
}

.available-gems-input input {
  width: 110px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 1em;
  text-align: center;
}

.available-gems-input input::placeholder {
  color: #555;
  font-style: italic;
}

.available-gems-input input:focus {
  outline: none;
  border-color: rgba(52, 152, 219, 0.5);
  background: rgba(255, 255, 255, 0.08);
}

/* Reference Table (replaces calculated costs) */
.gem-reference-table {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gem-ref-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 12px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
}

.gem-ref-row:hover {
  background: rgba(255,255,255,0.08);
}

.gem-ref-row .method-cost {
  font-weight: bold;
  color: #fff;
}

.gem-ref-row .method-costs {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: space-between;
  gap: 8px;
  padding-left: 4px;
}

.gem-ref-row .cost-per {
  font-size: 0.9em;
  color: #888;
}

.gem-ref-row .cost-specific {
  color: #555;
  font-size: 0.85em;
}

.gem-ref-row .cost-total {
  font-weight: bold;
  color: #f39c12;
  min-width: auto;
  text-align: right;
  font-size: 1.1em;
}

.gem-method-item.affordable .gem-ref-row {
  border-left: 3px solid rgba(46, 204, 113, 0.5);
}

.gem-method-item.affordable .cost-total {
  color: #2ecc71;
}

.method-no-formula {
  padding: 8px 0;
  color: #888;
  font-size: 0.9em;
  font-style: italic;
}

.gem-ref-row.clickable {
  cursor: pointer;
  transition: all 0.2s;
}

.gem-ref-row.clickable:hover {
  background: rgba(52, 152, 219, 0.2);
  border-left: 3px solid #3498db;
}

.gem-ref-row .method-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1em;
  font-weight: 500;
}

.gem-ref-row .method-info {
  font-size: 0.7em;
  color: #666;
  padding: 1px 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
}

/* Method Formula Popup */
.method-popup {
  position: relative;
  margin-top: 12px;
  background: rgba(20, 20, 30, 0.98);
  border: 1px solid rgba(52, 152, 219, 0.4);
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  /* Animation */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
}

.method-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.method-popup-title {
  font-size: 1em;
  font-weight: bold;
  color: #3498db;
  margin-bottom: 10px;
  text-align: center;
}

.method-popup-mechanics {
  font-size: 0.85em;
  color: #888;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.method-popup-steps {
  margin-bottom: 12px;
}

.method-step {
  font-size: 0.9em;
  color: #ccc;
  padding: 4px 0;
  padding-left: 15px;
  position: relative;
}

.method-step::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #666;
}

.method-popup-result {
  font-size: 1em;
  font-weight: bold;
  color: #2ecc71;
  text-align: center;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ============================================
   Expandable Method Items
   ============================================ */
.gem-method-item {
  margin-bottom: 4px;
}

.gem-method-item .gem-ref-row {
  border-radius: 6px;
  transition: all 0.2s ease;
}

.gem-method-item.expanded .gem-ref-row {
  background: rgba(52, 152, 219, 0.2);
  border-radius: 6px 6px 0 0;
}

.gem-method-item .method-arrow {
  font-size: 0.65em;
  color: #666;
  transition: transform 0.2s ease;
  display: inline-block;
}

.gem-method-item.expanded .method-arrow {
  transform: rotate(90deg);
  color: #3498db;
}

.method-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out;
}

.gem-method-item.expanded .method-details {
  max-height: 500px;
  transition: max-height 0.3s ease-in;
}

.method-details-content {
  padding: 10px 12px;
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid rgba(52, 152, 219, 0.3);
  border-top: none;
  border-radius: 0 0 8px 8px;
}

.method-calc-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.85em;
  color: #999;
}

.method-calc-row .highlight {
  color: #fff;
  font-weight: 500;
}

.method-calc-row .highlight-cost {
  color: #f39c12;
  font-weight: bold;
}

.method-calc-row.can-afford {
  color: #2ecc71;
}

.method-calc-row.cannot-afford {
  color: #e74c3c;
}

.method-formula {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.formula-mechanics {
  font-size: 0.85em;
  color: #888;
  margin-bottom: 8px;
}

.formula-step {
  font-size: 0.85em;
  color: #aaa;
  padding: 3px 0;
  padding-left: 5px;
}

.formula-result {
  font-size: 0.9em;
  font-weight: bold;
  color: #2ecc71;
  margin-top: 8px;
  text-align: right;
}

/* ============================================
   Info Box
   ============================================ */
.info-box {
  background: rgba(52, 152, 219, 0.15);
  border-left: 4px solid #3498db;
  padding: 15px;
  border-radius: 0 10px 10px 0;
  margin-top: 15px;
  font-size: 0.9em;
  color: #bbb;
  line-height: 1.6;
}

.info-box.success {
  background: rgba(46, 204, 113, 0.15);
  border-color: #2ecc71;
}

/* ============================================
   Collapsible Info
   ============================================ */
.collapsible {
  margin-top: 20px;
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.collapsible-header:hover {
  background: rgba(255,255,255,0.1);
}

.collapsible-header .title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
  color: #aaa;
}

.collapsible-header .arrow {
  transition: transform 0.2s;
}

.collapsible.open .collapsible-header .arrow {
  transform: rotate(180deg);
}

.collapsible-content {
  display: none;
  padding: 15px;
  background: rgba(0,0,0,0.2);
  border-radius: 0 0 10px 10px;
  font-size: 0.85em;
  color: #999;
  line-height: 1.7;
}

.collapsible.open .collapsible-content {
  display: block;
}

.collapsible-content code {
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.collapsible-content ul {
  margin: 10px 0 10px 20px;
}

.collapsible-content li {
  margin-bottom: 4px;
}

/* ============================================
   Merge Table
   ============================================ */
.merge-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.merge-table th,
.merge-table td {
  padding: 8px 12px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.merge-table th {
  color: #f39c12;
  font-size: 0.8em;
  font-weight: normal;
}

.merge-table td {
  font-size: 0.9em;
}

.merge-table tr:hover td {
  background: rgba(255,255,255,0.05);
}

/* ============================================
   Coming Soon Badge
   ============================================ */
.coming-soon {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(155, 89, 182, 0.3);
  color: #9b59b6;
  font-size: 0.7em;
  border-radius: 4px;
  margin-left: 8px;
}

/* ============================================
   Gem Calculator Specific
   ============================================ */
.input-group {
  margin-bottom: 15px;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  color: #aaa;
  font-size: 0.9em;
}

.input-group input {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  color: #fff;
  font-size: 1.1em;
}

.input-group input:focus {
  outline: none;
  border-color: #f39c12;
}

/* ============================================
   Comparison Table
   ============================================ */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  font-size: 0.85em;
}

.comparison-table th,
.comparison-table td {
  padding: 8px 4px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.comparison-table th {
  color: #f39c12;
  font-size: 0.85em;
  font-weight: normal;
}

.comparison-table td {
  font-size: 0.95em;
}

.comparison-table tr:hover td {
  background: rgba(255,255,255,0.05);
}

.comparison-table .highlight {
  color: #2ecc71;
  font-weight: bold;
}

.comparison-table .dim {
  color: #666;
}

/* Reference Table (Gem Spending) */
.card-subtitle {
  color: #888;
  font-size: 0.9em;
  margin: -5px 0 10px 0;
}

.reference-table th:first-child,
.reference-table td:first-child {
  text-align: left;
}

.reference-table .cost-cell {
  font-weight: bold;
  color: #fff;
}

.reference-table .info-cell {
  width: 30px;
  text-align: center;
}

.reference-table .info-icon {
  color: #888;
  cursor: help;
  font-size: 0.9em;
  transition: color 0.2s;
}

.reference-table .info-icon:hover {
  color: #f39c12;
}

/* ============================================
   Wheel Progress Calculator
   ============================================ */
.wheel-calc {
  margin-top: 20px;
  border: 2px solid rgba(243, 156, 18, 0.3);
}

.wheel-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.wheel-input-row label {
  color: #aaa;
  font-size: 0.9em;
}

.wheel-input-row input[type="number"] {
  width: 100px;
  padding: 10px 12px;
  border: 2px solid rgba(243, 156, 18, 0.5);
  border-radius: 8px;
  background: rgba(243, 156, 18, 0.1);
  color: #f39c12;
  font-size: 1.1em;
  font-weight: bold;
  text-align: center;
}

.wheel-input-row input[type="number"]:focus {
  outline: none;
  border-color: #f39c12;
  background: rgba(243, 156, 18, 0.2);
}

.wheel-input-row .input-hint {
  color: #666;
  font-size: 0.85em;
}

/* Wheel Results */
.wheel-results {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
}

.wheel-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.wheel-result-row:last-child {
  border-bottom: none;
}

.wheel-result-row .label {
  color: #888;
  font-size: 0.9em;
}

.wheel-result-row .value {
  font-weight: bold;
  color: #fff;
}

.wheel-result-row .value.highlight {
  color: #f39c12;
  font-size: 1.1em;
}

.wheel-result-row .value.mythic {
  color: #9b59b6;
}

.wheel-milestones {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.wheel-deficit-notice {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(243, 156, 18, 0.08);
  border-left: 3px solid #f39c12;
  border-radius: 4px;
  color: #ccc;
  font-size: 0.9em;
  line-height: 1.5;
}

[data-theme="light"] .wheel-deficit-notice {
  background: rgba(243, 156, 18, 0.12);
  color: #555;
}

.milestone-badge {
  display: inline-block;
  background: rgba(243, 156, 18, 0.2);
  color: #f39c12;
  padding: 4px 10px;
  border-radius: 15px;
  font-size: 0.8em;
  margin-right: 8px;
  margin-bottom: 6px;
}

.milestone-badge.passed {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  text-decoration: line-through;
  opacity: 0.6;
}

/* ============================================
   Desktop Overrides
   ============================================ */
@media (min-width: 601px) {
  .container {
    padding: 20px;
  }

  .card {
    padding: 20px;
  }

  .result-number {
    font-size: 3.5em;
  }

  .comparison-table {
    font-size: unset;
  }

  .comparison-table th,
  .comparison-table td {
    padding: 12px;
  }

  /* ============================================
     Gem Spending Reference - Desktop
     ============================================ */

  .gem-methods-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }

  .gem-methods-title {
    font-size: 0.9em;
  }

  .available-gems-input {
    width: auto;
    justify-content: flex-start;
  }

  .available-gems-input input {
    width: 100px;
    font-size: 0.9em;
  }

  /* Method rows: inline layout */
  .gem-ref-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0;
    padding: 8px 12px;
  }

  .gem-ref-row .method-name {
    font-size: inherit;
    font-weight: inherit;
  }

  .gem-method-item .method-arrow {
    font-size: 0.7em;
  }

  .gem-ref-row .method-costs {
    width: auto;
    justify-content: flex-end;
    gap: 12px;
    padding-left: 0;
  }

  .gem-ref-row .cost-per {
    font-size: 0.85em;
    color: #666;
  }

  .gem-ref-row .cost-specific {
    font-size: 0.9em;
  }

  .gem-ref-row .cost-total {
    min-width: 90px;
    font-size: inherit;
  }

  .method-details-content {
    padding: 12px 15px;
  }

  .method-calc-row {
    font-size: 0.9em;
  }
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast {
  position: fixed;
  bottom: 20px;
  left: 15px;
  right: 15px;
  background: var(--color-success-bg);
  color: #fff;
  padding: 15px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  animation: slideIn 0.3s ease-out;
}

@media (min-width: 601px) {
  .toast {
    left: auto;
    right: 20px;
    max-width: 400px;
    padding: 15px 25px;
  }
}

.toast.toast-error {
  background: var(--color-danger-bg);
}

.toast.toast-info {
  background: var(--color-info-bg);
}

.toast.fade-out {
  animation: slideOut 0.3s ease-out forwards;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}
