:root {
  color-scheme: light;
  --bg: #f4fbf6;
  --surface: #ffffff;
  --surface-soft: #eef8f1;
  --text: #17352a;
  --muted: #678077;
  --line: #d8e9df;
  --primary: #57cc02;
  --primary-dark: #43a302;
  --accent: #1cb0f6;
  --warning: #ffbf2e;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(35, 99, 62, 0.16);
  --radius: 8px;
}

body.dark {
  color-scheme: dark;
  --bg: #101814;
  --surface: #17241d;
  --surface-soft: #20342a;
  --text: #eaf7ef;
  --muted: #9eb3a8;
  --line: #31483a;
  --primary: #67dd0a;
  --primary-dark: #54ba03;
  --accent: #48bfff;
  --warning: #ffd166;
  --danger: #ff8787;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(28, 176, 246, 0.18), transparent 30rem),
    linear-gradient(135deg, var(--bg), var(--surface-soft));
  color: var(--text);
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.app-shell {
  width: min(100%, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 18px;
  display: grid;
  align-content: center;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 7vw, 4.4rem);
  line-height: 0.95;
}

.icon-button,
.audio-button {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(31, 81, 54, 0.12);
  transition: transform 180ms ease, background 180ms ease;
}

.icon-button:hover,
.audio-button:hover {
  transform: translateY(-2px);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px);
}

body.dark .stat-card {
  background: rgba(23, 36, 29, 0.76);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  line-height: 1;
}

.trainer-card {
  width: 100%;
  min-height: 540px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.toolbar,
.word-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.level-picker {
  min-width: min(100%, 220px);
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.level-picker select {
  width: 100%;
  min-height: 44px;
  padding: 0 42px 0 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

.loader-panel,
.empty-panel,
.word-panel {
  min-height: 310px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.4)),
    var(--surface-soft);
}

body.dark .loader-panel,
body.dark .empty-panel,
body.dark .word-panel {
  background:
    linear-gradient(180deg, rgba(31, 49, 39, 0.82), rgba(25, 40, 32, 0.58)),
    var(--surface-soft);
}

.loader-panel,
.empty-panel {
  display: grid;
  place-items: center;
  align-content: center;
  padding: 28px;
  text-align: center;
}

.loader-panel p,
.empty-copy {
  color: var(--muted);
}

.empty-title {
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 5vw, 2rem);
  font-weight: 900;
}

.empty-copy {
  max-width: 520px;
  margin-bottom: 0;
}

.bee-loader {
  width: min(82vw, 320px);
  height: 320px;
  margin-bottom: 10px;
  position: relative;
  animation: bee-float 950ms ease-in-out infinite alternate;
}

.bee {
  --bg-color: var(--surface-soft);
  width: 50px;
  height: 50px;
  background: black;
  border-radius: 50% 75% 0% 75%;
  background: linear-gradient(-50deg, black 15px, goldenrod 15px, goldenrod 25px, black 25px, black 40px, goldenrod 40px, goldenrod 50px, black 50px);
  box-shadow: inset 0 0 0 2px black, inset 5px -5px 5px 5px rgba(139, 69, 19, 0.5), -10px 20px 35px saddlebrown;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-20deg) scale(1.2);
  transform-origin: center;
  z-index: 1;
}

.bee::before {
  content: "";
  width: 35px;
  height: 35px;
  border-radius: 75% 50% 75% 25%;
  background: radial-gradient(circle at 10px 15px, black 3px, goldenrod 3px, goldenrod 20px, black);
  box-shadow: 0 0 0 2px black;
  position: absolute;
  left: -22px;
  top: -15px;
  transform: rotate(30deg);
}

.bee::after {
  content: "";
  width: 30px;
  height: 30px;
  position: absolute;
  left: -33px;
  top: -28px;
  border-radius: 50%;
  z-index: -1;
  box-shadow: inset -2px 1px 0 black, 1px -2px 0 var(--bg-color), 3px -3px 0 black;
  animation: hair 0.33s linear infinite;
}

.flip {
  transform: translate(-50%, -50%) rotate(20deg) scaleX(-1) scale(1.2) !important;
}

.bee .wings {
  width: 50px;
  height: 50px;
  background: linear-gradient(to bottom left, black, transparent 50px);
  border-radius: 50% 50% 50% 25%;
  position: absolute;
  left: 25px;
  top: -25px;
  opacity: 0.5;
  transform-origin: left bottom;
  perspective: 200px;
  animation: buzz 0.33s linear infinite;
}

.bee .limbs {
  width: 10px;
  height: 10px;
  border-right: 2px solid black;
  border-left: 2px solid black;
  position: absolute;
  top: 100%;
  left: 25px;
}

.bee .limbs::before {
  content: "";
  width: 100%;
  height: 100%;
  border-right: 2px solid black;
  border-left: 2px solid black;
  position: absolute;
  top: -20px;
  left: -33px;
  transform: rotate(60deg);
}

.word-panel {
  padding: clamp(18px, 4vw, 32px);
  display: grid;
  align-content: space-between;
  gap: 22px;
}

.word-heading {
  align-items: flex-start;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(28, 176, 246, 0.16);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 900;
}

h2 {
  margin: 10px 0 0;
  overflow-wrap: anywhere;
  font-size: clamp(2.5rem, 10vw, 5.6rem);
  line-height: 0.95;
}

.audio-button {
  flex: 0 0 auto;
  background: var(--accent);
  color: white;
}

.audio-button svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

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

.reveal-box {
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.hidden-text {
  margin: 12px 0 0;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 750;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.success-button,
.warning-button,
.danger-button,
.ghost-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius);
  font-weight: 900;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.success-button:hover,
.warning-button:hover,
.danger-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  width: 100%;
  min-height: 58px;
  background: var(--primary);
  color: #102111;
  box-shadow: 0 6px 0 var(--primary-dark);
  font-size: 1.08rem;
}

.primary-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--primary-dark);
}

.secondary-button {
  width: 100%;
  background: rgba(28, 176, 246, 0.14);
  color: var(--accent);
}

.success-button {
  background: var(--primary);
  color: #102111;
}

.success-button.is-selected,
.warning-button.is-selected,
.danger-button.is-selected {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

.warning-button {
  background: var(--warning);
  color: #302000;
}

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

.rating-status {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.ghost-button {
  border: 2px solid var(--line);
  background: transparent;
  color: var(--text);
}

.hidden {
  display: none !important;
}

@keyframes bee-float {
  from {
    transform: translateY(42px);
  }

  to {
    transform: translateY(-42px);
  }
}

@keyframes hair {
  50% {
    transform: translateY(2px);
  }
}

@keyframes buzz {
  50% {
    transform: scale(0.9) rotateY(90deg) rotateX(90deg);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 20px 12px;
    align-content: start;
  }

  .topbar {
    align-items: flex-start;
  }

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

  .trainer-card {
    min-height: auto;
    padding: 14px;
  }

  .toolbar,
  .word-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .word-heading {
    gap: 18px;
  }

  .audio-button {
    align-self: flex-start;
  }

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