/* Mewgenics Guide - Dark Gaming Theme */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-card: #1a1a2e;
  --bg-hover: #252540;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-muted: #6a6a80;
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-yellow: #eab308;
  --accent-cyan: #22d3ee;
  --accent-orange: #f97316;
  --border: #2a2a40;
  --border-hover: #3a3a55;
  --font-mono: 'Courier New', 'Consolas', monospace;
  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 4px 12px rgba(0,0,0,0.4);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Navigation */
nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  overflow-x: auto;
}

nav .logo {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  text-decoration: none;
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

nav a:hover, nav a.active {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Layout */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.15s, transform 0.15s;
}

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

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 0.5rem;
}

.card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.card .tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
}

.tag-green { background: rgba(34,197,94,0.15); color: var(--accent-green); }
.tag-red { background: rgba(239,68,68,0.15); color: var(--accent-red); }
.tag-yellow { background: rgba(234,179,8,0.15); color: var(--accent-yellow); }
.tag-cyan { background: rgba(34,211,238,0.15); color: var(--accent-cyan); }
.tag-orange { background: rgba(249,115,22,0.15); color: var(--accent-orange); }
.tag-purple { background: rgba(124,58,237,0.15); color: var(--accent-light); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
}

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

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-secondary);
  color: var(--accent-light);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:hover td {
  background: var(--bg-hover);
}

/* Content sections */
.content-section {
  margin: 2rem 0;
}

.content-section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 1rem;
}

.content-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 1.25rem 0 0.5rem;
}

.content-section p {
  margin: 0.5rem 0;
  color: var(--text-secondary);
}

.content-section ul, .content-section ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

.content-section li {
  margin: 0.3rem 0;
}

/* Info boxes */
.info-box {
  background: rgba(124,58,237,0.1);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1rem 0;
}

.info-box.warning {
  background: rgba(239,68,68,0.1);
  border-left-color: var(--accent-red);
}

.info-box.tip {
  background: rgba(34,197,94,0.1);
  border-left-color: var(--accent-green);
}

.info-box h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--accent-light);
}

.info-box.warning h4 { color: var(--accent-red); }
.info-box.tip h4 { color: var(--accent-green); }

.info-box p, .info-box ul {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Home hero */
.hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 1rem auto;
}

/* Tool containers */
.tool-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1rem 0;
}

.tool-container h2 {
  font-size: 1.2rem;
  color: var(--accent-light);
  margin-bottom: 1rem;
}

.tool-row {
  display: flex;
  gap: 1rem;
  margin: 0.75rem 0;
  align-items: center;
  flex-wrap: wrap;
}

.tool-row label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 100px;
}

.tool-row input, .tool-row select {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  min-width: 60px;
}

.tool-row input:focus, .tool-row select:focus {
  outline: none;
  border-color: var(--accent);
}

.tool-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.tool-btn:hover { opacity: 0.85; }

.tool-output {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  min-height: 60px;
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.6;
}

/* Stat bars */
.stat-bar {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.stat-bar .bar {
  height: 18px;
  border-radius: 2px;
  transition: width 0.3s;
}

.stat-bar .label {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 30px;
}

/* Utility */
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* ── Breeding Guide: Risk Zones ── */
.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.legend-item {
  flex: 1 1 180px;
  border-radius: 10px;
  padding: 12px 16px;
  border: 1px solid;
}
.legend-item .range { font-size: 1.25rem; font-weight: 700; }
.legend-item .label { font-size: 0.85rem; opacity: 0.75; margin-top: 2px; }
.legend-item .desc  { font-size: 0.8rem;  margin-top: 6px; }

.z-green  { background: #0d2a1a; border-color: #1e7a44; }
.z-green .range  { color: #4ece7a; }
.z-yellow { background: #2a2500; border-color: #8a7000; }
.z-yellow .range { color: #f0c030; }
.z-orange { background: #2a1500; border-color: #9a5000; }
.z-orange .range { color: #f07030; }
.z-red    { background: #2a0a0a; border-color: #9a1010; }
.z-red .range    { color: #f04040; }

/* Breeding: Tree wrap */
.tree-wrap {
  background: #111128;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  overflow-x: auto;
  margin: 1rem 0;
}
.tree-wrap svg text { font-family: var(--font-sans); }

/* Breeding: Formula box */
.formula {
  background: var(--bg-card);
  border-left: 3px solid var(--accent-light);
  border-radius: 0 8px 8px 0;
  padding: 12px 18px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #e0c8ff;
  margin-bottom: 12px;
}
.formula .note { font-family: var(--font-sans); font-size: 0.8rem; color: #7070aa; margin-top: 4px; }

/* Breeding: Strategy cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 1rem 0;
}
.cards .card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.cards .card h3 { font-size: 0.9rem; color: var(--accent-light); margin-bottom: 8px; }
.cards .card p  { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.6; }
.cards .card .num {
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent-light);
  opacity: 0.25;
  float: right;
  line-height: 1;
}
.cards .card .tag { margin-top: 0.5rem; }

/* Breeding: Coef span */
.coef { font-weight: 700; font-size: 1rem; }

/* Breeding: Cycle flow */
.cycle-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  margin: 1rem 0;
}
.cycle-step {
  border-radius: 8px;
  padding: 8px 14px;
  text-align: center;
}
.cycle-arrow { color: #4a4a70; font-size: 1.2rem; }

/* ── Teams: Attribute Badges ── */
.attr-badge {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  border-radius: 4px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
}
.attr-S { background: #7a5500; color: #ffd700; }
.attr-A { background: #0d3320; color: #4ece7a; }
.attr-B { background: #0d1a3a; color: #6090ff; }
.attr-C { background: #1a1a2e; color: #9090b0; }
.attr-D { background: #2a1a00; color: #f0a030; }
.attr-F { background: #2a0a0a; color: #f04040; }

/* Teams: Class picker card */
.class-pick-btn {
  display: inline-block;
  margin: 0.25rem;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  border: 1px solid;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.15s;
}
.class-pick-btn:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}
.class-pick-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* Teams: Slot card */
.slot-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  min-height: 100px;
  text-align: center;
  position: relative;
}
.slot-card.empty {
  border-style: dashed;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.slot-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--accent-red);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.7rem;
  cursor: pointer;
}

/* Teams: Radar chart */
.chart-wrap {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
  text-align: center;
}
.chart-wrap canvas {
  max-width: 100%;
  height: auto;
}

/* Teams: Score display */
.team-score-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
  text-align: center;
}
.team-score-value {
  font-size: 2.5rem;
  font-weight: 800;
}
.team-score-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Teams: Coverage gap */
.gap-warning {
  background: rgba(239,68,68,0.1);
  border: 1px solid var(--accent-red);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.8rem;
  color: var(--accent-red);
}
.gap-warning.gap-ok {
  background: rgba(34,197,94,0.1);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

/* Teams: Attribute breakdown table */
.attr-breakdown {
  font-size: 0.82rem;
  margin: 0.75rem 0;
}
.attr-breakdown td {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

/* Teams: Collapsible sections */
details.guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0.75rem 0;
  overflow: hidden;
}
details.guide-section summary {
  padding: 0.9rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent-light);
  cursor: pointer;
  background: var(--bg-secondary);
  user-select: none;
}
details.guide-section summary:hover {
  background: var(--bg-hover);
}
details.guide-section .section-body {
  padding: 0.75rem 1rem;
  max-width: 100%;
  overflow-x: auto;
}
details.guide-section .section-body table {
  font-size: 0.75rem;
}
details.guide-section .section-body th,
details.guide-section .section-body td {
  padding: 0.3rem 0.4rem;
}

/* Teams: Synergy note */
.synergy-note {
  background: rgba(124,58,237,0.08);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin: 0.3rem 0;
  font-size: 0.8rem;
  color: var(--accent-light);
}

/* ── Dynasty Builder ─────────────────────────────────────────────────────── */
.dynasty-wrap {
  position: relative;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 28px,
    rgba(255,255,255,0.018) 28px, rgba(255,255,255,0.018) 29px
  ),
  repeating-linear-gradient(
    90deg, transparent, transparent 28px,
    rgba(255,255,255,0.018) 28px, rgba(255,255,255,0.018) 29px
  ),
  #0c0c16;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: 580px;
  cursor: default;
  user-select: none;
}

.dynasty-pan {
  position: absolute;
  top: 0; left: 0;
  width: 3000px; height: 2000px;
  transform-origin: 0 0;
}

.dynasty-pan svg {
  position: absolute;
  top: 0; left: 0;
  width: 3000px; height: 2000px;
  pointer-events: none;
  overflow: visible;
}

/* ── Cat portrait nodes ── */
.cat-node {
  position: absolute;
  width: 100px;
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.cat-node:active { cursor: grabbing; }

.cat-portrait {
  width: 80px; height: 80px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
  position: relative;
  flex-shrink: 0;
}

/* Frame styles */
.cat-node.frame-gen0  .cat-portrait {
  border: 5px solid #c4a030;
  box-shadow: 0 0 0 2px #7a6010, inset 0 0 10px rgba(0,0,0,0.6), 0 0 12px rgba(196,160,48,0.4);
}
.cat-node.frame-gen1  .cat-portrait {
  border: 4px solid #a0a8b8;
  box-shadow: 0 0 0 2px #50586a, inset 0 0 8px rgba(0,0,0,0.5);
}
.cat-node.frame-gen2  .cat-portrait {
  border: 4px solid #6070a0;
  box-shadow: 0 0 0 2px #303860, inset 0 0 8px rgba(0,0,0,0.5);
}
.cat-node.frame-gen3  .cat-portrait {
  border: 4px solid #408060;
  box-shadow: 0 0 0 2px #205040, inset 0 0 8px rgba(0,0,0,0.5);
}
.cat-node.frame-stray .cat-portrait {
  border: 3px dashed #22c55e;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.4);
}

.cat-node.cat-selected .cat-portrait {
  outline: 3px solid #a78bfa;
  outline-offset: 3px;
  box-shadow: 0 0 18px rgba(167,139,250,0.6), inset 0 0 8px rgba(0,0,0,0.5);
}

.cat-badge {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  bottom: -4px; right: -4px;
  border: 2px solid #0c0c16;
}

.cat-label {
  margin-top: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(10,10,20,0.85);
  padding: 2px 5px;
  border-radius: 3px;
}

/* ── Toolbar ── */
.dynasty-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  align-items: center;
}

.dt-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.dt-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.dt-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.dt-btn-active {
  background: #2d1a5c;
  border-color: #7c3aed;
  color: #a78bfa;
}

.dynasty-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Popup ── */
.dynasty-popup-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#dt-popup {
  display: none;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: #16162a;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 1.25rem;
  width: 300px;
  z-index: 60;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.pp-title {
  color: var(--accent-light);
  font-size: 1rem;
  margin-bottom: 1rem;
}

#dt-popup label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.65rem;
}

#dt-popup input[type="text"],
#dt-popup select {
  display: block;
  width: 100%;
  margin-top: 3px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

#dt-popup input[type="checkbox"] {
  margin-right: 6px;
}

.pp-emoji-row, .pp-color-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.pp-emoji {
  background: var(--bg-primary);
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: border-color 0.1s;
}
.pp-emoji:hover, .pp-emoji-sel {
  border-color: var(--accent);
}

.pp-color {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.1s, transform 0.1s;
}
.pp-color:hover, .pp-color-sel {
  border-color: #fff;
  transform: scale(1.15);
}

.pp-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

/* Responsive */
@media (max-width: 768px) {
  nav { gap: 0.75rem; padding: 0.5rem 1rem; }
  nav .logo { font-size: 0.95rem; }
  .hero h1 { font-size: 1.8rem; }
  .card-grid { grid-template-columns: 1fr; }
  .container { padding: 1rem; }
  .tool-row { flex-direction: column; align-items: stretch; }
  .tool-row label { min-width: auto; }
}
