:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --ink: #16211f;
  --muted: #65716e;
  --line: #d7dfda;
  --panel: #ffffff;
  --teal: #0f766e;
  --teal-dark: #0b4f4a;
  --coral: #e85d4f;
  --amber: #f3b33d;
  --sea: #d8f1ec;
  --sky: #e8f3ff;
  --shadow: 0 18px 48px rgba(22, 33, 31, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 14% 8%, rgba(243, 179, 61, 0.2), transparent 26rem),
    linear-gradient(180deg, var(--sky), var(--bg) 38%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 18px 92px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0 16px;
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1.04rem;
}

.brand span {
  color: var(--muted);
  font-size: 0.82rem;
}

.score-pill {
  display: flex;
  align-items: baseline;
  justify-content: center;
  min-width: 74px;
  height: 42px;
  gap: 4px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--teal-dark);
  font-weight: 800;
}

.score-pill small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.main-view {
  outline: none;
}

.screen {
  display: grid;
  gap: 18px;
}

.hero-game {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  min-height: 310px;
  overflow: hidden;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #e4f5f2 54%, #ffe7ba 100%);
  box-shadow: var(--shadow);
}

.hero-copy {
  align-self: center;
  padding: 30px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  max-width: 620px;
  margin-bottom: 12px;
  font-size: clamp(2.25rem, 7vw, 4.9rem);
  line-height: 0.93;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.55rem;
  line-height: 1.12;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.lead {
  max-width: 560px;
  color: #33413d;
  font-size: 1rem;
  line-height: 1.55;
}

.hero-art {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 20px;
}

.hero-art img {
  width: min(100%, 280px);
  height: auto;
  filter: drop-shadow(0 24px 28px rgba(15, 79, 74, 0.2));
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.button.warn {
  background: var(--coral);
}

.compact-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin-top: 8px;
  padding: 0 16px;
  border: 1px dashed rgba(15, 118, 110, 0.46);
  border-radius: 8px;
  background: var(--sea);
  color: var(--teal-dark);
  font-weight: 800;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.button:focus-visible,
.nav-button:focus-visible,
.answer:focus-visible,
.module-card:focus-visible {
  outline: 3px solid rgba(243, 179, 61, 0.58);
  outline-offset: 2px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.metric,
.panel,
.module-card,
.answer,
.lesson-panel,
.exam-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.metric {
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 1.5rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.section-head.compact {
  align-items: center;
  margin-bottom: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.performance-panel {
  display: grid;
}

.performance-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.performance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.performance-row.is-weak {
  border-color: rgba(232, 93, 79, 0.34);
  background: #fff5f3;
}

.performance-row strong,
.performance-row span {
  display: block;
}

.performance-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.performance-score {
  min-width: 48px;
  color: var(--teal-dark);
  font-size: 1.04rem;
  font-weight: 900;
  text-align: right;
}

.performance-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.module-card {
  display: grid;
  min-height: 166px;
  padding: 16px;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.module-card:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 118, 110, 0.38);
  box-shadow: 0 14px 30px rgba(22, 33, 31, 0.1);
}

.module-card.is-done {
  border-color: rgba(15, 118, 110, 0.46);
  background: linear-gradient(180deg, #fff, var(--sea));
}

.tag {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef5f3;
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 800;
}

.module-card p,
.lesson-panel p,
.panel p {
  color: var(--muted);
  line-height: 1.48;
}

.progress-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ece9;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.lesson-panel,
.panel {
  padding: 18px;
}

.lesson-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.lesson-list li {
  display: flex;
  gap: 10px;
  line-height: 1.42;
}

.lesson-list li::before {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.ripeam-stage {
  overflow: hidden;
  min-height: 320px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: #d8f1ec;
  box-shadow: var(--shadow);
}

.ripeam-stage svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 320px;
}

.ripeam-stage.has-fog {
  background: #edf6f4;
}

.danger-pulse circle {
  transform-origin: center;
  animation: dangerPulse 900ms ease-in-out infinite alternate;
}

.safe-wake {
  animation: wakeIn 900ms ease-out both;
}

.game-result-badge {
  filter: drop-shadow(0 10px 18px rgba(22, 33, 31, 0.16));
}

.nav-lights {
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.85));
}

@keyframes dangerPulse {
  from {
    opacity: 0.38;
    transform: scale(0.9);
  }

  to {
    opacity: 0.95;
    transform: scale(1.08);
  }
}

@keyframes wakeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.game-panel {
  position: sticky;
  top: 78px;
}

.game-options {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.question-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.answers {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.answer {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  color: var(--ink);
  text-align: left;
}

.answer.is-correct {
  border-color: rgba(15, 118, 110, 0.58);
  background: #ddf7ed;
}

.answer.is-wrong {
  border-color: rgba(232, 93, 79, 0.55);
  background: #ffe7e3;
}

.answer:disabled {
  cursor: default;
}

.answer.exam-feedback-pop {
  animation: examPositive 0.55s ease both;
}

.answer.exam-feedback-shake {
  animation: examNegative 0.45s ease both;
}

@keyframes examPositive {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(15, 118, 110, 0);
  }
  45% {
    transform: scale(1.015);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.08);
  }
}

@keyframes examNegative {
  0%, 100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-4px);
  }
  40% {
    transform: translateX(4px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(3px);
  }
}

.feedback {
  display: none;
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: #f5f7f4;
  line-height: 1.45;
}

.feedback.is-visible {
  display: block;
}

.exam-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.exam-row + .exam-row {
  margin-top: 10px;
}

.result {
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff, #e8f3ff);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 780px;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid rgba(215, 223, 218, 0.86);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 -8px 30px rgba(22, 33, 31, 0.12);
  backdrop-filter: blur(16px);
}

.nav-button[data-view="library"] {
  display: none;
}

.nav-button {
  display: grid;
  min-width: 0;
  min-height: 58px;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.nav-button.is-active {
  background: var(--sea);
  color: var(--teal-dark);
}

.nav-icon {
  font-size: 1.2rem;
  line-height: 1;
}

@media (max-width: 860px) {
  .hero-game,
  .quiz-layout,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-screen {
    gap: 12px;
  }

  .game-screen .section-head {
    gap: 8px;
  }

  .ripeam-stage {
    position: sticky;
    top: 72px;
    z-index: 9;
    min-height: clamp(220px, 46vh, 320px);
  }

  .ripeam-stage svg {
    min-height: clamp(220px, 46vh, 320px);
  }

  .hero-art {
    min-height: 160px;
    padding-top: 0;
  }

  .metrics,
  .performance-grid,
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .game-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px 12px 90px;
  }

  .topbar {
    padding-top: 4px;
  }

  .brand span {
    display: none;
  }

  .hero-copy {
    padding: 22px;
  }

  .metrics,
  .performance-grid,
  .grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .section-head.compact {
    align-items: start;
  }

  .exam-row {
    grid-template-columns: 1fr;
  }

  .ripeam-stage {
    top: 66px;
    min-height: clamp(210px, 44vh, 280px);
  }

  .ripeam-stage svg {
    min-height: clamp(210px, 44vh, 280px);
  }

}
