/* Tutorial surfaces share semantic colors; the game's saved theme selects the palette.
   Scoped importance is required because the legacy app applies global button styles. */
:is(#cityrail-tutorial-overlay, #cr-onboarding) {
  --guide-bg: #202022;
  --guide-material: rgba(38, 38, 40, 0.94);
  --guide-sidebar: rgba(52, 52, 55, 0.72);
  --guide-field: rgba(118, 118, 128, 0.18);
  --guide-text: #f5f5f7;
  --guide-muted: #b0b0b6;
  --guide-line: rgba(255, 255, 255, 0.12);
  --guide-accent: #0a84ff;
  --guide-action: #0071e3;
  --guide-link: #69b2ff;
  --guide-warning: #ffd078;
  --guide-shadow: 0 24px 80px #0006, 0 2px 10px #0002;
  color: var(--guide-text);
  font:
    15px/1.6 -apple-system,
    BlinkMacSystemFont,
    'SF Pro Text',
    'PingFang SC',
    sans-serif;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
html.cityrail-light-ui :is(#cityrail-tutorial-overlay, #cr-onboarding) {
  --guide-bg: var(--ui-surface,#fff);
  --guide-material: rgba(250, 250, 252, 0.94);
  --guide-sidebar: rgba(242, 242, 247, 0.82);
  --guide-field: rgba(118, 118, 128, 0.1);
  --guide-text: #1d1d1f;
  --guide-muted: #636368;
  --guide-line: rgba(60, 60, 67, 0.14);
  --guide-accent: #007aff;
  --guide-link: #0066d6;
  --guide-warning: #825000;
  --guide-shadow: 0 24px 80px #15203326, 0 2px 10px #15203312;
}
:is(#cityrail-tutorial-overlay, #cr-onboarding) * {
  box-sizing: border-box;
}
html body :is(#cityrail-tutorial-overlay, #cr-onboarding) button {
  appearance: none;
  min-height: 44px;
  border: 0 !important;
  border-radius: 12px !important;
  background: transparent !important;
  color: var(--guide-text) !important;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background-color 120ms ease,
    opacity 120ms ease,
    transform 120ms ease;
}
html body :is(#cityrail-tutorial-overlay, #cr-onboarding) button:active {
  transform: scale(0.97);
}
html body :is(#cityrail-tutorial-overlay, #cr-onboarding) :is(button, a, input):focus-visible {
  outline: 3px solid var(--guide-accent) !important;
  outline-offset: 3px !important;
}
html body :is(#cityrail-tutorial-overlay, #cr-onboarding) :is(h2, h3, h4) {
  color: var(--guide-text) !important;
}
:is(#cityrail-tutorial-overlay, #cr-onboarding) svg {
  display: block;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#cityrail-tutorial-overlay {
  width: min(1100px, calc(100vw - 64px));
  height: min(840px, calc(100dvh - 64px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--guide-line);
  border-radius: 24px;
  background: var(--material-panel,var(--guide-material));
  backdrop-filter: var(--material-blur,blur(32px) saturate(150%));
  -webkit-backdrop-filter: var(--material-blur,blur(32px) saturate(150%));
  box-shadow: var(--guide-shadow);
}

#cityrail-tutorial-overlay::backdrop {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.cr-guide-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.cr-guide-header {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 0 0 auto;
  padding: 15px 22px;
  box-shadow: 0 1px 0 var(--guide-line);
  position: relative;
  z-index: 1;
}
.cr-guide-header h2 {
  outline: none;
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.cr-guide-header p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--guide-muted);
}
html body #cityrail-tutorial-overlay [data-guide-close] {
  display: grid;
  place-items: center;
  width: 44px;
  flex: 0 0 44px;
  border-radius: 50% !important;
  background: var(--guide-field) !important;
  color: var(--guide-muted) !important;
}
html body #cityrail-tutorial-overlay [data-guide-contents] {
  display: none;
}
.cr-guide-layout {
  display: grid;
  grid-template-columns: 254px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}
.cr-guide-layout aside {
  padding: 20px 14px;
  background: var(--guide-sidebar);
  box-shadow: inset -1px 0 var(--guide-line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
}
.cr-guide-layout nav {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.cr-guide-search {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 4px 22px;
}
.cr-guide-search svg {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--guide-muted);
  pointer-events: none;
}
.cr-guide-search input {
  appearance: none;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px 8px 34px;
  border: 0;
  border-radius: 10px;
  background: var(--guide-field);
  color: var(--guide-text);
  font: inherit;
  font-size: 13px;
}
.cr-guide-search input::placeholder {
  color: var(--guide-muted);
  opacity: 1;
}
.cr-guide-nav-group {
  padding: 16px 11px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--guide-muted);
}
.cr-guide-nav-group:first-child {
  padding-top: 0;
}
html body #cityrail-tutorial-overlay nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  margin: 2px 0;
  text-align: left;
  border-radius: 9px !important;
  line-height: 1.45;
  font-size: 13px;
  font-weight: 450;
}
.cr-guide-nav-number {
  flex: 0 0 20px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}
html body #cityrail-tutorial-overlay nav [aria-current='step'] {
  color: #fff !important;
  background: var(--guide-action) !important;
  font-weight: 550;
}
.cr-guide-article {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 34px 40px 40px;
  background: var(--guide-bg);
  user-select: text;
}
.cr-guide-eyebrow {
  color: var(--guide-link);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.cr-guide-article h3 {
  margin: 9px 0 14px;
  font-size: clamp(26px, 2.8vw, 34px);
  line-height: 1.25;
  letter-spacing: -0.035em;
  font-weight: 700;
  text-wrap: balance;
}
.cr-guide-intro {
  margin: 0 0 24px;
  color: var(--guide-muted);
  font-size: 15px;
  line-height: 1.75;
}
.cr-guide-article figure {
  width: min(100%, 480px);
  margin: 0 auto 30px;
}
.cr-guide-article img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--guide-field);
  border-radius: 16px;
  border: 1px solid var(--guide-line);
}
.cr-guide-article figcaption {
  margin-top: 10px;
  color: var(--guide-muted);
  font-size: 11px;
  line-height: 1.6;
}
.cr-guide-article figcaption a {
  display: inline-block;
  margin-left: 4px;
  color: var(--guide-link);
  text-decoration: none;
  white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) {
.cr-guide-article figcaption a:hover {
  text-decoration: underline;
}
}
.cr-guide-article ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: guide;
}
.cr-guide-article li {
  counter-increment: guide;
  display: flex;
  gap: 16px;
  padding: 0 0 26px;
}
.cr-guide-article li::before {
  content: counter(guide);
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  height: 30px;
  margin-top: 1px;
  border-radius: 50%;
  color: var(--guide-link);
  background: var(--guide-field);
  font-size: 13px;
  font-weight: 600;
}
.cr-guide-article h4 {
  margin: 2px 0 7px;
  font-size: 17px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.cr-guide-article li p {
  margin: 0;
  color: var(--guide-muted);
  font-size: 14px;
  line-height: 1.8;
}
.cr-guide-tip {
  margin: 2px 0 0;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--guide-field);
  color: var(--guide-muted);
  font-size: 13px;
  line-height: 1.75;
}
.cr-guide-tip strong {
  display: block;
  margin-bottom: 5px;
  color: var(--guide-text);
  font-weight: 600;
}
.cr-guide-footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 12px 24px;
  box-shadow: 0 -1px 0 var(--guide-line);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--guide-muted);
}
.cr-guide-footer div {
  display: flex;
  gap: 8px;
}
html body #cityrail-tutorial-overlay .cr-guide-footer button {
  padding: 10px 22px;
  border-radius: 999px !important;
  font-size: 14px;
}
html body #cityrail-tutorial-overlay [data-guide-prev] {
  color: var(--guide-link) !important;
}
html body #cityrail-tutorial-overlay [data-guide-next] {
  color: #fff !important;
  background: var(--guide-action) !important;
}
html body #cityrail-tutorial-overlay button:disabled {
  opacity: 0.35;
  cursor: default;
}
.cr-guide-no-results {
  padding: 12px;
  color: var(--guide-muted);
  font-size: 13px;
}
#cityrail-tutorial-open {
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: #007aff;
  color: #fff;
  font: inherit;
  cursor: pointer;
}
#cr-onboarding {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
}
#cr-onboarding[hidden],
#cr-onboarding [hidden] {
  display: none !important;
}
.cr-coach-ring {
  position: fixed;
  border: 2px solid #78b8ff;
  border-radius: 12px;
  box-shadow: 0 0 0 3px #007aff24;
  pointer-events: none;
}
.cr-coach-ring[data-pin='true'] {
  border-radius: 50%;
}
.cr-coach-card {
  pointer-events: auto;
  position: absolute;
  right: 12px;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 4px 16px 12px;
  border-radius: 24px;
  border: 1px solid var(--guide-line);
  background: var(--material-panel,var(--guide-material));
  backdrop-filter: var(--material-blur,blur(28px) saturate(150%));
  -webkit-backdrop-filter: var(--material-blur,blur(28px) saturate(150%));
  box-shadow: var(--guide-shadow);
}
.cr-coach-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--guide-muted);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
html body #cr-onboarding :is([data-coach-exit], [data-coach-collapse]) {
  margin-right: -8px;
  padding: 8px;
  font-size: 11px;
  font-weight: 400;
  color: var(--guide-muted) !important;
  white-space: nowrap;
}
.cr-coach-progress {
  height: 3px;
  margin: 0 0 8px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--guide-field);
}
.cr-coach-progress i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--guide-accent);
  transform-origin: left;
  transition: transform 180ms ease-out;
}
.cr-coach-card h2 {
  margin: 0 0 4px;
  outline: none;
  font-size: 17px;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.cr-coach-card p {
  margin: 0 0 8px;
  color: var(--guide-muted);
  font-size: 13px;
  line-height: 1.5;
}
.cr-coach-card [data-coach-status] {
  font-size: 12px;
  color: var(--guide-warning);
}
.cr-coach-card [data-coach-status]:empty {
  display: none;
}
html body #cr-onboarding .cr-coach-primary {
  display: inline-block;
  width: auto;
  padding: 9px 16px;
  border-radius: 999px !important;
  background: var(--guide-action) !important;
  color: #fff !important;
  font-size: 14px;
  font-weight: 600;
}
html body #cr-onboarding .cr-coach-primary:disabled {
  opacity: 0.45;
  cursor: wait;
}
html body #cr-onboarding :is(.cr-coach-recover, .cr-coach-alternate) {
  display: inline-block;
  margin: 0 0 0 8px;
  padding: 10px 2px;
  color: var(--guide-link) !important;
  font-size: 12px;
}
html body #cr-onboarding .cr-coach-pin {
  pointer-events: auto;
  position: fixed;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  display: grid;
  place-items: center;
  border: 3px solid #fff !important;
  border-radius: 50% !important;
  background: #007aff !important;
  color: #fff !important;
  box-shadow: 0 4px 16px #0004;
  font-size: 21px;
  font-weight: 600;
}
.cr-tutorial-sync-notice {
  position: fixed;
  z-index: 100800;
  top: 75px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 14px 20px;
  border-radius: 18px;
  background: #28282a;
  color: #f5f5f7;
  box-shadow: 0 8px 28px #0004;
  font:
    13px/1.6 -apple-system,
    BlinkMacSystemFont,
    'PingFang SC',
    sans-serif;
}
@media (hover: hover) {
  html body #cityrail-tutorial-overlay nav button:not([aria-current='step']):hover {
    background: var(--guide-field) !important;
  }
  html body :is(#cityrail-tutorial-overlay, #cr-onboarding) button:hover {
    filter: brightness(1.08);
  }
}
@media (max-width: 680px) {
  #cityrail-tutorial-overlay {
    width: calc(100vw - 16px);
    height: calc(100dvh - 24px);
    border-radius: 24px;
  }
  .cr-guide-header {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr) 44px;
    padding: 11px 14px;
    gap: 8px;
  }
  .cr-guide-header > div {
    text-align: center;
  }
  .cr-guide-header h2 {
    font-size: 16px;
  }
  .cr-guide-header p {
    display: none;
  }
  html body #cityrail-tutorial-overlay [data-guide-close] {
    grid-column: 3;
    grid-row: 1;
  }
  html body #cityrail-tutorial-overlay [data-guide-contents] {
    display: flex;
    align-items: center;
    gap: 5px;
    grid-column: 1;
    grid-row: 1;
    padding: 0;
    font-size: 14px;
    color: var(--guide-link) !important;
  }
  .cr-guide-layout {
    display: block;
    position: relative;
  }
  .cr-guide-layout aside {
    display: none;
    height: 100%;
    padding: 18px 16px 28px;
    box-shadow: none;
  }
  .cr-guide-article {
    height: 100%;
    padding: 28px 22px;
  }
  #cityrail-tutorial-overlay[data-contents='open'] aside {
    display: flex;
  }
  #cityrail-tutorial-overlay[data-contents='open'] .cr-guide-article {
    display: none;
  }
  #cityrail-tutorial-overlay[data-contents='open'] .cr-guide-footer {
    display: none;
  }
  .cr-guide-search input {
    min-height: 44px;
    font-size: 16px;
  }
  .cr-guide-search svg {
    width: 18px;
    height: 18px;
  }
  html body #cityrail-tutorial-overlay nav button {
    min-height: 48px;
    font-size: 15px;
  }
  .cr-guide-article h3 {
    font-size: 28px;
  }
  .cr-guide-intro {
    font-size: 15px;
  }
  .cr-guide-article img {
    height: auto;
  }
  .cr-guide-article li {
    gap: 12px;
  }
  .cr-guide-footer {
    padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  }
  html body #cityrail-tutorial-overlay .cr-guide-footer button {
    padding: 10px 15px;
    font-size: 13px;
  }
  .cr-coach-card {
    padding: 2px 14px 10px;
    border-radius: 22px;
  }
  .cr-coach-card h2 {
    font-size: 17px;
  }
  .cr-coach-progress {
    margin-bottom: 8px;
  }
}
@media (max-height: 480px) {
  #cityrail-tutorial-overlay {
    height: calc(100dvh - 16px);
    width: calc(100vw - 24px);
    border-radius: 18px;
  }
  .cr-guide-header {
    padding-top: 5px;
    padding-bottom: 5px;
  }
  .cr-guide-footer {
    padding-top: 5px;
    padding-bottom: 5px;
  }
  .cr-coach-card {
    width: min(330px, calc(100vw - 24px));
    padding: 2px 16px 12px;
    border-radius: 18px;
  }
  .cr-coach-card h2 {
    font-size: 18px;
    margin-bottom: 6px;
  }
  .cr-coach-card p {
    font-size: 13px;
    line-height: 1.55;
    margin-bottom: 10px;
  }
  .cr-coach-progress {
    margin-bottom: 10px;
  }
}
/* The tutorial occupies a dock, never a full-screen hit surface. Keep the
   control center above it so charts and their controls remain scrollable. */
html[data-cityrail-onboarding='active'] body #ctrl-center-overlay {
  bottom: var(--cr-coach-space, 176px) !important;
  height: auto !important;
  max-height: calc(100dvh - var(--cr-coach-space, 176px)) !important;
}
#cr-onboarding[data-collapsed='true']
  .cr-coach-card
  :is(p, .cr-coach-primary, .cr-coach-alternate, .cr-coach-recover, .cr-coach-progress) {
  display: none !important;
}
#cr-onboarding[data-collapsed='true'] .cr-coach-card h2 {
  margin-bottom: 0;
}
@media (max-width: 760px) {
  .cr-coach-card {
    right: 8px;
    width: calc(100vw - 16px);
  }
  html[data-cityrail-onboarding='active']
    body
    :is(
      #new-line-dialog-overlay,
      #station-detail-overlay,
      #line-config-overlay,
      #settings-overlay,
      #cc-express-modal
    ) {
    bottom: var(--cr-coach-space, 176px) !important;
    height: auto !important;
  }
  html[data-cityrail-onboarding='active']
    body
    :is(
      #settings-panel,
      #station-detail-panel,
      #line-config-panel,
      #new-line-dialog,
      .cc-express-dialog,
      .cityrail-depot-panel
    ) {
    max-height: calc(100dvh - var(--cr-coach-space, 176px) - 80px) !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  html body :is(#cityrail-tutorial-overlay, #cr-onboarding),
  html body :is(#cityrail-tutorial-overlay, #cr-onboarding) * {
    transition: none !important;
  }
  #cityrail-tutorial-overlay {
    transform: none;
  }
  html body :is(#cityrail-tutorial-overlay, #cr-onboarding) button:active {
    transform: none;
    opacity: 0.75;
  }
}
@media (prefers-reduced-transparency: reduce) {
  #cityrail-tutorial-overlay,
  .cr-coach-card {
    background: var(--guide-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  #cityrail-tutorial-overlay::backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .cr-guide-layout aside {
    background: var(--guide-bg);
  }
}
@media (prefers-contrast: more) {
  :is(#cityrail-tutorial-overlay, #cr-onboarding) {
    --guide-muted: #eee;
    --guide-line: #aaa;
  }
  html.cityrail-light-ui :is(#cityrail-tutorial-overlay, #cr-onboarding) {
    --guide-muted: #303034;
    --guide-line: #636366;
  }
  #cityrail-tutorial-overlay,
  .cr-coach-card {
    background: var(--guide-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
