:root {
  color-scheme: light;
  --white: #ffffff;
  --ink: #142b46;
  --muted: #58667b;
  --cobalt: #245ddb;
  --mint: #ddefe6;
  --line: #c5cedb;
  --track: #e6e9ef;
  --soft: #f5f7fa;
  --focus: #1357df;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--white);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  z-index: 5;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-150%);
  border-radius: 8px;
  background: var(--ink);
  color: var(--white);
  font-size: 16px;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: flex;
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  flex-direction: column;
}

.app-header {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.header-link,
.text-button {
  min-height: 44px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--cobalt);
  cursor: pointer;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
}

.text-button {
  min-height: 44px;
  text-align: left;
}

.header-link:hover,
.text-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.global-notice {
  display: flex;
  margin-top: 12px;
  padding: 12px 14px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}

.global-notice p {
  margin: 0;
}

.global-notice .text-button {
  flex: 0 0 auto;
}

main {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.screen {
  display: flex;
  flex: 1;
  flex-direction: column;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.button {
  display: inline-flex;
  width: 100%;
  min-height: 54px;
  padding: 12px 18px;
  align-items: center;
  justify-content: center;
  border: 1.5px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button:disabled,
.header-link:disabled,
.text-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.button-primary {
  border-color: var(--cobalt);
  background: var(--cobalt);
  color: var(--white);
}

.button-primary:hover:not(:disabled) {
  border-color: #174dc2;
  background: #174dc2;
}

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

.button-secondary:hover:not(:disabled) {
  border-color: var(--cobalt);
  color: var(--cobalt);
}

.preview-label {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

/* Login */
.login-screen {
  justify-content: center;
  padding: 32px 0 48px;
}

.login-copy {
  margin-bottom: 30px;
}

.form-stack {
  display: grid;
  gap: 20px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.field input {
  width: 100%;
  min-height: 54px;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.3;
}

.field input:focus-visible {
  border-color: var(--cobalt);
}

.form-stack .button {
  margin-top: 8px;
}

/* Welcome */
.welcome-screen {
  padding-top: 8px;
}

.welcome-compass {
  display: grid;
  width: 180px;
  height: 180px;
  margin: clamp(24px, 6vh, 42px) auto 26px;
  place-items: center;
  border-radius: 12px;
  background: var(--mint);
}

.welcome-compass svg {
  display: block;
  width: 100%;
  height: 100%;
}

.compass-letter {
  fill: var(--ink);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
}

.compass-svg-label,
.map-north-letter {
  fill: var(--ink);
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
}

.map-labels text {
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
}

.welcome-copy h1 {
  max-width: 390px;
}

.welcome-subtitle {
  margin: 13px 0 0;
  font-size: 20px;
  line-height: 1.4;
}

.welcome-detail {
  max-width: 360px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.welcome-actions {
  margin-top: auto;
  padding-top: 30px;
}

.course-label {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
}

/* Task */
.task-screen {
  padding-bottom: 2px;
}

.progress-block {
  margin-top: 20px;
}

.progress-track,
.feedback-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.progress-segment {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--track);
}

.progress-segment.is-current,
.progress-segment.is-complete {
  background: var(--cobalt);
}

.progress-caption {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.35;
}

.task-intro {
  margin-top: 21px;
}

.task-intro p {
  margin: 8px 0 0;
  font-size: 18px;
  line-height: 1.42;
}

.task-diagram {
  display: flex;
  width: 100%;
  height: min(240px, 62vw);
  min-height: 184px;
  margin-top: 16px;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--mint);
}

.task-diagram svg {
  display: block;
  width: 100%;
  height: 100%;
}

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

.answer-button {
  display: flex;
  min-width: 0;
  min-height: 62px;
  padding: 10px 8px;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.answer-button:hover:not(:disabled) {
  border-color: var(--cobalt);
  background: #f5f8ff;
}

.answer-button[aria-pressed="true"] {
  border-color: var(--cobalt);
  background: #eaf0ff;
  color: var(--ink);
}

.hint-button {
  margin-top: 16px;
  border-color: var(--cobalt);
  color: var(--cobalt);
}

.hint-button:hover:not(:disabled) {
  background: #f5f8ff;
}

.hint-panel {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--mint);
}

.hint-panel p {
  margin-bottom: 0;
}

.hint-source {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
}

.hint-copy {
  margin-top: 4px;
  font-size: 17px;
  line-height: 1.45;
}

.hint-status {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.support-note {
  display: flex;
  margin-top: 12px;
  padding: 10px 12px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-left: 3px solid var(--cobalt);
  background: var(--soft);
  font-size: 15px;
  line-height: 1.4;
}

.support-note p {
  margin: 0;
}

.support-note .text-button {
  flex: 0 0 auto;
  font-size: 15px;
}

/* Answer feedback */
.feedback-screen {
  padding-top: 20px;
}

.feedback-progress {
  margin-top: 4px;
}

.feedback-mark {
  display: grid;
  width: 116px;
  height: 116px;
  margin: clamp(28px, 8vh, 60px) auto 25px;
  place-items: center;
  border-radius: 50%;
  background: var(--mint);
}

.feedback-mark svg {
  width: 58px;
  height: 58px;
}

.feedback-mark.is-incorrect {
  background: var(--soft);
}

.feedback-copy p {
  margin: 10px 0 0;
  font-size: 19px;
  line-height: 1.45;
}

.feedback-copy .feedback-assistance {
  color: var(--muted);
  font-size: 16px;
}

.feedback-actions {
  margin-top: auto;
  padding-top: 36px;
}

/* Pause and finish states */
.pause-screen,
.finish-screen,
.ready-screen {
  padding-top: 8px;
}

.pause-illustration {
  display: grid;
  width: 100%;
  height: min(220px, 58vw);
  min-height: 170px;
  margin-top: 25px;
  place-items: center;
  border-radius: 12px;
  background: var(--mint);
}

.pause-illustration svg {
  height: 78%;
  max-height: 180px;
}

.pause-copy {
  margin-top: 24px;
}

.pause-copy p {
  margin: 8px 0 0;
  font-size: 18px;
  line-height: 1.42;
}

.pause-copy .pause-step {
  margin-top: 14px;
  color: var(--muted);
  font-size: 16px;
}

.pause-actions {
  display: grid;
  margin-top: auto;
  padding-top: 32px;
  gap: 12px;
}

.finish-screen {
  padding-top: 4px;
}

.finish-mark {
  width: 150px;
  height: 150px;
  margin: clamp(25px, 6vh, 48px) auto 24px;
}

.finish-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.finish-copy {
  text-align: center;
}

.finish-copy h1 {
  font-size: 30px;
}

.finish-copy p {
  margin: 12px 0 0;
  font-size: 20px;
  line-height: 1.4;
}

.finish-stats {
  display: grid;
  margin-top: 28px;
  gap: 8px;
}

.finish-stats p {
  display: flex;
  min-height: 62px;
  margin: 0;
  padding: 14px 16px;
  align-items: center;
  border-radius: 10px;
  background: var(--soft);
  font-size: 17px;
  line-height: 1.35;
}

.finish-actions {
  margin-top: auto;
  padding-top: 28px;
}

.ready-screen {
  justify-content: center;
}

.ready-copy p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.ready-actions {
  margin-top: auto;
  padding-top: 36px;
}

/* Parent overview */
.parent-screen {
  padding-top: 32px;
}

.parent-subtitle {
  margin: 9px 0 26px;
  color: var(--muted);
  font-size: 18px;
}

.parent-progress {
  padding: 19px 0 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.parent-progress h2 {
  margin-bottom: 16px;
}

.parent-progress-count {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.parent-stats {
  display: grid;
  margin-top: 14px;
  gap: 7px;
}

.parent-stats p,
.parent-current {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.4;
}

.parent-current {
  margin-top: 13px;
  color: var(--muted);
}

.parent-connection {
  padding: 21px 0 18px;
}

.parent-connection h2 {
  margin-bottom: 9px;
}

.parent-connection p {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.45;
}

.parent-connection .parent-model-status {
  margin-top: 7px;
  color: var(--muted);
  font-size: 15px;
}

.parent-connection .parent-usage {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.parent-check-button {
  margin-top: 14px;
}

.parent-model-check-result {
  margin-top: 12px;
  padding: 13px 14px;
  border-left: 3px solid var(--cobalt);
  border-radius: 0 8px 8px 0;
  background: var(--soft);
}

.parent-model-check-result p {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.parent-model-check-result p + p {
  margin-top: 5px;
}

.parent-model-check-result .parent-check-text {
  margin-top: 9px;
  font-size: 16px;
}

.parent-model-check-result .parent-check-usage {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.parent-actions {
  margin-top: auto;
  padding-top: 24px;
}

.loading-screen {
  justify-content: center;
}

@media (max-width: 360px) {
  .app-shell {
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }

  .header-actions {
    gap: 9px;
  }

  .header-link {
    font-size: 16px;
  }

  h1 {
    font-size: 28px;
  }

  .answer-button {
    font-size: 18px;
  }
}

@media (max-height: 840px) and (min-width: 361px) {
  .app-shell {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .progress-block {
    margin-top: 13px;
  }

  .task-intro {
    margin-top: 15px;
  }

  .task-diagram {
    height: min(204px, 54vw);
    min-height: 160px;
    margin-top: 12px;
  }

  .answer-button {
    min-height: 56px;
  }

  .hint-button {
    margin-top: 12px;
  }

  .welcome-compass {
    width: 150px;
    height: 150px;
    margin-top: 20px;
    margin-bottom: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
