:root {
  color-scheme: dark;
  --page: #111111;
  --panel: #121212;
  --panel-soft: #151515;
  --surface: #171717;
  --surface-soft: #1d1d1d;
  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.86);
  --muted: rgba(255, 255, 255, 0.52);
  --muted-strong: rgba(255, 255, 255, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.30);
  --danger: #fca5a5;
  --focus: 0 0 0 4px rgba(255, 255, 255, 0.12);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

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

h1 {
  color: var(--text);
  font-size: clamp(34px, 4vw, 58px);
  font-weight: 950;
  line-height: 0.98;
}

h2 {
  color: var(--text);
  font-size: 17px;
  font-weight: 930;
  line-height: 1.1;
}

h3 {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.app-shell {
  min-height: 100vh;
  padding: 0 24px 42px;
}

.catalog-frame {
  width: min(1500px, 100%);
  margin: 0 auto;
}

.global-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  min-height: 70px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.game-nav {
  display: flex;
  gap: 10px;
  min-width: 0;
  overflow-x: auto;
  padding: 9px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.game-link {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  flex: 0 0 212px;
  min-height: 56px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted-strong);
  padding: 7px 12px 7px 7px;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out), transform 160ms var(--ease-out), color 160ms var(--ease-out);
}

.game-link span {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  line-height: 1.12;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.game-link-icon {
  display: block;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111111;
  object-fit: cover;
}

.game-link.active {
  border-color: rgba(255, 255, 255, 0.38);
  background: #181818;
  color: #ffffff;
  box-shadow: inset 0 -2px 0 #ffffff;
}

.utility-actions {
  display: flex;
  justify-content: flex-end;
}

.utility-button,
.faq-back-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted-strong);
  padding: 0 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  transition: border-color 150ms var(--ease-out), color 150ms var(--ease-out), background-color 150ms var(--ease-out), transform 150ms var(--ease-out);
}

.layout {
  display: grid;
  gap: 16px;
  padding-top: 24px;
}

.page-heading {
  display: grid;
  gap: 12px;
  padding: 4px 0 0;
}

.catalog-announcement {
  max-width: 980px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151515;
  color: var(--text-soft);
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.45;
  white-space: pre-line;
}

.selector-panel,
.results {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.selector-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.results {
  display: grid;
  gap: 14px;
  padding: 14px;
  scroll-margin-top: 32px;
}

.selector-header,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.selector-header > div,
.section-head > div {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.section-head.compact {
  align-items: center;
}

.section-meta,
.field span {
  color: var(--muted);
}

.section-meta {
  font-size: 13px;
  font-weight: 760;
}

.selected-summary {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
  min-width: max-content;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted-strong);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.selected-summary strong,
.count-control span {
  color: #ffffff;
}

.selector-toolbar {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) minmax(170px, 210px) minmax(190px, 230px) minmax(220px, 260px);
  align-items: end;
  gap: 12px;
}

.field[hidden] {
  display: none;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span {
  overflow: hidden;
  font-size: 12px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.range-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111111;
  color: var(--text);
  padding: 10px 13px;
  outline: none;
  transition: border-color 145ms var(--ease-out), box-shadow 145ms var(--ease-out), background-color 145ms var(--ease-out);
}

select {
  padding-right: 34px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

input:focus,
select:focus {
  border-color: rgba(255, 255, 255, 0.44);
  box-shadow: var(--focus);
}

.primary-button,
.ghost-button,
.copy-button,
.page-button,
.remove-button {
  cursor: pointer;
  font-weight: 900;
  transition: border-color 145ms var(--ease-out), background-color 145ms var(--ease-out), color 145ms var(--ease-out), transform 145ms var(--ease-out);
}

.primary-button,
.ghost-button,
.copy-button {
  min-height: 44px;
  border-radius: 8px;
}

.primary-button {
  border: 1px solid #ffffff;
  background: #ffffff;
  color: #111111;
  padding: 0 22px;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.ghost-button,
.copy-button,
.page-button,
.result-items-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted-strong);
  padding: 0 14px;
}

.copy-button {
  min-width: 130px;
  color: var(--text-soft);
}

.selector-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  grid-auto-rows: 164px;
  align-content: start;
  gap: 12px;
  min-height: 498px;
  max-height: 498px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #111111;
  padding: 12px;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.character-card {
  position: relative;
  display: grid;
  grid-template-rows: 96px minmax(42px, 1fr);
  align-self: start;
  min-width: 0;
  min-height: 164px;
  align-items: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out), transform 160ms var(--ease-out), opacity 160ms var(--ease-out);
}

.character-card.selected {
  border-color: rgba(255, 255, 255, 0.56);
  background: #181818;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.character-card.selected::after {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: #111111;
  content: "\2713";
  font-size: 13px;
  font-weight: 950;
}

.character-image-frame {
  display: grid;
  width: 96px;
  height: 96px;
  max-width: 100%;
  margin: 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f0f0f;
}

.selected-row img,
.character-card img,
.result-item img,
.image-placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 0;
}

.character-image-frame img,
.character-card.provider-uma-musume .character-image-frame img {
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
  object-position: center;
}

.character-card > span:last-child {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.12;
  text-align: center;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.selected-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111111;
  padding: 12px;
}

#selected-count {
  display: inline-grid;
  min-width: 28px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #ffffff;
  color: #111111;
  font-weight: 950;
}

.selected-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.selected-list.empty {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.selected-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 74px 32px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 6px;
}

.selected-row.no-count {
  grid-template-columns: 40px minmax(0, 1fr) 32px;
}

.selected-row img,
.result-item img,
.image-placeholder {
  border-radius: 5px;
}

.selected-row strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-row input {
  min-height: 30px;
  padding: 4px 8px;
}

.count-control {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
}

.count-control span {
  font-size: 12px;
  font-weight: 950;
  text-align: center;
}

.count-control input {
  min-height: 32px;
  padding: 4px 6px;
  text-align: center;
}

.remove-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #111111;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.error-box {
  border: 1px solid rgba(252, 165, 165, 0.40);
  border-radius: 8px;
  background: rgba(252, 165, 165, 0.10);
  color: #fecaca;
  padding: 12px 14px;
  font-weight: 850;
}

.result-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.account-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  transition: border-color 165ms var(--ease-out), transform 165ms var(--ease-out);
}

.account-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  padding: 16px 16px 12px;
}

.account-id-block {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.account-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-code {
  overflow: hidden;
  color: var(--text);
  font-size: 22px;
  font-weight: 950;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
}

.price-stack,
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.price-stack {
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted-strong);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 950;
}

.badge.gems,
.badge.server {
  color: var(--text-soft);
}

.badge.price {
  min-height: 36px;
  border-color: #ffffff;
  background: #ffffff;
  color: #111111;
  padding: 4px 13px;
  font-size: 14px;
}

.result-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  padding: 12px 16px 16px;
}

.result-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-width: 154px;
  max-width: 232px;
  flex: 1 1 168px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 6px;
}

.result-item.no-count {
  grid-template-columns: 46px minmax(0, 1fr);
}

.image-placeholder {
  background: rgba(255, 255, 255, 0.10);
}

.result-item span {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-item b {
  min-width: 24px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.10);
  padding: 2px 7px;
  color: var(--muted-strong);
  font-size: 12px;
  text-align: center;
}

.result-items-toggle {
  display: none;
  width: calc(100% - 32px);
  min-height: 40px;
  margin: -6px 16px 16px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.page-button {
  min-width: 42px;
  min-height: 42px;
  border-radius: 8px;
}

.page-button.active {
  border-color: rgba(255, 255, 255, 0.42);
  background: #1f1f1f;
  color: #ffffff;
}

.page-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.page-jump label {
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 850;
}

.page-jump input {
  width: 92px;
  min-height: 42px;
  padding: 0 11px;
  font-weight: 800;
}

.loader {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  color: var(--muted);
}

.character-grid > .loader,
.result-list > .loader {
  display: grid;
  grid-column: 1 / -1;
  min-height: 164px;
  place-items: center;
  text-align: center;
}

.game-nav::-webkit-scrollbar,
.character-grid::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.game-nav::-webkit-scrollbar-track,
.character-grid::-webkit-scrollbar-track {
  background: transparent;
}

.game-nav::-webkit-scrollbar-thumb,
.character-grid::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  background-clip: content-box;
}

.faq-page {
  min-height: 100vh;
  padding: 18px 24px 56px;
  background: #111111;
  color: var(--text);
}

.faq-shell {
  position: relative;
  display: grid;
  width: min(780px, 100%);
  margin: 0 auto;
  gap: 30px;
}

.faq-back-link {
  position: absolute;
  top: 0;
  right: 0;
}

.faq-hero {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 0 96px;
  margin-top: 34px;
  text-align: center;
}


.faq-hero h1 {
  max-width: 700px;
  color: #ffffff;
  font-size: clamp(42px, 6vw, 56px);
  font-weight: 950;
  line-height: 0.96;
  text-align: center;
}

.faq-list {
  display: grid;
  gap: 10px;
}

.faq-item {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.faq-item summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 60px;
  color: rgba(255, 255, 255, 0.92);
  padding: 18px 21px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.2;
  list-style: none;
}

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

.faq-item summary::after {
  color: rgba(255, 255, 255, 0.55);
  content: "+";
  font-size: 25px;
  font-weight: 500;
  line-height: 1;
}

.faq-item[open] summary::after {
  content: "-";
}

.faq-item p,
.faq-item ul {
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.68);
  padding: 17px 21px 19px;
  font-size: 15px;
  line-height: 1.55;
}

.faq-item ul {
  display: grid;
  gap: 8px;
  margin: 0;
  list-style-position: outside;
  padding-left: 42px;
}

.faq-item li::marker {
  color: rgba(255, 255, 255, 0.50);
  font-weight: 900;
}

@media (hover: hover) and (pointer: fine) {
  .game-link:hover,
  .character-card:hover,
  .account-card:hover,
  .utility-button:hover,
  .faq-back-link:hover,
  .ghost-button:hover,
  .copy-button:hover,
  .page-button:hover,
  .result-items-toggle:hover,
  .faq-item:hover {
    border-color: rgba(255, 255, 255, 0.32);
  }

  .primary-button:hover {
    background: #e8e8e8;
  }

  .faq-item summary:hover {
    color: #ffffff;
  }

  .remove-button:hover {
    border-color: rgba(252, 165, 165, 0.68);
    color: var(--danger);
  }
}

.primary-button:active,
.ghost-button:active,
.copy-button:active,
.page-button:active,
.remove-button:active,
.game-link:active,
.character-card:active,
.utility-button:active,
.faq-back-link:active {
  transform: scale(0.98);
}

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

  .utility-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .game-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    padding-top: 0;
  }

  .selector-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 0 12px 28px;
  }

  .global-header {
    gap: 12px;
    padding: 10px 0;
  }

  .game-nav {
    flex-direction: column;
    overflow-x: visible;
    padding: 0;
    width: 100%;
  }

  .game-link {
    grid-template-columns: 52px minmax(0, 1fr);
    flex: 0 0 auto;
    width: 100%;
    min-height: 66px;
    padding: 8px 12px 8px 8px;
  }

  .game-link-icon {
    width: 48px;
    height: 48px;
  }

  .selector-panel,
  .results {
    padding: 12px;
  }

  .selector-header,
  .section-head,
  .account-head {
    align-items: stretch;
    flex-direction: column;
  }

  .account-head {
    display: flex;
  }

  .account-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .character-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    min-height: 418px;
    max-height: 418px;
  }
}

@media (max-width: 760px) {
  .faq-page {
    padding: 16px 12px 34px;
  }

  .faq-shell {
    gap: 22px;
  }

  .faq-back-link {
    position: static;
    width: max-content;
    justify-self: end;
  }

  .faq-hero {
    padding: 0;
    margin-top: 8px;
  }

  .faq-hero h1 {
    font-size: 42px;
  }

  .faq-item summary {
    min-height: 56px;
    padding: 16px 18px;
    font-size: 15px;
  }

  .faq-item p,
  .faq-item ul {
    padding: 15px 18px 17px;
  }

  .faq-item ul {
    padding-left: 38px;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 32px;
  }

  .selector-toolbar,
  .selector-buttons,
  .range-fields {
    grid-template-columns: 1fr;
  }

  .character-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 410px;
    max-height: 410px;
    gap: 10px;
    padding: 10px;
  }

  .selected-list,
  .result-list {
    grid-template-columns: 1fr;
  }

  .selected-row {
    grid-template-columns: 38px minmax(0, 1fr) 72px 32px;
  }

  .selected-row.no-count {
    grid-template-columns: 38px minmax(0, 1fr) 32px;
  }

  .result-item {
    max-width: none;
    flex-basis: 100%;
  }

  .account-card:not(.items-expanded) .result-items .result-item:nth-child(n + 6) {
    display: none;
  }

  .result-items-toggle {
    display: inline-flex;
  }

  .page-jump {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }

  .page-jump input {
    width: min(120px, 34vw);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}