:root {
  --ink: #1b1a17;
  --muted: #4a4a45;
  --bg: #f5efe6;
  --surface: #fff9f2;
  --accent: #ff8a3c;
  --accent-strong: #f15a24;
  --accent-soft: #ffe1c8;
  --teal: #2f8f83;
  --shadow: rgba(18, 15, 10, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "DM Sans", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #fff3d6, transparent 55%),
    radial-gradient(circle at 85% 10%, #d7f5e2, transparent 45%), var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

.back-link {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 10;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  background: var(--surface);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  box-shadow: 0 10px 20px var(--shadow);
}

.back-link:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.sky,
.terrain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.sky {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.65), transparent 45%);
}

.terrain {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600' viewBox='0 0 600 600'><path d='M0 420 C120 380 220 420 320 380 C420 340 520 380 600 340 L600 600 L0 600 Z' fill='%23f4d8b8'/><path d='M0 460 C150 430 240 470 360 430 C480 390 560 450 600 430 L600 600 L0 600 Z' fill='%23f6c89f'/></svg>");
  opacity: 0.35;
  background-size: 600px;
  background-repeat: repeat-x;
  background-position: bottom;
}

.page {
  position: relative;
  z-index: 1;
  padding: 5.5rem 6vw 4rem;
}

.hero {
  max-width: 680px;
  margin-bottom: 2.5rem;
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}

h1 {
  font-family: "Fugaz One", "DM Sans", sans-serif;
  font-size: clamp(2.2rem, 2.8vw + 1.4rem, 3.4rem);
  margin: 0.6rem 0 0.5rem;
}

.lead {
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.6;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
  gap: 2rem;
  align-items: start;
}

.quiz {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mode-toggle {
  display: inline-flex;
  background: var(--surface);
  border-radius: 999px;
  padding: 0.3rem;
  box-shadow: 0 10px 20px var(--shadow);
  gap: 0.3rem;
  width: fit-content;
}

.mode-button {
  border: none;
  background: transparent;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  color: var(--muted);
}

.mode-button.is-active {
  background: var(--accent);
  color: #1f1300;
}

.mode-button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.card {
  background: var(--surface);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 18px 40px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  animation: rise 0.5s ease;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pill {
  background: var(--accent-soft);
  color: #5c2a00;
  font-weight: 700;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.progress {
  color: var(--muted);
  font-weight: 600;
}

h2 {
  font-size: clamp(1.4rem, 1.6vw + 1rem, 2rem);
}

.hint {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.answer-area {
  display: grid;
  gap: 0.75rem;
}

.option {
  border: 1px solid transparent;
  background: #fff;
  border-radius: 16px;
  padding: 0.8rem 1rem;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease, border 0.15s ease;
}

.option:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.option.is-correct {
  border-color: var(--teal);
  background: rgba(47, 143, 131, 0.12);
}

.option.is-wrong {
  border-color: #c94d2e;
  background: rgba(201, 77, 46, 0.1);
}

.option:disabled {
  cursor: default;
  transform: none;
}

.type-form {
  display: flex;
  gap: 0.6rem;
}

.type-form input {
  flex: 1;
  border-radius: 14px;
  border: 1px solid #dfd2c2;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
}

.type-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.type-form button {
  border: none;
  background: var(--teal);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.feedback {
  min-height: 1.4rem;
  font-weight: 600;
}

.feedback.good {
  color: var(--teal);
}

.feedback.bad {
  color: #c94d2e;
}

.actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.actions button {
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.4rem;
  font-weight: 700;
  cursor: pointer;
}

.actions .primary {
  background: var(--accent-strong);
  color: #fff;
}

.actions .ghost {
  background: #fff;
  border: 1px solid #e6d7c8;
}

.actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.side {
  display: grid;
  gap: 1rem;
}

.panel {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  padding: 1.4rem;
  box-shadow: 0 12px 30px var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.panel h3 {
  font-size: 1.1rem;
}

.link {
  background: none;
  border: none;
  color: var(--teal);
  cursor: pointer;
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.meter {
  height: 10px;
  background: #efe4d6;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 1rem;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--accent));
  transition: width 0.3s ease;
}

.list {
  display: grid;
  gap: 0.8rem;
}

.list-group {
  background: #fff7ef;
  border-radius: 14px;
  padding: 0.8rem;
}

.list-group h4 {
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
}

.list-group ul {
  list-style: none;
  display: grid;
  gap: 0.3rem;
  font-weight: 600;
}

.hidden {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .back-link {
    position: static;
    margin-bottom: 1.5rem;
    display: inline-block;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 2.5rem 5vw 3rem;
  }

  .type-form {
    flex-direction: column;
  }

  .actions {
    flex-direction: column;
  }
}
