/* 40K Attack Calculator — Apple pastel lavender/blue dark theme */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;

  /* Pastel lavender-blue dark palette */
  --bg: #161622;
  --surface: #1e1e30;
  --surface-raised: #282842;
  --tile-bg: #1e1e30;
  --tile-border: #33334d;
  --tile-focus: #8b8bf5;

  --text: #f0eeff;
  --text-secondary: #8b8ba8;
  --text-tertiary: #555570;

  --accent: #8b7cf6;
  --accent-hover: #a093f8;
  --accent-glow: rgba(139, 124, 246, 0.2);
  --accent-solid: #7c6ef0;

  --red: #f87171;
  --green: #6ee7b7;
  --orange: #fbbf24;

  --bar-fill: #8b7cf6;
  --bar-fill-max: #c084fc;

  --divider: rgba(139, 124, 246, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font);
  background: #0d0d18;
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
}

/* ========== APP CHROME ========== */

.app-chrome {
  width: 100%;
  max-width: 560px;
  background: var(--bg);
  border-radius: var(--radius-xl);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 0 0 0.5px rgba(139, 124, 246, 0.1);
  overflow: hidden;
  animation: windowAppear 0.5s var(--spring) both;
}

@keyframes windowAppear {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Titlebar */
.titlebar {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 0.5px solid var(--divider);
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.traffic-lights { display: flex; gap: 8px; align-items: center; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: none; outline: none; }
.dot-close { background: #ff5f57; }
.dot-min   { background: #febc2e; }
.dot-max   { background: #28c840; }

.titlebar-text {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.menu-btn, .save-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  outline: none;
}

.menu-btn:hover, .save-btn:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.save-btn {
  margin-left: auto;
}

/* ========== LOADOUT DRAWER ========== */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
  animation: fadeIn 0.2s var(--ease-out);
  display: none;
}

.drawer-backdrop.open {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.loadout-drawer {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  max-height: 70dvh;
  background: var(--bg);
  border-bottom: 1px solid var(--tile-border);
  z-index: 100;
  display: none;
  flex-direction: column;
  animation: drawerIn 0.25s var(--ease-out);
}

.loadout-drawer.open {
  display: flex;
  overflow: hidden;
}

@keyframes drawerIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.06);
}

.drawer-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.drawer-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-tertiary);
  font-size: 20px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  outline: none;
}

.drawer-close:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.loadout-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.loadout-empty {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  padding: 24px 0;
}

.loadout-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.loadout-item:hover {
  background: var(--surface-raised);
}

.loadout-item-info {
  flex: 1;
  min-width: 0;
}

.loadout-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loadout-item-detail {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.loadout-item-type {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.loadout-type-attacker {
  background: rgba(139, 124, 246, 0.15);
  color: var(--accent-hover);
}

.loadout-type-defender {
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
}

.loadout-type-full {
  background: rgba(110, 231, 183, 0.12);
  color: var(--green);
}

.loadout-item-delete {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.15s;
  opacity: 0;
  flex-shrink: 0;
  outline: none;
}

.loadout-item:hover .loadout-item-delete {
  opacity: 1;
}

.loadout-item-delete:hover {
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
}

.drawer-footer {
  padding: 8px 12px 12px;
  border-top: 0.5px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: center;
}

/* Main body */
.app-body {
  padding: 20px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ========== ZONES ========== */

.zone { padding: 4px 0; }

/* ========== CSV IMPORT/EXPORT ========== */

.csv-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.btn-csv {
  background: var(--surface-raised);
  color: var(--text-tertiary);
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s var(--ease-smooth);
  outline: none;
}

.btn-csv:hover {
  color: var(--text-secondary);
  background: var(--tile-border);
}

.btn-csv:active {
  transform: scale(0.97);
}

/* ========== OVERWATCH TOGGLE ========== */

.overwatch-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 12px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--tile-border);
  border-radius: var(--radius-sm);
  user-select: none;
  transition: all 0.2s var(--ease-smooth);
}

.overwatch-toggle:hover {
  border-color: rgba(139, 124, 246, 0.25);
}

.overwatch-toggle:has(input:checked) {
  border-color: var(--orange);
  background: rgba(251, 191, 36, 0.08);
}

.overwatch-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.overwatch-switch {
  width: 34px;
  height: 20px;
  background: var(--surface-raised);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s var(--ease-smooth);
  flex-shrink: 0;
}

.overwatch-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--text-tertiary);
  border-radius: 50%;
  transition: all 0.2s var(--spring);
}

.overwatch-toggle input:checked + .overwatch-switch {
  background: var(--orange);
}

.overwatch-toggle input:checked + .overwatch-switch::after {
  left: 17px;
  background: #fff;
}

.overwatch-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  transition: color 0.15s;
  letter-spacing: -0.01em;
}

.overwatch-toggle input:checked ~ .overwatch-label {
  color: var(--orange);
}

.overwatch-hint {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-left: auto;
}

/* ========== UNIT NAME ========== */

.unit-name-input {
  width: 100%;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  padding: 4px 2px;
  margin-bottom: 10px;
  border-bottom: 1.5px solid transparent;
  outline: none;
  text-align: center;
  letter-spacing: -0.01em;
  transition: border-color 0.2s;
}

.unit-name-input:hover {
  border-bottom-color: var(--tile-border);
}

.unit-name-input:focus {
  border-bottom-color: var(--accent);
}

.unit-name-input::placeholder {
  color: var(--text-tertiary);
}

/* ========== STAT TILES ========== */

.stat-tiles {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.stat-tile {
  flex: 1;
  max-width: 100px;
  aspect-ratio: 1;
  background: var(--tile-bg);
  border: 1.5px solid var(--tile-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  cursor: pointer;
  outline: none;
}

.stat-tile:hover {
  border-color: rgba(139, 124, 246, 0.25);
  transform: translateY(-1px);
}

.stat-tile:focus-within {
  border-color: var(--tile-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
  transform: translateY(-1px);
}

.tile-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1;
}

.tile-input {
  width: 100%;
  text-align: center;
  font-family: var(--font);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  background: none;
  border: none;
  outline: none;
  padding: 0;
  line-height: 1.1;
  -moz-appearance: textfield;
  letter-spacing: -0.02em;
}

.tile-input::-webkit-inner-spin-button,
.tile-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.tile-input::placeholder {
  color: var(--text-tertiary);
  font-size: 22px;
}

/* Disabled tile (e.g. BS/WS when Torrent is active) */
.stat-tile.tile-disabled {
  opacity: 0.4;
  pointer-events: none;
  border-style: dashed;
}

.stat-tile.tile-disabled .tile-input {
  color: var(--text-tertiary);
}

.tile-input-text {
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
  text-transform: uppercase;
  font-size: 22px;
}

/* ========== WEAPON PROFILE ========== */

.weapon-profile {
  margin-bottom: 16px;
  animation: profileIn 0.35s var(--spring) both;
}

.weapon-profile.removing {
  animation: profileOut 0.25s var(--ease-smooth) forwards;
  pointer-events: none;
}

@keyframes profileIn {
  from { opacity: 0; transform: scale(0.95) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes profileOut {
  to { opacity: 0; transform: scale(0.95); height: 0; margin: 0; overflow: hidden; }
}

/* Weapon toolbar */
.weapon-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  padding: 0 4px;
}

.weapon-name-input {
  flex: 1;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 6px;
  outline: none;
  transition: background 0.15s;
  letter-spacing: -0.01em;
  text-align: center;
  min-width: 0;
}

.weapon-name-input:hover { background: var(--surface-raised); }
.weapon-name-input:focus { background: var(--surface-raised); }

/* Count control */
.count-control {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface-raised);
  border-radius: 20px;
  padding: 2px;
}

.count-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--text-tertiary);
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  transition: all 0.15s var(--ease-smooth);
  outline: none;
}

.count-btn:hover {
  background: var(--text-secondary);
  transform: scale(1.05);
}

.count-btn:active { transform: scale(0.92); }

.count-display {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  min-width: 36px;
  text-align: center;
  letter-spacing: -0.01em;
  user-select: none;
}

/* Remove weapon */
.btn-remove-weapon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  flex-shrink: 0;
  outline: none;
}

.btn-remove-weapon:hover {
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
}

/* Divider between weapon profiles */
.weapon-profile + .weapon-profile {
  padding-top: 16px;
  border-top: 0.5px solid var(--divider);
}

/* ========== ZONE ACTIONS ========== */

.zone-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.circle-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--surface-raised);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s var(--ease-smooth);
  outline: none;
}

.circle-btn:hover {
  background: var(--tile-border);
  color: var(--text);
  transform: scale(1.06);
}

.circle-btn:active { transform: scale(0.93); }

/* ========== VERSUS DIVIDER ========== */

.versus-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
}

.hazard-stripes {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 1px;
  opacity: 0.4;
}

.versus-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ========== DEFENDER TILES ========== */

.defender-tiles { justify-content: center; }

/* Defender toolbar */
.defender-toolbar {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

/* ========== CALCULATE BUTTON ========== */

.btn-calc {
  width: 100%;
  padding: 14px;
  margin-top: 20px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-solid), var(--accent-hover));
  color: #fff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s var(--ease-smooth);
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  outline: none;
}

.btn-calc:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(139, 124, 246, 0.35);
}

.btn-calc:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 8px rgba(139, 124, 246, 0.2);
}

.btn-calc.computing .btn-calc-label { opacity: 0; }

.btn-calc-spinner {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

.btn-calc.computing .btn-calc-spinner {
  display: flex;
}

.btn-calc-spinner::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========== RESULTS ========== */

.results-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 0.5px solid var(--divider);
  animation: resultsIn 0.45s var(--spring) both;
}

@keyframes resultsIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.result-card {
  background: var(--surface);
  border: 0.5px solid rgba(139, 124, 246, 0.08);
  border-radius: var(--radius-md);
  padding: 16px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform 0.2s var(--spring);
}

.result-card:hover { transform: translateY(-2px); }

.result-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.result-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-sub {
  font-size: 10px;
  color: var(--text-tertiary);
}

.result-value.counting { transition: none; }

/* Chart */
.chart-section h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.chart-container {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding: 4px 0;
}

.chart-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  cursor: default;
  position: relative;
}

.chart-bar {
  width: 100%;
  max-width: 48px;
  border-radius: 4px 4px 2px 2px;
  min-height: 2px;
  transition: height 0.5s var(--spring);
  background: var(--bar-fill);
  opacity: 0.8;
}

.chart-bar.bar-max { background: var(--bar-fill-max); opacity: 1; }
.chart-bar-wrapper:hover .chart-bar { opacity: 1; filter: brightness(1.15); }

.chart-bar-pct {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transform: translateY(4px);
  animation: fadeUp 0.3s var(--ease-out) forwards;
}

.chart-bar-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-top: 3px;
}

@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }

/* Tooltip */
.chart-bar-wrapper .chart-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

.chart-bar-wrapper:hover .chart-tooltip {
  display: block;
  animation: tooltipIn 0.15s var(--ease-out);
}

@keyframes tooltipIn {
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Breakdown */
.breakdown-details {
  margin-top: 16px;
  border-top: 0.5px solid var(--divider);
  padding-top: 12px;
}

.breakdown-details summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
  outline: none;
}

.breakdown-details summary::-webkit-details-marker { display: none; }

.breakdown-details summary::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-tertiary);
  border-bottom: 1.5px solid var(--text-tertiary);
  transform: rotate(-45deg);
  transition: transform 0.2s var(--ease-smooth);
}

.breakdown-details[open] summary::before { transform: rotate(45deg); }
.breakdown-details summary:hover { color: var(--text); }

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  animation: listIn 0.3s var(--ease-out);
}

@keyframes listIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.breakdown-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.breakdown-item strong { color: var(--text); font-weight: 700; }

.breakdown-item .tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-raised);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.breakdown-item .tag-accent {
  background: var(--accent-glow);
  color: var(--accent-hover);
}

.breakdown-item .arrow {
  color: var(--text-tertiary);
  font-size: 10px;
  margin: 0 1px;
}

/* ========== WEAPON ORDER OPTIMIZER ========== */

.order-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 0.5px solid var(--divider);
}

.order-section h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.order-card {
  background: var(--surface);
  border: 1px solid var(--tile-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
}

.order-card.order-smart {
  border-color: rgba(139, 124, 246, 0.35);
  background: rgba(139, 124, 246, 0.08);
}

.order-card.order-best {
  border-color: rgba(110, 231, 183, 0.25);
  background: rgba(110, 231, 183, 0.05);
}

.order-card.order-worst {
  border-color: rgba(248, 113, 113, 0.15);
  background: rgba(248, 113, 113, 0.03);
  opacity: 0.7;
}

.order-rank {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.order-smart .order-rank { color: var(--accent-hover); }
.order-best .order-rank { color: var(--green); }
.order-worst .order-rank { color: var(--red); }

.order-sequence {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.order-step {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-raised);
  padding: 3px 8px;
  border-radius: 5px;
}

.order-arrow {
  font-size: 11px;
  color: var(--text-tertiary);
}

.order-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
  margin-bottom: 8px;
}

/* Step-by-step instructions */
.order-instructions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.order-instruction-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.order-step-num {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
}

.order-step-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.order-instruction-note {
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
  margin-top: 2px;
  padding-left: 28px;
}

.order-stats {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--text-secondary);
}

.order-comparison {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.order-gain {
  color: var(--green);
  font-weight: 600;
}

.order-save {
  color: var(--accent-hover);
  font-weight: 600;
}

/* Verdict */
.order-verdict {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--tile-border);
}

.verdict-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.verdict-skip {
  background: rgba(110, 231, 183, 0.15);
  color: var(--green);
}

.verdict-maybe {
  background: rgba(251, 191, 36, 0.15);
  color: var(--orange);
}

.verdict-yes {
  background: rgba(139, 124, 246, 0.2);
  color: var(--accent-hover);
}

.verdict-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.verdict-text strong {
  color: var(--text);
}

/* ========== EXPORT BUTTON ========== */

.btn-export {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 16px;
  padding: 10px;
  border: 1px solid var(--tile-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s var(--ease-smooth);
  outline: none;
}

.btn-export:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface-raised);
}

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

/* ========== MODIFIER PANELS ========== */

.btn-mods-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  padding: 5px 10px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s var(--ease-smooth);
  position: relative;
  flex-shrink: 0;
  outline: none;
}

.btn-mods-toggle:hover {
  background: var(--tile-border);
  color: var(--text);
}

.btn-mods-toggle.active {
  background: var(--accent-glow);
  color: var(--accent-hover);
}

.mod-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  padding: 0 4px;
  line-height: 1;
}

.mod-panel {
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  animation: modPanelIn 0.25s var(--ease-out);
}

@keyframes modPanelIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mod-panel-header {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.mod-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}

.mod-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 4px;
  border-radius: 6px;
  transition: background 0.15s;
  user-select: none;
}

.mod-toggle:hover { background: rgba(139, 124, 246, 0.06); }

.mod-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mod-switch {
  width: 30px;
  height: 18px;
  background: var(--surface-raised);
  border-radius: 9px;
  position: relative;
  transition: background 0.2s var(--ease-smooth);
  flex-shrink: 0;
}

.mod-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-tertiary);
  border-radius: 50%;
  transition: all 0.2s var(--spring);
}

.mod-checkbox:checked + .mod-switch {
  background: var(--accent);
}

.mod-checkbox:checked + .mod-switch::after {
  left: 14px;
  background: #fff;
}

.mod-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.15s;
  line-height: 1.2;
}

.mod-checkbox:checked ~ .mod-name { color: var(--text); }

/* Info icon with tooltip */
.mod-info {
  margin-left: auto;
  color: var(--text-tertiary);
  cursor: help;
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.mod-info:hover { opacity: 1; }

.mod-info::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  right: -4px;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 8px;
  border-radius: 6px;
  white-space: nowrap;
  max-width: 220px;
  white-space: normal;
  line-height: 1.3;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 20;
}

.mod-info:hover::after {
  opacity: 1;
  transform: translateY(0);
}

/* Modifier pills in breakdown */
.breakdown-mods {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  width: 100%;
  margin-top: 4px;
}

.mod-pill {
  font-size: 9px;
  font-weight: 600;
  color: var(--accent-hover);
  background: var(--accent-glow);
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.02em;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 480px) {
  body { padding: 8px; }
  .app-chrome { border-radius: var(--radius-lg); }

  .stat-tile {
    max-width: 80px;
    border-radius: var(--radius-sm);
  }

  .tile-input { font-size: 22px; }
  .tile-label { font-size: 10px; }

  .versus-text { font-size: 11px; }
  .versus-divider { padding: 18px 0; gap: 12px; }

  .results-grid { grid-template-columns: 1fr; }
  .result-card {
    flex-direction: row;
    justify-content: space-between;
    padding: 12px 16px;
  }
  .result-value { font-size: 22px; }

  .mod-grid { grid-template-columns: 1fr; }
}

/* ===== Weapon type toggle (ranged / melee) ===== */
.wp-type-toggle {
  border: 1px solid var(--tile-border);
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  padding: 5px 8px;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  outline: none;
  transition: all 0.15s var(--ease-smooth);
}
.wp-type-toggle:hover { color: var(--text); }
.wp-type-toggle.is-melee {
  color: var(--danger, #f87171);
  border-color: currentColor;
}

/* ===== MODIFIERS +/− label ===== */
.mods-toggle-text { white-space: nowrap; letter-spacing: 0.04em; font-size: 10px; font-weight: 700; }
.mods-toggle-sign { font-size: 12px; font-weight: 800; }

/* ===== Phase scope (All / Ranged / Melee) ===== */
.calc-scope {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 6px;
}
.calc-scope-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.scope-btn {
  flex: 1;
  border: 1px solid var(--tile-border);
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  padding: 6px 0;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  transition: all 0.15s var(--ease-smooth);
  outline: none;
}
.scope-btn:hover { color: var(--text); }
.scope-btn.active {
  background: var(--accent-glow);
  color: var(--accent-hover);
  border-color: var(--accent-hover);
}
