:root {
  color-scheme: light;
  --ink: #1e1930;
  --muted: #696477;
  --surface: #fff;
  --background: #f8f5fb;
  --hero: #171326;
  --accent: #d72678;
  --accent-dark: #a91659;
  --bonus: #7452d6;
  --line: #e7e0ec;
  --shadow: 0 14px 35px rgb(46 25 63 / 10%);
  --radius: 1.25rem;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 18rem;
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 0.2rem solid #ff91c2;
  outline-offset: 0.2rem;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.7rem 1rem;
  color: #fff;
  background: var(--accent-dark);
  border-radius: 0.5rem;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.hero {
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 80% 15%, rgb(215 38 120 / 30%), transparent 25rem),
    radial-gradient(circle at 10% 85%, rgb(116 82 214 / 22%), transparent 22rem),
    var(--hero);
}

.hero__inner {
  width: min(70rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(4rem, 10vw, 7rem) 0;
  text-align: center;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: #f3a6cb;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow--dark {
  color: var(--accent-dark);
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(3.5rem, 12vw, 8rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

h1 span {
  color: #ff5da7;
}

.hero__text {
  max-width: 37rem;
  margin: 1.5rem auto 2rem;
  color: #d9d4e5;
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.random-button,
.primary-button {
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0.5rem 1.5rem rgb(215 38 120 / 25%);
  font-weight: 800;
}

.random-button {
  padding: 0.9rem 1.4rem;
}

.primary-button {
  padding: 0.9rem 1.75rem;
}

.random-button:hover,
.primary-button:hover {
  background: var(--accent-dark);
}

main {
  width: min(75rem, calc(100% - 2rem));
  margin: 0 auto;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(12rem, 1fr) auto;
  gap: 1rem;
  align-items: end;
  margin: -1.8rem 0 4rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field label,
.music-controls label {
  font-size: 0.82rem;
  font-weight: 800;
}

input[type="search"],
select {
  width: 100%;
  min-height: 3rem;
  padding: 0.65rem 0.8rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfc6d5;
  border-radius: 0.7rem;
}

.result-count {
  min-width: 7.5rem;
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: right;
}

.language-section {
  margin-bottom: 4rem;
  scroll-margin-top: 1rem;
}

.section-heading {
  display: flex;
  gap: 1rem;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

h2 {
  margin: 0;
  font-size: clamp(1.75rem, 5vw, 2.65rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.count-badge {
  display: grid;
  flex: 0 0 auto;
  width: 3.25rem;
  height: 3.25rem;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
  font-weight: 900;
}

.count-badge--bonus {
  background: var(--bonus);
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: 1rem;
}

.language-card {
  position: relative;
  min-width: 0;
  padding: 1.25rem;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 0.25rem 1rem rgb(46 25 63 / 5%);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.language-card:hover {
  transform: translateY(-0.2rem);
  box-shadow: var(--shadow);
}

.language-card:active {
  transform: translateY(-0.1rem);
}

.language-card:focus-visible {
  outline: 0.2rem solid #ff91c2;
  outline-offset: 0.2rem;
}

.language-card.is-highlighted {
  border-color: var(--accent);
  box-shadow:
    0 0 0 0.2rem rgb(215 38 120 / 18%),
    var(--shadow);
}

.language-card.is-speaking {
  border-color: var(--bonus);
  box-shadow: 0 0 0 0.2rem rgb(116 82 214 / 18%);
}

.card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.flag {
  font-size: 2rem;
  line-height: 1;
}

.speak-button,
.icon-button {
  display: inline-flex;
  min-width: 2.75rem;
  min-height: 2.75rem;
  gap: 0.45rem;
  align-items: center;
  justify-content: center;
  color: var(--accent-dark);
  background: #fff0f7;
  border: 0;
  border-radius: 50%;
}

.speak-button:hover,
.icon-button:hover {
  color: #fff;
  background: var(--accent);
}

.language-card[aria-pressed="true"] .speak-button {
  color: #fff;
  background: var(--bonus);
}

.language-name {
  margin: 0;
  font-size: 1.05rem;
}

.native-name {
  min-height: 1.5em;
  margin: 0.1rem 0 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.word {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  font-weight: 900;
  line-height: 1.1;
}

.transliteration,
.note {
  min-height: 1.3em;
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.note {
  min-height: 0;
  color: #76658e;
  font-style: italic;
}

.extras {
  padding-top: 2rem;
  border-top: 2px dashed #d8cce4;
}

.empty-state,
.error-message {
  margin: 3rem auto;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.music-controls {
  position: sticky;
  z-index: 10;
  bottom: 1rem;
  display: flex;
  width: fit-content;
  max-width: calc(100% - 2rem);
  gap: 0.9rem;
  align-items: center;
  margin: 2rem auto;
  padding: 0.65rem 0.9rem;
  color: #fff;
  background: rgb(23 19 38 / 94%);
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 999px;
  box-shadow: 0 0.8rem 2rem rgb(23 19 38 / 25%);
  backdrop-filter: blur(0.5rem);
}

.music-controls .icon-button {
  width: auto;
  padding: 0.55rem 0.8rem;
  color: #fff;
  background: rgb(255 255 255 / 10%);
  border-radius: 999px;
}

.music-controls label {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.music-controls input[type="range"] {
  width: 6rem;
  accent-color: #ff5da7;
}

.music-status {
  max-width: 13rem;
  color: #d9d4e5;
  font-size: 0.75rem;
}

footer {
  padding: 2.5rem 1rem 4rem;
  color: #cfc9da;
  background: var(--hero);
  text-align: center;
}

footer a {
  color: #ff91c2;
}

.welcome {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  padding: 1rem;
  place-items: center;
  background: rgb(15 11 28 / 78%);
  backdrop-filter: blur(0.5rem);
}

.welcome__card {
  width: min(31rem, 100%);
  max-height: calc(100dvh - 2rem);
  padding: clamp(1.5rem, 6vw, 3rem);
  overflow-y: auto;
  background: #fff;
  border-radius: 1.5rem;
  box-shadow: 0 2rem 5rem rgb(0 0 0 / 35%);
  text-align: center;
}

.welcome__card h2 {
  margin-bottom: 1rem;
}

.welcome__card p:not(.eyebrow) {
  color: var(--muted);
}

.welcome__globe {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 3rem;
}

.toast {
  position: fixed;
  z-index: 60;
  right: 1rem;
  bottom: 6rem;
  width: min(25rem, calc(100% - 2rem));
  padding: 0.9rem 1rem;
  color: #fff;
  background: #352a4d;
  border-radius: 0.8rem;
  box-shadow: var(--shadow);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 47rem) {
  .toolbar {
    grid-template-columns: 1fr;
    margin-bottom: 3rem;
  }

  .result-count {
    margin: 0;
    text-align: left;
  }

  .music-controls {
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 1rem;
  }

  .music-status {
    flex-basis: 100%;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
