/* The art-only reference keeps its original proportions. Product screens reflow with the reader's font size. */
:root {
  --type-caption: .9375rem;
  --type-body: 1.125rem;
  --type-control: 1.0625rem;
  --type-heading: clamp(1.625rem, 1.3rem + 2cqw, 2rem);
  --type-korean: clamp(1.625rem, 1.3rem + 2.2cqw, 2.125rem);
  --tap-size: 48px;
}
/* Use regional glyphs for shared Han characters and keep Korean examples in the study font. */
:root:lang(en), [lang|=en] { font-family: "Pretendard Variable", system-ui, "Avenir Next", Arial, sans-serif; }
:root:lang(ja), [lang|=ja] { font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans CJK JP", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif; }
:root:lang(zh-Hant), [lang|=zh-Hant] { font-family: "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
:root:lang(ko), [lang|=ko], .wordmark small[lang|=ko] { font-family: "Pretendard Variable", "Apple SD Gothic Neo", "Noto Sans CJK KR", "Noto Sans KR", "Malgun Gothic", sans-serif; }
body { font-size: var(--type-body); line-height: 1.55; }
.layout:has(> .app-nav:not([hidden])) {min-height:calc(100dvh - var(--safe-top))}
.layout { container-type: inline-size; display: flex; flex-direction: column; padding-bottom: 0; }
.layout:has(> .app-nav:not([hidden])) > .cab:is([data-view=placement],[data-view=letters]),
.layout:has(> .app-nav:not([hidden])) > .cab:is([data-view=placement],[data-view=letters]) .cab-content { display: flex; flex: 1; }
.layout:has(> .app-nav:not([hidden])) .start-page { min-height: 0; flex: 1; }
.cab { flex: none; }
.layout:has(> .cab[data-view=reference]) {max-width:470px}
.layout:has(> .cab[data-view=reference]) .app-nav { position: static; }
.cab:not([data-view=reference]), .panel, .app-nav {
  overflow-wrap: anywhere;
  word-break: normal;
  line-break: strict;
}
:where(.cab:not([data-view=reference]), .panel, .app-nav) :lang(ko) { word-break: keep-all; }
:where(.cab:not([data-view=reference]), .panel, .app-nav) :is(button, select, summary, input) {
  max-inline-size: 100%;
  min-inline-size: min(var(--tap-size), 100%);
  line-height: 1.4;
  font-family: inherit;
}
:where(.cab:not([data-view=reference]), .panel, .app-nav) :is(button, select, summary) { min-block-size: var(--tap-size); }
:where(.cab, .panel, .app-nav) :is(button, summary, a, select, input):focus-visible {
  outline: 3px solid #273ca5;
  outline-offset: 3px;
}
.start-page header, .brand-row, .boarding-top, .route-heading, .start-progress,
.letter-sound, .setting, .pass-art footer, .trip-breakdown { flex-wrap: wrap; }
.wordmark { min-inline-size: 0; }
.wordmark > span:last-child { font-size: 1.625rem; line-height: 1.12; }
.wordmark small { font-size: var(--type-caption); letter-spacing: .015em; }
.wallet-chip { min-height: var(--tap-size); }
.wallet-chip b { font-size: var(--type-control); }
.start-page header small, .start-progress, .station-board small, .station-center > span,
.cab-sign .station-center > span, .route-heading small, .day-goal, .trip-breakdown,
.stop-plaque small, .boarding-pass .pass-route, .start-ticket .letter-note,
.start-ticket .stroke-count, .pass-art footer, .pass-art > small, .ink-chip small,
.word-reading, .test-caption, .transcript small, .ink-model small { font-size: var(--type-caption); line-height: 1.45; }
.start-page .start-ticket h1, .boarding-pass h1, .test-card h1, .route-heading h1, .panel h2 {
  font-size: var(--type-heading);
  line-height: 1.25;
  letter-spacing: -.035em;
  word-break: normal;
}
:where(.start-ticket, .boarding-pass, .test-card, .route-heading, .panel) :is(h1,h2):lang(ko) { word-break: keep-all; }
.start-ticket p, .boarding-pass h1 + p, .guide-place, .point-rules li, .panel h3 { font-size: var(--type-body); line-height: 1.55; }
.boarding-top select, .course-option, .start-solid, .start-outline, .start-text,
.ink-chip, .depart-button, .mode-link, .answer-field, .undo, .answer-tile,
.traveler-choice b, .panel button:not(.close-panel), .panel select, .map-album, .guide-toggle {
  min-height: var(--tap-size);
  font-size: var(--type-control);
  line-height: 1.4;
}
.traveler-choice b { min-height: 0; }
.depart-button { padding: .65em .85em; }
.start-text, .mode-link { text-align: start; }
.character-options { grid-template-columns: repeat(auto-fit, minmax(min(100%, 7rem), 1fr)); }
.traveler-choice { min-width: 0; grid-template-columns: minmax(0, 1fr) auto; gap: .25em; }
.ink-chip small { margin-top: .15em; }
.letter-sound > b, .ink-model b, .test-result span:lang(ko), .dialogue b:lang(ko),
.assembled:lang(ko), .course-option:lang(ko), .answer-tile:lang(ko), .guide-example, .album-item p:lang(ko),
.test-hint > span:lang(ko), .transcript b:lang(ko), .built-answer output:lang(ko), .answer-field:lang(ko) {
  font-size: var(--type-korean); line-height: 1.42;
}
.letter-block { width: min(100%, 15rem); height: auto; min-height: min(55cqw, 12rem); padding: .4em; }
.letter-block strong { font-size: 4rem; }
.letter-block span { font-size: 1.5rem; }

/* The current station and its neighbours form one transit sign even on a narrow screen. */
.station-board, .cab-sign .station-board { grid-template-columns: minmax(min-content,1fr) minmax(0,1.45fr) minmax(min-content,1fr); text-align: center; }
.station-board .neighbor, .station-board .station-center { min-width: 0; padding: .4rem .2rem; }
.station-board .neighbor:lang(en) { overflow-wrap: normal; }
.station-board .neighbor b { font-size: 1.0625rem; line-height: 1.25; }
.station-board .station-center strong:lang(ko) { font-size: var(--type-korean); line-height: 1.2; }
.station-board .station-center > span { white-space: normal; }
.route-heading { display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-areas: 'context goal' 'title title'; align-items: center; gap: .45rem .75rem; }
.route-heading > div { display: contents; }
.route-heading small { grid-area: context; }
.route-heading h1 { grid-area: title; margin: 0; }
.day-goal { grid-area: goal; align-items: center; display: flex; flex-wrap: wrap; gap: .1rem .4rem; max-width: 9rem; }

.day-goal b { font-size: var(--type-body); }
.depart { position: relative; bottom: auto; }

/* Navigation occupies its own row in the document, including when labels need a second line. */
.app-nav {
  position: sticky; inset: auto 0 0; transform: none; width: 100%; margin-top: auto;
  grid-template-columns: repeat(5,minmax(0,1fr)); gap: 2px; min-height: 0;
}
.app-nav .nav-tab { overflow-wrap: normal; font-weight: 700; min-height: var(--tap-size); font-size: var(--type-control); line-height: 1.25; padding: 4px 2px; }

/* Learning and reward cards share a train-car frame. Only the artwork is layered. */
.cab:is([data-view=lesson], [data-view=reward], [data-view=story]) { aspect-ratio: auto; overflow: visible; }
.cab:is([data-view=lesson], [data-view=reward], [data-view=story]) > .cab-art { display: none; }
.cab[data-view=story] .cab-content { position: relative; }
.cab:is([data-view=lesson], [data-view=reward]) .cab-content {
  position: relative; inset: auto; display: grid; align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'sign sign' 'track count' 'card card' 'foot foot';
  gap: .65rem .5rem; padding: .9rem clamp(10px,4cqw,20px) .75rem;
  background: linear-gradient(100deg, #65cfa9, #94edc7 50%, #65cfa9);
  isolation: isolate;
}
.cab-sign { grid-area: sign; position: relative; inset: auto; height: auto; border-radius: 2rem; }
.cab:not([data-view=reference]) .station-count {
  grid-area: count; position: static; width: auto; height: auto; padding: .2em .65em;
  font-size: var(--type-caption); line-height: 1.4; border-width: 2px;
}
.cab:not([data-view=reference]) .progress-track {
  grid-area: track; position: relative; inset: auto; height: 1.65rem; padding: 0 .55rem; gap: 1px; border-width: 2px;
}
.progress-track span { width: min(.8rem, 6%); border-width: 1.5px; }
.progress-track.long span { width: min(.58rem, 4%); border-width: 1px; }
.learn-card {
  grid-area: card; position: relative; inset: auto; width: auto; height: auto; min-width: 0; overflow: visible;
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: .8rem .5rem;
  padding: .65rem; border: 3px solid var(--ink); border-radius: 1.6rem;
  box-shadow: 3px 5px #26986b, inset 2px 2px #e5e6df;
}
.learn-card > .card-photo, .reward-content .reward-photo { width: 100%; height: auto; min-height: 0; aspect-ratio: 1.9; }
.learn-card > .card-photo { grid-column: 1 / -1; }
.card-photo:has(.photo-ticket) { display: grid; align-content: start; justify-items: end; }
.card-photo:has(.photo-ticket) > img { position: absolute; inset: 0; z-index: -1; }
.photo-ticket {
  position: relative; inset: auto; max-width: calc(100% - 1rem); margin: .5rem; padding: .2em .55em;
  font-size: var(--type-caption); line-height: 1.35; transform: rotate(2deg);
}
.word-info, .word-info:has(.phrase) { padding: 0 0 .35rem .3rem; }
.word-info h1, .word-info h1.phrase { font-size: var(--type-korean); letter-spacing: -.035em; line-height: 1.35; margin: 0 0 .3em; }
.word-info h1:not(.phrase) { font-size: clamp(2rem, 1.55rem + 3.5cqw, 2.75rem); }
.word-info p, .word-info:has(.phrase) p { font-size: var(--type-body); line-height: 1.5; font-weight: 650; }
.listener {
  position: static; width: max(48px, 3.25rem); height: auto; margin: 0 .2rem .35rem 0;
  border: 2px solid var(--ink); box-shadow: 2px 3px #57ce9d;
}
.speaker-glyph { width: 1.7rem; height: 1.6rem; }
.reward-content { display: flex; flex-direction: column; gap: .65rem; padding: 1rem; }
.reward-content h1 { font-size: var(--type-heading); line-height: 1.25; margin: 0; }
.reward-content > p { font-size: var(--type-korean); line-height: 1.45; }
.reward-tag { font-size: var(--type-control); padding: .25em .9em; }
.platform-floor { grid-area: foot; position: absolute; inset: 0 calc(-1 * clamp(10px,4cqw,20px)) -.75rem; z-index: -1; }
.platform-guide { grid-area: foot; position: static; width: 20%; align-self: end; height: auto; max-height: 6rem; }
.next-button {
  grid-area: foot; position: static; width: 76%; height: auto; min-height: var(--tap-size); justify-self: end;
  font-size: 1.25rem; line-height: 1.4; border-width: 2px; border-radius: 1.4rem; padding: .55em .7em .75em;
}
.next-button span { font-size: 1.5rem; }
.cab:not([data-view=reference]) .flash-note, .cab[data-view=test] .flash-note {
  position: static; transform: none; width: auto; grid-column: 1 / -1; display: block;
  margin: .5rem; padding: .45em .6em; border: 2px solid var(--ink); font-size: var(--type-body); line-height: 1.45;
}

/* Dialogues, settings and feedback can grow to accommodate translated instructions. */
.conversation-prompt { flex-wrap: wrap; }
.conversation-prompt .dialogue { flex: 1 1 10rem; min-width: 0; text-align: start; }
.mode-links { gap: .25rem .75rem; }
.test-card h2 { font-size: 1.375rem; line-height: 1.45; }
.field-label, .test-hint, .test-result, .mic-note { font-size: var(--type-body); line-height: 1.5; }
.built-answer { flex-wrap: wrap; }
.answer-field::placeholder { font-size: var(--type-control); }
.panel {
  --dialog-gutter:clamp(8px,3vw,12px);
  max-width:100%;
  position:fixed;
  inset:calc(var(--visual-top,0px) + var(--safe-top) + var(--dialog-gutter))
    calc(var(--safe-right) + var(--dialog-gutter)) calc(var(--visual-bottom,0px) + var(--safe-bottom) + var(--dialog-gutter))
    calc(var(--safe-left) + var(--dialog-gutter));
  margin:auto;
  width:min(27rem,calc(100% - var(--safe-left) - var(--safe-right) - 2 * var(--dialog-gutter)));
  max-height:calc(var(--visual-height,100dvh) - var(--safe-top) - var(--safe-bottom) - 2 * var(--dialog-gutter));
  padding:clamp(12px,4vw,23px);
}
.panel .close-panel { width: var(--tap-size); height: var(--tap-size); font-size: 1.625rem; }
.panel h2 { padding-inline-end: 44px; min-block-size: var(--tap-size); }
.panel select { width: auto; min-width: 0; max-width: 100%; }
.panel details > summary, .choose-other > summary, .test-hint > summary { align-content: center; padding-block: .42em; }
.pass-art > strong { font-size: 2.5rem; }
.pass-art > div b, .pass-art i { font-size: var(--type-body); }
.point-rules li { align-items: baseline; }
.point-rules .ui-icon { align-self: center; }
.point-rules b { flex: none; }
.guide-place a { display: inline-block; align-content: center; min-height: var(--tap-size); }

@container (max-width: 22rem) {
  .station-board, .cab-sign .station-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .station-board .station-center { grid-column: 1 / -1; grid-row: 1; border-bottom: 1px solid #a1b6a4; }
  .station-center::before, .station-center::after { display: none; }
  .station-board .neighbor { padding-inline: .3rem; }
  .station-board .neighbor:lang(en) { overflow-wrap: anywhere; }
}
@container (max-width: 18rem) {
  .route-heading { grid-template-columns: minmax(0,1fr); grid-template-areas: 'context' 'title' 'goal'; }
  .day-goal { max-width: 100%; }
  .app-nav .nav-tab { overflow-wrap: anywhere; }
  .app-nav { position: static; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .learn-card { grid-template-columns: minmax(0,1fr); }
  .listener { justify-self: end; }
  .platform-guide { width: 18%; }
}

.wallet-chip > span { font-size: 1.25rem; }
.reward-content { font-size: var(--type-body); }
:is(.reward-photo, .album-art) .signed-tag:has(b) {
  width: auto; height: auto; max-width: 65%; max-height: none; min-height: 1.4em;
  padding-inline: .4em; font-size: var(--type-caption); line-height: 1.35;
}
.traveler-choice > span { width: max(22px, 1.45rem); height: max(22px, 1.45rem); line-height: 1; }

.trip-option { padding-block: .8rem; border-block-start: 1px dashed #96a38e; }
.panel .trip-option h3 { margin: 0; }
.panel .trip-option p { margin: .4em 0 .65em; }
.start-ticket > .card-photo { width: 100%; height: auto; min-height: 0; aspect-ratio: 1.85; border-radius: .8rem; }
.story-illustration {
  background-color: #bee8d1;
  background-image: radial-gradient(ellipse at 23% 82%, #a1d6b7 0 12%,transparent 12.5%),
    linear-gradient(180deg,transparent 68%,#3b705b 68% 70%,#ffe493 70% 75%,#e6d8bb 75% 100%),
    repeating-linear-gradient(112deg,#a6dec4 0 14px,#c5eed7 15px 48px);
}
.story-illustration > img.traveler { z-index: -1; position: absolute; inset: auto auto 7% 7%; width: 40%; height: 78%; object-fit: contain; }
:is(.reward-photo,.album-art) .story-illustration > .traveler { display: none; }
/* A large caption gets its own row so the scene and the traveler's name remain visible. */
@container (max-width: 22rem) {
  .start-ticket > .card-photo:has(.photo-ticket), .learn-card > .card-photo:has(.photo-ticket),
  .reward-content .reward-photo .card-photo:has(.photo-ticket) {
    display: flex; flex-direction: column-reverse; align-items: start;
    height: auto; min-height: 0; aspect-ratio: auto; background-color: #fff3c7;
  }
  .card-photo:has(.photo-ticket) > img { position: static; z-index: auto; width: 100%; height: auto; aspect-ratio: 1.95; object-fit: cover; }
  .card-photo:has(.photo-ticket) > .photo-ticket { max-width: calc(100% - .75rem); margin: .35rem; transform: none; }
  .reward-content .reward-photo:has(.photo-ticket) { height: auto; aspect-ratio: auto; }
  .reward-photo .reward-guide { width: 22%; height: auto; max-height: 30cqw; }
  .card-photo.story-illustration > img.traveler { width: 100%; height: 32cqw; object-fit: contain; }
  .reward-photo .story-illustration:has(.photo-ticket)::before { content: ''; width: 100%; height: 32cqw; }
}

@media (max-height:500px) { .layout > .app-nav {position:static} }
:root[data-ime-overlap] .layout > .app-nav {position:static}
