:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --accent2: #f5a623;
  --text: #eaeaea;
  --text-muted: #8892a4;
  --border: #2a3a5e;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ---- NAV ---- */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .logo {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
}
nav a {
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.2s;
  font-size: 0.95rem;
}
nav a:hover, nav a.active { color: var(--text); }

/* ---- PAGE WRAPPER ---- */
.page { max-width: 1400px; margin: 0 auto; padding: 2rem 1.5rem; }

h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.25rem; }
.subtitle { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.95rem; }

/* ---- HOME ---- */
.home-hero {
  text-align: center;
  padding: 3rem 1rem 1rem;
}
.home-hero h1 { font-size: 3rem; color: var(--accent); }
.home-hero p { color: var(--text-muted); font-size: 1.1rem; margin-top: 0.5rem; }

.home-buttons {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 3rem 1rem;
}

.home-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 20px;
  width: 260px;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-align: center;
}
.home-btn:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(233,69,96,0.3);
}
.home-btn img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  image-rendering: pixelated;
}
.home-btn .btn-icon { font-size: 4rem; line-height: 1; }
.home-btn h2 { font-size: 1.4rem; font-weight: 700; }
.home-btn p { color: var(--text-muted); font-size: 0.85rem; line-height: 1.4; }

/* ---- SEARCH BAR ---- */
.search-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.search-bar input {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.search-bar input:focus { border-color: var(--accent); }

/* ---- GRID ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
}
.grid.items-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  text-align: center;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.card img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
}
.items-grid .card img {
  width: 64px;
  height: 64px;
}
.card .poke-num { color: var(--text-muted); font-size: 0.75rem; }
.card .poke-name { font-size: 0.85rem; font-weight: 600; }

.card .item-name { font-size: 0.82rem; font-weight: 600; line-height: 1.3; }
.card .item-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
}
.card .tag {
  background: var(--surface2);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ---- DETAIL PAGE ---- */
.detail-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
}
.detail-header img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  image-rendering: pixelated;
}
.detail-header h1 { font-size: 2rem; }
.detail-header .poke-num { color: var(--text-muted); font-size: 1rem; }

.detail-section { margin-bottom: 2rem; }
.detail-section h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 1rem; color: var(--accent2); }

.traits-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.trait-badge {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 500;
}
.trait-badge.milieu {
  background: rgba(245,166,35,0.2);
  color: var(--accent2);
  border: 1px solid rgba(245,166,35,0.4);
}

.compat-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.compat-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.compat-item:hover { border-color: var(--accent); }
.compat-item img { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; }
.compat-item .compat-name { flex: 1; font-weight: 600; }
.compat-item .compat-score {
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  min-width: 40px;
  text-align: center;
}

/* ---- SYNERGY TABLE ---- */
.synergy-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.synergy-filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.synergy-filters h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.filter-group:last-child { margin-bottom: 0; }
.filter-sep {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0;
}
.filter-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.filter-chip input { display: none; }
.filter-chip.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}
.filter-chip.milieu-chip.checked {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #1a1a2e;
}

.synergy-table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table.synergy-table {
  border-collapse: collapse;
  min-width: 100%;
  background: var(--surface);
}
table.synergy-table thead th {
  background: var(--surface2);
  padding: 0.5rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}
table.synergy-table thead th.col-name {
  text-align: left;
  padding-left: 0.75rem;
  min-width: 160px;
  position: sticky;
  left: 0;
  z-index: 3;
}
table.synergy-table thead th.col-sep {
  background: var(--bg);
  border-right: 2px solid var(--accent2);
  width: 6px;
  padding: 0;
}
table.synergy-table tbody tr:hover td { background: rgba(255,255,255,0.03); }

table.synergy-table td {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
}
table.synergy-table td.col-name {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
  padding-left: 0.5rem;
  min-width: 160px;
}
table.synergy-table td.col-name .td-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
table.synergy-table td.col-name img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  image-rendering: pixelated;
}
table.synergy-table td.col-name .td-pname { font-size: 0.82rem; font-weight: 600; }
table.synergy-table td.col-sep {
  background: var(--bg);
  border-right: 2px solid var(--accent2);
  padding: 0;
  width: 6px;
}
table.synergy-table td.match {
  background: rgba(233,69,96,0.35);
}
table.synergy-table td.match-milieu {
  background: rgba(245,166,35,0.35);
}

/* ---- BACK BUTTON ---- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
}
.back-btn:hover { color: var(--text); }

/* ---- POKEMON SPRITE placeholder ---- */
.sprite-placeholder {
  width: 72px;
  height: 72px;
  background: var(--surface2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

/* ---- COUNT BADGE ---- */
.count-badge {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ---- ITEM DETAIL ---- */
.item-detail-icon {
  font-size: 5rem;
  line-height: 1;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
  .home-buttons { flex-direction: column; align-items: center; }
  .detail-header { flex-direction: column; text-align: center; }
  h1 { font-size: 1.5rem; }
}
