:root {
  --page: #f7f9fb;
  --ink: #16202a;
  --muted: #627080;
  --line: #dce4ec;
  --card: #ffffff;
  --blue: #2f6df6;
  --blue-soft: #e9f0ff;
  --green: #188a5a;
  --green-soft: #e7f6ef;
  --red: #c9483b;
  --red-soft: #fae9e7;
  --amber: #d88316;
  --amber-soft: #fff3de;
  --shadow: 0 18px 50px rgba(27, 43, 62, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
}

button {
  font: inherit;
}

.page {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.topbar,
.hero,
.level-band,
.trainer,
.guide {
  margin-bottom: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.back-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.top-actions,
.trainer-actions,
.rating-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: stretch;
  padding: 28px 0 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 14px;
  font-size: 72px;
  line-height: 0.98;
}

h2 {
  margin-bottom: 8px;
  font-size: 34px;
  line-height: 1.1;
}

.hero-text,
#levelDescription {
  max-width: 690px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.hero-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.hero-stats div,
.level-band,
.trainer,
.guide {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.hero-stats div {
  padding: 16px;
}

.hero-stats span {
  display: block;
  font-size: 30px;
  font-weight: 900;
}

.hero-stats small {
  color: var(--muted);
  font-weight: 800;
}

.level-band,
.trainer,
.guide {
  padding: 20px;
}

.section-head {
  margin-bottom: 16px;
}

.levels {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.level-card {
  min-height: 148px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.level-card:hover {
  transform: translateY(-2px);
}

.level-card.active {
  border-color: rgba(47, 109, 246, 0.48);
  background: var(--blue-soft);
}

.level-card.locked {
  opacity: 0.54;
  cursor: not-allowed;
}

.level-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 17px;
}

.level-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.level-meta {
  margin-top: 12px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.trainer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.speed-control {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f8fb;
}

.speed-button,
.ghost-button,
.primary-button,
.secondary-button,
.rating {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.speed-button {
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
}

.speed-button.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.ghost-button {
  padding: 9px 12px;
  color: var(--blue);
  background: #fff;
}

.ghost-button.danger {
  color: var(--red);
}

.exercise-shell {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
}

.exercise-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.pill {
  display: inline-flex;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
}

.timer-wrap {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.timer-ring {
  display: grid;
  place-items: center;
  width: 128px;
  height: 128px;
  border: 10px solid var(--blue-soft);
  border-top-color: var(--blue);
  border-radius: 50%;
  background: #fff;
}

.timer-ring.running {
  animation: timerPulse 1000ms ease-in-out infinite;
}

.timer-ring span {
  font-size: 38px;
  font-weight: 900;
}

.task-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 900;
}

#ruPrompt {
  margin-bottom: 0;
  font-size: 42px;
  line-height: 1.12;
}

.answer-panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(24, 138, 90, 0.22);
  border-radius: 10px;
  background: var(--green-soft);
}

.answer-label {
  margin-bottom: 6px;
  color: var(--green);
  font-weight: 900;
}

.answer-text {
  margin-bottom: 10px;
  font-size: 34px;
  font-weight: 900;
  line-height: 1.15;
}

.structure {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  color: var(--green);
  font-weight: 900;
}

.explanation {
  margin-bottom: 0;
  color: #2e5d4a;
  line-height: 1.5;
}

.primary-button,
.secondary-button,
.rating {
  padding: 12px 16px;
}

.primary-button {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.secondary-button {
  color: var(--muted);
  background: #fff;
}

.rating.easy {
  color: var(--green);
  background: var(--green-soft);
  border-color: rgba(24, 138, 90, 0.24);
}

.rating.mistake {
  color: var(--red);
  background: var(--red-soft);
  border-color: rgba(201, 72, 59, 0.24);
}

.rating.slow {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: rgba(216, 131, 22, 0.25);
}

.trainer-actions,
.rating-actions {
  margin-top: 18px;
}

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

.guide-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.guide-grid strong,
.guide-grid span {
  display: block;
}

.guide-grid strong {
  margin-bottom: 6px;
}

.guide-grid span {
  color: var(--muted);
  line-height: 1.4;
}

@keyframes timerPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.025);
  }
}

@media (max-width: 900px) {
  .hero,
  .trainer-head,
  .timer-wrap {
    grid-template-columns: 1fr;
  }

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

  h1 {
    font-size: 52px;
  }

  #ruPrompt {
    font-size: 32px;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 20px, 1080px);
    padding-top: 14px;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .levels,
  .guide-grid {
    grid-template-columns: 1fr;
  }

  .timer-ring {
    width: 112px;
    height: 112px;
  }
}
