:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #5c6c68;
  --paper: #f7f4e8;
  --panel: #fffdf4;
  --line: #d8d0b8;
  --forest: #214f49;
  --leaf: #6f8e3f;
  --sun: #d18c3b;
  --berry: #a34545;
  --sky: #2f5c76;
  --right: #b8732a;
  --wrong: #2f6f8f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(247, 244, 232, 0.94), rgba(227, 233, 211, 0.9)),
    radial-gradient(circle at 15% 10%, rgba(209, 140, 59, 0.22), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(47, 92, 118, 0.18), transparent 30%);
  color: var(--ink);
}

button,
select {
  font: inherit;
}

.app {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(280px, 1.05fr);
  gap: 28px;
  align-items: center;
  min-height: 330px;
  overflow: hidden;
  border-bottom: 2px solid rgba(33, 79, 73, 0.18);
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.eyebrow,
.tag,
.label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 620px;
  margin-bottom: 14px;
  font-size: clamp(3rem, 9vw, 6.8rem);
  line-height: 0.9;
}

.intro {
  max-width: 520px;
  color: #354743;
  font-size: 1.18rem;
  line-height: 1.5;
}

.cat-scene svg {
  display: block;
  width: 100%;
  filter: drop-shadow(0 18px 30px rgba(23, 33, 31, 0.18));
}

.control-panel,
.quiz-shell,
.result-panel {
  margin-top: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 244, 0.86);
  box-shadow: 0 14px 38px rgba(56, 72, 61, 0.12);
}

.control-panel {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
  padding: 18px;
}

label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef8;
  color: var(--ink);
  padding: 0 12px;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.secondary-button {
  border: 1px solid var(--line);
  background: #fffef8;
  color: var(--forest);
}

.quiz-shell {
  padding: 18px;
}

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

.status-row > div {
  border: 1px solid rgba(216, 208, 184, 0.82);
  background: #fffef8;
  padding: 14px;
}

.status-row strong {
  font-size: 1.4rem;
}

.question-card {
  margin-top: 16px;
  min-height: 310px;
  border: 1px solid rgba(216, 208, 184, 0.82);
  background: #fffef8;
  padding: 22px;
}

.question-visual {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.question-visual .tag {
  margin-bottom: 0;
}

.icon-label {
  margin: 0 0 3px;
  color: var(--forest);
  font-size: 0.95rem;
  font-weight: 900;
}

.question-icon {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border: 1px solid rgba(33, 79, 73, 0.18);
  border-radius: 8px;
  background: #eef3e6;
  position: relative;
  box-shadow: inset 0 0 0 7px rgba(255, 253, 244, 0.72);
}

.question-icon::before,
.question-icon::after {
  content: "";
  position: absolute;
  inset: 10px;
  background: var(--forest);
  opacity: 0.94;
}

.icon-cat {
  background: #f7ead8;
}

.icon-cat::before {
  clip-path: polygon(20% 32%, 18% 8%, 35% 23%, 50% 18%, 65% 23%, 82% 8%, 80% 32%, 88% 52%, 78% 78%, 50% 88%, 22% 78%, 12% 52%);
}

.icon-cat::after {
  inset: 26px 20px 19px;
  background: #fffdf4;
  opacity: 0.9;
  clip-path: polygon(0 0, 18% 42%, 36% 0, 50% 58%, 64% 0, 82% 42%, 100% 0, 86% 100%, 14% 100%);
}

.icon-clan {
  background: #e8f0df;
}

.icon-clan::before {
  clip-path: polygon(50% 4%, 90% 22%, 84% 72%, 50% 96%, 16% 72%, 10% 22%);
}

.icon-clan::after {
  inset: 18px;
  background: #fffdf4;
  opacity: 0.9;
  clip-path: polygon(50% 0, 62% 34%, 98% 34%, 68% 54%, 80% 92%, 50% 68%, 20% 92%, 32% 54%, 2% 34%, 38% 34%);
}

.icon-prophecy {
  background: #e8eef4;
}

.icon-prophecy::before {
  clip-path: polygon(50% 0, 60% 32%, 94% 34%, 66% 54%, 76% 88%, 50% 68%, 24% 88%, 34% 54%, 6% 34%, 40% 32%);
}

.icon-prophecy::after {
  inset: 13px 11px 11px 25px;
  background: #fffdf4;
  clip-path: circle(46% at 42% 42%);
}

.icon-battle {
  background: #f1e5df;
}

.icon-battle::before {
  clip-path: polygon(10% 16%, 24% 10%, 42% 72%, 34% 88%, 22% 76%, 18% 50%, 3% 38%);
}

.icon-battle::after {
  inset: 10px;
  background: var(--berry);
  opacity: 0.85;
  clip-path: polygon(38% 10%, 52% 8%, 62% 74%, 54% 92%, 42% 80%, 40% 54%, 26% 40%);
  box-shadow: 16px 0 0 rgba(163, 69, 69, 0.85);
}

.icon-herb {
  background: #e8f2df;
}

.icon-herb::before {
  clip-path: polygon(45% 92%, 55% 92%, 55% 50%, 82% 28%, 58% 34%, 54% 8%, 46% 8%, 42% 34%, 18% 28%, 45% 50%);
}

.icon-herb::after {
  inset: 14px;
  background: var(--leaf);
  opacity: 0.85;
  clip-path: polygon(50% 0, 66% 28%, 100% 22%, 76% 50%, 94% 82%, 58% 72%, 50% 100%, 42% 72%, 6% 82%, 24% 50%, 0 22%, 34% 28%);
}

.question-card h2 {
  margin-bottom: 18px;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  line-height: 1.18;
}

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

.answer-button {
  min-height: 72px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  text-align: left;
  line-height: 1.25;
  white-space: normal;
  user-select: text;
}

.lookup-word {
  min-height: 0;
  border: 0;
  border-bottom: 2px dotted rgba(33, 79, 73, 0.35);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  padding: 0 1px;
  cursor: help;
  font-weight: inherit;
}

.lookup-word:hover,
.lookup-word:focus-visible {
  background: rgba(209, 140, 59, 0.16);
  outline: 2px solid rgba(209, 140, 59, 0.24);
}

.answer-button:hover:not(:disabled),
.answer-button:focus-visible {
  outline: 3px solid rgba(209, 140, 59, 0.28);
}

.answer-button.correct {
  border-color: var(--right);
  background: rgba(209, 140, 59, 0.12);
}

.answer-button.wrong {
  border-color: var(--wrong);
  background: rgba(47, 111, 143, 0.12);
}

.feedback {
  margin-top: 16px;
  border-left: 4px solid var(--sun);
  background: rgba(209, 140, 59, 0.1);
  padding: 12px 14px;
  line-height: 1.5;
}

.feedback.correct {
  border-left-color: var(--sun);
  background: rgba(209, 140, 59, 0.12);
}

.feedback.wrong {
  border-left-color: var(--wrong);
  background: rgba(47, 111, 143, 0.1);
}

.word-popover {
  position: fixed;
  z-index: 20;
  max-width: min(320px, calc(100vw - 24px));
  border: 1px solid rgba(33, 79, 73, 0.32);
  border-radius: 8px;
  background: #fffef8;
  box-shadow: 0 14px 36px rgba(23, 33, 31, 0.18);
  color: var(--ink);
  padding: 12px 14px;
}

.word-popover::before {
  content: "";
  position: absolute;
  left: 22px;
  top: -8px;
  width: 14px;
  height: 14px;
  border-left: 1px solid rgba(33, 79, 73, 0.32);
  border-top: 1px solid rgba(33, 79, 73, 0.32);
  background: #fffef8;
  transform: rotate(45deg);
}

.word-popover__term {
  font-size: 1.05rem;
  font-weight: 900;
}

.word-popover__meta {
  margin-top: 2px;
  color: var(--forest);
  font-size: 0.82rem;
  font-weight: 800;
}

.word-popover__meaning {
  margin-top: 6px;
  font-size: 0.98rem;
  line-height: 1.35;
}

.word-popover__example {
  margin-top: 8px;
  border-top: 1px solid rgba(216, 208, 184, 0.82);
  padding-top: 8px;
  color: #354743;
  font-size: 0.9rem;
  line-height: 1.35;
}

.result-panel p:last-child {
  margin-bottom: 0;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.result-panel {
  padding: 24px;
  border-color: rgba(33, 79, 73, 0.32);
}

.result-panel h2 {
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  margin-bottom: 10px;
}

.result-panel p {
  max-width: 720px;
  color: #354743;
  font-size: 1.08rem;
  line-height: 1.55;
}

.progress-track {
  width: min(680px, 100%);
  height: 12px;
  margin: 16px 0;
  border: 1px solid rgba(33, 79, 73, 0.18);
  border-radius: 999px;
  background: #ece6d4;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--leaf), var(--sun));
  transition: width 300ms ease;
}

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

.stat-tile {
  border: 1px solid rgba(216, 208, 184, 0.86);
  background: #fffef8;
  padding: 12px;
}

.stat-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-tile strong {
  display: block;
  margin-top: 5px;
  font-size: 1.35rem;
}

.medal-section {
  width: min(780px, 100%);
  margin: 16px 0 18px;
}

.medal-message {
  margin-bottom: 10px;
  color: #354743;
  font-size: 0.98rem;
}

.badge-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.medal-card {
  min-height: 118px;
  border: 1px solid rgba(33, 79, 73, 0.18);
  background: #fffef8;
  padding: 10px 8px;
  text-align: center;
}

.medal-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #e9efe0;
  color: var(--forest);
  font-size: 1rem;
  font-weight: 900;
  box-shadow: inset 0 0 0 6px rgba(255, 253, 244, 0.78);
}

.medal-icon::before {
  content: "";
  position: absolute;
  inset: 10px;
  background: currentColor;
  opacity: 0.9;
}

.medal-icon span {
  position: relative;
  z-index: 1;
  color: #fffdf4;
  text-shadow: 0 1px 2px rgba(23, 33, 31, 0.22);
}

.medal-character .medal-icon {
  background: #f7ead8;
}

.medal-character .medal-icon::before {
  clip-path: polygon(20% 32%, 18% 8%, 35% 24%, 50% 18%, 65% 24%, 82% 8%, 80% 32%, 88% 53%, 76% 80%, 50% 92%, 24% 80%, 12% 53%);
}

.medal-clan .medal-icon {
  background: #e8f0df;
}

.medal-clan .medal-icon::before {
  clip-path: polygon(50% 2%, 90% 22%, 84% 72%, 50% 98%, 16% 72%, 10% 22%);
}

.medal-place .medal-icon {
  background: #e8eef4;
  color: #2f5c76;
}

.medal-place .medal-icon::before {
  clip-path: polygon(6% 72%, 22% 48%, 34% 58%, 48% 30%, 63% 56%, 76% 42%, 94% 72%, 94% 88%, 6% 88%);
}

.medal-herb .medal-icon {
  background: #e8f2df;
  color: var(--leaf);
}

.medal-herb .medal-icon::before {
  clip-path: polygon(45% 94%, 55% 94%, 55% 50%, 82% 28%, 58% 34%, 54% 8%, 46% 8%, 42% 34%, 18% 28%, 45% 50%);
}

.medal-object .medal-icon {
  background: #f2ead7;
  color: var(--sun);
}

.medal-object .medal-icon::before {
  clip-path: polygon(50% 0, 62% 34%, 98% 34%, 68% 54%, 80% 92%, 50% 68%, 20% 92%, 32% 54%, 2% 34%, 38% 34%);
}

.medal-name {
  display: block;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.15;
}

.leaderboard {
  width: min(680px, 100%);
  margin: 12px 0 18px;
  border: 1px solid rgba(216, 208, 184, 0.86);
  background: #fffef8;
  padding: 14px;
}

.leaderboard ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.leaderboard li {
  color: #354743;
  line-height: 1.35;
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 20px, 1120px);
    padding-top: 12px;
  }

  .hero,
  .control-panel,
  .answers {
    grid-template-columns: 1fr;
  }

  .status-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .status-row > div {
    padding: 10px 12px;
  }

  .status-row strong {
    font-size: 1.25rem;
  }

  .hero {
    gap: 16px;
    min-height: auto;
    padding-bottom: 18px;
  }

  h1 {
    font-size: clamp(2.8rem, 16vw, 4.6rem);
  }

  .cat-scene {
    max-width: 520px;
  }

  .control-panel {
    align-items: stretch;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .question-icon {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

}
