:root {
  color-scheme: dark;
  --bg: #0b0f1a;
  --panel: #141a2b;
  --panel-2: #1b2338;
  --text: #eef2ff;
  --muted: #a6b0c3;
  --accent: #7c5cff;
  --accent-2: #2be4ff;
  --danger: #ff5c5c;
  --card: #101624;
  --border: #273150;
  --caught-border-legacy: #7c5cff;
  --caught-shadow-legacy: 0 0 0 1px rgba(124, 92, 255, 0.4);
  --caught-bg-legacy: #0f1628;
  --caught-border: rgba(124, 92, 255, 0.75);
  --caught-shadow: 0 0 0 1px rgba(124, 92, 255, 0.18) inset;
  --caught-bg: rgba(124, 92, 255, 0.12);
  --body-grad-start: #1a2238;
  --body-grad-end: #0a0f1c;
  --box-border-color: #1f2a44;
  --box-bg-color: rgba(12, 18, 32, 0.6);
  --card-bg-color: #0f1628;
  --card-border-color: #1f2a44;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  background: radial-gradient(circle at top, var(--body-grad-start), var(--body-grad-end) 65%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
  color: var(--text);
  min-height: 100vh;
}

body.light-theme {
  color-scheme: light;
  --bg: #d8dde6;
  --panel: #cfd6e2;
  --panel-2: #c6cfdd;
  --text: #111a2f;
  --muted: #415171;
  --border: #a8b5cd;
  --caught-border: rgba(124, 92, 255, 0.65);
  --caught-shadow: 0 0 0 1px rgba(124, 92, 255, 0.18) inset;
  --caught-bg: rgba(124, 92, 255, 0.14);
  --body-grad-start: #dbe0e9;
  --body-grad-end: #c5cedc;
  --box-border-color: #aebad1;
  --box-bg-color: rgba(203, 212, 226, 0.88);
  --card-bg-color: #d4dce9;
  --card-border-color: #b0bdd3;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 32px 48px 24px;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

.brand p {
  color: var(--muted);
}

.logo {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 700;
}

.mode-toggle {
  display: inline-flex;
  background: var(--panel);
  border-radius: 999px;
  padding: 4px;
   border: 1px solid var(--border);
}

.mode-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.settings-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 60;
}

.settings-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  position: relative;
  z-index: 61;
  pointer-events: auto;
}

.settings-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 460px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  z-index: 40;
  display: none;
  gap: 14px;
}

.settings-menu-wrap.open .settings-menu {
  display: grid;
}

.settings-menu h3 {
  font-size: 22px;
}

.settings-menu p {
  color: var(--muted);
  font-size: 13px;
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text);
  font-size: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.settings-toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 78px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.settings-toggle input::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background-color: var(--panel-2);
  background-image: url("https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/792.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 30px 30px;
  border: 1px solid var(--border);
  transition: transform 0.2s ease;
}

.settings-toggle input:checked {
  border-color: rgba(124, 92, 255, 0.7);
  background: rgba(124, 92, 255, 0.12);
}

.settings-toggle input:checked::before {
  background-image: url("https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/791.png");
  transform: translate(38px, -50%);
}

.settings-toggle input:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.settings-action {
  width: 100%;
  text-align: left;
  border-radius: 12px;
  background: transparent;
  border: 1px solid var(--border);
  padding: 13px 10px;
  font-size: 17px;
  white-space: nowrap;
}

.settings-action:hover {
  border-color: rgba(124, 92, 255, 0.6);
  background: rgba(124, 92, 255, 0.08);
}

.settings-row {
  display: flex;
  gap: 10px;
}

.settings-row .settings-action {
  flex: 1;
  width: auto;
}

.mode-button {
  background: transparent;
  color: var(--muted);
  padding: 8px 18px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.mode-button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #05070d;
}

main {
  padding: 16px 28px 36px;
  display: grid;
  gap: 18px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: stretch;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: flex-start;
}

.control-group.no-label {
  padding-top: 0;
}

.control-group.no-label::before {
  content: "";
  display: block;
  min-height: 20px;
}

.control-group label {
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
  min-height: 20px;
}

select,
input,
button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
}

button {
  cursor: pointer;
  font-weight: 600;
}

button.ghost {
  background: transparent;
}

.search-control {
  min-width: 240px;
}

.status-toggle {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.status-button {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
}

.status-button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #05070d;
}

.box-list {
  display: grid;
  gap: 22px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  justify-items: start;
}

.box {
  display: grid;
  gap: 12px;
  border: 1px solid var(--box-border-color);
  border-radius: 12px;
  padding: 12px;
  background: var(--box-bg-color);
  width: fit-content;
  align-self: start;
}

.filtered-results {
  width: 100%;
  grid-column: 1 / -1;
}

.filtered-results > .box-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.filtered-results .box-grid {
  grid-template-columns: repeat(auto-fill, 88px);
  justify-content: center;
  min-height: 0;
}

.filtered-subsection {
  display: grid;
  gap: 8px;
}

.filtered-subheader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.filtered-subheader h3 {
  font-size: 14px;
  font-weight: 600;
}

.filtered-subcount {
  color: var(--muted);
}

.box-list.filter-active .box:not(.filtered-results) {
  display: none;
}

.box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.box-header span {
  color: var(--muted);
  font-size: 14px;
}

.box-grid {
  display: grid;
  grid-template-columns: repeat(6, 88px);
  gap: 6px;
  justify-content: start;
  min-height: calc((5 * 118px) + (4 * 6px));
  align-content: start;
}

.card {
  background: var(--card-bg-color);
  border: 1px solid var(--card-border-color);
  border-radius: 14px;
  padding: 6px;
  display: grid;
  gap: 4px;
  position: relative;
  width: 88px;
  min-height: 118px;
}

.card.clickable {
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

.card.clickable:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 92, 255, 0.6);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.card.clickable:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}


.card.complete {
  border-color: var(--caught-border);
  box-shadow: var(--caught-shadow);
  background: var(--caught-bg);
}

.card header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  font-size: 10px;
  color: var(--muted);
}

.card img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin: 0 auto;
}

.card.shiny-unavailable img {
  filter: brightness(0) saturate(0) contrast(1.15);
}

.card.shiny-unavailable::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.3;
  white-space: normal;
  width: max-content;
  max-width: 220px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 20;
}

.card.shiny-unavailable:hover::after,
.card.shiny-unavailable:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.card h3 {
  font-size: 11px;
  text-align: center;
}


.stats {
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.5;
  display: block;
  white-space: normal;
  min-width: 250px;
}

.stats-row {
  display: grid;
  grid-template-columns: 120px 1fr 64px;
  gap: 8px;
}

.stats-label {
  font-weight: 600;
}

.stats-count {
  text-align: left;
}

.stats-percent {
  text-align: left;
}

.site-footer {
  padding: 24px 48px 40px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

@media (max-width: 1240px) {
  .box-list {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .box {
    width: fit-content;
    max-width: 100%;
  }
}

@media (max-width: 900px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 24px;
  }

  main {
    padding: 24px;
  }

  .mode-controls {
    width: 100%;
    justify-content: space-between;
  }

  .settings-menu {
    min-width: 0;
    width: min(420px, calc(100vw - 48px));
    padding: 14px;
    gap: 10px;
  }

  .settings-menu h3 {
    font-size: 18px;
  }

  .settings-toggle {
    font-size: 15px;
    padding: 10px 12px;
    gap: 12px;
  }

  .settings-toggle input {
    width: 62px;
    height: 36px;
  }

  .settings-toggle input::before {
    width: 28px;
    height: 28px;
    background-size: 22px 22px;
  }

  .settings-toggle input:checked::before {
    transform: translate(28px, -50%);
  }

  .settings-row {
    flex-direction: column;
    gap: 8px;
  }

  .settings-row .settings-action {
    width: 100%;
  }

  .settings-action {
    font-size: 15px;
    padding: 10px 10px;
    white-space: normal;
  }

  .site-footer {
    padding: 20px 24px 32px;
  }

  .box-grid {
    grid-template-columns: repeat(4, 88px);
    min-height: calc((8 * 118px) + (7 * 6px));
  }
}

@media (max-width: 600px) {
  .site-header {
    padding: 14px 12px 12px;
    gap: 12px;
    width: 100%;
    max-width: 100%;
  }

  .brand {
    gap: 10px;
  }

  .brand h1 {
    font-size: 22px;
    margin-bottom: 4px;
  }

  .brand p {
    font-size: 13px;
  }

  .logo {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  main {
    padding: 12px 10px 20px;
    gap: 12px;
    width: 100%;
    max-width: 100%;
  }

  .controls {
    flex-direction: column;
    gap: 10px;
  }

  .control-group {
    width: 100%;
  }

  .control-group.no-label::before {
    min-height: 0;
    display: none;
  }

  .search-control {
    min-width: 0;
  }

  .stats {
    min-width: 0;
    width: 100%;
    padding: 8px 10px;
  }

  .stats-row {
    grid-template-columns: 98px 1fr 56px;
    gap: 6px;
    font-size: 12px;
  }

  .status-toggle {
    width: 100%;
    flex-wrap: wrap;
  }

  .status-button {
    flex: 1 1 170px;
    text-align: center;
    padding: 8px 10px;
    font-size: 13px;
  }

  .mode-controls {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
  }

  .mode-toggle {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    overflow: hidden;
  }

  .mode-button {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 12px;
    font-size: 13px;
    white-space: normal;
    text-align: center;
  }

  .settings-button {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .settings-menu {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    right: 0;
    max-height: none;
    overflow: visible;
    padding: 12px;
    gap: 8px;
  }

  .settings-menu h3 {
    font-size: 16px;
  }

  .settings-toggle {
    font-size: 14px;
    padding: 8px 10px;
  }

  .settings-toggle input {
    width: 56px;
    height: 32px;
  }

  .settings-toggle input::before {
    width: 24px;
    height: 24px;
    background-size: 18px 18px;
  }

  .settings-toggle input:checked::before {
    transform: translate(24px, -50%);
  }

  .settings-action {
    font-size: 14px;
    padding: 9px 10px;
  }

  .box-list {
    gap: 14px;
  }

  .box {
    padding: 8px;
    gap: 8px;
  }

  .box-grid {
    grid-template-columns: repeat(3, 88px);
    min-height: calc((10 * 118px) + (9 * 6px));
    justify-content: center;
  }

  .site-footer {
    padding: 14px 12px 20px;
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 380px) {
  .mode-button {
    padding: 7px 10px;
    font-size: 12px;
  }
}
