:root {
  --bg-1: #f7fbff;
  --bg-2: #e3f3ff;
  --ink-strong: #12314c;
  --ink-soft: #34566f;
  --panel: rgba(255, 255, 255, 0.94);
  --border: rgba(18, 49, 76, 0.14);
  --accent: #ff8f1f;
  --accent-deep: #e57500;
  --blue-ok: #1387e5;
  --blue-ok-soft: #e6f4ff;
  --red-bad: #d3415a;
  --red-bad-soft: #ffeaf0;
  --shadow: 0 16px 40px rgba(14, 46, 72, 0.15);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Nunito", sans-serif;
  color: var(--ink-strong);
  background: radial-gradient(circle at 15% 18%, #ffffff 0%, var(--bg-1) 42%, var(--bg-2) 100%);
  position: relative;
  overflow-x: hidden;
}

.sky-layer,
.road-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.sky-layer {
  background:
    radial-gradient(circle at 10% 8%, rgba(255, 197, 106, 0.42), transparent 16%),
    radial-gradient(circle at 90% 12%, rgba(66, 171, 255, 0.28), transparent 22%),
    radial-gradient(circle at 28% 86%, rgba(39, 214, 166, 0.18), transparent 21%);
  animation: drift 12s ease-in-out infinite alternate;
}

.road-layer::before,
.road-layer::after {
  content: "";
  position: absolute;
  left: -5%;
  right: -5%;
  height: 120px;
  transform: rotate(-4deg);
}

.road-layer::before {
  bottom: -52px;
  background: linear-gradient(90deg, rgba(32, 58, 80, 0.24), rgba(23, 44, 61, 0.45));
}

.road-layer::after {
  bottom: -24px;
  height: 16px;
  background: repeating-linear-gradient(
    90deg,
    #fff9c4 0,
    #fff9c4 24px,
    transparent 24px,
    transparent 46px
  );
  opacity: 0.65;
}

.app-shell {
  width: min(980px, calc(100% - 1.4rem));
  margin: 1rem auto 2.6rem;
  position: relative;
  z-index: 2;
}

.topbar {
  text-align: center;
  margin-bottom: 0.9rem;
  padding: 0.4rem 0.5rem 0;
}

body.in-quiz .topbar {
  display: none;
}

body.in-quiz .app-shell {
  margin-top: 0.45rem;
}

.topbar h1 {
  font-family: "Baloo 2", cursive;
  font-size: clamp(1.95rem, 4vw, 2.75rem);
  margin: 0.2rem 0 0;
  color: #0d3558;
  letter-spacing: 0.02em;
}

.topbar p {
  margin: 0.5rem auto 0;
  max-width: 64ch;
  color: var(--ink-soft);
  font-size: 1.04rem;
}

.badge {
  display: inline-block;
  padding: 0.34rem 0.8rem;
  border-radius: 999px;
  background: #dff4ff;
  border: 1px solid #8acdf4;
  font-size: 0.88rem;
  color: #0d5f95;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(5px);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2.6vw, 2rem);
  margin: 0 auto;
  max-width: 840px;
}

.panel h2 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 1.95rem);
  color: #11385a;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 0.85rem;
}

.mode-btn {
  border: 2px solid #8fc9ef;
  background: #eff8ff;
  color: #14507a;
  border-radius: 16px;
  min-height: 70px;
  font-size: 1.06rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.mode-btn:hover,
.mode-btn:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 18px rgba(19, 71, 111, 0.16);
  background: #ffffff;
}

.mode-btn.is-active {
  border-color: var(--accent-deep);
  background: #fff4e7;
  color: #8f4500;
}

.pool-info {
  margin: 0 0 1rem;
  color: #466982;
  font-weight: 700;
}

.primary-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  min-height: 64px;
  background: linear-gradient(135deg, #ffa126, #ff7f11);
  color: #fff;
  font-size: 1.18rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.01em;
  box-shadow: 0 14px 24px rgba(202, 105, 0, 0.24);
  transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.2s ease;
}

.primary-btn:hover,
.primary-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 28px rgba(202, 105, 0, 0.28);
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.45rem;
  font-weight: 800;
  color: #25495f;
}

.progress-row p {
  margin: 0;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: #dbeffd;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #22b6f3, #1f8ad2);
  transition: width 0.35s ease;
}

.question-card {
  padding: 1rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(250, 254, 255, 0.95), rgba(238, 247, 255, 0.95));
  border: 1px solid #d3e8fa;
}

.category-label {
  margin: 0;
  font-size: 0.94rem;
  color: #4b6d84;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.question-text {
  margin: 0.5rem 0 0.95rem;
  font-size: clamp(1.35rem, 3.6vw, 1.8rem);
  line-height: 1.3;
  color: #103655;
}

.sign-figure {
  margin: 0 0 0.9rem;
  display: grid;
  justify-items: center;
  gap: 0.45rem;
}

.sign-figure img {
  width: min(220px, 72vw);
  aspect-ratio: 1;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid #c9dff2;
  padding: 0.8rem;
  box-shadow: 0 8px 16px rgba(31, 108, 166, 0.12);
}

.sign-figure figcaption {
  margin: 0;
  font-size: 0.92rem;
  color: #40657e;
  text-align: center;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.answer-btn {
  border: 2px solid #9bd2f4;
  background: #ffffff;
  color: #133f62;
  border-radius: 16px;
  min-height: 88px;
  font-size: clamp(1rem, 2.4vw, 1.1rem);
  font-weight: 800;
  text-align: left;
  padding: 0.95rem;
  cursor: pointer;
  line-height: 1.32;
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.answer-btn:hover,
.answer-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(23, 88, 136, 0.16);
  border-color: #4fafe9;
}

.answer-btn.is-disabled {
  pointer-events: none;
}

.answer-btn.is-wrong {
  border-color: var(--red-bad);
  background: var(--red-bad-soft);
  color: #8a1f35;
  animation: shake 0.35s ease;
}

.answer-btn.is-correct,
.answer-btn.is-correct-alt {
  border-color: var(--blue-ok);
  background: var(--blue-ok-soft);
  color: #0c4f8e;
  animation: pop 0.35s ease;
}

.feedback {
  min-height: 78px;
  margin-top: 0.9rem;
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  background: #f1f8ff;
  border: 1px solid #cfe6f8;
}

.feedback-title {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 800;
}

.feedback-title.ok {
  color: #0d63ab;
}

.feedback-title.bad {
  color: #a52842;
}

.feedback-text {
  margin: 0.35rem 0 0;
  color: #2f526b;
  line-height: 1.35;
  font-weight: 700;
}

.actions-row {
  margin-top: 1rem;
}

.result-tip {
  margin-top: 0.5rem;
  color: #3f647f;
  font-weight: 700;
}

.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 30;
  animation: confetti 0.8s ease forwards;
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(0, 10px, 0);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.96);
  }
  70% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

@keyframes confetti {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 1;
  }
  to {
    transform: translate3d(var(--dx), var(--dy), 0) rotate(var(--rot));
    opacity: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    margin-top: 0.55rem;
  }

  .panel {
    border-radius: 20px;
  }

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

  .answer-btn {
    min-height: 80px;
  }
}
