@layer reset, tokens, base, components, screens, utilities;

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    min-width: 320px;
    min-height: 100%;
    background: #efe9df;
    color-scheme: light;
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
  }

  body,
  h1,
  h2,
  h3,
  p,
  ol,
  ul,
  figure {
    margin: 0;
  }

  button,
  input {
    font: inherit;
  }

  button,
  a {
    -webkit-tap-highlight-color: transparent;
  }

  button {
    border: 0;
  }
}

@layer tokens {
  :root {
    --ink: #182033;
    --ink-soft: #536076;
    --paper: #fffdf9;
    --canvas: #f8f2e8;
    --canvas-deep: #efe4d3;
    --line: #d9d5cd;
    --line-dark: #aaa59b;
    --accent: #b45309;
    --accent-dark: #7c2d12;
    --accent-soft: #fff0e5;
    --accent-pale: #fff8f2;
    --success: #267a54;
    --success-soft: #e8f6ee;
    --danger: #b84934;
    --danger-soft: #fff0eb;
    --blue: #2e6fba;
    --blue-soft: #eaf3ff;
    --shadow-sm: 0 6px 18px rgb(24 32 51 / 8%);
    --shadow-md: 0 18px 50px rgb(24 32 51 / 14%);
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }
}

@layer base {
  body {
    min-height: 100svh;
    overflow-x: hidden;
    background:
      radial-gradient(circle at 15% 12%, rgb(255 255 255 / 90%) 0 8%, transparent 28%),
      linear-gradient(145deg, #f4ede3, #e7ebef);
    color: var(--ink);
    font-family:
      Pretendard,
      "Apple SD Gothic Neo",
      "Noto Sans KR",
      system-ui,
      sans-serif;
    font-size: 16px;
    line-height: 1.55;
  }

  button,
  a {
    color: inherit;
  }

  button:not(:disabled),
  a {
    cursor: pointer;
  }

  button:focus-visible,
  a:focus-visible,
  [tabindex]:focus-visible {
    outline: 3px solid #1d78d1;
    outline-offset: 3px;
  }

  button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
  }

  svg {
    display: block;
  }

  [hidden] {
    display: none !important;
  }
}

@layer components {
  .page-backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
  }

  .backdrop-shape {
    position: absolute;
    display: block;
    border: 1px solid rgb(24 32 51 / 10%);
    background: rgb(255 255 255 / 34%);
    transform: rotate(-8deg);
  }

  .backdrop-shape-one {
    top: 8vh;
    left: max(3vw, calc(50vw - 580px));
    width: 190px;
    height: 250px;
    border-radius: 45% 55% 42% 58%;
  }

  .backdrop-shape-two {
    right: max(2vw, calc(50vw - 620px));
    bottom: 5vh;
    width: 260px;
    height: 180px;
    border-radius: 58% 42% 62% 38%;
    border-color: rgb(217 105 43 / 18%);
    background: rgb(255 240 229 / 45%);
    transform: rotate(12deg);
  }

  .backdrop-grid {
    position: absolute;
    inset: 0;
    opacity: 0.16;
    background-image:
      linear-gradient(rgb(24 32 51 / 12%) 1px, transparent 1px),
      linear-gradient(90deg, rgb(24 32 51 / 12%) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(to bottom, transparent, #000 20%, #000 80%, transparent);
  }

  .skip-link {
    position: fixed;
    top: 8px;
    left: 50%;
    z-index: 100;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transform: translate(-50%, -150%);
    transition: transform 160ms ease;
  }

  .skip-link:focus {
    transform: translate(-50%, 0);
  }

  .app-frame {
    width: min(100%, 500px);
    min-height: 100svh;
    margin-inline: auto;
    overflow: clip;
    background: var(--paper);
  }

  .app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    min-height: calc(70px + var(--safe-top));
    align-items: center;
    justify-content: space-between;
    padding: calc(12px + var(--safe-top)) 20px 12px;
    border-bottom: 1px solid rgb(217 213 205 / 72%);
    background: rgb(255 253 249 / 88%);
    backdrop-filter: blur(18px);
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    text-decoration: none;
  }

  .brand-mark {
    position: relative;
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 2px solid var(--ink);
    border-radius: 13px 13px 17px 13px;
    background: var(--accent-soft);
    box-shadow: 3px 3px 0 var(--ink);
    transform: rotate(-2deg);
  }

  .brand-mark::after {
    position: absolute;
    right: 4px;
    bottom: -7px;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    background: var(--accent-soft);
    content: "";
    transform: skewY(36deg);
  }

  .brand-mark span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 8px 0 var(--accent), -8px 0 var(--accent);
  }

  .brand-copy {
    display: grid;
    line-height: 1.15;
  }

  .brand-copy strong {
    font-size: 1.05rem;
    letter-spacing: -0.03em;
  }

  .brand-copy small {
    margin-top: 4px;
    color: var(--ink-soft);
    font-size: 0.68rem;
    font-weight: 650;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .network-status {
    display: none;
    align-items: center;
    gap: 5px;
    color: var(--ink-soft);
    font-size: 0.72rem;
    font-weight: 700;
  }

  .network-status span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
  }

  .network-status.is-offline span {
    background: var(--danger);
  }

  .icon-button {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    transition: border-color 160ms ease, transform 160ms ease;
  }

  .icon-button:hover {
    border-color: var(--accent);
    transform: rotate(-12deg);
  }

  .icon-button svg {
    width: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
  }

  #app {
    min-height: calc(100svh - 114px - var(--safe-top) - var(--safe-bottom));
  }

  .screen {
    min-height: calc(100svh - 114px - var(--safe-top) - var(--safe-bottom));
    padding: 22px 20px 32px;
    animation: screen-in 280ms ease both;
  }

  .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--accent-dark);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .eyebrow::before {
    width: 18px;
    height: 2px;
    background: currentColor;
    content: "";
  }

  .screen-title {
    margin-top: 8px;
    font-size: clamp(1.65rem, 8vw, 2.25rem);
    line-height: 1.18;
    letter-spacing: -0.055em;
  }

  .screen-description {
    margin-top: 10px;
    color: var(--ink-soft);
    font-size: 0.94rem;
  }

  .primary-button,
  .secondary-button,
  .text-button {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    font-weight: 800;
    transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
  }

  .primary-button {
    padding: 0 24px;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 8px 0 var(--accent-dark);
  }

  .primary-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 0 var(--accent-dark);
  }

  .primary-button:active:not(:disabled) {
    transform: translateY(5px);
    box-shadow: 0 3px 0 var(--accent-dark);
  }

  .secondary-button {
    padding: 0 22px;
    border: 1.5px solid var(--line-dark);
    background: #fff;
  }

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

  .text-button {
    min-height: 44px;
    padding: 0 10px;
    background: transparent;
    color: var(--accent-dark);
  }

  .button-row {
    display: flex;
    gap: 12px;
  }

  .button-row > * {
    flex: 1;
  }

  .progress-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #ece8e0;
  }

  .progress-value {
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 280ms ease;
  }

  .app-footer {
    display: flex;
    min-height: calc(44px + var(--safe-bottom));
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px calc(8px + var(--safe-bottom));
    border-top: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink-soft);
    font-size: 0.7rem;
  }

  .app-footer button {
    min-height: 28px;
    padding: 0;
    background: transparent;
    color: var(--ink-soft);
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .toast-region {
    position: fixed;
    z-index: 80;
    right: 16px;
    bottom: calc(20px + var(--safe-bottom));
    left: 16px;
    display: grid;
    justify-items: center;
    pointer-events: none;
  }

  .toast {
    max-width: 420px;
    padding: 12px 18px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    box-shadow: var(--shadow-md);
    font-size: 0.86rem;
    font-weight: 700;
    animation: toast-in 220ms ease both;
  }

  .modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: end center;
    padding: 18px;
    background: rgb(24 32 51 / 42%);
    backdrop-filter: blur(6px);
  }

  .modal-card {
    width: min(100%, 460px);
    padding: 24px;
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow-md);
  }

  .modal-card h2 {
    font-size: 1.3rem;
  }

  .modal-card p,
  .modal-card ol {
    margin-top: 12px;
    color: var(--ink-soft);
  }

  .modal-card ol {
    padding-left: 22px;
  }

  .modal-card .button-row {
    margin-top: 22px;
  }
}

@layer screens {
  .journey-hero {
    position: relative;
    margin-top: 24px;
    padding: 22px;
    overflow: hidden;
    border: 1px solid #edc7ac;
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, var(--accent-pale), #fff 78%);
    box-shadow: var(--shadow-sm);
  }

  .journey-hero::after {
    position: absolute;
    top: -28px;
    right: -34px;
    width: 126px;
    height: 126px;
    border: 18px solid rgb(217 105 43 / 10%);
    border-radius: 50%;
    content: "";
  }

  .lesson-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .meta-chip {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 0 11px;
    border: 1px solid #eadacb;
    border-radius: 999px;
    background: rgb(255 255 255 / 78%);
    color: var(--ink-soft);
    font-size: 0.72rem;
    font-weight: 750;
  }

  .journey-list {
    position: relative;
    display: grid;
    gap: 4px;
    margin-top: 26px;
    list-style: none;
  }

  .journey-list::before {
    position: absolute;
    top: 34px;
    bottom: 34px;
    left: 25px;
    width: 3px;
    border-radius: 999px;
    background: #e4ded4;
    content: "";
  }

  .journey-step {
    position: relative;
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 13px;
    align-items: center;
    min-height: 76px;
    padding: 9px 8px 9px 0;
    border-radius: 18px;
  }

  .journey-step.is-current {
    background: #fff;
    box-shadow: var(--shadow-sm);
  }

  .step-number {
    position: relative;
    z-index: 1;
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    border: 2px solid #cfc9bf;
    border-radius: 50%;
    background: var(--paper);
    color: var(--ink-soft);
    font-weight: 900;
  }

  .is-current .step-number {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 6px var(--accent-soft);
  }

  .is-complete .step-number {
    border-color: var(--success);
    background: var(--success-soft);
    color: var(--success);
  }

  .step-copy strong,
  .step-copy span {
    display: block;
  }

  .step-copy strong {
    font-size: 0.94rem;
  }

  .step-copy span {
    margin-top: 3px;
    color: var(--ink-soft);
    font-size: 0.75rem;
  }

  .step-status {
    padding: 5px 8px;
    border-radius: 999px;
    background: #f0ede7;
    color: var(--ink-soft);
    font-size: 0.66rem;
    font-weight: 800;
  }

  .is-current .step-status {
    background: var(--accent-soft);
    color: var(--accent-dark);
  }

  .journey-hero .primary-button {
    width: 100%;
    margin-top: 24px;
  }

  .today-note {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 13px;
    align-items: center;
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px dashed var(--line-dark);
    border-radius: var(--radius-md);
    color: var(--ink-soft);
    font-size: 0.78rem;
  }

  .today-note strong {
    color: var(--ink);
  }

  .note-icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 12px;
    background: var(--blue-soft);
    color: var(--blue);
    font-weight: 900;
  }

  .lesson-toolbar {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 12px;
    align-items: center;
  }

  .lesson-toolbar .icon-button:hover {
    transform: none;
  }

  .lesson-progress-label {
    color: var(--ink-soft);
    font-size: 0.75rem;
    font-weight: 800;
  }

  .lesson-progress {
    margin-top: 14px;
  }

  .comic-stage {
    margin-top: 20px;
  }

  .comic-panel {
    position: relative;
    min-height: 335px;
    overflow: hidden;
    border: 2px solid var(--ink);
    border-radius: 26px;
    background: #dfe5e7;
    box-shadow: 7px 8px 0 var(--ink);
  }

  .panel-art {
    position: relative;
    height: 220px;
    overflow: hidden;
    background:
      linear-gradient(180deg, transparent 64%, rgb(24 32 51 / 9%) 64%),
      linear-gradient(145deg, #e9eef0, #cfd8dc);
  }

  .panel-art::before,
  .panel-art::after {
    position: absolute;
    content: "";
  }

  .panel-art::before {
    right: 18px;
    bottom: 25px;
    width: 118px;
    height: 72px;
    border: 2px solid var(--ink);
    border-radius: 9px;
    background: #f8f4ec;
    box-shadow: inset 0 -16px #d9d0c1;
    transform: skewY(-2deg);
  }

  .panel-art::after {
    right: 34px;
    bottom: 95px;
    width: 64px;
    height: 46px;
    border: 2px solid var(--ink);
    border-radius: 6px;
    background: #a9c9d9;
  }

  .character {
    position: absolute;
    bottom: 31px;
    left: 40px;
    width: 104px;
    height: 154px;
  }

  .character-head {
    position: absolute;
    top: 0;
    left: 26px;
    width: 54px;
    height: 62px;
    border: 2px solid var(--ink);
    border-radius: 48% 48% 44% 44%;
    background: #f3c7a6;
  }

  .character-head::before {
    position: absolute;
    top: -8px;
    right: -3px;
    left: -3px;
    height: 28px;
    border: 2px solid var(--ink);
    border-radius: 48% 56% 36% 38%;
    background: #3a3440;
    content: "";
  }

  .character-body {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 96px;
    border: 2px solid var(--ink);
    border-radius: 45px 45px 12px 12px;
    background: var(--accent-soft);
  }

  .scene-two .character {
    right: 36px;
    left: auto;
    transform: scaleX(-1);
  }

  .scene-three .panel-art {
    background:
      linear-gradient(180deg, transparent 62%, rgb(24 32 51 / 9%) 62%),
      linear-gradient(145deg, #f2e7cf, #d7dfe5);
  }

  .scene-four .panel-art::after {
    width: 76px;
    height: 54px;
    background: #f5dc83;
  }

  .speech-bubble {
    position: absolute;
    z-index: 2;
    top: 22px;
    right: 22px;
    width: min(58%, 230px);
    padding: 14px 16px;
    border: 2px solid var(--ink);
    border-radius: 18px 18px 7px 18px;
    background: #fff;
    font-size: 0.78rem;
    font-weight: 750;
    line-height: 1.5;
  }

  .scene-two .speech-bubble {
    right: auto;
    left: 22px;
    border-radius: 18px 18px 18px 7px;
  }

  .panel-caption {
    min-height: 112px;
    padding: 17px 18px 19px;
    background: var(--paper);
  }

  .panel-caption small {
    display: block;
    margin-bottom: 7px;
    color: var(--accent-dark);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.05em;
  }

  .panel-caption p {
    font-size: 0.97rem;
    font-weight: 720;
    line-height: 1.75;
  }

  .word-token {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    margin: 1px 2px;
    padding: 0 8px;
    border: 1.5px solid var(--accent);
    border-radius: 9px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-weight: 900;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
  }

  .comic-actions {
    margin-top: 22px;
  }

  .comic-actions .primary-button {
    width: 100%;
  }

  .word-sheet {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid #edc7ac;
    border-radius: var(--radius-md);
    background: var(--accent-pale);
    animation: sheet-in 220ms ease both;
  }

  .word-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .word-sheet h2 {
    font-family: Georgia, serif;
    font-size: 1.55rem;
  }

  .word-sheet .part-of-speech {
    color: var(--ink-soft);
    font-size: 0.72rem;
    font-weight: 800;
  }

  .pronounce-button {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
  }

  .word-sheet .meaning {
    margin-top: 10px;
    font-weight: 850;
  }

  .word-sheet .english-example {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #edc7ac;
    color: var(--ink-soft);
    font-family: Georgia, serif;
    font-size: 0.9rem;
  }

  .card-screen {
    display: grid;
    align-content: start;
  }

  .card-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
    color: var(--ink-soft);
    font-size: 0.76rem;
    font-weight: 800;
  }

  .card-stage {
    position: relative;
    display: grid;
    min-height: 410px;
    place-items: center;
    margin-top: 14px;
    perspective: 1200px;
    touch-action: pan-y;
  }

  .study-card-shadow {
    position: absolute;
    width: min(84%, 350px);
    height: 350px;
    border: 2px solid #e7bd9e;
    border-radius: 30px;
    background: #fff5ed;
    transform: rotate(4deg) translate(7px, 8px);
  }

  .study-card {
    position: relative;
    width: min(88%, 370px);
    height: 360px;
    border: 2px solid var(--ink);
    border-radius: 30px;
    background: transparent;
    box-shadow: var(--shadow-md);
    transform-style: preserve-3d;
    transition: transform 420ms cubic-bezier(0.2, 0.78, 0.2, 1), opacity 180ms ease;
    user-select: none;
  }

  .study-card.is-flipped {
    transform: rotateY(180deg);
  }

  .study-card.is-dragging {
    transition: none;
  }

  .card-face {
    position: absolute;
    inset: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: 28px;
    overflow: hidden;
    border-radius: 27px;
    background: #fff;
    text-align: center;
    backface-visibility: hidden;
  }

  .card-back {
    align-content: start;
    transform: rotateY(180deg);
  }

  .card-context-label {
    padding: 6px 11px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 0.68rem;
    font-weight: 850;
  }

  .card-word {
    margin-top: 34px;
    font-family: Georgia, serif;
    font-size: clamp(2.1rem, 11vw, 3.35rem);
    line-height: 1;
  }

  .card-hint {
    margin-top: 18px;
    color: var(--ink-soft);
    font-size: 0.82rem;
  }

  .card-meaning {
    margin-top: 10px;
    color: var(--accent-dark);
    font-size: 1.35rem;
    font-weight: 900;
  }

  .context-thumbnail {
    position: relative;
    width: 100%;
    height: 112px;
    margin-top: 20px;
    overflow: hidden;
    border: 1.5px solid var(--ink);
    border-radius: 16px;
    background: #dfe5e7;
  }

  .context-thumbnail::before {
    position: absolute;
    bottom: -18px;
    left: 18px;
    width: 70px;
    height: 82px;
    border: 2px solid var(--ink);
    border-radius: 50% 50% 20px 20px;
    background: #f3c7a6;
    content: "";
  }

  .context-thumbnail::after {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 116px;
    height: 48px;
    border: 1.5px solid var(--ink);
    border-radius: 13px;
    background: #fff;
    content: "";
  }

  .card-example {
    margin-top: 16px;
    color: var(--ink-soft);
    font-family: Georgia, serif;
    font-size: 0.78rem;
    line-height: 1.5;
  }

  .swipe-overlay {
    position: absolute;
    z-index: 5;
    top: 36px;
    padding: 7px 12px;
    border: 3px solid currentColor;
    border-radius: 10px;
    background: rgb(255 255 255 / 88%);
    font-size: 0.9rem;
    font-weight: 950;
    opacity: 0;
    pointer-events: none;
  }

  .swipe-overlay-left {
    left: 24px;
    color: var(--danger);
    transform: rotate(-8deg);
  }

  .swipe-overlay-right {
    right: 24px;
    color: var(--success);
    transform: rotate(8deg);
  }

  .swipe-instructions {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    color: var(--ink-soft);
    font-size: 0.7rem;
    font-weight: 800;
  }

  .rating-actions {
    display: grid;
    grid-template-columns: 1fr 56px 1fr;
    gap: 10px;
    margin-top: 16px;
  }

  .rating-button {
    display: inline-flex;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1.5px solid;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 850;
  }

  .rating-button.is-unknown {
    border-color: #e4a18f;
    background: var(--danger-soft);
    color: var(--danger);
  }

  .rating-button.is-known {
    border-color: #8ec8ab;
    background: var(--success-soft);
    color: var(--success);
  }

  .undo-button {
    display: grid;
    min-width: 50px;
    min-height: 50px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
  }

  .quiz-card {
    margin-top: 24px;
    padding: 22px;
    border: 2px solid var(--ink);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: 7px 8px 0 var(--ink);
  }

  .quiz-card h2 {
    margin-top: 12px;
    font-family: Georgia, serif;
    font-size: 1.45rem;
    line-height: 1.45;
  }

  .quiz-options {
    display: grid;
    gap: 10px;
    margin-top: 22px;
  }

  .quiz-option {
    display: flex;
    min-height: 52px;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    border: 1.5px solid var(--line-dark);
    border-radius: 16px;
    background: #fff;
    text-align: left;
    font-weight: 750;
  }

  .quiz-option span {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 9px;
    background: #f1eee8;
    font-size: 0.72rem;
  }

  .quiz-option:hover:not(:disabled) {
    border-color: var(--accent);
    background: var(--accent-pale);
  }

  .quiz-option.is-correct {
    border-color: var(--success);
    background: var(--success-soft);
  }

  .quiz-option.is-wrong {
    border-color: var(--danger);
    background: var(--danger-soft);
  }

  .quiz-feedback {
    margin-top: 16px;
    padding: 13px 15px;
    border-radius: 15px;
    background: #f3f1ec;
    color: var(--ink-soft);
    font-size: 0.82rem;
  }

  .quiz-card .primary-button {
    width: 100%;
    margin-top: 18px;
  }

  .completion-screen {
    text-align: center;
  }

  .completion-seal {
    position: relative;
    display: grid;
    width: 116px;
    height: 116px;
    margin: 20px auto 0;
    place-items: center;
    border: 3px solid var(--accent);
    border-radius: 50%;
    background: var(--accent-pale);
    box-shadow: 0 0 0 10px #fff, 0 0 0 12px #edc7ac;
  }

  .completion-seal strong,
  .completion-seal span {
    display: block;
  }

  .completion-seal strong {
    font-family: Georgia, serif;
    font-size: 1.8rem;
  }

  .completion-seal span {
    color: var(--accent-dark);
    font-size: 0.7rem;
    font-weight: 850;
  }

  .completion-screen .screen-title {
    margin-top: 28px;
  }

  .completion-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
    margin-top: 24px;
  }

  .stat-card {
    padding: 15px 8px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
  }

  .stat-card strong,
  .stat-card span {
    display: block;
  }

  .stat-card strong {
    font-size: 1.35rem;
  }

  .stat-card span {
    margin-top: 3px;
    color: var(--ink-soft);
    font-size: 0.68rem;
    font-weight: 750;
  }

  .completion-route {
    position: relative;
    display: flex;
    justify-content: space-between;
    margin-top: 28px;
    padding: 0 5px;
  }

  .completion-route::before {
    position: absolute;
    top: 13px;
    right: 22px;
    left: 22px;
    height: 4px;
    border-radius: 999px;
    background: var(--accent);
    content: "";
  }

  .route-point {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    gap: 6px;
    color: var(--ink-soft);
    font-size: 0.65rem;
    font-weight: 800;
  }

  .route-point::before {
    width: 28px;
    height: 28px;
    border: 6px solid var(--accent-soft);
    border-radius: 50%;
    background: var(--accent);
    content: "";
  }

  .next-review-card {
    margin-top: 28px;
    padding: 17px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #f5f3ef;
    text-align: left;
  }

  .next-review-card span,
  .next-review-card strong {
    display: block;
  }

  .next-review-card span {
    color: var(--ink-soft);
    font-size: 0.72rem;
    font-weight: 750;
  }

  .next-review-card strong {
    margin-top: 5px;
  }

  .completion-screen .button-row {
    margin-top: 20px;
  }

  .empty-state {
    display: grid;
    min-height: 70vh;
    place-items: center;
    padding: 24px;
    text-align: center;
  }

  .empty-state > div {
    max-width: 330px;
  }

  .empty-state h1 {
    margin-top: 18px;
    font-size: 1.5rem;
  }

  .empty-state p {
    margin-top: 8px;
    color: var(--ink-soft);
  }
}

@layer utilities {
  .visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  @keyframes screen-in {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
  }

  @keyframes sheet-in {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
  }

  @keyframes toast-in {
    from {
      opacity: 0;
      transform: translateY(8px) scale(0.98);
    }
  }

  @media (min-width: 700px) {
    body {
      padding-block: 26px;
    }

    .app-frame {
      min-height: calc(100svh - 52px);
      border: 1px solid rgb(24 32 51 / 14%);
      border-radius: 34px;
      box-shadow: 0 32px 90px rgb(24 32 51 / 18%);
    }

    .app-header {
      border-radius: 34px 34px 0 0;
    }

    .network-status {
      display: inline-flex;
    }
  }

  @media (max-width: 370px) {
    .screen {
      padding-right: 15px;
      padding-left: 15px;
    }

    .brand-copy small,
    .step-status {
      display: none;
    }

    .journey-step {
      grid-template-columns: 48px 1fr;
    }

    .rating-actions {
      grid-template-columns: 1fr 50px 1fr;
      gap: 7px;
    }

    .rating-button {
      font-size: 0.72rem;
    }
  }

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