:root {
  color-scheme: light;
  --bg: #fff7fb;
  --bg-accent: #eef8ff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --text: #2f2340;
  --muted: #6e6180;
  --primary: #ff78b2;
  --primary-strong: #f04b92;
  --secondary: #7ec8ff;
  --border: rgba(146, 122, 178, 0.2);
  --success: #3caf7d;
  --warning: #f1a93b;
  --shadow: 0 18px 50px rgba(125, 102, 170, 0.14);
  --hero-accent: rgba(255, 120, 178, 0.18);
  --hero-accent-strong: rgba(240, 75, 146, 0.35);
}

body.dark {
  color-scheme: dark;
  --bg: #17131f;
  --bg-accent: #1d2333;
  --surface: rgba(30, 26, 40, 0.92);
  --surface-strong: #241f31;
  --text: #f7efff;
  --muted: #c2b6d6;
  --primary: #ff88c0;
  --primary-strong: #ff5ca6;
  --secondary: #8ad4ff;
  --border: rgba(255, 255, 255, 0.1);
  --success: #54d79a;
  --warning: #ffd166;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --hero-accent: rgba(255, 136, 192, 0.15);
  --hero-accent-strong: rgba(255, 92, 166, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 182, 213, 0.35), transparent 24%),
    radial-gradient(circle at top right, rgba(126, 200, 255, 0.28), transparent 24%),
    linear-gradient(160deg, var(--bg), var(--bg-accent));
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.app-shell {
  width: min(1140px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

.topbar,
.section-header,
.actions,
.monster-card,
.info-grid,
.legend,
.chips,
.dex-header,
.progress-headline-row {
  display: flex;
}

.topbar {
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--muted);
}

h1 {
  margin-bottom: 0.35rem;
  font-size: clamp(2rem, 4vw, 3rem);
}

.subtitle,
.section-copy,
.roster-meta,
.roster-habitats,
.roster-count,
.micro-copy {
  margin-bottom: 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

.card {
  grid-column: span 12;
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1.2rem;
}

.hero-card {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 1rem;
  background:
    radial-gradient(circle at top left, var(--hero-accent), transparent 36%),
    var(--surface);
}

.status-card,
.map-card,
.dex-card,
.roster-card {
  grid-column: span 6;
}

.hero-copy h2 {
  font-size: clamp(1.4rem, 2vw, 2rem);
  margin-bottom: 0.75rem;
}

.hero-copy p,
.dex-entry p,
.encounter-content p,
.section-copy {
  color: var(--muted);
  line-height: 1.55;
}

.pill,
.status-badge,
.chip,
.rarity-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.9rem;
}

.pill {
  background: rgba(255, 120, 178, 0.13);
  color: var(--primary-strong);
}

.pill.subtle {
  background: rgba(126, 200, 255, 0.14);
  color: #2b6ea3;
}

.monster-card,
.roster-item,
.progress-card {
  gap: 1rem;
  background: linear-gradient(160deg, rgba(255,255,255,0.65), rgba(255,240,248,0.88));
  border: 1px solid rgba(255, 120, 178, 0.18);
  border-radius: 22px;
  padding: 1rem;
}

.monster-card {
  align-items: center;
}

body.dark .monster-card,
body.dark .roster-item,
body.dark .progress-card {
  background: linear-gradient(160deg, rgba(42, 35, 57, 0.88), rgba(31, 42, 57, 0.94));
}

.portrait-image {
  display: block;
  object-fit: cover;
}

.monster-avatar,
.encounter-portrait,
.mini-avatar {
  border-radius: 50%;
  background: radial-gradient(circle at top, #ffffff, #ffd6e8 62%, #c6eeff);
  box-shadow: inset 0 -8px 18px rgba(255, 120, 178, 0.2);
}

.monster-avatar,
.encounter-portrait {
  width: 96px;
  height: 96px;
  padding: 0.4rem;
}

.mini-avatar {
  width: 62px;
  height: 62px;
  padding: 0.28rem;
}

.section-header {
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.map-header {
  align-items: flex-start;
}

.info-grid {
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.info-grid > div {
  flex: 1 1 180px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0.85rem;
}

.label {
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.actions,
.chips {
  flex-wrap: wrap;
  gap: 0.75rem;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.progress-card {
  display: grid;
  gap: 0.75rem;
}

.progress-headline-row {
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(126, 200, 255, 0.18);
  border: 1px solid rgba(126, 200, 255, 0.18);
}

.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  transition: width 0.25s ease;
}

.primary-button,
.secondary-button,
.ghost-button,
.roster-item {
  border-radius: 999px;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 0;
  padding: 0.8rem 1.1rem;
  cursor: pointer;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  box-shadow: 0 10px 24px rgba(240, 75, 146, 0.26);
}

.secondary-button {
  background: rgba(126, 200, 255, 0.16);
  color: var(--text);
  border: 1px solid rgba(126, 200, 255, 0.25);
}

.ghost-button {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border);
  min-width: 48px;
}

button:hover,
.roster-item:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.message-box {
  margin-top: 1rem;
  background: rgba(255, 120, 178, 0.09);
  border: 1px solid rgba(255, 120, 178, 0.2);
  border-radius: 18px;
  padding: 0.9rem 1rem;
  color: var(--text);
}

.status-badge.idle {
  background: rgba(146, 122, 178, 0.16);
  color: var(--muted);
}

.status-badge.searching {
  background: rgba(241, 169, 59, 0.18);
  color: #9a6700;
}

.status-badge.encounter {
  background: rgba(60, 175, 125, 0.18);
  color: #1f7e55;
}

.map-panel {
  width: 100%;
  min-height: 420px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

.legend {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 0.94rem;
  margin-top: 1rem;
}

.chip {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text);
}

.chip-player::before,
.chip-radius::before,
.chip-monster::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.chip-player::before {
  background: #4c9aff;
}

.chip-radius::before {
  background: #7ec8ff;
}

.chip-monster::before {
  background: #ff78b2;
}

.dex-header {
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.dex-status {
  font-weight: 700;
  color: var(--primary-strong);
}

.dex-habitats {
  font-weight: 600;
}

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

.roster-item {
  width: 100%;
  text-align: left;
  display: block;
  cursor: pointer;
  border: 1px solid var(--border);
  padding: 1rem;
}

.roster-item.active {
  border-color: var(--hero-accent-strong);
  box-shadow: 0 12px 24px rgba(240, 75, 146, 0.18);
}

.roster-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.roster-art {
  width: 66px;
  height: 66px;
  border-radius: 18px;
  padding: 0.2rem;
  background: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.35);
}

.roster-emoji {
  font-size: 1.7rem;
}

.rarity-badge {
  font-size: 0.76rem;
  padding: 0.3rem 0.65rem;
}

.rarity-haeufig {
  background: rgba(126, 200, 255, 0.18);
  color: #2b6ea3;
}

.rarity-selten {
  background: rgba(127, 213, 140, 0.18);
  color: #2d7d42;
}

.rarity-sehr-selten {
  background: rgba(255, 120, 178, 0.18);
  color: var(--primary-strong);
}

.monster-marker {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  padding: 0.25rem;
  background: linear-gradient(180deg, #fff5fb, #ffd5e9);
  border: 2px solid var(--marker-accent, rgba(255, 120, 178, 0.7));
  box-shadow: 0 12px 24px rgba(240, 75, 146, 0.28);
}

.monster-marker img {
  width: 100%;
  height: 100%;
  border-radius: 14px;
}

.player-popup,
.monster-popup {
  font-weight: 600;
}

.encounter-dialog {
  border: 0;
  border-radius: 28px;
  padding: 0;
  width: min(92vw, 480px);
  background: transparent;
}

.encounter-dialog::backdrop {
  background: rgba(16, 12, 24, 0.52);
  backdrop-filter: blur(4px);
}

.encounter-content {
  background: var(--surface-strong);
  color: var(--text);
  padding: 1.4rem;
  border-radius: 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.encounter-portrait {
  margin: 0 auto 1rem;
}

.leaflet-control-attribution {
  font-size: 11px;
}

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

@media (max-width: 860px) {
  .hero-card,
  .status-card,
  .map-card,
  .dex-card,
  .roster-card {
    grid-column: span 12;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 1rem, 100%);
    padding-top: 0.75rem;
  }

  .topbar,
  .section-header,
  .dex-header,
  .progress-headline-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .card {
    padding: 1rem;
    border-radius: 20px;
  }

  .map-panel {
    min-height: 340px;
  }

  .monster-avatar,
  .encounter-portrait {
    width: 82px;
    height: 82px;
  }
}
