:root {
  --bg-deep: #1a2218;
  --bg-mid: #243022;
  --surface: #2c3a28;
  --surface-2: #354632;
  --ink: #f7f4ec;
  --ink-muted: #c9d2c0;
  --accent: #c4a35a;
  --accent-soft: rgba(196, 163, 90, 0.18);
  --good: #7dcb86;
  --good-bg: rgba(111, 191, 122, 0.14);
  --bad: #e58a7c;
  --bad-bg: rgba(224, 122, 106, 0.14);
  --line: rgba(247, 244, 236, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font: "Roboto", system-ui, sans-serif;
  --display: "Roboto", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-deep);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 55% at 15% -10%, rgba(196, 163, 90, 0.16), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 10%, rgba(70, 110, 72, 0.35), transparent 50%),
    linear-gradient(165deg, #1f2a1c 0%, #161d14 45%, #1a2218 100%);
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.app {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.75rem 0 3rem;
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background:
    radial-gradient(circle at center, transparent 28%, var(--accent) 29% 34%, transparent 35%),
    radial-gradient(circle at center, var(--accent) 0 8%, transparent 9%);
  box-shadow: inset 0 0 0 7px rgba(196, 163, 90, 0.15);
  flex-shrink: 0;
}

.brand-name {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.45rem, 4vw, 1.85rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.brand-sub {
  margin: 0.2rem 0 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.stats {
  display: flex;
  gap: 0.65rem;
}

.stats[hidden],
.stat[hidden],
.card[hidden],
.feedback[hidden],
.btn[hidden],
.results-badge[hidden] {
  display: none !important;
}

.stat {
  min-width: 4.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(44, 58, 40, 0.55);
  backdrop-filter: blur(8px);
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 500;
}

.stat-value {
  display: block;
  margin-top: 0.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card {
  background: linear-gradient(180deg, rgba(53, 70, 50, 0.92), rgba(44, 58, 40, 0.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.5rem 1.35rem;
}

.progress-row {
  margin-bottom: 1.35rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.55rem;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

.qid {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 700;
}

.progress-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #9a7d3d, var(--accent));
  transition: width 0.35s ease;
}

.question {
  margin: 0 0 1.35rem;
  font-family: var(--display);
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.options {
  display: grid;
  gap: 0.65rem;
}

.option {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(26, 34, 24, 0.35);
  color: var(--ink);
  padding: 0.95rem 1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: start;
  cursor: pointer;
  font: inherit;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    transform 0.15s ease;
}

.option:hover:not(:disabled) {
  border-color: rgba(196, 163, 90, 0.45);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.option:disabled {
  cursor: default;
}

.option-letter {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
  flex-shrink: 0;
}

.option-text {
  padding-top: 0.15rem;
}

.option.correct {
  border-color: rgba(111, 191, 122, 0.55);
  background: var(--good-bg);
}

.option.correct .option-letter {
  background: rgba(111, 191, 122, 0.22);
  color: var(--good);
}

.option.wrong {
  border-color: rgba(224, 122, 106, 0.55);
  background: var(--bad-bg);
}

.option.wrong .option-letter {
  background: rgba(224, 122, 106, 0.22);
  color: var(--bad);
}

.option.dim {
  opacity: 0.55;
}

.feedback {
  margin-top: 1.15rem;
  padding: 0.95rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  animation: pop 0.28s ease both;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.feedback.is-correct {
  background: var(--good-bg);
  border-color: rgba(111, 191, 122, 0.35);
}

.feedback.is-wrong {
  background: var(--bad-bg);
  border-color: rgba(224, 122, 106, 0.35);
}

.feedback-title {
  margin: 0;
  font-weight: 700;
}

.feedback-detail {
  margin: 0.35rem 0 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  min-height: 2.75rem;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0.7rem 1.2rem;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #1a2218;
  margin-left: auto;
}

.btn-primary:hover {
  background: #d4b56b;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid transparent;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
  font-weight: 500;
}

.btn-ghost:hover {
  color: var(--ink);
}

.foot {
  margin-top: 1.25rem;
  color: var(--ink-muted);
  font-size: 0.88rem;
  text-align: center;
}

.foot p {
  margin: 0;
}

.setup-kicker {
  margin: 0 0 0.55rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
}

.setup-title {
  margin-bottom: 0.7rem;
  font-weight: 700;
}

.setup-copy {
  margin: 0 0 1.4rem;
  color: var(--ink-muted);
  font-size: 1rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.mode-card {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(26, 34, 24, 0.45);
  color: var(--ink);
  padding: 1.15rem 1.05rem;
  cursor: pointer;
  font: inherit;
  display: grid;
  gap: 0.4rem;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    transform 0.15s ease;
}

.mode-card--exam {
  border-color: rgba(196, 163, 90, 0.35);
  background: linear-gradient(
    160deg,
    rgba(196, 163, 90, 0.14),
    rgba(26, 34, 24, 0.45) 55%
  );
}

.mode-card:hover:not(:disabled) {
  border-color: rgba(196, 163, 90, 0.55);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.mode-card:disabled {
  opacity: 0.5;
  cursor: wait;
}

.mode-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mode-icon {
  width: 1.85rem;
  height: 1.85rem;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.mode-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.mode-name {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.15;
}

.mode-desc {
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.mode-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.mode-meta span {
  display: inline-block;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.mode-card--exam .mode-meta span {
  border-color: rgba(196, 163, 90, 0.35);
  background: rgba(196, 163, 90, 0.12);
  color: #e6d3a0;
}

.results-score {
  margin: 0 0 0.5rem;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.results-badge {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.results-badge.is-pass {
  background: var(--good-bg);
  color: var(--good);
  border: 1px solid rgba(111, 191, 122, 0.35);
}

.results-badge.is-fail {
  background: var(--bad-bg);
  color: var(--bad);
  border: 1px solid rgba(224, 122, 106, 0.35);
}

.stat-timer-wrap .stat-value {
  font-variant-numeric: tabular-nums;
}

.stat-timer-wrap.is-urgent {
  border-color: rgba(224, 122, 106, 0.55);
  background: var(--bad-bg);
}

.stat-timer-wrap.is-urgent .stat-value,
.stat-timer-wrap.is-urgent .stat-label {
  color: var(--bad);
}

.results-actions {
  margin-top: 1.5rem;
}

@media (max-width: 560px) {
  .app {
    width: min(100% - 1.25rem, 760px);
    padding-top: 1.1rem;
  }

  .stats {
    width: 100%;
  }

  .stat {
    flex: 1;
  }

  .card {
    padding: 1.15rem;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .btn-primary {
    width: 100%;
    margin-left: 0;
  }

  .btn-ghost {
    align-self: center;
  }
}
