@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --ink: #1a1510;
  --ink-soft: #3a3127;
  --paper: #f6efe4;
  --panel: #fff8ef;
  --panel-strong: #f2e6d7;
  --accent: #e07a3f;
  --accent-dark: #b65521;
  --accent-2: #2a9d8f;
  --accent-3: #f2c14e;
  --shadow: 0 18px 35px rgba(27, 21, 16, 0.15);
  --radius: 18px;
  --radius-sm: 12px;
  --stroke: rgba(26, 21, 16, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff1d6 0%, #f0f5f6 45%, #f7efe5 100%);
  min-height: 100vh;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: -1;
}

body::before {
  width: 40vw;
  height: 40vw;
  top: -10vw;
  right: -10vw;
  background: radial-gradient(circle, rgba(224, 122, 63, 0.35), transparent 70%);
}

body::after {
  width: 35vw;
  height: 35vw;
  bottom: -12vw;
  left: -8vw;
  background: radial-gradient(circle, rgba(42, 157, 143, 0.25), transparent 70%);
}

h1,
h2,
.hero__badge,
.panel__subhead {
  font-family: "Fraunces", "Times New Roman", serif;
  letter-spacing: 0.01em;
}

.page {
  padding: 28px 4vw 48px;
}

.hero {
  background: linear-gradient(120deg, #fff8ef 0%, #f8ead6 50%, #f1e7da 100%);
  border-radius: calc(var(--radius) + 6px);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(26, 21, 16, 0.08);
  border-radius: calc(var(--radius) + 2px);
  pointer-events: none;
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--accent-3);
  color: var(--ink);
  border-radius: 999px;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.hero__auth {
  position: absolute;
  top: 22px;
  right: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
}

.auth-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255, 248, 239, 0.75);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  font-weight: 600;
}

.auth-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  background: #f1e7da;
}

.auth-btn {
  font-size: 0.85rem;
  padding: 6px 12px;
}

.auth-btn.active {
  background: white;
  border-color: var(--stroke);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(26, 21, 16, 0.1);
}

.auth-name {
  color: inherit;
  text-decoration: none;
}

.auth-name:hover {
  text-decoration: underline;
}

.discord-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5865f2;
  display: inline-block;
  margin-right: 6px;
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.2);
}

.hero h1 {
  margin: 10px 0 6px;
  font-size: clamp(1.8rem, 2.5vw, 2.6rem);
}

.hero__lede {
  margin: 0 0 18px;
  color: var(--ink-soft);
  max-width: 720px;
}

body.profile-mode .layout {
  display: none;
}

body.profile-mode .profile-layout {
  display: grid;
}

body.profile-mode .hero__controls,
body.profile-mode .hero__status,
body.profile-mode .mode-selector {
  display: none;
}

@media (max-width: 720px) {
  .hero__auth {
    position: static;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

.hero__controls {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 16px;
}

.control-group {
  display: grid;
  gap: 10px;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px dashed var(--stroke);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
}

.file-label input {
  display: none;
}

textarea {
  resize: vertical;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  padding: 10px 12px;
  font-family: "Space Grotesk", sans-serif;
}

.hero__status {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-weight: 600;
}

.layout {
  display: grid;
  gap: 22px;
  margin-top: 24px;
  grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.3fr);
}

.profile-layout {
  display: none;
  gap: 22px;
  margin-top: 24px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.profile-summary {
  grid-column: 1 / -1;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #fff;
  background: #f1e7da;
}

.profile-header__name {
  font-size: 1.4rem;
  font-weight: 700;
}

.profile-header__id {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.profile-list {
  display: grid;
  gap: 14px;
}

.profile-card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.profile-card__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.profile-card__title {
  font-weight: 700;
}

.profile-card__meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.profile-card__sub {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.profile-matches {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.profile-match {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
}

.profile-match__meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.profile-outcome {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
}

.profile-outcome--win {
  background: var(--accent-2);
}

.profile-outcome--loss {
  background: var(--accent-dark);
}

.profile-outcome--draw {
  background: var(--accent-3);
  color: var(--ink);
}

.profile-empty {
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
}

.btn.btn-sm {
  padding: 6px 10px;
  font-size: 0.75rem;
}

.player-link {
  color: inherit;
  text-decoration: none;
}

.player-link:hover {
  text-decoration: underline;
}

.challenge-link {
  color: inherit;
  text-decoration: none;
}

.challenge-link:hover {
  text-decoration: underline;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  border: 1px solid rgba(26, 21, 16, 0.08);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel__header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.panel__subhead {
  font-size: 1.1rem;
  margin-top: 6px;
}

.btn {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 18px rgba(224, 122, 63, 0.25);
}

a.btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--stroke);
  box-shadow: none;
}

.builder-only {
  display: inline-flex;
}

.budget-only {
  display: none;
}

.builder-budgets {
  display: none;
  gap: 10px;
}

.speed-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.speed-label select {
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--stroke);
  background: #fff;
}

.seed-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.seed-label input {
  width: 90px;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--stroke);
  background: #fff;
  font-family: "Space Grotesk", sans-serif;
}

.builder__teams {
  display: grid;
  gap: 14px;
}

.team-panel {
  border: 1px solid var(--stroke);
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
}

.team-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.creator-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--stroke);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  font-size: 0.7rem;
}

.creator-badge__label {
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.62rem;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 10px;
}

.team-synergy {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.team-synergy__title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-weight: 700;
}

.team-synergy__list {
  display: grid;
  gap: 8px;
}

.team-synergy__empty {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.synergy-card {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  display: grid;
  gap: 4px;
}

.synergy-card.is-active {
  border-color: rgba(42, 157, 143, 0.6);
  background: rgba(42, 157, 143, 0.08);
}

.synergy-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
}

.synergy-card__element {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.synergy-card__status {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.synergy-card.is-active .synergy-card__status {
  color: #2a9d8f;
}

.synergy-card__name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

.synergy-card__desc {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* Front/Back row theming in team grids */
/* Budget mode: Team A renders front-back (F0-F2, B0-B2) */
/* Challenge mode: Team A renders back-front (B0-B2, F0-F2), Team B renders front-back (F0-F2, B0-B2) */
/* Goal: Front lines (orange) face each other, back lines (blue) face each other */

/* Default: nth-child(1-3) = front (orange), nth-child(4-6) = back (blue) */
/* This applies to budget mode Team A and challenge mode Team B */
.team-grid .slot:nth-child(1),
.team-grid .slot:nth-child(2),
.team-grid .slot:nth-child(3) {
  /* First row = front line (default) */
  background: linear-gradient(135deg, #fff9f0, #fff);
  border-color: rgba(224, 122, 63, 0.3);
}

.team-grid .slot:nth-child(4),
.team-grid .slot:nth-child(5),
.team-grid .slot:nth-child(6) {
  /* Second row = back line (default) */
  background: linear-gradient(135deg, #f0f9ff, #fff);
  border-color: rgba(42, 157, 143, 0.3);
}

/* Override for challenge mode Team A: nth-child(1-3) = back (blue), nth-child(4-6) = front (orange) */
body.challenge-mode .team-panel[data-team="A"] .team-grid .slot:nth-child(1),
body.challenge-mode .team-panel[data-team="A"] .team-grid .slot:nth-child(2),
body.challenge-mode .team-panel[data-team="A"] .team-grid .slot:nth-child(3) {
  /* Team A first row = back line in challenge mode */
  background: linear-gradient(135deg, #f0f9ff, #fff);
  border-color: rgba(42, 157, 143, 0.3);
}

body.challenge-mode .team-panel[data-team="A"] .team-grid .slot:nth-child(4),
body.challenge-mode .team-panel[data-team="A"] .team-grid .slot:nth-child(5),
body.challenge-mode .team-panel[data-team="A"] .team-grid .slot:nth-child(6) {
  /* Team A second row = front line in challenge mode */
  background: linear-gradient(135deg, #fff9f0, #fff);
  border-color: rgba(224, 122, 63, 0.3);
}

.slot {
  position: relative;
  border: 1px dashed rgba(26, 21, 16, 0.2);
  border-radius: 14px;
  padding: 8px;
  min-height: 86px;
  background: #fffaf3;
  display: grid;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.slot:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.slot__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

.slot__name {
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.slot__icon {
  font-size: 1.3rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.slot__icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.slot__icon--secondary {
  font-size: 0.9em;
  opacity: 0.85;
}

.slot__stats {
  font-size: 0.72rem;
  color: var(--ink-soft);
  display: grid;
  gap: 4px;
}

.slot__tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(42, 157, 143, 0.14);
}

.roster {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.roster-card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.roster-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.roster-card.selected {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(42, 157, 143, 0.18);
}

.roster-card__icon {
  font-size: 2rem;
  line-height: 1;
  text-align: center;
  margin-bottom: 4px;
}

.roster-card__icon img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.roster-card__title {
  font-weight: 700;
  font-size: 1rem;
}

.roster-card__desc {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.roster-card__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.74rem;
}

.roster-card__stats span {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(224, 122, 63, 0.1);
}

/* Tier badges on roster cards */
.roster-card__tiers {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.tier-cost-badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tier-cost-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tier-cost-badge.tier-1 {
  background: linear-gradient(135deg, #cd7f32, #b87333);
  color: #fff;
  border-color: #a0522d;
}

.tier-cost-badge.tier-2 {
  background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
  color: #1a1510;
  border-color: #909090;
}

.tier-cost-badge.tier-3 {
  background: linear-gradient(135deg, #ffd700, #ffcc00);
  color: #1a1510;
  border-color: #d4af37;
}

/* Unit stat tooltip */
.unit-tooltip {
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 300px;
  max-width: 360px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.unit-tooltip.visible {
  opacity: 1;
}

.unit-tooltip__header {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--stroke);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.unit-tooltip__header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.unit-tooltip__class-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 1.1rem;
}

.unit-tooltip__class-icon {
  line-height: 1;
}

.unit-tooltip__class-separator {
  opacity: 0.4;
  font-size: 0.8rem;
}

.unit-tooltip__tier {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.unit-tooltip__tier.tier-1 {
  background: linear-gradient(135deg, #cd7f32, #b87333);
  color: #fff;
}

.unit-tooltip__tier.tier-2 {
  background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
  color: #1a1510;
}

.unit-tooltip__tier.tier-3 {
  background: linear-gradient(135deg, #ffd700, #ffcc00);
  color: #1a1510;
}

.unit-tooltip__section {
  margin-bottom: 10px;
}

.unit-tooltip__section:last-child {
  margin-bottom: 0;
}

.unit-tooltip__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 4px;
  font-weight: 600;
}

.unit-tooltip__stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  font-size: 0.82rem;
}

.unit-tooltip__stat {
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
  background: rgba(224, 122, 63, 0.05);
  border-radius: 4px;
}

.unit-tooltip__stat-name {
  font-weight: 600;
  color: var(--ink-soft);
}

.unit-tooltip__stat-value {
  font-weight: 700;
  color: var(--ink);
}

.unit-tooltip__stat-bonus {
  font-size: 0.7rem;
  color: var(--ink-soft);
  font-weight: 600;
  cursor: help;
}

.unit-tooltip__stat-mod {
  font-size: 0.7rem;
  color: var(--accent-2);
  font-weight: 600;
}

.unit-tooltip__combat {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
}

.unit-tooltip__combat-stat {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(42, 157, 143, 0.05);
  border-radius: 4px;
}

.unit-tooltip__combat-label {
  font-weight: 600;
  color: var(--ink-soft);
}

.unit-tooltip__combat-value {
  font-weight: 700;
  color: var(--ink);
}

.unit-tooltip__scaled {
  color: var(--accent-2);
  font-weight: 600;
}

.unit-tooltip__weapon-bonus {
  color: #4a9eff;
  font-weight: 600;
}

.unit-tooltip__skills {
  display: grid;
  gap: 8px;
}

.unit-tooltip__skill {
  padding: 8px;
  background: rgba(224, 122, 63, 0.05);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.unit-tooltip__skill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.unit-tooltip__skill-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink);
}

.unit-tooltip__skill-cost {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.unit-tooltip__skill-cost.mana-cost {
  background: linear-gradient(135deg, rgba(42, 157, 143, 0.2), rgba(42, 157, 143, 0.3));
  color: var(--accent-2);
}

.unit-tooltip__skill-cost.adr-cost {
  background: linear-gradient(135deg, rgba(224, 122, 63, 0.2), rgba(224, 122, 63, 0.3));
  color: var(--accent);
}

.unit-tooltip__skill-desc {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-style: italic;
}

.unit-tooltip__skill-formula {
  font-size: 0.76rem;
  color: var(--ink-soft);
  font-family: 'Courier New', monospace;
  margin-bottom: 3px;
  font-weight: 500;
}

.unit-tooltip__skill-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  font-family: 'Courier New', monospace;
}

.unit-tooltip__secondary {
  background: var(--panel);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(26, 21, 16, 0.08);
}

.unit-tooltip__secondary-passive {
  margin-top: 6px;
}

.unit-tooltip__passive-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 3px;
}

.unit-tooltip__passive-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  font-family: 'Courier New', monospace;
}

.unit-tooltip__passive-desc {
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.3;
}

.unit-tooltip__passive-desc .attr-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.unit-tooltip__passive-desc .attr-icon {
  font-size: 0.9em;
}

.unit-tooltip__weapon {
  background: linear-gradient(135deg, rgba(120, 120, 255, 0.08), rgba(80, 80, 200, 0.06));
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(120, 120, 255, 0.2);
}

.unit-tooltip__weapon-stats {
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a9eff;
  margin-top: 6px;
  font-family: 'Courier New', monospace;
}

.unit-tooltip__weapon-mods {
  font-size: 0.85rem;
  color: var(--ink);
  margin-top: 4px;
  line-height: 1.4;
}

.unit-tooltip__weapon-effects {
  font-size: 0.85rem;
  color: #ff9944;
  margin-top: 4px;
  line-height: 1.4;
  font-style: italic;
}

.unit-tooltip__synergies {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.08), rgba(255, 165, 0, 0.06));
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 165, 0, 0.2);
}

.unit-tooltip__synergy {
  margin-top: 6px;
}

.unit-tooltip__synergy:first-child {
  margin-top: 0;
}

.unit-tooltip__synergy-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 3px;
}

.unit-tooltip__synergy-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  font-family: 'Courier New', monospace;
}

.unit-tooltip__synergy-desc {
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.3;
}

.unit-tooltip__synergy-desc .attr-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.unit-tooltip__synergy-desc .attr-icon {
  font-size: 0.9em;
}

.unit-tooltip__battle-stats {
  background: linear-gradient(135deg, rgba(224, 91, 79, 0.08), rgba(216, 69, 63, 0.06));
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(224, 91, 79, 0.2);
}

.formula-attr {
  color: var(--accent-2);
  font-weight: 700;
}

.attr-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}

.attr-icon {
  font-size: 0.85em;
  line-height: 1;
}

.attr-sup {
  font-size: 0.65em;
  margin-left: 2px;
  vertical-align: super;
  opacity: 0.85;
}

.formula-token {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.attr--hp {
  color: #e05b4f;
}

.attr--str {
  color: #d8453f;
}

.attr--int {
  color: #3f8cff;
}

.attr--agi {
  color: #2a9d8f;
}

.attr--cha {
  color: #e07a3f;
}

.formula-total {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
}

.status-name {
  color: var(--accent);
  font-weight: 700;
  text-transform: capitalize;
}

.hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.arena {
  display: grid;
  grid-template-rows: auto auto;
  gap: 20px;
  padding: 14px;
  border-radius: var(--radius);
  background: linear-gradient(140deg, #fef8f2, #f1f5f6);
  border: 1px solid rgba(26, 21, 16, 0.08);
  min-height: 280px;
  position: relative;
  overflow: hidden;
}

.arena__empty {
  grid-column: 1 / -1;
  align-self: center;
  text-align: center;
  color: var(--ink-soft);
}

.summary-view {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.summary-team {
  display: grid;
  gap: 10px;
}

.summary-team__title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.summary-grid {
  display: grid;
  gap: 10px;
}

.summary-card {
  border-radius: 12px;
  border: 1px solid rgba(26, 21, 16, 0.12);
  background: #fffdf8;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.summary-card__header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 0.88rem;
}

.summary-card__slot {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.summary-card__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  font-size: 0.74rem;
  color: var(--ink-soft);
}

.summary-stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.summary-stat__value {
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.summary-stat__label {
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(26, 21, 16, 0.08);
}

.summary-stat.damage .summary-stat__label,
.summary-stat.damage .summary-stat__value {
  color: #d8453f;
}

.summary-stat.damage-taken .summary-stat__label,
.summary-stat.damage-taken .summary-stat__value {
  color: #b85a2a;
}

.summary-stat.heal .summary-stat__label,
.summary-stat.heal .summary-stat__value {
  color: #1b8f6c;
}

.summary-stat.heal-recv .summary-stat__label,
.summary-stat.heal-recv .summary-stat__value {
  color: #2a9d8f;
}

.summary-stat.shield .summary-stat__label,
.summary-stat.shield .summary-stat__value {
  color: #3f8cff;
}

.summary-stat.shield-recv .summary-stat__label,
.summary-stat.shield-recv .summary-stat__value {
  color: #4aa3ff;
}

.summary-stat.hp .summary-stat__label,
.summary-stat.hp .summary-stat__value {
  color: #e05b4f;
}

.summary-stat.death .summary-stat__label,
.summary-stat.death .summary-stat__value {
  color: #6b6b6b;
}

.squad {
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(26, 21, 16, 0.06);
}

.squad[data-team="A"] {
  background: linear-gradient(135deg, rgba(42, 157, 143, 0.04), rgba(42, 157, 143, 0.08));
  border-color: rgba(42, 157, 143, 0.15);
}

.squad[data-team="B"] {
  background: linear-gradient(135deg, rgba(224, 122, 63, 0.04), rgba(224, 122, 63, 0.08));
  border-color: rgba(224, 122, 63, 0.15);
}

.squad__title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.squad-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

/* Front/Back row theming in combat arena */
/* Note: Team A has back-front order, Team B has front-back order */

.squad:first-child .squad-row:first-of-type {
  /* Team A first row = back line */
  padding: 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(42, 157, 143, 0.08), rgba(240, 249, 255, 0.5));
}

.squad:first-child .squad-row:last-of-type {
  /* Team A second row = front line */
  padding: 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(224, 122, 63, 0.08), rgba(255, 249, 240, 0.5));
}

.squad:last-child .squad-row:first-of-type {
  /* Team B first row = front line */
  padding: 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(224, 122, 63, 0.08), rgba(255, 249, 240, 0.5));
}

.squad:last-child .squad-row:last-of-type {
  /* Team B second row = back line */
  padding: 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(42, 157, 143, 0.08), rgba(240, 249, 255, 0.5));
}

.arena-slot {
  min-height: 120px;
  border-radius: 14px;
  border: 1px dashed rgba(26, 21, 16, 0.16);
  padding: 8px;
  background: #fff;
  display: grid;
  gap: 6px;
  align-content: start;
}

.unit-card {
  display: grid;
  gap: 6px;
  padding: 8px;
  padding-right: 18px;
  padding-left: 18px;
  border-radius: 12px;
  background: #fffdf8;
  border: 1px solid rgba(26, 21, 16, 0.12);
  position: relative;
}

.unit-card.is-dead {
  opacity: 0.45;
  filter: grayscale(0.4);
}

.unit-card.has-shield {
  border-color: rgba(63, 140, 255, 0.6);
  box-shadow: 0 0 0 2px rgba(63, 140, 255, 0.2), 0 0 14px rgba(63, 140, 255, 0.25);
}

.unit-card.summary-mode {
  overflow: visible;
}

.summary-overlay {
  position: absolute;
  top: 32px;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(26, 21, 16, 0.08);
  display: grid;
  pointer-events: none;
}

.summary-overlay__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 8px;
  font-size: 0.68rem;
}

.summary-overlay .summary-stat__label {
  font-size: 0.6rem;
  padding: 1px 4px;
}

.summary-dead-icon {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.9rem;
  background: rgba(26, 21, 16, 0.75);
  color: #fff;
  border-radius: 999px;
  padding: 2px 6px;
  z-index: 3;
}

.summary-detail {
  position: absolute;
  left: 100%;
  top: 0;
  margin-left: 12px;
  min-width: 200px;
  background: rgba(255, 255, 255, 0.98);
  border: 2px solid rgba(26, 21, 16, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 12px 24px rgba(26, 21, 16, 0.2);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}

.summary-mode:hover .summary-detail {
  opacity: 1;
  transform: translateX(0);
}

.summary-detail__title {
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  color: var(--ink-soft);
}

.summary-detail__grid {
  display: grid;
  gap: 4px;
  font-size: 0.72rem;
}

.summary-detail__row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.summary-detail__label {
  color: var(--ink-soft);
}

.summary-detail__value {
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.unit-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.86rem;
  position: relative;
  z-index: 2;
}

.unit-card__icon {
  font-size: 1.2rem;
  line-height: 1;
  margin-right: 4px;
}

.unit-card__icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  vertical-align: middle;
}

.unit-card__icon--secondary {
  font-size: 1em;
  opacity: 0.85;
  margin-right: 4px;
}

.unit-card__name {
  flex: 1;
}

.unit-card__slot {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.unit-card__statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.unit-card__statuses.is-empty {
  display: none;
}

.status-badge {
  display: grid;
  grid-template-rows: auto 3px;
  gap: 2px;
  align-items: center;
  justify-items: center;
  min-width: 26px;
  padding: 3px 4px 4px;
  border-radius: 8px;
  border: 1px solid rgba(26, 21, 16, 0.12);
  background: rgba(26, 21, 16, 0.05);
  position: relative;
  font-size: 0.7rem;
  color: var(--ink);
}

.status-badge__icon {
  font-size: 0.85rem;
  line-height: 1;
}

.status-badge__bar {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: rgba(26, 21, 16, 0.12);
  overflow: hidden;
}

.status-badge__fill {
  display: block;
  height: 100%;
  width: 100%;
  transition: width 0.08s linear;
}

.status-badge--buff {
  border-color: rgba(46, 125, 50, 0.4);
  background: rgba(46, 125, 50, 0.12);
  color: #1b5e20;
}

.status-badge--buff .status-badge__fill {
  background: linear-gradient(90deg, #7bdc8a, #2e7d32);
}

.status-badge--debuff {
  border-color: rgba(245, 101, 69, 0.45);
  background: rgba(245, 101, 69, 0.12);
  color: #b23b2a;
}

.status-badge--debuff .status-badge__fill {
  background: linear-gradient(90deg, #f56545, #b71c1c);
}

.status-badge__stack {
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 0.55rem;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(26, 21, 16, 0.78);
  color: #fff;
  font-weight: 700;
}

.bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(26, 21, 16, 0.08);
  overflow: visible;
  position: relative;
}

.bar__fill {
  position: absolute;
  inset: 0;
  width: 0%;
  transition: width 0.2s ease;
  border-radius: 999px;
  z-index: 1;
}

.bar__chunk {
  position: absolute;
  inset: 0;
  width: 0%;
  opacity: 0;
  border-radius: 999px;
  pointer-events: none;
  z-index: 2;
}

.bar.hp .bar__fill {
  background: linear-gradient(90deg, #f56545, #f2c14e);
}

.bar.hp {
  height: 8px;
}

.bar.shield .bar__fill {
  background: linear-gradient(90deg, #6ec1ff, #3f8cff);
}

.bar.shield {
  height: 4px;
}

.bar.mana .bar__fill {
  background: linear-gradient(90deg, #7d5fff, #3b82f6);
  /* Transition disabled during playback - updated via RAF */
  transition: none;
}

.bar.mana {
  height: 5px;
}

.bar.mana .bar__chunk {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.7), rgba(125, 95, 255, 0.15));
  mix-blend-mode: screen;
}

.bar.mana .bar__chunk.is-active {
  animation: manaChunkFade 520ms ease-out;
}

.bar__shield {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(110, 193, 255, 0.95), rgba(63, 140, 255, 0.7));
  opacity: 0.8;
  transition: width 0.2s ease;
  z-index: 2;
  pointer-events: none;
}

.bar__threshold {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5), inset 0 0 2px rgba(255, 255, 255, 0.8);
  z-index: 2;
  pointer-events: none;
}

.attack-bar {
  position: absolute;
  right: 6px;
  top: 8px;
  bottom: 8px;
  width: 6px;
  border-radius: 999px;
  background: rgba(26, 21, 16, 0.1);
  overflow: hidden;
}

.attack-bar span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, #f2c14e, #e07a3f);
  /* No transition - updated every frame via RAF for smooth animation */
}

.resource-bar {
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 6px;
  border-radius: 999px;
  background: rgba(26, 21, 16, 0.1);
  overflow: visible;
}

.resource-bar__fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, #f66b6b, #ff8c42);
  transition: height 0.2s ease;
  border-radius: 999px;
}

.resource-bar__threshold {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5), inset 0 0 2px rgba(255, 255, 255, 0.8);
  z-index: 2;
  pointer-events: none;
}

.unit-card__meta {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 4px 8px;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.bar-row {
  display: grid;
  gap: 2px;
}

.bar-label {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.bar-label__icon {
  font-size: 0.75rem;
  line-height: 1;
}

.bar-label__name {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.bar-label__value {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 600;
}

.bar-label__value--strong {
  font-size: 0.78rem;
  font-weight: 700;
}

.bar-label__shield {
  margin-left: 6px;
  font-size: 0.65rem;
  color: #3f8cff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bar-label--adrenaline {
  justify-self: start;
  margin-top: 2px;
  color: #b2543a;
  font-weight: 700;
}

.unit-card__skills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.62rem;
}

.skill-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(26, 21, 16, 0.15);
  background: rgba(26, 21, 16, 0.06);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.skill-chip--mana {
  border-color: rgba(61, 117, 255, 0.4);
  background: rgba(61, 117, 255, 0.12);
}

.skill-chip--adrenaline {
  border-color: rgba(245, 101, 69, 0.45);
  background: rgba(245, 101, 69, 0.12);
}

.skill-chip__resource {
  font-weight: 700;
  color: var(--ink);
  opacity: 0.7;
}

.skill-chip__name {
  font-weight: 600;
  color: var(--ink);
}

.skill-chip__cost {
  opacity: 0.8;
}

.skill-chip__cooldown {
  font-weight: 700;
  color: #f56545;
}

.skill-chip.is-cooldown {
  opacity: 0.7;
}

.skill-chip.is-ready {
  border-color: rgba(46, 125, 50, 0.55);
  background: rgba(46, 125, 50, 0.15);
  color: #1b5e20;
}

.stat-line {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.stat-label {
  font-weight: 600;
}

.stat-number {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.stat-number--strong {
  font-size: 0.78rem;
  font-weight: 700;
}

.stat-suffix {
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.timeline {
  display: grid;
  gap: 8px;
}

.timeline input[type="range"] {
  width: 100%;
}

.timeline__meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.event-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.event-feed li {
  padding: 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(26, 21, 16, 0.1);
  font-size: 0.82rem;
  cursor: pointer;
}

.event-feed li.active {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(42, 157, 143, 0.18);
}

@keyframes manaChunkFade {
  0% {
    opacity: 0.85;
  }
  70% {
    opacity: 0.35;
  }
  100% {
    opacity: 0;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(224, 122, 63, 0.4);
  }
  70% {
    transform: scale(1.02);
    box-shadow: 0 0 0 10px rgba(224, 122, 63, 0);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes hit {
  0% {
    transform: translate(0, 0) scale(1);
  }
  20% {
    transform: translate(4px, -4px) scale(1.01);
  }
  45% {
    transform: translate(-6px, 6px) scale(0.98);
  }
  70% {
    transform: translate(3px, -2px) scale(1.01);
  }
  100% {
    transform: translate(0, 0) scale(1);
  }
}

@keyframes attackVector {
  0% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(
        calc(var(--attack-x, 18px) * -0.25),
        calc(var(--attack-y, 0px) * -0.25)
      )
      scale(1.01);
  }
  50% {
    transform: translate(var(--attack-x, 18px), var(--attack-y, 0px))
      scale(1.06);
  }
  70% {
    transform: translate(
        calc(var(--attack-x, 18px) * 0.35),
        calc(var(--attack-y, 0px) * 0.35)
      )
      scale(1.02);
  }
  100% {
    transform: translate(0, 0) scale(1);
  }
}

@keyframes recoilVector {
  0% {
    transform: translate(0, 0) scale(1);
  }
  20% {
    transform: translate(var(--recoil-x, 14px), var(--recoil-y, 0px))
      scale(0.97);
  }
  50% {
    transform: translate(
        calc(var(--recoil-x, 14px) * -0.6),
        calc(var(--recoil-y, 0px) * -0.4)
      )
      scale(1.03);
  }
  80% {
    transform: translate(
        calc(var(--recoil-x, 14px) * 0.3),
        calc(var(--recoil-y, 0px) * 0.2)
      )
      scale(1);
  }
  100% {
    transform: translate(0, 0) scale(1);
  }
}

.unit-card.is-active {
  animation: pulse 0.6s ease;
  border-color: var(--accent);
}

.unit-card.is-hit {
  animation: hit 0.7s ease;
  border-color: #f56545;
}

.unit-card.is-attacking-right,
.unit-card.is-attacking-left {
  animation: attackVector 0.42s ease-out;
}

.unit-card.is-hit-right,
.unit-card.is-hit-left {
  animation: recoilVector 0.52s ease-out;
  border-color: #f56545;
}

.unit-card.is-heal {
  animation: pulse 0.7s ease;
  border-color: var(--accent-2);
}

.unit-card.is-shield {
  animation: pulse 0.7s ease;
  border-color: #3f8cff;
}

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.fx-line {
  position: absolute;
  height: 3px;
  background: rgba(224, 122, 63, 0.9);
  transform-origin: left center;
  animation: lineFade 0.8s ease forwards;
  box-shadow: 0 0 4px rgba(224, 122, 63, 0.6);
}

.fx-line.skill {
  background: rgba(42, 157, 143, 0.9);
  box-shadow: 0 0 6px rgba(42, 157, 143, 0.8);
}

.fx-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #f2c14e;
  box-shadow: 0 0 10px rgba(242, 193, 78, 0.8);
  animation: dotTravel 0.6s ease forwards;
}

.fx-dot.skill {
  background: #4ed7c4;
  box-shadow: 0 0 10px rgba(78, 215, 196, 0.8);
}

.fx-impact {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid rgba(245, 101, 69, 0.75);
  animation: impact 0.55s ease forwards;
}

.fx-impact.skill {
  border-color: rgba(42, 157, 143, 0.75);
}

.fx-wave {
  position: absolute;
  width: var(--fx-size, 120px);
  height: var(--fx-size, 120px);
  border-radius: 50%;
  border: 2px solid var(--fx-color, rgba(242, 92, 84, 0.9));
  box-shadow: 0 0 18px var(--fx-glow, rgba(242, 92, 84, 0.5));
  background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, transparent 65%);
  transform: translate(-50%, -50%) scale(0.25);
  animation: fxWave var(--fx-duration, 640ms) ease-out forwards;
}

.fx-wave--hit {
  border-width: 1.5px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18) 0%, transparent 65%);
}

.fx-orb {
  position: absolute;
  width: var(--fx-size, 14px);
  height: var(--fx-size, 14px);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--fx-accent, #ffd166) 0%, var(--fx-color, #ff7a18) 60%, rgba(0, 0, 0, 0.1) 100%);
  box-shadow: 0 0 14px var(--fx-glow, rgba(255, 122, 24, 0.6));
  display: grid;
  place-items: center;
  font-size: calc(var(--fx-size, 14px) * 0.6);
  animation: fxOrbTravel var(--fx-duration, 520ms) ease-out forwards;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.fx-burst {
  position: absolute;
  width: var(--fx-size, 26px);
  height: var(--fx-size, 26px);
  border-radius: 50%;
  border: 2px solid var(--fx-color, #ff7a18);
  box-shadow: 0 0 14px var(--fx-glow, rgba(255, 122, 24, 0.6));
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22) 0%, transparent 60%);
  transform: translate(-50%, -50%) scale(0.3);
  animation: fxBurst var(--fx-duration, 520ms) ease-out forwards;
}

.fx-charge {
  position: absolute;
  width: var(--fx-size, 60px);
  height: var(--fx-size, 60px);
  border-radius: 50%;
  border: 2px solid var(--fx-color, #4f8dff);
  box-shadow: 0 0 20px var(--fx-glow, rgba(79, 141, 255, 0.6));
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 65%);
  transform: translate(-50%, -50%) scale(0.5);
  animation: fxCharge var(--fx-duration, 240ms) ease-out forwards;
  display: grid;
  place-items: center;
  font-size: calc(var(--fx-size, 60px) * 0.32);
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.fx-slash {
  position: absolute;
  width: 46px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--fx-color, #f25c54), var(--fx-accent, #ff9b54), transparent);
  box-shadow: 0 0 10px var(--fx-glow, rgba(242, 92, 84, 0.6));
  transform: translate(-50%, -50%) rotate(var(--fx-rotate, 20deg)) scaleX(0.2);
  animation: fxSlash var(--fx-duration, 420ms) ease-out forwards;
}

.fx-beam {
  position: absolute;
  left: 0;
  top: 0;
  height: calc(6px * var(--fx-scale, 1));
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--fx-color, #f6c453), var(--fx-accent, #fff2b2), transparent);
  box-shadow: 0 0 16px var(--fx-glow, rgba(246, 196, 83, 0.6));
  transform-origin: left center;
  animation: fxBeam var(--fx-duration, 420ms) ease-out forwards;
}

.fx-label {
  position: absolute;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  background: rgba(26, 21, 16, 0.78);
  color: #fff;
  animation: labelFloat 1s ease forwards;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.fx-label.skill {
  background: rgba(42, 157, 143, 0.85);
}

.fx-label--damage {
  background: rgba(220, 64, 56, 0.88);
}

.fx-label--heal {
  background: rgba(42, 157, 143, 0.88);
}

.fx-label--shield {
  background: rgba(63, 140, 255, 0.88);
}

.fx-label--block {
  background: rgba(63, 140, 255, 0.88);
}

.fx-label.is-crit {
  box-shadow: 0 0 0 1px rgba(255, 214, 120, 0.55), 0 0 12px rgba(255, 168, 74, 0.45);
}

.fx-crit {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255, 214, 120, 0.28);
  color: #ffe3a6;
}

.fx-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0;
  text-transform: none;
  background: rgba(255, 255, 255, 0.18);
}

@keyframes lineFade {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes dotTravel {
  0% {
    transform: translate(0, 0) scale(0.7);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(1);
    opacity: 0;
  }
}

@keyframes impact {
  0% {
    transform: scale(0.15);
    opacity: 0.8;
  }
  80% {
    opacity: 0.4;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

@keyframes fxWave {
  0% {
    transform: translate(-50%, -50%) scale(0.25);
    opacity: 0.9;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.8);
    opacity: 0;
  }
}

@keyframes fxOrbTravel {
  0% {
    transform: translate(0, 0) scale(0.6);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(1.1);
    opacity: 0.85;
  }
}

@keyframes fxBurst {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0.9;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.6);
    opacity: 0;
  }
}

@keyframes fxCharge {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0;
  }
  60% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 0;
  }
}

@keyframes fxSlash {
  0% {
    transform: translate(-50%, -50%) rotate(var(--fx-rotate, 20deg)) scaleX(0.2);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) rotate(var(--fx-rotate, 20deg)) scaleX(1.2);
    opacity: 0;
  }
}

@keyframes fxBeam {
  0% {
    transform: translate(var(--beam-x), var(--beam-y)) rotate(var(--beam-rot)) scaleX(0.05);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--beam-x), var(--beam-y)) rotate(var(--beam-rot)) scaleX(1);
    opacity: 0;
  }
}

@keyframes labelFloat {
  0% {
    transform: translateY(0) scale(var(--fx-scale, 1));
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translateY(-12px) scale(var(--fx-scale, 1));
    opacity: 0;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .summary-view {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ======================================
   BUDGET MODE STYLES
   ====================================== */

/* Mode Selector */
.mode-selector {
  display: flex;
  gap: 8px;
  margin: 16px 0 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
}

.mode-btn {
  flex: 1;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
}

.mode-btn.active {
  background: white;
  border-color: var(--stroke);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(26, 21, 16, 0.08);
}

/* Budget Bar */
.budget-bar {
  margin: 16px 0;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fff9f0, #f5f5f5);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(26, 21, 16, 0.08);
}

.budget-bar__label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.budget-bar__values {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.budget-bar__remaining {
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.budget-bar__progress {
  height: 8px;
  background: rgba(26, 21, 16, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.budget-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent-3));
  border-radius: 999px;
  transition: width 0.3s ease, background 0.3s ease;
}

.budget-bar.over-budget .budget-bar__fill {
  background: linear-gradient(90deg, #e63946, #f77f00);
}

.budget-bar.over-budget .budget-bar__values {
  color: #c83232;
}

/* Budget Selector */
.budget-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  border: 1px solid var(--stroke);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.budget-selector select {
  padding: 4px 8px;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  background: white;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Unit Cost Badge */
.unit-cost {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 3px 7px;
  background: linear-gradient(135deg, var(--accent-3), #f4d06f);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 2;
}

.unit-card.unaffordable {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.7);
}

.unit-card.unaffordable::after {
  content: "Can't afford";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.2s;
}

.unit-card.unaffordable:hover::after {
  opacity: 1;
}

/* Tier Badge */
.tier-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  z-index: 2;
  border: 2px solid;
  /* Default fallback */
  background: linear-gradient(135deg, var(--accent-2), #38b5a3);
  color: white;
  border-color: var(--accent-2);
}

/* Tier 1 - Bronze */
.tier-badge.tier-1 {
  background: linear-gradient(135deg, #cd7f32, #b87333);
  color: white;
  border-color: #8b5a1f;
}

/* Tier 2 - Silver */
.tier-badge.tier-2 {
  background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
  color: #2c2c2c;
  border-color: #808080;
}

/* Tier 3 - Gold */
.tier-badge.tier-3 {
  background: linear-gradient(135deg, #ffd700, #ffb700);
  color: #2c2c2c;
  border-color: #cc9900;
}

/* Modal Styles */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 21, 16, 0.5);
  backdrop-filter: blur(4px);
}

.modal__content {
  position: relative;
  background: white;
  border-radius: var(--radius);
  padding: 28px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
}

.modal__content--character {
  max-width: 860px;
  width: calc(100% - 24px);
}

.modal__content--help {
  max-width: 980px;
  width: calc(100% - 24px);
}

.help-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.help-modal__title {
  font-size: 1.4rem;
  font-weight: 700;
}

.help-modal__subtitle {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.help-modal__body {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 24px;
}

.help-modal__text h3 {
  margin: 12px 0 6px;
  font-size: 0.95rem;
}

.help-modal__text ul {
  margin: 0 0 12px 16px;
  padding: 0;
  color: var(--ink);
  font-size: 0.85rem;
}

.help-modal__hint {
  margin-top: 12px;
  padding: 8px 10px;
  background: rgba(26, 21, 16, 0.06);
  border-radius: 10px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.help-card {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto minmax(140px, 1fr);
  gap: 12px;
  align-items: center;
}

.unit-card--help {
  width: 260px;
  pointer-events: none;
}

.help-card__visual {
  display: flex;
  justify-content: center;
}

.help-card__labels {
  display: grid;
  gap: 10px;
  align-content: space-between;
}

.help-card__labels--left {
  justify-items: end;
  text-align: right;
}

.help-card__labels--right {
  justify-items: start;
  text-align: left;
}

.help-callout {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(26, 21, 16, 0.85);
  color: #fff;
  padding: 4px 6px;
  border-radius: 8px;
  max-width: 140px;
  line-height: 1.2;
}

.help-card__legend {
  margin-top: 12px;
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.help-team {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(26, 21, 16, 0.1);
  display: grid;
  gap: 10px;
}

.help-team__title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

.help-team__grid {
  display: grid;
  gap: 8px;
}

.help-team__row {
  display: grid;
  grid-template-columns: 52px repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.help-team__row-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-weight: 700;
}

.help-slot {
  border-radius: 10px;
  border: 1px dashed rgba(26, 21, 16, 0.2);
  padding: 8px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink);
}

.help-slot--front {
  background: linear-gradient(135deg, #fff9f0, #fff);
  border-color: rgba(224, 122, 63, 0.3);
}

.help-slot--back {
  background: linear-gradient(135deg, #f0f9ff, #fff);
  border-color: rgba(42, 157, 143, 0.3);
}

.help-budget {
  display: grid;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.help-budget__bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(26, 21, 16, 0.1);
  overflow: hidden;
}

.help-budget__fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #f2c14e, #e07a3f);
}

.help-tooltip {
  border-radius: 12px;
  border: 1px solid rgba(26, 21, 16, 0.12);
  padding: 10px 12px;
  background: #fffdf8;
  display: grid;
  gap: 6px;
  font-size: 0.78rem;
}

.help-tooltip__title {
  font-weight: 700;
  font-size: 0.82rem;
}

.help-tooltip__row {
  color: var(--ink);
}

.help-tooltip__note {
  color: var(--ink-soft);
  font-size: 0.74rem;
}

@media (max-width: 900px) {
  .help-modal__body {
    grid-template-columns: 1fr;
  }
  .help-card {
    grid-template-columns: 1fr;
  }
  .help-card__labels--left,
  .help-card__labels--right {
    justify-items: start;
    text-align: left;
  }
}

.character-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.character-modal__title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
}

.character-modal__subtitle {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.character-modal__slot {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(26, 21, 16, 0.08);
  color: var(--ink-soft);
  font-weight: 700;
}

.character-modal__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.character-modal__form {
  display: grid;
  gap: 12px;
}

.character-modal__field {
  display: grid;
  gap: 6px;
}

.character-modal__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 700;
}

.character-modal__hint {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.character-modal__preview {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.character-modal__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  gap: 12px;
}

.character-modal__actions-right {
  display: flex;
  gap: 10px;
}

.budget-bar--modal {
  display: grid;
  gap: 6px;
  background: rgba(26, 21, 16, 0.04);
  padding: 10px;
  border-radius: 12px;
}

.unit-tooltip--embedded {
  position: static;
  opacity: 1;
  pointer-events: auto;
  border-width: 1px;
  box-shadow: none;
  max-width: none;
  min-width: auto;
}

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

.modal__content h3 {
  margin: 0 0 16px;
  font-family: "Fraunces", serif;
  font-size: 1.5rem;
  color: var(--ink);
}

/* Tier Options */
.tier-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}

.tier-option {
  padding: 14px;
  background: var(--panel);
  border: 2px solid var(--stroke);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tier-option:hover {
  border-color: var(--accent-2);
  background: var(--panel-strong);
  transform: translateY(-2px);
}

.tier-option__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tier-option__tier {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-2);
}

.tier-option__cost {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-3);
  background: rgba(242, 193, 78, 0.2);
  padding: 4px 10px;
  border-radius: 6px;
}

.tier-option__stats {
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.tier-option.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.tier-option--empty {
  cursor: default;
  text-align: center;
  font-weight: 600;
  color: var(--ink-soft);
  border-style: dashed;
  background: transparent;
}

/* Skill Selection */
.skill-selection {
  margin: 20px 0;
  padding: 20px;
  background: var(--panel);
  border: 2px solid var(--stroke);
  border-radius: 12px;
}

.skill-selection h4 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
  color: var(--accent-2);
}

.skill-picker {
  margin-bottom: 16px;
}

.skill-picker label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skill-picker__label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

.skill-select {
  padding: 10px 12px;
  background: var(--page);
  border: 2px solid var(--stroke);
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.skill-select:hover {
  border-color: var(--accent-2);
  background: var(--panel-strong);
}

.skill-select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(111, 132, 222, 0.2);
}

.skill-tooltip {
  position: fixed;
  z-index: 1500;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px;
  min-width: 260px;
  max-width: 340px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.skill-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.skill-tooltip__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.skill-tooltip__title {
  color: var(--ink);
}

.skill-tooltip__cost {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 6px;
}

.skill-tooltip__cost.mana-cost {
  background: rgba(77, 110, 210, 0.15);
  color: #3b4aad;
}

.skill-tooltip__cost.adr-cost {
  background: rgba(230, 122, 69, 0.18);
  color: #b24a1f;
}

.skill-tooltip__desc {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.skill-tooltip__meta {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.skill-tooltip__effect {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--stroke);
}

.skill-tooltip__effect:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.skill-tooltip__effect-line {
  font-size: 0.8rem;
  color: var(--ink);
}

.skill-picker__actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--stroke);
}

.skill-picker__actions .btn {
  flex: 1;
}

/* Settings page */
.settings-layout {
  margin-top: 12px;
}

.settings-panel .panel__header {
  align-items: center;
}

.settings-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.settings-card {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.settings-card h3 {
  margin: 0;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.settings-field {
  display: grid;
  gap: 6px;
}

.settings-field__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.settings-field label {
  font-size: 0.78rem;
  color: var(--ink);
  font-weight: 600;
}

.settings-input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  font-family: inherit;
}

.settings-input--number {
  width: 100px;
  text-align: right;
}

.settings-range {
  width: 100%;
  accent-color: var(--accent-2);
  cursor: pointer;
}

.settings-input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(111, 132, 222, 0.2);
}

.settings-note {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.settings-status {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.settings-status.is-success {
  color: #2a9d8f;
}

.settings-status.is-error {
  color: #c44536;
}

/* Challenge URL Box */
.challenge-url-box {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.challenge-url-box input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--stroke);
  border-radius: 8px;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  background: var(--panel);
}

.challenge-stats {
  margin: 16px 0;
  padding: 14px;
  background: var(--panel);
  border-radius: 10px;
  line-height: 1.8;
}

.challenge-stats strong {
  color: var(--ink);
  font-weight: 600;
}

/* Budget Mode Body Class */
body.budget-mode .budget-bar,
body.budget-mode .budget-selector,
body.budget-mode #createChallenge {
  display: block !important;
}

body.challenge-mode .budget-bar,
body.challenge-mode .budget-selector,
body.challenge-mode #createChallenge {
  display: block !important;
}

body.builder-mode .budget-selector {
  display: block !important;
}

body.builder-mode .builder-budgets {
  display: grid;
}

body.budget-mode #runBattle,
body.budget-mode #quick3v3,
body.budget-mode #syncFromLog {
  display: none !important;
}

body.challenge-mode #runBattle,
body.challenge-mode #quick3v3,
body.challenge-mode #syncFromLog,
body.challenge-mode #clearTeams {
  display: none !important;
}

body.budget-mode .builder-only {
  display: none !important;
}

body.budget-mode .budget-only {
  display: inline-flex !important;
}

body.challenge-mode .builder-only,
body.challenge-mode .budget-only {
  display: none !important;
}

body.challenge-mode .challenge-only {
  display: inline-flex !important;
}

body.budget-mode .challenge-only,
body.builder-mode .challenge-only {
  display: none !important;
}

.budget-selector select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

body.challenge-mode .mode-selector {
  display: none;
}

body.budget-mode .hero__controls,
body.challenge-mode .hero__controls {
  display: none;
}

body.challenge-stage-setup .panel.combat {
  display: none;
}

body.challenge-stage-combat .panel.builder {
  display: none;
}

body.challenge-stage-setup .layout,
body.challenge-stage-combat .layout {
  grid-template-columns: minmax(0, 1fr);
}

/* Hide Team B in Budget Mode (players only build Team A) */
body.budget-mode .team-panel[data-team="B"] {
  display: none !important;
}

/* Read-only slots (for displaying challenge teams) */
.slot--readonly {
  opacity: 0.85;
  cursor: default;
  background: #f5f5f5;
}

.slot--readonly:hover {
  transform: none;
  border-color: rgba(26, 21, 16, 0.2);
}

/* Battle Recap Styles */
.recap {
  margin-top: 20px;
  padding: 16px;
  background: var(--panel);
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
}

.recap__summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px;
  background: var(--panel-strong);
  border-radius: var(--radius-sm);
}

.recap__stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recap__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 600;
}

.recap__value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.recap__teams {
  display: grid;
  gap: 16px;
}

.recap__team {
  border-radius: 16px;
  padding: 12px;
  border: 1px solid rgba(26, 21, 16, 0.12);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.9), rgba(249, 242, 232, 0.9));
}

.recap__team--creator {
  box-shadow: inset 4px 0 0 rgba(224, 122, 63, 0.6);
}

.recap__team--challenger {
  box-shadow: inset 4px 0 0 rgba(42, 157, 143, 0.6);
}

.recap__team-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.recap__team-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--ink);
}

.recap__team-pill {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(26, 21, 16, 0.08);
  color: var(--ink-soft);
  font-weight: 700;
}

.recap__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.recap-card {
  border-radius: 14px;
  border: 1px solid rgba(26, 21, 16, 0.1);
  background: #fffdf8;
  padding: 12px;
  display: grid;
  gap: 10px;
  position: relative;
}

.recap-card.team-creator {
  border-left: 3px solid var(--accent);
}

.recap-card.team-challenger {
  border-left: 3px solid var(--accent-2);
}

.recap-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.recap-card__identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.recap-card__icon {
  font-size: 1.3rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.recap-card__icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.recap-card__text {
  display: grid;
  gap: 2px;
}

.recap-card__name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
}

.recap-card__class {
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.recap-card__slot {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.recap-card__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
}

.recap-pair {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 10px;
  background: rgba(26, 21, 16, 0.06);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.recap-pair span {
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 0.62rem;
  color: var(--ink-soft);
}

.recap-pair strong {
  font-weight: 700;
  color: var(--ink);
}

.recap-pair em {
  font-style: normal;
  color: var(--ink-soft);
}

.recap-pair--damage strong {
  color: #d8453f;
}

.recap-pair--heal strong {
  color: #1b8f6c;
}

.recap-pair--shield strong {
  color: #3f8cff;
}

.recap-pair--hp strong {
  color: #e05b4f;
}

.recap-card__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.recap-chip {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(26, 21, 16, 0.08);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}

.recap-chip--muted {
  color: var(--ink-soft);
}

.recap__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.recap__table th {
  text-align: left;
  padding: 10px 8px;
  background: var(--panel-strong);
  border-bottom: 2px solid var(--stroke);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.recap__table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(26, 21, 16, 0.1);
}

.recap__table tbody tr:hover {
  background: var(--panel-strong);
}

.recap__table tbody tr.team-creator {
  border-left: 3px solid var(--accent);
}

.recap__table tbody tr.team-challenger {
  border-left: 3px solid var(--accent-2);
}

.player-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.player-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(26, 21, 16, 0.15);
  background: #f1e7da;
}

.saved-team-list {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.saved-team-card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
  display: grid;
  gap: 6px;
}

.saved-team-card__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.saved-team-card__title {
  font-weight: 700;
}

.saved-team-card__meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.saved-team-card__actions {
  display: flex;
  justify-content: flex-end;
}

.saved-team-card__hint {
  font-size: 0.8rem;
  color: var(--ink-soft);
}
