:root {
  color-scheme: light;
  --paper: #f7f3ea;
  --paper-strong: #fffdf7;
  --ink: #252525;
  --soft-ink: #6f6a63;
  --shade: #ddd7cc;
  --warning: #d95d55;
  --line: #00a84d;
  --focus: #1268d3;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --app-height: 100dvh;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

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

canvas:focus-visible {
  outline-offset: -5px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  min-height: 100dvh;
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 14px 11px, rgba(37, 37, 37, 0.035) 1.2px, transparent 1.6px);
  background-size: 22px 22px;
}

.screen {
  min-height: 100dvh;
}

.loading-screen {
  display: grid;
  place-content: center;
  gap: 20px;
  text-align: center;
  font-weight: 800;
}

.loading-mark {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.loading-mark span {
  width: 14px;
  height: 14px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  animation: loading-bob 0.85s infinite alternate;
}

.loading-mark span:nth-child(2) { animation-delay: 0.14s; }
.loading-mark span:nth-child(3) { animation-delay: 0.28s; }

.opening {
  position: relative;
  display: grid;
  grid-template-rows: minmax(300px, 56vh) 1fr;
  overflow: hidden;
  padding-top: var(--safe-top);
}

.opening__skip {
  position: absolute;
  z-index: 5;
  top: calc(14px + var(--safe-top));
  right: calc(16px + var(--safe-right));
  min-height: 44px;
  padding: 8px 13px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.92);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.opening__carriage {
  position: relative;
  align-self: stretch;
  min-height: 300px;
  overflow: hidden;
  border-bottom: 5px solid var(--ink);
  background: #eee8dc;
}

.opening__rail {
  position: absolute;
  inset: 22px 0 auto;
  height: 16px;
  border-block: 4px solid var(--ink);
}

.opening__rail i {
  position: absolute;
  top: 14px;
  width: 4px;
  height: 72px;
  background: var(--ink);
}

.opening__rail i::after {
  content: "";
  position: absolute;
  left: -17px;
  bottom: -28px;
  width: 36px;
  height: 28px;
  border: 4px solid var(--ink);
  border-radius: 12px 12px 18px 18px;
  background: var(--paper);
}

.opening__rail i:nth-child(1) { left: 10%; }
.opening__rail i:nth-child(2) { left: 30%; }
.opening__rail i:nth-child(3) { left: 50%; }
.opening__rail i:nth-child(4) { left: 70%; }
.opening__rail i:nth-child(5) { left: 90%; }

.opening__window {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 104px;
  height: 112px;
  border: 5px solid var(--ink);
  background: #dfe9e8;
}

.opening__window::after {
  content: "";
  position: absolute;
  inset: 0 50%;
  border-left: 4px solid var(--ink);
}

.opening__seat {
  position: absolute;
  left: 17%;
  right: 17%;
  bottom: 22px;
  height: 116px;
  border: 5px solid var(--ink);
  border-radius: 24px 24px 10px 10px;
  background: #c6b4a1;
}

.opening-person {
  position: absolute;
  bottom: 34px;
  width: 72px;
  height: 100px;
  border: 5px solid var(--ink);
  border-radius: 32px 32px 20px 20px;
  background: #e8dfce;
}

.opening-person::before {
  content: "";
  position: absolute;
  top: -62px;
  left: 5px;
  width: 52px;
  height: 52px;
  border: 5px solid var(--ink);
  border-radius: 50%;
  background: #eccbb1;
}

.opening-person::after {
  content: "•  •";
  position: absolute;
  top: -48px;
  left: 14px;
  font-weight: 900;
  letter-spacing: 8px;
}

.opening-person--one { left: 10%; }
.opening-person--target {
  left: 50%;
  transform: translateX(-50%);
  background: #7b8798;
}
.opening-person--three { right: 10%; }

.opening-phone {
  position: absolute;
  top: 14px;
  right: 4px;
  width: 24px;
  height: 42px;
  border: 4px solid var(--ink);
  border-radius: 5px;
  background: #d9e8df;
  animation: opening-phone 1.1s 1.05s both;
}

.opening-player {
  position: absolute;
  left: 11%;
  bottom: 24px;
  display: grid;
  place-items: center;
  width: 76px;
  height: 164px;
  border: 7px solid var(--ink);
  border-radius: 38px 38px 22px 22px;
  background: repeating-linear-gradient(
    0deg,
    #e9e0cf 0 9px,
    #cfc4b3 9px 12px
  );
  font-weight: 900;
}

.opening__bubble {
  position: absolute;
  z-index: 2;
  margin: 0;
  padding: 12px 18px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: var(--paper-strong);
  font-size: clamp(20px, 4vw, 36px);
  font-weight: 900;
  opacity: 0;
}

.opening__bubble::after {
  content: "";
  position: absolute;
  bottom: -18px;
  width: 22px;
  height: 22px;
  border-right: 4px solid var(--ink);
  border-bottom: 4px solid var(--ink);
  background: var(--paper-strong);
  transform: rotate(45deg);
}

.opening__bubble--one {
  top: 18%;
  left: 25%;
  animation: bubble-in 0.28s 0.25s forwards;
}

.opening__bubble--two {
  top: 38%;
  right: 14%;
  animation: bubble-in 0.28s 1.05s forwards;
}

.opening__title {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 22px max(20px, var(--safe-right)) calc(22px + var(--safe-bottom));
  text-align: center;
  opacity: 0;
  transform: translateY(18px);
  animation: title-in 0.38s 1.85s forwards;
}

.opening__eyebrow,
.opening__hook,
.opening__best {
  margin: 0;
}

.opening__eyebrow {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.opening__title h1 {
  margin: 0;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: clamp(38px, 7vw, 72px);
  font-weight: 1000;
  letter-spacing: -0.07em;
}

.opening__hook {
  color: var(--soft-ink);
  font-size: 15px;
  font-weight: 800;
}

.opening__secondary,
.result__retry {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 20px;
}

.opening__best {
  color: var(--soft-ink);
  font-size: 13px;
  font-weight: 700;
}

.opening.is-ready .opening__bubble,
.opening.is-ready .opening__title,
.opening.is-ready .opening-phone {
  animation-delay: 0s;
  animation-duration: 0.01s;
}

.comic-button {
  min-height: 48px;
  padding: 11px 20px;
  border: 4px solid var(--ink);
  border-radius: 10px;
  background: var(--paper-strong);
  box-shadow: 5px 5px 0 var(--ink);
  font-weight: 900;
  cursor: pointer;
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.comic-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 7px 7px 0 var(--ink);
}

.comic-button:active {
  transform: translate(4px, 4px);
  box-shadow: 1px 1px 0 var(--ink);
}

.comic-button--primary {
  background: var(--line);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

.comic-button--danger {
  background: #f4d6d3;
}

.text-button {
  min-height: 44px;
  padding: 7px 2px 4px;
  border: 0;
  border-bottom: 3px solid var(--ink);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
}

.game {
  height: 100dvh;
  min-height: 380px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  padding:
    var(--safe-top)
    var(--safe-right)
    var(--safe-bottom)
    var(--safe-left);
  background: #e9e4d9;
}

.hud {
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(130px, 1.2fr) auto minmax(130px, 0.8fr) 48px;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 8px 12px;
  border-bottom: 4px solid var(--ink);
  background: var(--paper);
}

.hud__route {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
  font-weight: 900;
}

.hud__route span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-dot {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--line);
}

.hud__numbers {
  display: flex;
  gap: 6px;
  margin: 0;
}

.hud__numbers div {
  min-width: 62px;
  padding: 4px 8px;
  border-inline-start: 2px solid var(--shade);
  text-align: center;
}

.hud__numbers dt,
.result-stats dt {
  color: var(--soft-ink);
  font-size: 10px;
  font-weight: 900;
}

.hud__numbers dd,
.result-stats dd {
  margin: 1px 0 0;
  font-variant-numeric: tabular-nums;
  font-weight: 1000;
}

.face-meter {
  min-width: 110px;
}

.face-meter__label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 900;
}

.face-meter__track {
  height: 14px;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #e2dcd0;
}

.face-meter__track span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--line);
  transition: width 120ms linear, background-color 200ms ease;
}

.icon-button {
  width: 46px;
  height: 46px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-strong);
  font-weight: 1000;
  cursor: pointer;
}

.stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
  touch-action: none;
  user-select: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.signal-ticker {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%) translateY(18px);
  max-width: min(86%, 560px);
  margin: 0;
  padding: 8px 13px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: rgba(255, 253, 247, 0.92);
  font-size: 13px;
  font-weight: 900;
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
}

.signal-ticker.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.tutorial-coach {
  position: absolute;
  right: 16px;
  bottom: 18px;
  width: min(340px, calc(100% - 32px));
  padding: 14px 16px;
  border: 4px solid var(--ink);
  border-radius: 18px 18px 5px 18px;
  background: var(--paper-strong);
  box-shadow: 7px 7px 0 var(--ink);
}

.tutorial-coach span {
  color: var(--soft-ink);
  font-size: 11px;
  font-weight: 900;
}

.tutorial-coach strong {
  display: block;
  margin: 4px 0;
  font-size: 17px;
}

.tutorial-coach p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.tutorial-coach button {
  position: absolute;
  top: 8px;
  right: 9px;
  min-height: 34px;
  border: 0;
  border-bottom: 2px solid var(--ink);
  background: transparent;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.seat-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 220px;
  padding: 16px 20px;
  border: 5px solid var(--ink);
  border-radius: 18px;
  background: var(--paper-strong);
  box-shadow: 8px 8px 0 var(--ink);
  text-align: center;
  font-size: 20px;
  font-weight: 1000;
  transform: translate(-50%, -50%) rotate(-1deg);
}

.game-footer {
  min-height: 42px;
  padding: 5px 12px;
  border-top: 4px solid var(--ink);
  background: var(--paper);
  text-align: center;
}

.game-footer p {
  margin: 5px;
  color: var(--soft-ink);
  font-size: 11px;
  font-weight: 700;
}

kbd {
  padding: 1px 5px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-weight: 900;
}

.touch-controls {
  display: none;
  justify-content: center;
  gap: 8px;
}

.touch-controls button {
  min-width: 58px;
  min-height: 44px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--paper-strong);
  font-weight: 900;
}

.result {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 20px;
  padding:
    calc(28px + var(--safe-top))
    max(18px, var(--safe-right))
    calc(42px + var(--safe-bottom))
    max(18px, var(--safe-left));
  overflow-y: auto;
}

.result__header {
  text-align: center;
}

.result__kicker,
.result__score {
  margin: 0;
}

.result__kicker {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.result__header h2 {
  margin: 8px 0 2px;
  font-size: clamp(26px, 5vw, 50px);
  letter-spacing: -0.05em;
}

.result__score {
  display: inline;
  font-size: clamp(64px, 12vw, 120px);
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
}

.result__header > span {
  font-size: 22px;
  font-weight: 900;
}

.result__body {
  width: min(760px, 100%);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0;
}

.result-stats div {
  padding: 14px 8px;
  border-block: 3px solid var(--ink);
  text-align: center;
}

.result-stats dd {
  font-size: 22px;
}

.result__comment {
  margin: 18px 0 0;
  text-align: center;
  font-weight: 800;
}

.community-post {
  width: min(720px, 100%);
  border: 5px solid var(--ink);
  background: var(--paper-strong);
  box-shadow: 9px 9px 0 var(--ink);
}

.community-post__bar {
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 4px solid var(--ink);
  background: #e6dfd2;
  font-size: 12px;
  font-weight: 900;
}

.community-post h3,
.community-post > p {
  margin: 16px;
}

.community-post__scene {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 220px;
  border-block: 3px solid var(--ink);
  background: #eee9df;
}

.post-person {
  display: grid;
  place-items: center;
  width: 96px;
  height: 170px;
  border: 6px solid var(--ink);
  border-radius: 48px 48px 20px 20px;
  background: repeating-linear-gradient(0deg, #d8cebc 0 12px, #ece4d6 12px 16px);
  font-weight: 1000;
}

.community-post__scene i {
  position: absolute;
  top: 42px;
  font-size: 42px;
  font-style: normal;
  font-weight: 900;
}

.community-post__scene i:nth-of-type(1) { left: 18%; }
.community-post__scene i:nth-of-type(2) { right: 18%; }

.community-post ul {
  margin: 12px 16px 18px;
  padding: 0;
  list-style: none;
}

.community-post li {
  padding: 8px 9px;
  border-top: 1px solid var(--shade);
  font-size: 13px;
}

.result__share-preview {
  width: min(270px, 78vw);
  max-height: 380px;
  overflow: hidden;
  border: 4px solid var(--ink);
  background: #fff;
  box-shadow: 7px 7px 0 var(--ink);
}

#result-card-preview {
  display: block;
  width: 100%;
  height: auto;
}

.result__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.manual-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: min(720px, 100%);
  font-size: 12px;
  font-weight: 900;
}

.manual-link input {
  min-width: 0;
  height: 44px;
  padding: 8px 10px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--paper-strong);
}

.comic-dialog {
  width: min(440px, calc(100% - 30px));
  padding: 0;
  border: 5px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
}

.comic-dialog::backdrop {
  background: rgba(37, 37, 37, 0.62);
}

.comic-dialog form {
  display: grid;
  gap: 14px;
  padding: 22px;
  text-align: center;
}

.comic-dialog h2,
.comic-dialog p {
  margin: 0;
}

.comic-dialog h2 {
  font-size: 24px;
}

.comic-dialog p {
  color: var(--soft-ink);
  line-height: 1.55;
}

.dialog-illustration {
  font-size: 40px;
  font-weight: 900;
}

.dialog-small {
  font-size: 12px;
  font-weight: 900;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 48px;
  padding: 6px 2px;
  border-bottom: 2px solid var(--shade);
  text-align: left;
  font-weight: 800;
}

.setting-row input[type="checkbox"] {
  width: 26px;
  height: 26px;
  accent-color: var(--line);
}

.setting-row--range {
  grid-template-columns: 1fr minmax(130px, 44%);
}

.setting-row input[type="range"] {
  accent-color: var(--line);
}

.settings-dialog__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

body.is-high-contrast {
  --paper: #fffdf7;
  --ink: #0d0d0d;
  --soft-ink: #343434;
  --shade: #8b8b8b;
}

body.is-low-face .hud {
  box-shadow: inset 0 -5px 0 var(--warning);
}

@media (max-width: 700px) {
  .opening {
    grid-template-rows: minmax(330px, 58vh) 1fr;
  }

  .opening__seat {
    left: 8%;
    right: 8%;
  }

  .opening-player {
    left: 5%;
    width: 58px;
  }

  .opening__bubble--one {
    left: 8%;
  }

  .opening__bubble--two {
    right: 5%;
  }

  .hud {
    grid-template-columns: minmax(96px, 1fr) auto 96px 42px;
    gap: 5px;
    min-height: 68px;
    padding-inline: 7px;
  }

  .hud__route {
    font-size: 11px;
  }

  .hud__numbers div {
    min-width: 48px;
    padding-inline: 4px;
  }

  .hud__numbers div:nth-child(3) {
    display: none;
  }

  .face-meter {
    min-width: 80px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .game-footer p {
    display: none;
  }

  .touch-controls {
    display: flex;
  }

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

  .result__actions {
    display: grid;
    width: min(420px, 100%);
  }
}

@media (orientation: portrait) and (max-width: 700px) {
  .opening__carriage {
    min-height: 350px;
  }

  .tutorial-coach {
    right: 12px;
    bottom: 14px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .opening {
    grid-template-columns: 58% 42%;
    grid-template-rows: 100dvh;
  }

  .opening__carriage {
    min-height: 100%;
    border-right: 5px solid var(--ink);
    border-bottom: 0;
  }

  .opening__title {
    align-self: stretch;
    padding-block: 12px;
  }

  .opening__title h1 {
    font-size: clamp(34px, 6vw, 52px);
  }

  .opening__hook {
    display: none;
  }

  .opening__seat {
    bottom: 28px;
  }

  .hud {
    min-height: 58px;
    padding-block: 4px;
  }

  .game-footer {
    min-height: 36px;
  }

  .touch-controls button {
    min-height: 38px;
  }

  .result {
    grid-template-columns: minmax(300px, 1fr) minmax(260px, 0.8fr);
    align-items: start;
    gap: 14px 24px;
  }

  .result__header,
  .result__body,
  .community-post {
    grid-column: 1;
  }

  .result__share-preview,
  .result__actions,
  .manual-link,
  .result__retry {
    grid-column: 2;
  }

  .result__share-preview {
    grid-row: 1 / span 2;
  }
}

@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;
  }
}

body.is-reduced-motion *,
body.is-reduced-motion *::before,
body.is-reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

@keyframes loading-bob {
  to { transform: translateY(-10px); }
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes title-in {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes opening-phone {
  0% { transform: translateY(0); }
  60% { transform: translateY(22px) rotate(-8deg); opacity: 1; }
  100% { transform: translateY(36px) rotate(-11deg); opacity: 0; }
}

/* -------------------------------------------------------------------------- */
/* Transit interface refresh                                                   */
/* -------------------------------------------------------------------------- */

:root {
  --line: #00a84f;
  --line-mist: color-mix(in srgb, var(--line), white 92%);
  --line-wash: color-mix(in srgb, var(--line), white 86%);
  --line-veil: color-mix(in srgb, var(--line), transparent 91%);
  --line-deep: color-mix(in srgb, var(--line), #10231e 22%);
  --paper: var(--line-mist);
  --paper-strong: #ffffff;
  --ink: #17342d;
  --soft-ink: #708c82;
  --shade: color-mix(in srgb, var(--line), white 84%);
  --warning: #ec806c;
  --focus: #0069d9;
  --panel-shadow: 0 18px 50px rgba(23, 52, 45, 0.13);
  font-family:
    "Pretendard Variable",
    "SUIT Variable",
    "Apple SD Gothic Neo",
    "Noto Sans KR",
    "Malgun Gothic",
    system-ui,
    sans-serif;
}

html,
body {
  background: var(--line-mist);
  color: var(--ink);
}

body {
  font-synthesis: none;
  text-rendering: geometricPrecision;
}

.app {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(circle at 14% 22%, var(--line-veil), transparent 26%),
    radial-gradient(circle at 78% 74%, rgba(109, 166, 216, 0.1), transparent 26%),
    var(--line-mist);
  transition: background-color 240ms ease;
}

.app::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0.42;
  background-image:
    linear-gradient(
      31deg,
      transparent 47%,
      color-mix(in srgb, var(--line), transparent 83%) 48% 49%,
      transparent 50%
    ),
    radial-gradient(
      circle,
      color-mix(in srgb, var(--line), transparent 78%) 0 3px,
      #ffffff 4px 7px,
      transparent 8px
    );
  background-position: 0 0, 42px 86px;
  background-size: 260px 180px, 260px 180px;
}

.loading-screen {
  gap: 15px;
  color: var(--soft-ink);
  letter-spacing: -0.03em;
}

.loading-mark span {
  width: 10px;
  height: 10px;
  border: 0;
  background: var(--line);
}

.opening {
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(330px, 0.72fr);
  grid-template-rows: minmax(0, 1fr);
  gap: clamp(20px, 4vw, 68px);
  align-items: center;
  padding:
    calc(26px + var(--safe-top))
    max(26px, calc(5vw + var(--safe-right)))
    calc(26px + var(--safe-bottom))
    max(26px, calc(5vw + var(--safe-left)));
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.65), transparent 55%),
    var(--line-mist);
  overflow: hidden;
}

.opening__skip {
  z-index: 20;
  top: calc(22px + var(--safe-top));
  right: calc(26px + var(--safe-right));
  min-height: 40px;
  padding: 8px 15px;
  border: 1px solid rgba(23, 52, 45, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 24px rgba(23, 52, 45, 0.08);
  color: var(--soft-ink);
  backdrop-filter: blur(15px);
}

.opening__carriage {
  position: relative;
  min-height: min(74vh, 720px);
  overflow: hidden;
  border: 1px solid rgba(23, 52, 45, 0.1);
  border-radius: clamp(24px, 3vw, 42px);
  background: var(--line-wash);
  box-shadow: var(--panel-shadow);
}

.opening__art {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(74vh, 720px);
  object-fit: cover;
}

.opening__mode {
  position: absolute;
  z-index: 4;
  top: 22px;
  left: 22px;
  display: grid;
  grid-template-columns: 44px auto;
  grid-template-rows: auto auto;
  column-gap: 11px;
  align-items: center;
  padding: 10px 15px 10px 10px;
  border: 1px solid rgba(23, 52, 45, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(23, 52, 45, 0.09);
  backdrop-filter: blur(18px);
}

.opening__mode > span {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: var(--line);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.opening__mode strong {
  font-size: 15px;
}

.opening__mode small {
  color: var(--soft-ink);
  font-size: 11px;
  font-weight: 700;
}

.opening__route-map {
  position: absolute;
  z-index: 3;
  right: 24px;
  bottom: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding-inline: 28px;
  border: 1px solid rgba(23, 52, 45, 0.1);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 32px rgba(23, 52, 45, 0.12);
  backdrop-filter: blur(17px);
}

.opening__route-map::before {
  position: absolute;
  right: 34px;
  left: 34px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  content: "";
}

.opening__route-map i {
  z-index: 1;
  width: 16px;
  height: 16px;
  border: 4px solid var(--line);
  border-radius: 50%;
  background: #fff;
}

.opening__route-map i.is-current {
  width: 22px;
  height: 22px;
  box-shadow: 0 0 0 7px color-mix(in srgb, var(--line), transparent 87%);
}

.opening__mini-train {
  position: absolute;
  z-index: 2;
  top: -12px;
  left: 46%;
  display: grid;
  place-items: center;
  width: 48px;
  height: 32px;
  border: 3px solid var(--ink);
  border-radius: 12px 12px 9px 9px;
  background: #fff;
  color: var(--line);
  font-size: 13px;
  font-weight: 1000;
  animation: metro-drift 2.8s ease-in-out infinite;
}

.opening__mini-train::before,
.opening__mini-train::after {
  position: absolute;
  bottom: -6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink);
  content: "";
}

.opening__mini-train::before { left: 8px; }
.opening__mini-train::after { right: 8px; }

.opening__bubble {
  z-index: 6;
  padding: 11px 17px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 12px 28px rgba(23, 52, 45, 0.14),
    inset 0 0 0 1px rgba(23, 52, 45, 0.08);
  font-size: clamp(18px, 2.4vw, 31px);
  font-weight: 900;
  letter-spacing: -0.06em;
}

.opening__bubble::after {
  bottom: -10px;
  width: 18px;
  height: 18px;
  border: 0;
  background: #fff;
  box-shadow: 7px 7px 15px rgba(23, 52, 45, 0.05);
}

.opening__bubble--one {
  top: 21%;
  left: 11%;
}

.opening__bubble--two {
  top: 36%;
  right: 13%;
  color: var(--line);
}

.opening__title {
  align-content: center;
  justify-items: center;
  gap: 13px;
  padding: clamp(12px, 2vw, 32px);
  text-align: center;
}

.opening__eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line), transparent 89%);
  color: var(--line);
  font-size: 12px;
  letter-spacing: 0.05em;
}

.opening__title h1 {
  max-width: 100%;
  margin-block: 3px;
  font-size: clamp(50px, 5.4vw, 76px);
  line-height: 0.98;
  letter-spacing: -0.095em;
  word-break: keep-all;
}

.opening__title h1::after {
  display: block;
  width: 74px;
  height: 7px;
  margin-top: 20px;
  border-radius: 6px;
  background: var(--line);
  content: "";
  margin-inline: auto;
}

.opening__hook {
  max-width: 23em;
  color: var(--soft-ink);
  font-size: 16px;
  line-height: 1.7;
}

.opening__line-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
}

.opening__line-picker button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 12px 5px 8px;
  border: 1px solid rgba(23, 52, 45, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 6px 16px rgba(23, 52, 45, 0.08);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.opening__line-picker button::before {
  display: block;
  width: 18px;
  height: 18px;
  border: 5px solid #fff;
  border-radius: 50%;
  background: var(--choice-line);
  box-shadow: 0 0 0 2px var(--choice-line);
  content: "";
}

.opening__line-picker button[aria-pressed="true"] {
  border-color: var(--choice-line);
  background: var(--choice-line);
  color: #fff;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--choice-line), transparent 72%);
}

.opening__orientation-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px 8px;
  max-width: 310px;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid rgba(23, 52, 45, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.3;
}

.opening__orientation-note > span {
  color: var(--line);
  font-size: 16px;
  line-height: 1;
}

.opening__orientation-note small {
  flex-basis: 100%;
  color: var(--soft-ink);
  font-size: 9px;
  font-weight: 700;
}

.opening__secondary,
.result__retry {
  justify-content: center;
}

.opening__best {
  color: var(--soft-ink);
  font-size: 12px;
}

.comic-button {
  min-height: 52px;
  padding: 12px 22px;
  border: 1px solid rgba(23, 52, 45, 0.14);
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 9px 24px rgba(23, 52, 45, 0.1);
  font-weight: 900;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background-color 150ms ease;
}

.comic-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 13px 30px rgba(23, 52, 45, 0.14);
}

.comic-button:active {
  transform: translateY(1px);
  box-shadow: 0 5px 15px rgba(23, 52, 45, 0.1);
}

.comic-button--primary {
  min-width: 172px;
  border-color: var(--line);
  background: var(--line);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--line), transparent 74%);
  color: #fff;
  text-shadow: none;
}

.comic-button--primary::after {
  margin-left: 14px;
  content: "→";
}

.comic-button--danger {
  border-color: rgba(236, 128, 108, 0.35);
  background: #fff2ef;
}

.text-button {
  min-height: 42px;
  padding: 8px 2px;
  border: 0;
  color: var(--soft-ink);
  font-size: 13px;
}

.text-button:hover {
  color: var(--line);
}

.game {
  position: relative;
  display: block;
  height: 100dvh;
  padding: 0;
  background: var(--line-mist);
}

.stage {
  position: absolute;
  inset: 0;
  background: var(--line-mist);
}

#game-canvas {
  cursor: default;
}

#game-canvas:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--line), transparent 50%);
  outline-offset: -3px;
}

.hud {
  position: absolute;
  z-index: 9;
  top: calc(14px + var(--safe-top));
  left: 50%;
  grid-template-columns:
    minmax(145px, 0.9fr)
    minmax(170px, 1.25fr)
    auto
    minmax(112px, 0.72fr)
    44px;
  gap: 8px;
  width: min(1120px, calc(100% - 28px - var(--safe-left) - var(--safe-right)));
  min-height: 68px;
  padding: 8px 10px 8px 13px;
  border: 1px solid rgba(23, 52, 45, 0.1);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 38px rgba(23, 52, 45, 0.13);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.hud__route {
  font-size: 13px;
}

.route-tracker {
  --route-marker: 6%;
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
  padding: 2px 8px;
}

.route-tracker__rail {
  position: relative;
  height: 20px;
}

.route-tracker__rail::before,
.route-tracker__fill {
  position: absolute;
  top: 9px;
  right: 6%;
  left: 6%;
  height: 3px;
  border-radius: 999px;
  content: "";
}

.route-tracker__rail::before {
  background: var(--line-wash);
}

.route-tracker__fill {
  right: auto;
  width: calc(var(--route-marker) - 6%);
  background: var(--line);
  background:
    linear-gradient(
      90deg,
      var(--line) 0%,
      var(--line) 58%,
      color-mix(in srgb, var(--line), white 48%) 76%,
      var(--line) 100%
    );
  background-size: 170% 100%;
  transition: width 120ms linear;
  animation: route-flow 1.25s linear infinite;
}

.route-tracker__node {
  position: absolute;
  top: 5px;
  width: 11px;
  height: 11px;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: #fff;
  transform: translateX(-50%);
}

.route-tracker__node--current { left: 6%; }
.route-tracker__node--next { left: 50%; }
.route-tracker__node--after { left: 94%; }

.route-tracker__train {
  position: absolute;
  z-index: 2;
  top: -1px;
  left: var(--route-marker);
  display: grid;
  place-items: center;
  width: 30px;
  height: 22px;
  border: 2px solid var(--ink);
  border-radius: 8px 8px 6px 6px;
  background: #fff;
  box-shadow: 0 4px 9px rgba(23, 52, 45, 0.2);
  color: var(--line);
  font-size: 10px;
  transform: translateX(-50%);
  transition: left 120ms linear;
  animation: route-train-pulse 1.4s ease-in-out infinite;
}

.route-tracker__train::before,
.route-tracker__train::after {
  position: absolute;
  bottom: -5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink);
  content: "";
}

.route-tracker__train::before { left: 5px; }
.route-tracker__train::after { right: 5px; }

.route-tracker__labels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  color: var(--soft-ink);
  font-size: 8px;
  font-weight: 850;
}

.route-tracker__labels span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-tracker__labels span:nth-child(2) { text-align: center; }
.route-tracker__labels span:nth-child(3) { text-align: right; }

.line-dot {
  width: 28px;
  height: 28px;
  border: 0;
  box-shadow: inset 0 0 0 7px #fff, 0 0 0 3px var(--line);
}

.hud__numbers {
  gap: 2px;
}

.hud__numbers div {
  min-width: 66px;
  padding-inline: 8px;
  border-color: var(--shade);
}

.hud__numbers dt {
  font-size: 9px;
}

.hud__numbers dd {
  color: var(--ink);
  font-size: 17px;
}

.face-meter__track {
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--line-wash);
}

.face-meter__track span {
  border-radius: inherit;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(23, 52, 45, 0.12);
  background: #f4f8f5;
  color: var(--ink);
  font-size: 13px;
}

.transit-console {
  position: absolute;
  z-index: 8;
  right: max(14px, var(--safe-right));
  bottom: calc(14px + var(--safe-bottom));
  left: max(14px, var(--safe-left));
  display: grid;
  grid-template-columns: 104px minmax(230px, 1fr) 90px 104px;
  align-items: stretch;
  width: min(780px, calc(100% - 28px - var(--safe-left) - var(--safe-right)));
  min-height: 78px;
  margin-inline: auto;
  overflow: hidden;
  border: 7px solid var(--line);
  border-radius: 39px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(23, 52, 45, 0.2);
}

.transit-console > button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  border: 0;
  background: var(--line);
  color: #fff;
  cursor: pointer;
}

.transit-console > button:hover {
  background: color-mix(in srgb, var(--line), #10231e 16%);
}

.transit-console > button b {
  font-size: 27px;
}

.transit-console > button span {
  font-size: 12px;
  font-weight: 900;
}

.transit-console__seat {
  border-inline: 1px solid rgba(255, 255, 255, 0.28) !important;
  background: var(--line-deep) !important;
}

.transit-console__seat:hover {
  background: color-mix(in srgb, var(--line), #10231e 34%) !important;
}

.transit-console__station {
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 7px 19px;
  background: #fff;
}

.transit-console__line {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--line);
  color: #fff;
  font-size: 18px;
  font-weight: 1000;
}

.transit-console__station > div {
  display: grid;
  min-width: 0;
}

.transit-console__station small,
.transit-console__station span:last-child {
  color: var(--soft-ink);
  font-size: 10px;
  font-weight: 800;
}

.transit-console__station strong {
  overflow: hidden;
  font-size: 22px;
  line-height: 1.08;
  letter-spacing: -0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-ticker {
  bottom: 111px;
  padding: 9px 15px;
  border: 1px solid rgba(23, 52, 45, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 26px rgba(23, 52, 45, 0.13);
  color: var(--ink);
  backdrop-filter: blur(14px);
}

.tutorial-coach {
  right: max(18px, var(--safe-right));
  bottom: calc(118px + var(--safe-bottom));
  padding: 16px 48px 16px 18px;
  border: 1px solid rgba(23, 52, 45, 0.1);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 15px 36px rgba(23, 52, 45, 0.16);
  backdrop-filter: blur(14px);
}

.tutorial-coach::before {
  display: block;
  width: 38px;
  height: 5px;
  margin-bottom: 8px;
  border-radius: 4px;
  background: var(--line);
  content: "";
}

.tutorial-coach span {
  color: var(--line);
}

.tutorial-coach button {
  border: 0;
  color: var(--soft-ink);
}

.seat-toast {
  border: 0;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 20px 50px rgba(23, 52, 45, 0.2);
  color: var(--line);
  transform: translate(-50%, -50%);
}

.game-footer {
  position: absolute;
  z-index: 7;
  right: 18px;
  bottom: 105px;
  width: auto;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
}

.game-footer p {
  margin: 4px 8px;
  font-size: 10px;
}

kbd {
  border: 1px solid rgba(23, 52, 45, 0.2);
  background: #fff;
}

.result {
  position: relative;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.2fr);
  align-items: start;
  align-content: center;
  gap: 16px clamp(22px, 5vw, 74px);
  min-height: 100dvh;
  padding:
    calc(38px + var(--safe-top))
    max(24px, calc(7vw + var(--safe-right)))
    calc(42px + var(--safe-bottom))
    max(24px, calc(7vw + var(--safe-left)));
  background:
    radial-gradient(circle at 16% 24%, var(--line-veil), transparent 29%),
    linear-gradient(135deg, #ffffff, var(--line-mist));
}

.result::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  content: "";
  pointer-events: none;
  opacity: 0.45;
  background:
    linear-gradient(
      23deg,
      transparent 48%,
      color-mix(in srgb, var(--line), transparent 88%) 49% 50%,
      transparent 51%
    ),
    radial-gradient(
      circle,
      #fff 0 5px,
      color-mix(in srgb, var(--line), transparent 65%) 6px 9px,
      transparent 10px
    );
  background-position: 0 0, 96px 74px;
  background-size: 340px 240px;
}

.result > * {
  z-index: 1;
}

.result__header {
  grid-column: 1;
  text-align: left;
}

.result__kicker {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--line-veil);
  color: var(--line);
  font-size: 11px;
}

.result__header h2 {
  margin-top: 14px;
  font-size: clamp(32px, 4.6vw, 60px);
  line-height: 1.04;
}

.result__score {
  color: var(--line);
  font-size: clamp(68px, 10vw, 132px);
  line-height: 1;
}

.result__body,
.community-post {
  grid-column: 1;
}

.result-stats {
  gap: 7px;
}

.result-stats div {
  padding: 13px 6px;
  border: 1px solid rgba(23, 52, 45, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
}

.result-stats dd {
  font-size: 19px;
}

.result__comment {
  text-align: left;
  line-height: 1.6;
}

.result__share-preview {
  grid-column: 2;
  grid-row: 1 / span 3;
  justify-self: center;
  width: min(100%, 460px);
  padding: 10px;
  border: 1px solid rgba(23, 52, 45, 0.1);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(18px);
}

.result__share-preview canvas {
  display: block;
  width: 100%;
  max-height: min(62vh, 620px);
  border-radius: 21px;
  object-fit: contain;
}

.result__actions,
.manual-link,
.result__retry {
  grid-column: 1;
}

.result__actions {
  justify-content: flex-start;
}

.community-post {
  overflow: hidden;
  border: 1px solid rgba(23, 52, 45, 0.12);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 16px 40px rgba(23, 52, 45, 0.13);
}

.community-post__bar {
  border: 0;
  background: var(--line-wash);
  color: var(--soft-ink);
}

.community-post__scene {
  position: relative;
  overflow: hidden;
  min-height: 230px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.22)),
    var(--line-wash);
}

.community-post__scene canvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 230px;
  object-fit: cover;
}

.manual-link input {
  border: 1px solid rgba(23, 52, 45, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.comic-dialog {
  width: min(92vw, 470px);
  border: 1px solid rgba(23, 52, 45, 0.12);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 28px 80px rgba(23, 52, 45, 0.25);
  color: var(--ink);
  backdrop-filter: blur(20px);
}

.comic-dialog::backdrop {
  background: rgba(17, 42, 35, 0.32);
  backdrop-filter: blur(7px);
}

.dialog-illustration {
  color: var(--line);
}

.setting-row {
  border-color: var(--shade);
}

body.is-low-face .hud {
  box-shadow:
    0 14px 38px rgba(23, 52, 45, 0.13),
    0 0 0 3px rgba(236, 128, 108, 0.24);
}

body.is-high-contrast .opening__carriage,
body.is-high-contrast .hud,
body.is-high-contrast .transit-console,
body.is-high-contrast .comic-dialog {
  border-color: #000;
}

@media (max-width: 920px) {
  .hud {
    grid-template-columns:
      minmax(128px, 0.85fr)
      minmax(128px, 1fr)
      auto
      minmax(96px, 0.65fr)
      42px;
  }

  .route-tracker {
    padding-inline: 2px;
  }

  .route-tracker__labels span:nth-child(3),
  .route-tracker__node--after {
    visibility: hidden;
  }

  .opening {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(330px, 58vh) auto;
    gap: 17px;
    align-items: stretch;
    padding: calc(18px + var(--safe-top)) 18px calc(22px + var(--safe-bottom));
    overflow-y: auto;
  }

  .opening__carriage,
  .opening__art {
    min-height: 0;
    height: 100%;
  }

  .opening__title {
    align-content: start;
    padding: 10px 6px 20px;
  }

  .opening__title h1 {
    font-size: clamp(46px, 11vw, 72px);
  }

  .opening__title h1::after {
    margin-top: 13px;
  }

  .opening__secondary {
    justify-content: flex-start;
  }

  .result {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .result__header,
  .result__body,
  .community-post,
  .result__share-preview,
  .result__actions,
  .manual-link,
  .result__retry {
    grid-column: 1;
    grid-row: auto;
  }

  .result__share-preview {
    width: min(100%, 410px);
  }
}

@media (max-width: 680px) {
  .hud {
    top: calc(8px + var(--safe-top));
    grid-template-columns: minmax(0, 1fr) auto 40px;
    grid-template-rows: 40px 31px 30px;
    gap: 3px 5px;
    width: calc(100% - 16px - var(--safe-left) - var(--safe-right));
    min-height: 111px;
    padding: 6px 7px 7px 10px;
    border-radius: 19px;
  }

  .hud__route {
    font-size: 11px;
  }

  .line-dot {
    width: 22px;
    height: 22px;
  }

  .hud__numbers {
    grid-column: 2;
    grid-row: 1;
  }

  .hud__numbers div {
    min-width: 48px;
    padding-inline: 4px;
  }

  .hud__numbers div:nth-child(3) {
    display: none;
  }

  .hud__numbers dd {
    font-size: 14px;
  }

  .face-meter {
    position: static;
    grid-row: 3;
    grid-column: 1 / -1;
    min-width: 0;
    padding: 2px 7px 0;
    border-radius: 0;
    background: transparent;
  }

  .face-meter__label {
    margin: 0 0 2px;
    font-size: 9px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .route-tracker {
    grid-row: 2;
    grid-column: 1 / -1;
    gap: 1px;
    padding: 0 7px;
  }

  .route-tracker__rail {
    height: 17px;
  }

  .route-tracker__rail::before,
  .route-tracker__fill {
    top: 7px;
  }

  .route-tracker__node {
    top: 3px;
  }

  .route-tracker__train {
    top: -2px;
  }

  .route-tracker__labels {
    font-size: 7px;
  }

  .transit-console {
    grid-template-columns: 57px minmax(140px, 1fr) 57px 57px;
    min-height: 68px;
    border-width: 5px;
    border-radius: 34px;
  }

  .transit-console > button {
    gap: 0;
  }

  .transit-console > button b {
    font-size: 22px;
  }

  .transit-console > button span {
    display: none;
  }

  .transit-console__station {
    grid-template-columns: 38px 1fr;
    gap: 8px;
    padding: 5px 10px;
  }

  .transit-console__line {
    width: 38px;
    height: 38px;
    font-size: 14px;
  }

  .transit-console__station strong {
    font-size: 17px;
  }

  .transit-console__station span:last-child {
    font-size: 9px;
  }

  .signal-ticker {
    bottom: 96px;
    font-size: 12px;
  }

  .tutorial-coach {
    right: 12px;
    bottom: calc(96px + var(--safe-bottom));
    left: 12px;
    width: auto;
  }

  .game-footer {
    display: none;
  }

  .opening__mode {
    top: 13px;
    left: 13px;
    transform: scale(0.86);
    transform-origin: top left;
  }

  .opening__route-map {
    right: 12px;
    bottom: 12px;
    left: 12px;
    height: 48px;
    padding-inline: 18px;
  }

  .opening__route-map::before {
    right: 22px;
    left: 22px;
  }

  .opening__bubble {
    font-size: clamp(15px, 4.5vw, 22px);
  }

  .opening__bubble--one {
    top: 26%;
    left: 7%;
  }

  .opening__bubble--two {
    top: 41%;
    right: 7%;
  }

  .opening__title {
    gap: 9px;
  }

  .opening__hook {
    display: none;
  }

  .result {
    gap: 14px;
    padding:
      calc(24px + var(--safe-top))
      max(16px, var(--safe-right))
      calc(32px + var(--safe-bottom))
      max(16px, var(--safe-left));
  }

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

@media (orientation: landscape) and (max-height: 560px) {
  .opening {
    height: 100dvh;
    min-height: 0;
    grid-template-columns: 60% 40%;
    grid-template-rows: minmax(0, 1fr);
    gap: 14px;
    padding: calc(10px + var(--safe-top)) 14px calc(10px + var(--safe-bottom));
    overflow: hidden;
  }

  .opening__carriage {
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 26px;
  }

  .opening__art {
    height: 100%;
    min-height: 0;
  }

  .opening__title {
    align-self: center;
    padding: 12px;
  }

  .opening__title h1 {
    font-size: clamp(38px, 6.5vw, 62px);
  }

  .opening__title h1::after {
    height: 5px;
    margin-top: 10px;
  }

  .opening__line-picker {
    gap: 5px;
  }

  .opening__line-picker button {
    min-height: 28px;
    padding: 3px 9px 3px 6px;
    font-size: 9px;
  }

  .opening__line-picker button::before {
    width: 14px;
    height: 14px;
    border-width: 4px;
  }

  .opening__eyebrow,
  .opening__hook,
  .opening__best {
    display: none;
  }

  .hud {
    top: calc(7px + var(--safe-top));
    min-height: 58px;
    padding-block: 5px;
  }

  .transit-console {
    bottom: calc(7px + var(--safe-bottom));
    min-height: 62px;
  }

  .signal-ticker {
    bottom: 80px;
  }

  .tutorial-coach {
    bottom: 82px;
  }

  .game-footer {
    display: none;
  }

  .result {
    grid-template-columns: minmax(280px, 0.85fr) minmax(300px, 1.15fr);
    gap: 10px 22px;
    padding:
      calc(16px + var(--safe-top))
      max(18px, var(--safe-right))
      calc(16px + var(--safe-bottom))
      max(18px, var(--safe-left));
  }

  .result__share-preview {
    grid-column: 2;
    grid-row: 1 / span 5;
    max-height: calc(100dvh - 32px);
  }

  .result__share-preview canvas {
    max-height: calc(100dvh - 52px);
  }
}

@keyframes metro-drift {
  0%,
  100% { transform: translateX(-11px) translateY(0); }
  50% { transform: translateX(11px) translateY(-2px); }
}

@keyframes route-flow {
  to { background-position: -170% 0; }
}

@keyframes route-train-pulse {
  0%,
  100% { box-shadow: 0 4px 9px rgba(23, 52, 45, 0.2); }
  50% {
    box-shadow:
      0 4px 9px rgba(23, 52, 45, 0.2),
      0 0 0 5px color-mix(in srgb, var(--line), transparent 87%);
  }
}

/* -------------------------------------------------------------------------- */
/* Mobile browser chrome and constrained landscape                             */
/* -------------------------------------------------------------------------- */

body,
.app,
.screen,
.opening,
.game,
.result {
  min-height: var(--app-height);
}

.app,
.screen,
.opening,
.game,
.result {
  height: var(--app-height);
}

@media (max-width: 920px) {
  .opening__title,
  .opening__secondary {
    justify-content: center;
    justify-items: center;
    text-align: center;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .opening__orientation-note {
    max-width: 250px;
    padding: 5px 9px;
    font-size: 9px;
  }

  .opening__orientation-note > span {
    font-size: 13px;
  }

  .opening__orientation-note small {
    font-size: 7px;
  }

  .hud {
    top: calc(3px + var(--safe-top));
    grid-template-columns:
      minmax(116px, 0.78fr)
      minmax(164px, 1.16fr)
      auto
      minmax(82px, 0.58fr)
      34px;
    gap: 3px 5px;
    width: min(980px, calc(100% - 12px - var(--safe-left) - var(--safe-right)));
    min-height: 46px;
    padding: 3px 5px 3px 8px;
    border-radius: 16px;
    box-shadow: 0 9px 24px rgba(23, 52, 45, 0.12);
  }

  .hud__route {
    gap: 6px;
    font-size: 10px;
  }

  .line-dot {
    width: 20px;
    height: 20px;
    box-shadow: inset 0 0 0 5px #fff, 0 0 0 2px var(--line);
  }

  .route-tracker {
    gap: 0;
    padding-inline: 2px;
  }

  .route-tracker__rail {
    height: 15px;
  }

  .route-tracker__rail::before,
  .route-tracker__fill {
    top: 7px;
    height: 2px;
  }

  .route-tracker__node {
    top: 4px;
    width: 8px;
    height: 8px;
    border-width: 2px;
  }

  .route-tracker__train {
    top: -3px;
    width: 26px;
    height: 18px;
    border-radius: 7px 7px 5px 5px;
    font-size: 8px;
  }

  .route-tracker__train::before,
  .route-tracker__train::after {
    bottom: -4px;
    width: 4px;
    height: 4px;
  }

  .route-tracker__labels {
    font-size: 7px;
  }

  .hud__numbers div {
    min-width: 45px;
    padding: 2px 4px;
  }

  .hud__numbers div:nth-child(3) {
    display: none;
  }

  .hud__numbers dt {
    font-size: 7px;
  }

  .hud__numbers dd {
    font-size: 13px;
  }

  .face-meter {
    min-width: 82px;
  }

  .face-meter__label {
    margin-bottom: 2px;
    font-size: 8px;
  }

  .face-meter__track {
    height: 7px;
  }

  .icon-button {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }

  .transit-console {
    bottom: calc(4px + var(--safe-bottom));
    grid-template-columns: 40px minmax(118px, 1fr) 40px 40px;
    width: min(460px, calc(100% - 16px - var(--safe-left) - var(--safe-right)));
    min-height: 44px;
    border-width: 3px;
    border-radius: 23px;
    box-shadow: 0 8px 21px rgba(23, 52, 45, 0.16);
  }

  .transit-console > button {
    gap: 0;
  }

  .transit-console > button b {
    font-size: 17px;
  }

  .transit-console > button span {
    display: none;
  }

  .transit-console__station {
    grid-template-columns: 29px 1fr;
    gap: 6px;
    padding: 3px 8px;
  }

  .transit-console__line {
    width: 29px;
    height: 29px;
    font-size: 11px;
  }

  .transit-console__station small,
  .transit-console__station span:last-child {
    font-size: 7px;
  }

  .transit-console__station strong {
    font-size: 13px;
    line-height: 1;
  }

  .tutorial-coach {
    right: 9px;
    bottom: calc(53px + var(--safe-bottom));
    left: auto;
    width: min(310px, calc(100% - 18px));
    padding: 9px 38px 9px 12px;
    border-radius: 15px;
  }

  .tutorial-coach::before {
    width: 28px;
    height: 3px;
    margin-bottom: 4px;
  }

  .tutorial-coach span {
    display: inline;
    margin-right: 5px;
    font-size: 8px;
  }

  .tutorial-coach strong {
    display: inline;
    margin: 0;
    font-size: 12px;
  }

  .tutorial-coach p {
    display: none;
  }

  .tutorial-coach button {
    top: 5px;
    right: 7px;
    min-height: 28px;
    font-size: 9px;
  }

  .signal-ticker {
    bottom: 53px;
    padding: 6px 11px;
    font-size: 10px;
  }

}

@media (orientation: landscape) and (max-height: 360px) {
  .hud {
    top: calc(2px + var(--safe-top));
    grid-template-columns:
      minmax(104px, 0.72fr)
      minmax(150px, 1.2fr)
      auto
      minmax(72px, 0.52fr)
      30px;
    width: min(900px, calc(100% - 8px - var(--safe-left) - var(--safe-right)));
    min-height: 40px;
    padding: 2px 4px 2px 7px;
    border-radius: 14px;
  }

  .hud__route {
    gap: 5px;
    font-size: 9px;
  }

  .line-dot {
    width: 17px;
    height: 17px;
    box-shadow: inset 0 0 0 4px #fff, 0 0 0 2px var(--line);
  }

  .route-tracker__labels {
    font-size: 6px;
  }

  .hud__numbers div {
    min-width: 39px;
    padding-inline: 3px;
  }

  .hud__numbers dt {
    font-size: 6px;
  }

  .hud__numbers dd {
    font-size: 11px;
  }

  .face-meter {
    min-width: 72px;
  }

  .face-meter__label {
    font-size: 7px;
  }

  .face-meter__track {
    height: 6px;
  }

  .icon-button {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }

  .transit-console {
    bottom: calc(2px + var(--safe-bottom));
    grid-template-columns: 36px minmax(108px, 1fr) 36px 36px;
    width: min(410px, calc(100% - 12px - var(--safe-left) - var(--safe-right)));
    min-height: 38px;
    border-radius: 20px;
  }

  .transit-console__station {
    grid-template-columns: 26px 1fr;
    gap: 5px;
    padding: 2px 7px;
  }

  .transit-console__line {
    width: 26px;
    height: 26px;
    font-size: 10px;
  }

  .transit-console__station strong {
    font-size: 12px;
  }

  .transit-console__station span:last-child {
    display: none;
  }

  .tutorial-coach,
  .signal-ticker {
    bottom: calc(45px + var(--safe-bottom));
  }
}
