.habitats-page {
  background: var(--pc-bg, #f8fafc);
}

.habitats-page section {
  padding: 0;
}

.hab-page {
  padding: 8.5rem 1rem 4rem;
  min-height: 75vh;
}

.hab-shell {
  max-width: 1040px;
  margin: 0 auto;
}

.hab-hero {
  text-align: center;
  margin-bottom: 1.35rem;
}

.hab-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hab-kicker a {
  color: var(--pc-brand, #4aa3df);
  text-decoration: none;
}

.hab-kicker a:hover {
  text-decoration: underline;
}

.hab-hero h1 {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  color: var(--pc-text, #111827);
  margin: 0 0 0.5rem;
  font-size: clamp(1.65rem, 3vw, 2.15rem);
}

.hab-subtitle {
  color: var(--pc-text-secondary, #4b5563);
  max-width: 720px;
  margin: 0 auto;
  line-height: 1.55;
}

.hab-card {
  background: var(--pc-surface, #fff);
  border: 1px solid var(--pc-border, #e5e7eb);
  border-radius: 16px;
  box-shadow: var(--pc-shadow, 0 8px 24px rgba(15, 23, 42, 0.05));
  overflow: hidden;
}

.hab-search {
  padding: 1.1rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--pc-border, #f1f5f9);
}

.hab-input-wrap {
  position: relative;
}

.hab-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--pc-muted, #94a3b8);
  pointer-events: none;
}

.hab-input {
  width: 100%;
  border: 1px solid var(--pc-input-border, #d1d5db);
  background: var(--pc-input-bg, #fff);
  color: var(--pc-text, #0f172a);
  border-radius: 10px;
  padding: 0.7rem 0.9rem 0.7rem 2.35rem;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hab-input:focus {
  border-color: var(--pc-brand, #4aa3df);
  box-shadow: 0 0 0 3px rgba(74, 163, 223, 0.2);
}

.hab-dim-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.hab-tab {
  border: 1px solid var(--pc-border, #e5e7eb);
  background: var(--pc-bg-soft, #f8fafc);
  color: var(--pc-text-secondary, #475569);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.hab-tab.is-active {
  background: rgba(74, 163, 223, 0.15);
  border-color: rgba(74, 163, 223, 0.45);
  color: var(--pc-brand, #4aa3df);
}

.hab-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  padding: 0.75rem 1.15rem;
  border-bottom: 1px solid var(--pc-border, #f1f5f9);
  color: var(--pc-muted, #64748b);
  font-size: 0.88rem;
}

.hab-stats strong {
  color: var(--pc-text, #0f172a);
}

.hab-stats-sep {
  opacity: 0.5;
}

.hab-empty-banner,
.hab-empty {
  margin: 1rem 1.15rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: var(--pc-bg-soft, #f8fafc);
  border: 1px solid var(--pc-border, #e5e7eb);
  color: var(--pc-text-secondary, #475569);
}

.hab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.65rem;
  padding: 1rem 1.15rem 1.25rem;
}

.hab-tile {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--pc-border, #e5e7eb);
  background: var(--pc-surface, #fff);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.hab-tile:hover {
  border-color: rgba(74, 163, 223, 0.55);
  box-shadow: var(--pc-shadow-soft, 0 4px 14px rgba(15, 23, 42, 0.05));
  transform: translateY(-1px);
  color: inherit;
  text-decoration: none;
}

.hab-tile.is-hidden {
  display: none;
}

.hab-tile-sprites {
  display: flex;
  gap: 0.1rem;
  min-height: 40px;
}

.hab-tile-sprites img,
.hab-mon img {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.hab-mon img {
  width: 64px;
  height: 64px;
  margin: -0.35rem 0;
}

.hab-tile-title {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  color: var(--pc-text, #0f172a);
}

.hab-tile-meta {
  font-size: 0.82rem;
  color: var(--pc-text-secondary, #4b5563);
  line-height: 1.35;
}

.hab-tile-meta svg,
.hab-tile-meta i {
  color: var(--pc-brand, #4aa3df);
  margin-right: 0.2rem;
}

.hab-tile-foot {
  font-size: 0.78rem;
  color: var(--pc-muted, #64748b);
  margin-top: auto;
}

.hab-hero-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.hab-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--pc-border, #e5e7eb);
  background: var(--pc-surface, #fff);
  color: var(--pc-text-secondary, #475569);
  font-size: 0.85rem;
}

.hab-pill strong {
  color: var(--pc-text, #0f172a);
}

.hab-pill svg,
.hab-pill i {
  color: var(--pc-brand, #4aa3df);
}

.hab-filter-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--pc-muted, #64748b);
}

.hab-section {
  padding: 1.1rem 1.15rem 1.2rem;
  border-bottom: 1px solid var(--pc-border, #f1f5f9);
}

.hab-section:last-child {
  border-bottom: 0;
}

.hab-section-title {
  font-family: "Montserrat", sans-serif;
  font-size: 1.08rem;
  font-weight: 700;
  margin: 0 0 0.65rem;
  color: var(--pc-text, #0f172a);
}

.hab-muted {
  color: var(--pc-muted, #64748b);
}

.hab-note {
  margin: 0.75rem 0 0;
  font-size: 0.84rem;
  color: var(--pc-muted, #64748b);
  line-height: 1.5;
}

.hab-note a,
.hab-related a {
  color: var(--pc-brand, #4aa3df);
  font-weight: 600;
  text-decoration: none;
}

.hab-note a:hover,
.hab-related a:hover {
  text-decoration: underline;
}

.hab-found-list {
  display: grid;
  gap: 0.6rem;
}

.hab-found {
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: var(--pc-bg-soft, #f8fafc);
  border: 1px solid var(--pc-border, #e5e7eb);
}

.hab-found-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  color: var(--pc-text, #0f172a);
}

.hab-found-kind {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(74, 163, 223, 0.15);
  color: var(--pc-brand, #4aa3df);
}

.hab-found-kind--feature {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.hab-found-kind--village {
  background: rgba(245, 158, 11, 0.18);
  color: #b45309;
}

.hab-found-rarity {
  font-size: 0.82rem;
}

.hab-biome-line {
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  color: var(--pc-text-secondary, #475569);
  line-height: 1.5;
}

.hab-table-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.hab-table-head .hab-section-title {
  margin-bottom: 0.35rem;
}

.hab-phase-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hab-select {
  border: 1px solid var(--pc-input-border, #d1d5db);
  background: var(--pc-input-bg, #fff);
  color: var(--pc-text, #0f172a);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-size: 0.9rem;
}

.hab-phase-hint {
  margin: 0 0 0.75rem;
  font-size: 0.86rem;
}

.hab-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--pc-border, #e5e7eb);
  border-radius: 12px;
}

.hab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  color: var(--pc-text, #0f172a);
}

.hab-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--pc-muted, #64748b);
  background: var(--pc-bg-soft, #f8fafc);
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--pc-border, #e5e7eb);
  white-space: nowrap;
}

.hab-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--pc-border, #f1f5f9);
  vertical-align: middle;
}

.hab-table tbody tr:last-child td {
  border-bottom: 0;
}

.hab-table tr.is-hidden {
  display: none;
}

.hab-nowrap {
  white-space: nowrap;
}

.hab-mon {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
  min-width: 180px;
}

.hab-mon:hover .hab-mon-name {
  color: var(--pc-brand, #4aa3df);
}

.hab-mon-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.hab-mon-name {
  font-weight: 650;
  font-size: 1rem;
}

.hab-mon-form {
  font-size: 0.76rem;
  color: var(--pc-muted, #64748b);
}

.hab-mon-types {
  display: flex;
  gap: 0.25rem;
}

.hab-mini-type {
  display: inline-flex;
  padding: 0.05rem 0.38rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hab-type) 22%, transparent);
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.hab-bucket {
  display: inline-block;
  margin: 0.1rem 0.2rem 0.1rem 0;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.hab-bucket--common {
  background: rgba(100, 116, 139, 0.15);
  color: #475569;
}

.hab-bucket--uncommon {
  background: rgba(16, 185, 129, 0.16);
  color: #047857;
}

.hab-bucket--rare {
  background: rgba(59, 130, 246, 0.16);
  color: #1d4ed8;
}

.hab-bucket--ultra-rare {
  background: rgba(168, 85, 247, 0.16);
  color: #7e22ce;
}

html[data-theme="dark"] .hab-bucket--common {
  color: #cbd5e1;
}

html[data-theme="dark"] .hab-bucket--uncommon {
  color: #6ee7b7;
}

html[data-theme="dark"] .hab-bucket--rare {
  color: #93c5fd;
}

html[data-theme="dark"] .hab-bucket--ultra-rare {
  color: #d8b4fe;
}

html[data-theme="dark"] .hab-found-kind--feature {
  color: #6ee7b7;
}

html[data-theme="dark"] .hab-found-kind--village {
  color: #fcd34d;
}

.hab-share-all {
  color: var(--pc-muted, #64748b);
  font-size: 0.85rem;
}

.hab-conditions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  min-width: 140px;
}

.hab-conditions span {
  font-size: 0.76rem;
  padding: 0.08rem 0.45rem;
  border-radius: 6px;
  background: var(--pc-bg-soft, #f1f5f9);
  color: var(--pc-text-secondary, #475569);
}

.hab-table td.hab-conditions {
  display: table-cell;
}

.hab-table td.hab-conditions span {
  display: inline-block;
  margin: 0.08rem 0.15rem 0.08rem 0;
}

.hab-phases-cell {
  font-size: 0.82rem;
  color: var(--pc-text-secondary, #475569);
  min-width: 70px;
}

.hab-explain ul {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
  color: var(--pc-text-secondary, #4b5563);
  line-height: 1.6;
}

.hab-explain p {
  color: var(--pc-text-secondary, #4b5563);
  line-height: 1.6;
  margin: 0 0 0.75rem;
}

.hab-related {
  font-size: 0.92rem;
}

.hab-faq {
  margin-top: 1.5rem;
}

.hab-faq h2 {
  font-family: "Montserrat", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--pc-text, #0f172a);
}

.hab-faq-item {
  background: var(--pc-surface, #fff);
  border: 1px solid var(--pc-border, #e5e7eb);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.55rem;
}

.hab-faq-item summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--pc-text, #0f172a);
}

.hab-faq-item p {
  margin: 0.65rem 0 0;
  color: var(--pc-text-secondary, #4b5563);
  line-height: 1.55;
}

.spawn-page .spawn-habitats {
  margin-top: 1.75rem;
  padding: 0;
}

.spawn-habitats-title {
  font-family: "Montserrat", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--pc-text, #0f172a);
}

.spawn-habitats--nospawn {
  margin-top: 1rem;
}

/* Shared "Habitats" block used on spawn + Pokédex pages */
.hab-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.55rem;
}

.hab-list-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--pc-border, #e5e7eb);
  background: var(--pc-surface, #fff);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.hab-list-item:hover {
  border-color: rgba(74, 163, 223, 0.55);
  color: inherit;
  text-decoration: none;
}

.hab-list-name {
  font-weight: 700;
  color: var(--pc-text, #0f172a);
}

.hab-list-meta {
  font-size: 0.8rem;
  color: var(--pc-text-secondary, #4b5563);
  line-height: 1.4;
}

.hab-list-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

@media (max-width: 640px) {
  .hab-page {
    padding-top: 7.25rem;
  }

  .hab-mon img {
    width: 48px;
    height: 48px;
  }
}
