:root {
  --bg: #141414;
  --bg-soft: #1d1d1d;
  --card: rgba(255, 255, 255, 0.05);
  --card-strong: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f6f6f6;
  --muted: rgba(255, 255, 255, 0.6);
  --accent: #e50914;
  --accent-soft: rgba(229, 9, 20, 0.16);
  --success: #39d98a;
  --warn: #ffb020;
  --dead: #ff5f73;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(229, 9, 20, 0.15), transparent 28%),
    radial-gradient(circle at bottom right, rgba(229, 9, 20, 0.12), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: 'Manrope', sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1680px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero,
.session-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.session-bar {
  margin-top: 16px;
}

.eyebrow,
.session-label {
  margin: 0 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: clamp(42px, 5vw, 78px);
  line-height: 0.92;
}

h2 {
  font-size: 32px;
}

h3 {
  font-size: 28px;
}

h4 {
  font-size: 22px;
}

.hero-actions,
.session-tools,
.view-switch,
.join-group,
.inline-form,
.panel-head,
.modal-head,
.player-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-heading {
  justify-content: space-between;
  align-items: start;
}

.primary-button,
.ghost-button,
.chip-button,
.status-button,
.import-button {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.small-button {
  min-height: 38px;
  padding: 0 14px;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.ghost-button,
.import-button,
.chip-button,
.status-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--line);
}

.chip-button,
.status-button {
  min-height: 34px;
  padding: 0 12px;
}

.chip-button.active,
.status-button.active,
.ghost-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

button:hover {
  transform: translateY(-1px);
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 18px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(229, 9, 20, 0.5);
}

.tracker-view {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(340px, 0.9fr) minmax(280px, 1fr);
  gap: 20px;
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.player-panel,
.center-panel {
  display: grid;
  gap: 20px;
  align-content: start;
}

.soul-links-panel {
  align-self: stretch;
}

.panel-card {
  padding: 20px;
  background: linear-gradient(180deg, var(--card-strong), var(--card));
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.dex-panel {
  padding: 0;
  overflow: hidden;
}

.dex-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  cursor: pointer;
  list-style: none;
}

.dex-summary::-webkit-details-marker {
  display: none;
}

.dex-summary::after {
  content: '+';
  margin-left: auto;
  color: var(--accent);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.dex-panel[open] .dex-summary::after {
  content: '−';
}

.dex-summary-count {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 12px;
  padding: 0 24px 24px;
  border-top: 1px solid var(--line);
}

.dex-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.dex-cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  transform: scale(1.15);
}

.dex-cell:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.12);
}

.dex-cell.caught {
  border-color: rgba(229, 9, 20, 0.7);
  background: rgba(229, 9, 20, 0.14);
}

.dex-cell.locked {
  opacity: 0.5;
  filter: grayscale(1);
}

.dex-cell.caught.locked {
  opacity: 0.78;
}

.dex-empty {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.meta-grid,
.bridge-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.meta-grid,
.bridge-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meta-tile,
.bridge-tile,
.route-row,
.pair-row,
.activity-row {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.meta-tile span,
.bridge-tile span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.section-grid,
.opponent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.pokemon-card {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top center, rgba(229, 9, 20, 0.2), transparent 40%),
    rgba(255, 255, 255, 0.05);
}

.pokemon-card.dead {
  background:
    radial-gradient(circle at top center, rgba(255, 95, 115, 0.2), transparent 40%),
    rgba(255, 255, 255, 0.04);
}

.pokemon-card img {
  width: 100%;
  height: 112px;
  object-fit: contain;
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.35));
}

.pokemon-card h4 {
  margin-top: 12px;
  font-size: 22px;
  line-height: 1;
}

.pokemon-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: white;
  background: #666;
}

.type-badge[data-type='normal'] { background: #a8a77a; }
.type-badge[data-type='fire'] { background: #ee8130; }
.type-badge[data-type='water'] { background: #6390f0; }
.type-badge[data-type='electric'] { background: #f7d02c; color: #231f20; }
.type-badge[data-type='grass'] { background: #7ac74c; }
.type-badge[data-type='ice'] { background: #96d9d6; color: #17363a; }
.type-badge[data-type='fighting'] { background: #c22e28; }
.type-badge[data-type='poison'] { background: #a33ea1; }
.type-badge[data-type='ground'] { background: #e2bf65; color: #2f2611; }
.type-badge[data-type='flying'] { background: #a98ff3; }
.type-badge[data-type='psychic'] { background: #f95587; }
.type-badge[data-type='bug'] { background: #a6b91a; }
.type-badge[data-type='rock'] { background: #b6a136; }
.type-badge[data-type='ghost'] { background: #735797; }
.type-badge[data-type='dragon'] { background: #6f35fc; }
.type-badge[data-type='dark'] { background: #705746; }
.type-badge[data-type='steel'] { background: #b7b7ce; color: #23252b; }
.type-badge[data-type='fairy'] { background: #d685ad; }

.pokemon-actions,
.route-actions,
.pair-actions,
.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.route-list,
.pair-list,
.activity-list,
.live-readout {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.live-readout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.debug-player {
  padding: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.debug-tile {
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.debug-tile span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.debug-json {
  max-height: 260px;
  overflow: auto;
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  color: #f8d5d7;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.route-top,
.pair-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pair-list {
  gap: 14px;
}

.soul-link-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, auto) minmax(140px, 1fr);
  gap: 12px;
  align-items: stretch;
  padding: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 24px;
}

.soul-center {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.soul-slot {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  min-height: 92px;
  padding: 10px 12px;
  border-radius: 22px;
  background:
    radial-gradient(circle at top center, rgba(229, 9, 20, 0.18), transparent 42%),
    rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  text-align: center;
}

.soul-slot img {
  width: 100%;
  max-width: 76px;
  height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
}

.soul-slot strong {
  font-size: 14px;
  line-height: 1.1;
}

.soul-slot span {
  color: var(--muted);
  font-size: 11px;
}

.soul-slot.empty {
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.dead-linked {
  filter: grayscale(1);
  opacity: 0.66;
  position: relative;
}

.dead-linked::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  top: 50%;
  height: 2px;
  background: rgba(255, 95, 115, 0.9);
  transform: rotate(-8deg);
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.06);
}

.pill.caught {
  background: rgba(57, 217, 138, 0.18);
}

.pill.seen {
  background: rgba(255, 176, 32, 0.18);
}

.pill.dead {
  background: rgba(255, 95, 115, 0.18);
}

.mini-empty {
  padding: 18px;
  border-radius: 22px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

.bridge-template {
  max-height: 240px;
  overflow: auto;
  margin-top: 16px;
  padding: 18px;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 22px;
  border: 1px solid var(--line);
  color: #f0b3b6;
  font-size: 12px;
  white-space: pre-wrap;
}

.modal {
  width: min(520px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.modal-card {
  display: grid;
  gap: 14px;
  padding: 22px;
  border-radius: 28px;
  background: #191919;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-card label {
  display: grid;
  gap: 8px;
}

.modal-card label span {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
}

@media (max-width: 1180px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .diagnostic-grid {
    grid-template-columns: 1fr;
  }

  .live-readout {
    grid-template-columns: 1fr;
  }

  .soul-link-row {
    grid-template-columns: 1fr;
  }

  .hero,
  .session-bar {
    flex-direction: column;
    align-items: stretch;
  }
}
