@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700&family=Cinzel:wght@500;700&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap");

/* ─── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:    #070b0e;
  --bg-raised:  #0d1419;
  --surface:    #111820;
  --surface-2:  #182030;
  --surface-3:  #1e2a3a;

  /* Gold accent */
  --gold:       #d6a620;
  --gold-light: #f5c84a;
  --gold-glow:  rgba(214, 166, 32, 0.18);

  /* Text */
  --text:       #dfd6c4;
  --text-dim:   #7a8898;
  --text-bright:#f5edd8;

  /* Status */
  --green:      #4a9c6a;
  --green-dim:  rgba(74, 156, 106, 0.14);
  --red:        #c0463a;
  --red-dim:    rgba(192, 70, 58, 0.14);
  --amber:      #c08030;
  --amber-dim:  rgba(192, 128, 48, 0.14);

  /* Borders */
  --border:     rgba(200, 151, 42, 0.14);
  --border-mid: rgba(200, 151, 42, 0.28);
  --border-hi:  rgba(200, 151, 42, 0.55);
  --border-sub: rgba(255, 255, 255, 0.06);

  /* Misc */
  --radius:     10px;
  --radius-lg:  16px;
  --ease:       cubic-bezier(0.22, 1, 0.36, 1);
}

/* ─── Reset & base ───────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", sans-serif;
  font-size: 15px;
  color: var(--text);
  background-color: var(--bg-base);
  background-image:
    radial-gradient(ellipse 80vw 60vh at 20% 10%, rgba(18,34,52,0.9) 0%, transparent 70%),
    radial-gradient(ellipse 70vw 50vh at 85% 88%, rgba(14,26,42,0.8) 0%, transparent 65%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

/* ─── Site navigation ────────────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 46px;
  display: flex;
  align-items: center;
  background: rgba(7, 11, 14, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.site-nav-inner {
  width: min(1120px, 95vw);
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.site-brand {
  font-family: "Cinzel", serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-right: 1.6rem;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
}
.site-brand:hover {
  color: var(--gold);
  opacity: 0.8;
}

.site-nav-links {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  height: 46px;
  padding: 0 0.85rem;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.nav-link:hover {
  color: var(--text);
  border-bottom-color: rgba(214, 166, 32, 0.35);
}

.nav-link.nav-active {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
}

.nav-divider {
  width: 1px;
  height: 16px;
  background: var(--border-sub);
  margin: 0 0.3rem;
  flex-shrink: 0;
}

.nav-link.nav-secondary {
  opacity: 0.7;
}

.nav-link.nav-secondary:hover {
  opacity: 1;
}

/* Pushes everything after it to the right */
.nav-divider-push {
  flex: 1;
  background: none;
  width: auto;
  height: auto;
  margin: 0;
}

.nav-link.nav-util {
  font-size: 0.74rem;
  opacity: 0.5;
  border-bottom-color: transparent !important;
  letter-spacing: 0.02em;
}

.nav-link.nav-util:hover {
  opacity: 0.85;
  border-bottom-color: transparent !important;
  color: var(--text);
}

.nav-link.nav-support {
  color: var(--gold);
  opacity: 0.6;
}

.nav-link.nav-support:hover {
  color: var(--gold-light);
  opacity: 1;
}

/* Creator avatar in nav */
.nav-avatar-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 46px;
  padding: 0 0.6rem 0 0.8rem;
  text-decoration: none;
  border-left: 1px solid var(--border-sub);
  opacity: 0.55;
  transition: opacity 160ms var(--ease);
  flex-shrink: 0;
}

.nav-avatar-link:hover {
  opacity: 1;
}

.nav-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.nav-avatar-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  white-space: nowrap;
}

.nav-avatar-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0.6;
}

.nav-avatar-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

.nav-avatar-link:hover .nav-avatar-label,
.nav-avatar-link:hover .nav-avatar-name {
  color: var(--text);
  opacity: 1;
}

@media (max-width: 760px) {
  .nav-avatar-text { display: none; }
  .nav-avatar-link { padding: 0 0.5rem 0 0.6rem; }
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  width: min(1120px, 95vw);
  margin: 1.5rem auto 3rem;
  display: grid;
  gap: 1rem;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 20px 40px rgba(0,0,0,0.45);
  transition: border-color 220ms var(--ease), box-shadow 220ms var(--ease);
}

/* thin top-edge highlight */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200,151,42,0.22) 40%, rgba(200,151,42,0.22) 60%, transparent);
  pointer-events: none;
}

/* ─── Collapsible sections (<details>/<summary>) ─────────────────────────── */
details.card > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  user-select: none;
}
details.card > summary::-webkit-details-marker,
details.card > summary::marker { display: none; }
details.card > summary h2 { margin: 0; }

.summary-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-mid);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  flex-shrink: 0;
  font-family: "Barlow Condensed", sans-serif;
  letter-spacing: 0;
}

.collapse-chevron {
  font-size: 0.72rem;
  color: var(--text-dim);
  transition: transform 200ms var(--ease);
  flex-shrink: 0;
  line-height: 1;
}
details.card:not([open]) .collapse-chevron { transform: rotate(-90deg); }

details.card > .section-body { margin-top: 0.9rem; }

/* ─── Page header (replaces hero card) ───────────────────────────────────── */
.page-header {
  padding: 1.6rem 0 1.2rem;
  border-bottom: 1px solid var(--border-sub);
}

.page-header .kicker {
  margin-bottom: 0.25rem;
}

.page-header h1 {
  margin-bottom: 0.3rem;
  line-height: 1.1;
}

.page-header > p {
  max-width: 60ch;
  color: var(--text-dim);
  font-size: 0.91rem;
  margin: 0;
}

/* ─── Hero card (legacy, kept for reference) ─────────────────────────────── */
.hero {
  background:
    linear-gradient(135deg, rgba(26,36,52,0.98) 0%, rgba(14,20,30,0.99) 100%);
  border-color: var(--border-mid);
  padding: 1.4rem 1.4rem 1.2rem;
}

.hero-links { margin-top: 0.8rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.page-link {
  display: inline-block;
  padding: 0.38rem 0.8rem;
  border: 1px solid var(--border-mid);
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--gold-light);
  background: rgba(200,151,42,0.07);
  letter-spacing: 0.01em;
  transition: background 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease);
}
.page-link:hover {
  background: rgba(200,151,42,0.14);
  border-color: var(--border-hi);
  color: #ffe08c;
}

.kicker {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}

/* ─── Typography ─────────────────────────────────────────────────────────── */
h1 {
  font-family: "Cinzel", serif;
  margin: 0 0 0.55rem;
  color: var(--text-bright);
  letter-spacing: 0.01em;
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
}
h2, h3 {
  font-family: "DM Sans", sans-serif;
  font-weight: 600;
  margin: 0 0 0.45rem;
  color: var(--text-bright);
  letter-spacing: 0em;
}
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }

p { margin: 0.3rem 0; color: var(--text-dim); font-size: 0.9rem; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }

th, td {
  border-bottom: 1px solid var(--border-sub);
  text-align: left;
  padding: 0.7rem 0.55rem;
  vertical-align: middle;
}

th {
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  background: rgba(0,0,0,0.22);
  position: sticky;
  top: 46px; /* below site-nav */
  z-index: 1;
}

tbody tr:nth-child(even) td { background: rgba(255,255,255,0.018); }
tr:hover td { background: rgba(200,151,42,0.05); }

/* ─── Form controls ──────────────────────────────────────────────────────── */
input, select, button { font: inherit; }

input, select {
  width: 100%;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

select {
  /* custom arrow */
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a9898' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 2rem;
  color-scheme: dark;
}

select option {
  background: #1a2430;
  color: #dfd6c4;
}

select optgroup {
  background: #111d28;
  color: #8a9898;
  font-weight: 600;
}

select optgroup option {
  background: #1a2430;
  color: #dfd6c4;
  font-weight: 400;
  padding-left: 0.5rem;
}

input:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,151,42,0.12);
}

/* ─── Pickers (civ / unit / age) ─────────────────────────────────────────── */
.civ-picker, .unit-picker, .unit-cell, .age-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  width: 100%;
}

.civ-picker, .age-picker {
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  transition: border-color 180ms var(--ease);
}
.civ-picker:focus-within, .age-picker:focus-within {
  border-color: var(--border-hi);
}

/* Icon size inside pickers — consistent across all tools */
.civ-picker .civ-icon,
.age-picker .age-icon,
.unit-picker .age-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
}

.unit-picker {
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.civ-picker select, .unit-picker select, .age-picker select {
  flex: 1; width: auto; min-width: 0; margin: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0.2rem 1.6rem 0.2rem 0.2rem;
}
.civ-picker select:focus, .unit-picker select:focus, .age-picker select:focus {
  box-shadow: none;
}

/* ─── Icons ──────────────────────────────────────────────────────────────── */
.inline-icon, .civ-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  background: var(--surface-3);
  padding: 3px;
  flex-shrink: 0;
  display: block;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4) inset;
  transition: border-color 160ms var(--ease);
}

.civ-icon {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-lg);
  padding: 5px;
}

.age-icon {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  background: var(--surface-3);
  padding: 5px;
  flex-shrink: 0;
  display: block;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4) inset;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
button {
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 0.48rem 0.9rem;
  background: var(--surface-2);
  color: var(--gold-light);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition:
    background 160ms var(--ease),
    border-color 160ms var(--ease),
    color 160ms var(--ease),
    box-shadow 160ms var(--ease),
    transform 120ms var(--ease);
}

button:hover {
  background: rgba(200,151,42,0.12);
  border-color: var(--border-hi);
  color: #ffe08c;
  box-shadow: 0 0 18px rgba(200,151,42,0.18);
  transform: translateY(-1px);
}

button.danger {
  color: #f08080;
  border-color: rgba(192,70,58,0.35);
  background: rgba(192,70,58,0.08);
}
button.danger:hover {
  background: rgba(192,70,58,0.18);
  border-color: rgba(192,70,58,0.6);
  color: #ff9e9e;
  box-shadow: 0 0 14px rgba(192,70,58,0.22);
}

/* ─── Row & section headers ──────────────────────────────────────────────── */
.row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
}

/* ─── Assumption / control grids ─────────────────────────────────────────── */
.assumption-row {
  margin-bottom: 0.75rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 0.6rem;
  max-width: 700px;
}
.assumption-row > label { display: block; }

.food-source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem;
}

/* ─── Radio cards ─────────────────────────────────────────────────────────── */
.radio-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}
.radio-card:has(input:checked) {
  border-color: var(--border-hi);
  background: rgba(200,151,42,0.08);
}
.radio-card:hover { border-color: var(--border-mid); }

.radio-card input { width: auto; margin-right: 0.4rem; accent-color: var(--gold); }
.radio-card span { font-weight: 600; color: var(--text-bright); font-size: 0.9rem; }
.radio-card small { display: block; color: var(--text-dim); font-size: 0.78rem; margin-top: 0.1rem; }

/* ─── Upgrade groups ──────────────────────────────────────────────────────── */
.upgrade-groups {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.comp-controls-grid {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 1fr 1fr;
}

.upgrade-group {
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0.6rem;
}

.upgrade-group-title {
  margin: 0 0 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--gold);
  font-family: "DM Sans", sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.upgrade-grid {
  display: grid;
  gap: 0.4rem;
  grid-template-columns: 1fr;
}

/* ─── Mode / composition boxes ───────────────────────────────────────────── */
.comp-mode-box {
  background: var(--surface-2);
  border-color: var(--border-mid);
}

.enemy-box {
  margin-top: 0.6rem;
  background: var(--surface-2);
}

.toggles-box {
  background:
    radial-gradient(400px 120px at 100% 0%, rgba(74,156,106,0.06), transparent 70%),
    var(--surface-2);
}

/* ─── Mode summary & tags ────────────────────────────────────────────────── */
.mode-summary { margin-top: 0.5rem; }

.mode-tone {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border-mid);
  background: rgba(200,151,42,0.08);
  color: var(--gold-light);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.12rem 0.6rem;
  letter-spacing: 0.04em;
}

.mode-tags { margin-top: 0.4rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }

.mode-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border-sub);
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
}

/* ─── Enemy role grid ─────────────────────────────────────────────────────── */
.enemy-role-grid {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.4rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ─── TC box ──────────────────────────────────────────────────────────────── */
.tc-box {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  background: var(--surface-3);
}

.tc-count-label {
  margin-top: 0.4rem;
  display: block;
  font-weight: 600;
  color: var(--text);
  font-size: 0.88rem;
}
.tc-count-label input { margin-top: 0.2rem; }

/* ─── Pills (upgrade checkboxes) ─────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border-sub);
  border-radius: 999px;
  background: var(--surface-3);
  font-weight: 500;
  color: var(--text);
  font-size: 0.84rem;
  cursor: pointer;
  width: fit-content;
  transition:
    border-color 140ms var(--ease),
    background 140ms var(--ease),
    box-shadow 140ms var(--ease);
}

/* Standalone pills get breathing room below */
.pill { margin-bottom: 0.65rem; }

/* Inside upgrade grid, pills fill the column and reset their margin */
.upgrade-grid .pill {
  display: flex;
  width: 100%;
  margin-bottom: 0;
}

.pill:hover {
  border-color: var(--border-mid);
  box-shadow: 0 0 8px rgba(200,151,42,0.1);
}

.pill:has(input:checked) {
  border-color: var(--green);
  background: var(--green-dim);
  color: #7febb0;
}

.pill input { width: auto; margin: 0; accent-color: var(--green); }

.pill-blocked { opacity: 0.45; filter: grayscale(0.6); pointer-events: none; }

.pill-hint { font-size: 0.76rem; color: var(--text-dim); }

/* ─── Role filter bar ─────────────────────────────────────────────────────── */
.role-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}
.role-filter-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border-mid);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 130ms var(--ease), border-color 130ms var(--ease), color 130ms var(--ease);
  user-select: none;
}
.role-filter-btn input { display: none; }
.role-filter-btn:hover {
  background: rgba(200,151,42,0.1);
  border-color: var(--gold);
  color: var(--gold-light);
}
.role-filter-btn.active {
  background: rgba(200,151,42,0.18);
  border-color: var(--gold-light);
  color: var(--gold-light);
  box-shadow: 0 0 6px rgba(200,151,42,0.25);
}

/* ─── Resource totals ─────────────────────────────────────────────────────── */
.totals-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.totals-grid article {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 1rem 1rem 0.85rem;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
  transition: transform 200ms var(--ease), border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}

.totals-grid article:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
/* resource-specific hover border-left handled by [data-resource]:hover below */

.res-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.res-icon { width: 18px; height: 18px; object-fit: contain; }

.big {
  margin: 0;
  font-size: clamp(2.2rem, 3.5vw, 3rem);
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1;
  font-family: "Barlow Condensed", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.total-vils { margin-top: 0.8rem; font-size: 1rem; }

.resource-rate { color: var(--text-dim); font-size: 0.82rem; margin-top: 0.55rem; }

/* ─── Effect box ──────────────────────────────────────────────────────────── */
.effect-box {
  margin-top: 0.7rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.effect-list {
  margin: 0.35rem 0 0;
  padding-left: 1rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.effect-list li { margin: 0.2rem 0; }

/* ─── Explorer stat panels ────────────────────────────────────────────────── */
.explorer-stats {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.explorer-stats article {
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  padding: 0.6rem 0.65rem;
  background: var(--surface-2);
}

/* ─── Unit grid & cards ───────────────────────────────────────────────────── */
.unit-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.unit-card {
  border: 1px solid var(--border-sub);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease), transform 180ms var(--ease);
}

.unit-card:hover {
  border-color: var(--border-mid);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 12px rgba(200,151,42,0.06);
  transform: translateY(-1px);
}

.unit-card > div { min-width: 0; flex: 1; }

.unit-title-row {
  margin: 0 0 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  line-height: 1.3;
}

.unit-title-row strong {
  font-size: 0.97rem;
  color: var(--text-bright);
}

.unit-sub {
  margin: 0 0 0.5rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.unit-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.1rem;
}

.unit-insights {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border-sub);
}

/* locked / unavailable */
.unit-card.unit-locked    { opacity: 0.72; }
.unit-card.unit-unavailable { opacity: 0.5; filter: grayscale(0.5); }

/* ─── Power badges ────────────────────────────────────────────────────────── */
.power-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  border: 1px solid;
  padding: 0.07rem 0.45rem;
  font-size: 0.71rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.power-s {
  border-color: rgba(100,220,140,0.6);
  background: rgba(74,156,106,0.16);
  color: #80f0b0;
}
.power-a {
  border-color: rgba(120,200,100,0.45);
  background: rgba(74,156,106,0.10);
  color: #a0e090;
}
.power-b {
  border-color: rgba(200,151,42,0.45);
  background: rgba(200,151,42,0.10);
  color: var(--gold-light);
}
.power-c {
  border-color: rgba(192,128,48,0.4);
  background: rgba(192,128,48,0.09);
  color: #d4a060;
}
.power-d {
  border-color: rgba(192,70,58,0.4);
  background: rgba(192,70,58,0.09);
  color: #e09090;
}

/* ─── Status chips ────────────────────────────────────────────────────────── */
.status-chip {
  display: inline-block;
  font-size: 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-sub);
  padding: 0.12rem 0.5rem;
  background: var(--surface-3);
  color: var(--text-dim);
}

.status-available  { border-color: rgba(74,156,106,0.5); background: var(--green-dim); color: #7febb0; }
.status-locked     { border-color: rgba(192,128,48,0.4); background: var(--amber-dim); color: #d4a060; }
.status-unavailable{ border-color: rgba(192,70,58,0.4);  background: var(--red-dim);   color: #e09090; }

/* ─── Tech progression ────────────────────────────────────────────────────── */
.tech-progression-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.progression-track {
  border: 1px solid var(--border-sub);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: 0.5rem;
}

.progression-card {
  border: 1px solid var(--border-sub);
}

.progression-card.best-core {
  border-color: rgba(74,156,106,0.5);
  background:
    radial-gradient(200px 80px at 0% 0%, rgba(74,156,106,0.10), transparent 70%),
    var(--surface-2);
  box-shadow: 0 0 16px rgba(74,156,106,0.10);
}

.progression-card.best-uu {
  border-color: var(--border-hi);
  background:
    radial-gradient(200px 80px at 0% 0%, rgba(200,151,42,0.10), transparent 70%),
    var(--surface-2);
  box-shadow: 0 0 16px rgba(200,151,42,0.10);
}

.progress-arrow {
  text-align: center;
  font-weight: 700;
  color: var(--text-dim);
  line-height: 1;
  margin: 0.18rem 0 0.28rem;
  font-size: 0.85rem;
}

/* ─── Driver pills ────────────────────────────────────────────────────────── */
.driver-pills {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  max-width: 420px;
}
.driver-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  row-gap: 0.18rem;
}
.driver-text {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-dim);
  flex: 1;
}
.driver-text-good { color: var(--text-dim); }
.driver-text-bad  { color: #b07070; }

.driver-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-sub);
  padding: 0.14rem 0.44rem;
  font-size: 0.74rem;
  background: var(--surface-3);
  color: var(--text-dim);
  line-height: 1.2;
  white-space: normal;
}

.driver-pill-good {
  border-color: rgba(74,156,106,0.4);
  background: var(--green-dim);
  color: #8ce8b4;
}
.driver-pill-bad {
  border-color: rgba(192,70,58,0.35);
  background: var(--red-dim);
  color: #e09090;
}

/* ─── Tech chips (Blacksmith / Support visual grid) ──────────────────────── */
.driver-key {
  display: inline-flex;
  align-items: center;
  font-size: 0.67rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-sub);
  color: var(--text-muted);
  margin-right: 2px;
  vertical-align: middle;
  line-height: 1.4;
}
.tech-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.66rem;
  padding: 1px 5px;
  border-radius: var(--radius);
  margin: 1px;
  white-space: nowrap;
  vertical-align: middle;
  line-height: 1.4;
  font-family: var(--font-ui);
  cursor: default;
}
.tech-chip-have {
  background: rgba(60, 140, 60, 0.14);
  color: #84cc84;
  border: 1px solid rgba(60, 140, 60, 0.28);
}
.tech-chip-miss {
  background: rgba(160, 50, 50, 0.10);
  color: #a07070;
  border: 1px solid rgba(160, 50, 50, 0.22);
  text-decoration: line-through;
  opacity: 0.75;
}
.tech-sep {
  display: inline-block;
  color: var(--text-muted);
  font-size: 0.65rem;
  margin: 0 3px;
  vertical-align: middle;
  opacity: 0.5;
}

/* ─── Scale pills ─────────────────────────────────────────────────────────── */
.scale-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  border-radius: 999px;
  border: 1px solid var(--border-sub);
  padding: 0.12rem 0.48rem;
  font-size: 0.74rem;
  line-height: 1.2;
  white-space: nowrap;
  font-weight: 600;
}

.scale-up-strong { border-color: rgba(74,156,106,0.55); background: rgba(74,156,106,0.15); color: #80f0b0; }
.scale-up        { border-color: rgba(74,156,106,0.38); background: rgba(74,156,106,0.09); color: #a0e090; }
.scale-flat      { border-color: var(--border-sub);     background: var(--surface-3);       color: var(--text-dim); }
.scale-down      { border-color: rgba(192,128,48,0.4);  background: var(--amber-dim);        color: #d4a060; }
.scale-drop      { border-color: rgba(192,70,58,0.4);   background: var(--red-dim);          color: #e09090; }

.drivers-cell { min-width: 320px; }

/* ─── Top-pick card ───────────────────────────────────────────────────────── */
.top-pick-card {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(200,151,42,0.08) 0%, var(--surface) 55%);
  box-shadow: 0 0 18px rgba(200,151,42,0.15), inset 0 1px 0 rgba(200,151,42,0.35);
}
.top-pick-body {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}
.top-pick-icon { border-radius: 50%; border: 2px solid var(--gold); flex-shrink: 0; }
.top-pick-name { margin: 0 0 0.2rem; font-size: 1.4rem; color: var(--gold-light); }

/* ─── Score explain ───────────────────────────────────────────────────────── */
.score-explain {
  margin: 0.4rem 0 0.8rem;
  border: 1px solid var(--border-sub);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.18);
  padding: 0.55rem 0.75rem;
}
.score-explain h3 { margin: 0 0 0.25rem; font-size: 0.82rem; color: var(--text-dim); }
.score-explain-note { margin: 0 0 0.4rem; font-size: 0.76rem; color: var(--text-muted); }

.score-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.3rem 0.7rem;
}

.legend-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.unit-note {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}

/* ─── Pill legend ─────────────────────────────────────────────────────────── */
.pill-legend {
  margin: 0.2rem 0 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.5rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.pill-legend span {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-sub);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  background: var(--surface-3);
}

/* ─── Row blocked ─────────────────────────────────────────────────────────── */
.row-blocked td { opacity: 0.55; }

.row-blocked .unit-note {
  color: var(--red);
  font-weight: 600;
}

/* ─── Row-header button transitions ──────────────────────────────────────── */
.row-header button, .card button {
  transition:
    background 160ms var(--ease),
    border-color 160ms var(--ease),
    color 160ms var(--ease),
    box-shadow 160ms var(--ease),
    transform 120ms var(--ease);
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */
.tiny { font-size: 0.88rem; }

.creator-footer {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.creator-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--border-mid);
  background: var(--surface-2);
  object-fit: cover;
  flex-shrink: 0;
}

.creator-footer a {
  color: var(--gold-light);
  font-weight: 600;
  text-decoration: none;
}
.creator-footer a:hover { text-decoration: underline; color: #ffe08c; }

.feedback-links { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.footer-pill {
  display: inline-block;
  border: 1px solid var(--border-mid);
  border-radius: 999px;
  background: rgba(200,151,42,0.07);
  padding: 0.22rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gold-light);
  text-decoration: none;
  transition: background 150ms var(--ease), border-color 150ms var(--ease);
}
.footer-pill:hover {
  background: rgba(200,151,42,0.14);
  border-color: var(--border-hi);
}

/* ─── Selection & scrollbar ──────────────────────────────────────────────── */
::selection {
  background: rgba(214, 166, 32, 0.28);
  color: var(--text-bright);
}

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb {
  background: var(--border-mid);
  border-radius: 999px;
  border: 1px solid var(--bg-base);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }
html { scrollbar-color: var(--border-mid) var(--bg-base); scrollbar-width: thin; }

/* ─── Page load entrance ──────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.layout > * {
  animation: fadeUp 380ms var(--ease) both;
}
.layout > *:nth-child(1) { animation-delay: 15ms; }
.layout > *:nth-child(2) { animation-delay: 65ms; }
.layout > *:nth-child(3) { animation-delay: 115ms; }
.layout > *:nth-child(4) { animation-delay: 165ms; }
.layout > *:nth-child(5) { animation-delay: 215ms; }
.layout > *:nth-child(6) { animation-delay: 265ms; }
.layout > *:nth-child(7) { animation-delay: 315ms; }

/* ─── Nav active fill ─────────────────────────────────────────────────────── */
.nav-link.nav-active {
  background: rgba(214, 166, 32, 0.08);
  border-radius: 4px 4px 0 0;
}

/* ─── Page header gold anchor ─────────────────────────────────────────────── */
.page-header {
  padding-left: 1.1rem;
  border-left: 2px solid var(--gold);
}

/* ─── Form label hierarchy ────────────────────────────────────────────────── */
label:not(.pill):not(.radio-card) {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ─── Section step — open state glow ─────────────────────────────────────── */
details[open] > summary .section-step {
  background: rgba(214, 166, 32, 0.14);
  border-color: var(--border-hi);
  color: var(--gold);
}

/* ─── Big numbers — output glow ───────────────────────────────────────────── */
.big {
  text-shadow: 0 0 40px rgba(214, 166, 32, 0.20);
}

/* ─── Top-pick card — richer gold presence ────────────────────────────────── */
.top-pick-card {
  box-shadow: 0 0 32px rgba(200, 151, 42, 0.22), inset 0 1px 0 rgba(200, 151, 42, 0.40);
}

/* ─── Section hint / guide text ──────────────────────────────────────────── */
.section-hint {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0 0 0.9rem;
  line-height: 1.5;
  padding: 0.45rem 0.7rem;
  border-left: 2px solid var(--border-sub);
  background: rgba(0, 0, 0, 0.14);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ─── Resource card identity ──────────────────────────────────────────────── */
/* Each resource gets a semantic left border + tinted corner gradient */
.totals-grid [data-resource="wood"] {
  border-left-color: #2e6020;
  background:
    radial-gradient(160px 70px at 0% 0%, rgba(46, 96, 32, 0.10), transparent 70%),
    var(--surface-2);
}
.totals-grid [data-resource="food"] {
  border-left-color: #7a4a1a;
  background:
    radial-gradient(160px 70px at 0% 0%, rgba(122, 74, 26, 0.10), transparent 70%),
    var(--surface-2);
}
.totals-grid [data-resource="gold"] {
  border-left-color: var(--gold);
  background:
    radial-gradient(160px 70px at 0% 0%, rgba(200, 151, 42, 0.10), transparent 70%),
    var(--surface-2);
}
.totals-grid [data-resource="stone"] {
  border-left-color: #445568;
  background:
    radial-gradient(160px 70px at 0% 0%, rgba(68, 85, 104, 0.10), transparent 70%),
    var(--surface-2);
}

.totals-grid [data-resource="wood"]:hover  { border-left-color: #3d8030; }
.totals-grid [data-resource="food"]:hover  { border-left-color: #9a5e24; }
.totals-grid [data-resource="gold"]:hover  { border-left-color: var(--gold-light); box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 20px rgba(200,151,42,0.10); }
.totals-grid [data-resource="stone"]:hover { border-left-color: #5a7082; }

/* ─── Ranking — position cells & row highlight ────────────────────────────── */
.rank-pos {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0;
}

tr.row-rank1 td { background: rgba(200, 151, 42, 0.04) !important; }
tr.row-rank1 td:first-child { border-left: 2px solid var(--gold); padding-left: calc(0.55rem - 2px); }
tr.row-rank1 .rank-pos { color: var(--gold); font-size: 1.3rem; }
tr.row-rank1 .unit-cell span { color: var(--gold-light); font-weight: 600; }

/* ─── Composition — main unit card ────────────────────────────────────────── */
.unit-card.unit-main {
  border-color: var(--border-mid);
  background:
    radial-gradient(220px 90px at 100% 0%, rgba(200, 151, 42, 0.06), transparent 70%),
    var(--surface-2);
}

/* ─── Total villagers summary emphasis ────────────────────────────────────── */
.total-vils {
  font-size: 0.95rem;
  color: var(--text);
}
.total-vils strong {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.01em;
}

/* ─── Primary button ──────────────────────────────────────────────────────── */
button.btn-primary {
  background: var(--gold);
  color: #080c0f;
  border-color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.03em;
}
button.btn-primary:hover {
  background: var(--gold-light);
  border-color: var(--gold-light);
  color: #060a0d;
  box-shadow: 0 0 28px rgba(214, 166, 32, 0.40);
  transform: translateY(-1px);
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .site-brand { display: none; }
  .nav-link { padding: 0 0.55rem; font-size: 0.75rem; }
  .layout { width: min(95vw, 680px); }
  .totals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .explorer-stats { grid-template-columns: 1fr; }
  .assumption-row { grid-template-columns: 1fr; }
  .upgrade-groups { grid-template-columns: 1fr; }
  .comp-controls-grid { grid-template-columns: 1fr; }
  .enemy-role-grid { grid-template-columns: 1fr; }
  .civ-icon, .age-icon { width: 54px; height: 54px; }
  .inline-icon { width: 32px; height: 32px; }
  th, td { padding: 0.45rem 0.3rem; font-size: 0.88rem; }
  button { padding: 0.45rem 0.7rem; }
  .creator-footer { align-items: flex-start; }
  .drivers-cell { min-width: 220px; }
  .score-legend { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
