:root {
  --bg-night: #0d1b2a;
  --bg-steel: #16263d;
  --panel: rgba(245, 247, 250, 0.92);
  --ink: #132238;
  --muted: #58708c;
  --accent: #f4a259;
  --accent-strong: #d97706;
  --sky: #5dade2;
  --success: #1f9d6c;
  --danger: #c44536;
  --shadow: 0 18px 45px rgba(8, 19, 35, 0.22);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  padding: 12px;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(244, 162, 89, 0.35), transparent 28%),
    radial-gradient(circle at bottom right, rgba(93, 173, 226, 0.28), transparent 30%),
    linear-gradient(145deg, #09131f 0%, #15314c 55%, #0a1827 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
}

body::before {
  top: 6%;
  right: 7%;
  width: 220px;
  height: 220px;
  border-radius: 36px;
  background: linear-gradient(135deg, rgba(244, 162, 89, 0.22), rgba(244, 162, 89, 0));
  transform: rotate(18deg);
}

body::after {
  bottom: 8%;
  left: 6%;
  width: 260px;
  height: 160px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(93, 173, 226, 0.18), rgba(93, 173, 226, 0));
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1160px, 100%);
  height: calc(100dvh - 24px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.app-shell:fullscreen {
  width: 100%;
  height: 100dvh;
  padding: 12px;
  background:
    radial-gradient(circle at top left, rgba(244, 162, 89, 0.35), transparent 28%),
    radial-gradient(circle at bottom right, rgba(93, 173, 226, 0.28), transparent 30%),
    linear-gradient(145deg, #09131f 0%, #15314c 55%, #0a1827 100%);
}

.screen-stack {
  height: 100%;
  min-height: 0;
}

.panel {
  height: 100%;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
  animation: rise 0.5s ease;
}

.hidden {
  display: none;
}

.app-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(245, 247, 250, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 28px rgba(8, 19, 35, 0.18);
  backdrop-filter: blur(14px);
}

.toolbar-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #edf4fb;
  font-weight: 700;
}

.toolbar-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ffd38e);
  box-shadow: 0 0 0 6px rgba(244, 162, 89, 0.16);
}

.toolbar-button,
.primary-button,
.secondary-button,
.answer-button {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.toolbar-button {
  padding: 10px 16px;
  font-weight: 700;
  color: #0c2137;
  background: linear-gradient(135deg, #f6cf9f 0%, #ffffff 100%);
  box-shadow: 0 12px 24px rgba(8, 19, 35, 0.18);
}

.toolbar-button:hover,
.primary-button:hover,
.secondary-button:hover,
.answer-button:hover {
  transform: translateY(-2px);
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  padding: 24px;
  min-height: 0;
}

.hero-copy,
.setup-card,
.review-section {
  min-height: 0;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-copy h1,
.setup-card h2,
.question-card h2,
.results-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

.hero-copy h1 {
  font-size: clamp(2.3rem, 4vw, 4rem);
  line-height: 0.95;
  margin-top: 8px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.78rem;
  font-weight: 700;
}

.intro {
  max-width: 54ch;
  margin: 14px 0 18px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

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

.library-card,
.stat-card,
.result-card {
  background: rgba(255, 255, 255, 0.82);
  border-radius: var(--radius-lg);
  padding: 14px;
  border: 1px solid rgba(19, 34, 56, 0.08);
}

.library-label,
.stat-card span,
.result-card span,
.progress-copy span,
.timer-box span,
.field span,
.rules p,
.review-heading p,
.question-kicker {
  color: var(--muted);
}

.library-card strong,
.stat-card strong,
.result-card strong {
  display: block;
  margin-top: 7px;
  font-size: 1.45rem;
}

.setup-card {
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 248, 252, 0.92));
  border-radius: var(--radius-xl);
  padding: 22px;
  border: 1px solid rgba(19, 34, 56, 0.08);
}

.setup-card h2 {
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.94rem;
  font-weight: 700;
}

select {
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(19, 34, 56, 0.14);
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

select:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 4px rgba(93, 173, 226, 0.16);
}

.helper-text {
  margin: 4px 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.primary-button,
.secondary-button {
  padding: 13px 18px;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, #ffb774 100%);
  color: #2a1a08;
  box-shadow: 0 12px 24px rgba(217, 119, 6, 0.24);
}

.secondary-button {
  background: rgba(19, 34, 56, 0.08);
  color: var(--ink);
}

.rules {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: rgba(19, 34, 56, 0.05);
}

.rules p {
  margin: 7px 0;
  line-height: 1.45;
}

.quiz-screen,
.results-screen {
  padding: 22px;
}

.quiz-screen {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 14px;
}

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

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(244, 162, 89, 0.18);
  color: #8f4a05;
  font-weight: 700;
}

.chip-alt {
  background: rgba(93, 173, 226, 0.14);
  color: #184f79;
}

.chip-dark {
  background: rgba(19, 34, 56, 0.1);
  color: var(--ink);
}

.timer-box {
  min-width: 190px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: rgba(19, 34, 56, 0.06);
}

.timer-box strong {
  display: block;
  margin: 6px 0 10px;
  font-size: 1.5rem;
}

.timer-track,
.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(19, 34, 56, 0.08);
}

.timer-bar,
.progress-bar {
  height: 100%;
  border-radius: inherit;
  transition: width 0.25s ease, background 0.25s ease;
}

.timer-bar {
  width: 100%;
  background: linear-gradient(90deg, #67d58d 0%, #f4a259 70%, #c44536 100%);
}

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

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-weight: 700;
}

.progress-bar {
  width: 0%;
  background: linear-gradient(90deg, var(--sky), var(--accent));
}

.question-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at top right, rgba(244, 162, 89, 0.15), transparent 25%),
    linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid rgba(19, 34, 56, 0.08);
}

.question-kicker {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  font-weight: 700;
}

.question-card h2 {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.2;
}

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

.answer-button {
  min-height: 80px;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  background: #ffffff;
  border: 1px solid rgba(19, 34, 56, 0.12);
  color: var(--ink);
  box-shadow: 0 10px 18px rgba(13, 27, 42, 0.05);
}

.answer-button strong {
  display: inline-flex;
  width: 34px;
  height: 34px;
  margin-right: 12px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: rgba(19, 34, 56, 0.08);
}

.answer-button:disabled {
  cursor: default;
}

.answer-button.correct {
  background: rgba(31, 157, 108, 0.12);
  border-color: rgba(31, 157, 108, 0.42);
}

.answer-button.wrong {
  background: rgba(196, 69, 54, 0.12);
  border-color: rgba(196, 69, 54, 0.36);
}

.answer-button.dimmed {
  opacity: 0.68;
}

.feedback-panel {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: rgba(19, 34, 56, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.feedback-panel p {
  margin: 0;
  line-height: 1.55;
}

.feedback-panel.correct {
  background: rgba(31, 157, 108, 0.12);
}

.feedback-panel.wrong,
.feedback-panel.timeout {
  background: rgba(196, 69, 54, 0.11);
}

.results-screen {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 16px;
}

.results-header h2 {
  font-size: clamp(1.9rem, 3.5vw, 2.8rem);
  margin: 8px 0 10px;
}

.results-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.results-actions {
  display: flex;
  gap: 12px;
}

.results-actions .primary-button,
.results-actions .secondary-button {
  width: auto;
}

.review-section {
  display: flex;
  flex-direction: column;
  padding-top: 18px;
  border-top: 1px solid rgba(19, 34, 56, 0.08);
}

.review-heading h3 {
  margin: 0;
  font-size: 1.25rem;
}

.review-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.review-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(19, 34, 56, 0.08);
}

.review-card.good {
  background: rgba(31, 157, 108, 0.08);
}

.review-card.bad {
  background: rgba(196, 69, 54, 0.07);
}

.review-card h4 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.review-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.mini-tag {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(19, 34, 56, 0.08);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.review-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

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

@media (max-width: 920px) {
  body {
    overflow: auto;
    padding: 10px;
  }

  .app-shell {
    height: auto;
    min-height: calc(100dvh - 20px);
  }

  .hero {
    grid-template-columns: 1fr;
    height: auto;
  }

  .quiz-screen,
  .results-screen {
    height: auto;
  }

  .quiz-topbar {
    flex-direction: column;
  }

  .timer-box {
    width: 100%;
  }

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

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

@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  .app-shell {
    min-height: calc(100dvh - 16px);
    gap: 10px;
  }

  .app-toolbar {
    border-radius: 22px;
    padding: 10px 12px;
  }

  .toolbar-mark {
    font-size: 0.92rem;
  }

  .toolbar-button {
    padding: 9px 14px;
    font-size: 0.92rem;
  }

  .hero,
  .quiz-screen,
  .results-screen {
    padding: 16px;
  }

  .library-strip,
  .stats-grid,
  .results-grid {
    grid-template-columns: 1fr 1fr;
  }

  .feedback-panel,
  .results-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .results-actions .primary-button,
  .results-actions .secondary-button {
    width: 100%;
  }

  .question-card {
    padding: 18px;
  }
}
