:root {
  color-scheme: dark;
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  background: #101116;
  color: #f5f4f1;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #19191f;
  --muted: #a4a8b4;
  --yellow: #ffb000;
  --cyan: #55e8d0;
  --pink: #f064c5;
  --purple: #a879ff;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 0, rgb(168 121 255 / 9%), transparent 36rem),
    #101116;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.page-shell {
  display: flex;
  width: min(100% - 40px, 1080px);
  min-height: 100vh;
  margin: 0 auto;
  flex-direction: column;
}

.topbar {
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgb(168 121 255 / 18%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--yellow);
  box-shadow: 0 0 22px rgb(255 176 0 / 22%);
  color: #17130b;
}

.language-control {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.8rem;
}

.language-picker {
  position: relative;
}

.language-trigger {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid #393a46;
  border-radius: 8px;
  background: var(--surface);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.language-trigger:hover,
.language-trigger[aria-expanded="true"] {
  border-color: var(--purple);
}

.language-chevron {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.language-options {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  min-width: 100%;
  padding: 5px;
  border: 1px solid #393a46;
  border-radius: 9px;
  background: #19191f;
  box-shadow: 0 12px 30px rgb(0 0 0 / 35%);
}

.language-option {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  text-align: left;
  white-space: nowrap;
}

.language-option:hover,
.language-option[aria-selected="true"] {
  background: rgb(168 121 255 / 15%);
  color: var(--yellow);
}

.language-option:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -2px;
}

.language-flag {
  display: block;
  width: 19px;
  height: 13px;
  flex: 0 0 auto;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 2px;
  box-shadow: 0 0 8px rgb(168 121 255 / 20%);
}

.icon-library {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

main {
  flex: 1;
}

.hero {
  width: min(100%, 740px);
  margin: 0 auto;
  padding: clamp(62px, 11vw, 112px) 0 54px;
  text-align: center;
}

.page-shell.has-result .hero {
  width: min(100%, 900px);
  padding: 22px 0 16px;
}

.page-shell.has-result .eyebrow {
  margin-bottom: 8px;
}

.page-shell.has-result h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.page-shell.has-result .intro {
  display: none;
}

.page-shell.has-result #finder-form {
  margin-top: 15px;
}

.page-shell.has-result .result-section {
  margin-bottom: 48px;
}

.eyebrow,
.result-label {
  margin: 0 0 16px;
  color: var(--cyan);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: clamp(2.4rem, 7vw, 4.7rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.99;
  text-wrap: balance;
}

.intro {
  max-width: 530px;
  margin: 22px auto 34px;
  color: var(--muted);
  line-height: 1.7;
}

#finder-form {
  width: min(100%, 620px);
  margin: 0 auto;
  text-align: left;
}

#finder-form > label {
  display: block;
  margin-bottom: 9px;
  font-size: 0.87rem;
  font-weight: 700;
}

.search-row {
  display: flex;
  gap: 10px;
  padding: 7px;
  border: 1px solid #373844;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 18px 60px rgb(0 0 0 / 22%);
}

.search-row input {
  width: 100%;
  min-width: 0;
  padding: 12px 13px;
  border: 0;
  background: transparent;
  color: #fff;
}

.search-row input:focus-visible {
  outline-offset: -2px;
}

.search-row input::placeholder {
  color: #777986;
}

#submit-button,
.secondary-button {
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 9px;
  background: var(--yellow);
  color: #101116;
  font-weight: 800;
  transition: filter 140ms ease, transform 140ms ease;
}

#submit-button:hover,
.secondary-button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

#submit-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.input-hint {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.form-message {
  min-height: 1.4em;
  margin: 8px 2px 0;
  color: #ff8e9b;
  font-size: 0.88rem;
}

.result-section {
  width: min(100%, 790px);
  margin: 0 auto 80px;
}

.result-label {
  margin-bottom: 12px;
}

.result-card {
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) 1.2fr;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 11%);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 20px 70px rgb(0 0 0 / 28%);
  animation: reveal 400ms ease both;
}

.portrait-frame {
  min-height: 330px;
  overflow: hidden;
  border: 2px solid transparent;
  background: linear-gradient(145deg, #242633, #15161c);
}

.result-card.common .portrait-frame {
  border-color: var(--cyan);
}

.result-card.rare .portrait-frame {
  border-color: var(--pink);
}

.result-card.legendary .portrait-frame {
  border-color: var(--yellow);
}

.portrait-frame img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 330px;
  object-fit: cover;
}

.character-details {
  align-self: center;
  padding: clamp(24px, 5vw, 44px);
}

.rarity-badge {
  display: inline-flex;
  padding: 6px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rarity-badge.common {
  color: var(--cyan);
}

.rarity-badge.rare {
  color: var(--pink);
}

.rarity-badge.legendary {
  color: var(--yellow);
}

.character-details h2 {
  margin: 16px 0 7px;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  letter-spacing: -0.025em;
}

.character-game {
  margin: 0;
  color: var(--cyan);
  font-size: 0.9rem;
  font-weight: 700;
}

.character-description {
  margin: 22px 0 28px;
  color: #c1c1cb;
  line-height: 1.75;
}

.secondary-button {
  min-height: 42px;
  padding: 0 15px;
  background: transparent;
  color: #fff;
  border: 1px solid #4a4b57;
}

footer {
  padding: 24px 0;
  border-top: 1px solid rgb(168 121 255 / 18%);
  color: #858692;
  font-size: 0.74rem;
  line-height: 1.6;
  text-align: center;
}

footer p {
  max-width: 780px;
  margin: 0 auto;
}

[hidden] {
  display: none !important;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 600px) {
  .page-shell {
    width: min(100% - 28px, 1080px);
  }

  .topbar {
    min-height: 72px;
  }

  .brand {
    font-size: 0.75rem;
  }

  .language-control {
    gap: 5px;
    font-size: 0.7rem;
  }

  .page-shell.has-result .hero {
    padding: 20px 0 14px;
  }

  .page-shell.has-result h1 {
    font-size: clamp(1.45rem, 6.4vw, 1.9rem);
  }

  .page-shell.has-result #finder-form {
    margin-top: 12px;
  }

  .page-shell.has-result .result-section {
    margin-bottom: 36px;
  }

  .search-row {
    flex-direction: column;
  }

  #submit-button {
    width: 100%;
  }

  .result-card {
    grid-template-columns: 1fr;
  }

  .portrait-frame,
  .portrait-frame img {
    min-height: 0;
    aspect-ratio: 9 / 16;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
