.cw-game {
  --cw-ink: #14332f;
  --cw-muted: #49605b;
  --cw-line: #c4d4c8;
  --cw-panel: #fcfcf1;
  --cw-ochre: #af631d;
  --cw-teal: #267977;
  --cw-edge: #385c51;
  max-inline-size: 980px;
  margin-inline: auto;
  padding: clamp(.42rem, 1.6vw, 1rem);
  border: 1px solid #a9c6b1;
  border-radius: 1.15rem;
  background: #e6f0e0;
  color: var(--cw-ink);
  text-align: start;
  font-family: inherit;
  line-height: 1.4;
}
.cw-game *, .cw-game *::before, .cw-game *::after { box-sizing: border-box; }
.cw-game [hidden] { display: none !important; }
.cw-game h2, .cw-game p, .cw-game dl, .cw-game dd { margin: 0; }
.cw-game h2 { font-size: 1.03rem; line-height: 1.2; color: var(--cw-ink); }
.cw-game button, .cw-game select {
  min-block-size: 44px;
  padding: .4rem .56rem;
  border: 1px solid var(--cw-line);
  border-radius: .57rem;
  background: #fffef5;
  color: var(--cw-ink);
  line-height: 1.25;
  font-family: inherit;
  font-size: .86rem;
  font-weight: 650;
}
.cw-game button:enabled, .cw-game select:enabled, .cw-auto:has(input:enabled) { cursor: pointer; }
.cw-game button:enabled:hover, .cw-game select:enabled:hover { border-color: #518272; background: #fff; }
.cw-game button:focus-visible, .cw-game select:focus-visible, .cw-auto:focus-within {
  outline: 3px solid #136a6a;
  outline-offset: 2px;
}
.cw-game button:disabled, .cw-game select:disabled { opacity: .68; }
.cw-routebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, max-content);
  align-items: end;
  gap: .55rem;
  margin-block-end: .55rem;
}
.cw-routepicker, .cw-wallet { display: grid; gap: .12rem; }
.cw-routepicker label, .cw-wallet span { font-size: .73rem; font-weight: 720; color: var(--cw-muted); }
.cw-routepicker select { inline-size: 100%; min-inline-size: 0; }
.cw-wallet { text-align: end; padding: 0 .16rem .24rem; }
.cw-wallet strong { font-size: clamp(.99rem, 3vw, 1.32rem); font-variant-numeric: tabular-nums; }
.cw-main { display: grid; grid-template-columns: minmax(0, 1.13fr) minmax(0, 1fr); gap: .7rem; }
.cw-routearea { display: flex; min-inline-size: 0; flex-direction: column; gap: .55rem; grid-column: 1; grid-row: 1 / 3; }
.cw-control { grid-column: 2; grid-row: 1; }
.cw-workshop { grid-column: 2; grid-row: 2; }
.cw-main { align-items: start; }

.cw-scene {
  --sky-top: #86c7d7;
  --sky-bottom: #f5edbd;
  --rock-back: #91b4a1;
  --rock-mid: #529982;
  --rock-front: #276952;
  --water: #a0d3ba;
  position: relative;
  overflow: hidden;
  inline-size: 100%;
  aspect-ratio: 1.78;
  border: 1px solid #67958b;
  border-radius: .9rem;
  direction: ltr;
  isolation: isolate;
  background: linear-gradient(165deg, var(--sky-top), var(--sky-bottom));
}
.cw-scene[data-route="saddle"] {
  --sky-top: #91b9da;
  --sky-bottom: #eff2e5;
  --rock-back: #9bb4c0;
  --rock-mid: #6d889e;
  --rock-front: #426e6f;
  --water: #bbdfd8;
}
.cw-scene[data-route="gorge"] {
  --sky-top: #70a6c3;
  --sky-bottom: #d9ebd9;
  --rock-back: #90b5bc;
  --rock-mid: #4e8793;
  --rock-front: #26576d;
  --water: #91d4d8;
}
.cw-sun, .cw-cloud, .cw-ridge-back, .cw-ridge-middle, .cw-ridge-front, .cw-river, .cw-track, .cw-fixed { position: absolute; }
.cw-sun {
  inset: 8% auto auto 25%;
  width: 15%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff9ce;
  opacity: .88;
  box-shadow: 0 0 1rem #fff8d180;
}
.cw-cloud { width: 20%; height: 4%; border-radius: 100%; background: #fffcef9e; }
.cw-cloud-one { top: 25%; left: 4%; }
.cw-cloud-two { top: 17%; left: 59%; width: 13%; }
.cw-ridge-back, .cw-ridge-middle, .cw-ridge-front, .cw-river, .cw-track, .cw-fixed { inset: 0; }
.cw-ridge-back {
  background: var(--rock-back);
  clip-path: polygon(0 59%, 12% 43%, 23% 49%, 36% 27%, 44% 35%, 48% 32%, 58% 43%, 65% 38%, 76% 16%, 87% 28%, 92% 16%, 100% 23%, 100% 100%, 0 100%);
}
.cw-ridge-middle {
  background: linear-gradient(20deg, var(--rock-mid) 42%, color-mix(in srgb, var(--rock-mid) 56%, #fffde7));
  clip-path: polygon(0 69%, 15% 60%, 29% 66%, 38% 52%, 46% 58%, 61% 30%, 65% 46%, 76% 29%, 85% 31%, 92% 18%, 100% 23%, 100% 100%, 0 100%);
}
.cw-ridge-front {
  background: repeating-linear-gradient(127deg, #141f2820 0 2%, #ffffff0c 3% 5%, transparent 6% 9%), var(--rock-front);
  clip-path: polygon(0 90%, 9% 86%, 15% 89%, 29% 76%, 47% 84%, 59% 71%, 68% 78%, 86% 41%, 94% 50%, 100% 37%, 100% 100%, 0 100%);
}
.cw-river {
  background: linear-gradient(10deg, var(--water), #dcfbf5 80%);
  clip-path: polygon(15% 100%, 31% 94%, 49% 88%, 61% 90%, 53% 91%, 42% 96%, 40% 100%);
  opacity: .82;
}
.cw-scene[data-route="saddle"] .cw-ridge-middle {
  clip-path: polygon(0 75%, 18% 72%, 28% 64%, 43% 64%, 54% 24%, 63% 46%, 73% 53%, 83% 34%, 90% 23%, 100% 27%, 100% 100%, 0 100%);
}
.cw-scene[data-route="gorge"] .cw-ridge-front {
  clip-path: polygon(0 81%, 20% 84%, 24% 99%, 52% 97%, 56% 78%, 71% 69%, 83% 33%, 92% 35%, 95% 25%, 100% 29%, 100% 100%, 0 100%);
}
.cw-scene[data-route="gorge"] .cw-river { clip-path: polygon(25% 100%, 39% 91%, 49% 90%, 49% 93%, 38% 95%, 36% 100%); }
.cw-rail, .cw-station, .cw-tower, .cw-cabin { position: absolute; }
.cw-rail {
  z-index: 2;
  transform-origin: left center;
  height: 1.5px;
  background: #2e4443;
  box-shadow: 0 3px 0 #f4edcd9e, 0 4.5px 0 #33524d;
}
.cw-tower {
  z-index: 1;
  width: 5px;
  height: 15%;
  translate: -50% -2px;
  background: #425653;
  border-inline-start: 1px solid #d2d7c2;
}
.cw-tower::before {
  content: '';
  display: block;
  margin-inline-start: -6px;
  inline-size: 17px;
  block-size: 5px;
  border-radius: 4px;
  background: #293f3d;
  box-shadow: 0 2px #f0ecd588;
}
.cw-tower::after {
  content: '';
  position: absolute;
  inset: 24% -5px -2px;
  border-bottom: 3px solid #224843;
  border-inline: 2px solid #b0beb0;
  clip-path: polygon(30% 0, 70% 0, 100% 100%, 0 100%);
}
.cw-station {
  z-index: 1;
  translate: -50% -9%;
  width: clamp(20px, 9%, 63px);
  height: 14%;
  border: 2px solid #594a36;
  border-radius: 2px;
  box-shadow: 0 2px 0 #153b32a0;
  background: repeating-linear-gradient(90deg,#ebdbbb 0 17%,#3b5955 18% 37%,#e0c7a5 38% 54%);
}
.cw-station::before {
  content: '';
  position: absolute;
  inset: -39% -14% 84%;
  border-radius: 2px;
  background: #ac6848;
  clip-path: polygon(12% 100%, 28% 0, 76% 0, 100% 100%);
  box-shadow: inset 0 -4px #76432e70;
}
.cw-high { background: repeating-linear-gradient(90deg,#efdab6 0 13%,#546e60 14% 30%,#dbc996 31% 48%); }
.cw-cabin {
  pointer-events: none;
  width: clamp(35px, 10.4%, 58px);
  aspect-ratio: 1;
  translate: -50% -7%;
  filter: drop-shadow(0 2px 2px #0b363945);
}
.cw-scene[data-running="true"] .cw-cabin { transition: left .12s linear, top .12s linear; }
@media (prefers-reduced-motion: reduce) {
  .cw-scene[data-running="true"] .cw-cabin { transition: none; }
}
.cw-cabin[data-side="up"] { z-index: 3; }
.cw-cabin[data-side="down"] { z-index: 4; }
.cw-cabin img, .cw-cabin-fallback { position: absolute; inset: 0; width: 100%; height: 100%; }
.cw-cabin img { visibility: hidden; object-fit: contain; }
.cw-cabin[data-art="true"] img { visibility: visible; }
.cw-cabin[data-art="true"] .cw-cabin-fallback { display: none; }
.cw-cabin-fallback::before {
  content: '';
  position: absolute;
  inset: 4% 34% 51%;
  border: 3px solid #263e3b;
  border-inline-start: 0;
  border-radius: 5px;
}
.cw-cabin-fallback::after {
  content: '';
  position: absolute;
  inset: 43% 14% 7%;
  border: 2px solid #233a3a;
  border-bottom: 4px solid var(--cw-ochre);
  border-radius: 5px 5px 8px 8px;
  background: repeating-linear-gradient(90deg,#e4cc9c 0 14%,#285854 14% 39%);
}
.cw-cabin[data-side="down"] .cw-cabin-fallback::after { border-bottom-color: var(--cw-teal); }
.cw-terrain { padding-inline: .15rem; color: var(--cw-muted); font-size: .81rem; }

.cw-control, .cw-packet, .cw-workshop {
  min-inline-size: 0;
  display: grid;
  align-content: start;
  gap: .54rem;
  padding: clamp(.54rem, 1.6vw, .92rem);
  border: 1px solid var(--cw-line);
  border-radius: .78rem;
  background: var(--cw-panel);
}
.cw-control-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .14rem .4rem;
}
.cw-control-heading > span, .cw-weight { font-size: .74rem; color: var(--cw-muted); }
.cw-cargo {
  --livery: var(--cw-ochre);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, max-content);
  gap: .25rem .4rem;
  align-items: center;
  border-block-start: 1px solid #d9e4d4;
  padding-block-start: .37rem;
}
.cw-cargo[data-livery="teal"] { --livery: var(--cw-teal); }
.cw-cargo label { font-size: .85rem; font-weight: 750; display: flex; gap: .4rem; align-items: center; }
.cw-chip { inline-size: .78rem; block-size: .7rem; border-radius: .21rem; background: var(--livery); box-shadow: inset 0 -2px #15352e60; }
.cw-weight { text-align: end; }
.cw-cargo select { min-inline-size: 0; inline-size: 100%; padding-inline: .43rem .2rem; }
.cw-stepper { display: flex; gap: .14rem; align-items: center; }
.cw-stepper button { min-inline-size: 44px; padding: .32rem; font-size: 1.05rem; }
.cw-stepper output { min-inline-size: 3em; text-align: center; font-size: .69rem; font-variant-numeric: tabular-nums; }
.cw-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .32rem; }
.cw-stat { padding: .3rem .42rem; border-radius: .45rem; background: #e6eddf; min-inline-size: 0; }
.cw-stat[data-stat="estimate"] { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; gap: .25rem; }
.cw-stat dt { font-size: .72rem; font-weight: 610; color: var(--cw-muted); }
.cw-stat dd { font-size: .85rem; font-weight: 730; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cw-stat[data-limit="true"] { background: #f5ddd4; color: #762b28; }
.cw-stat[data-limit="true"] dt { color: #762b28; }
.cw-feedback, .cw-auto-note, .cw-packet p, .cw-save { font-size: .77rem; color: var(--cw-muted); }
.cw-feedback { padding-inline-start: .47rem; border-inline-start: 3px solid #7ca28c; }
.cw-feedback[data-kind="problem"] { border-color: #ae5546; color: #7a2e29; }
.cw-feedback[data-kind="paired"] { border-color: #227868; color: #195b4d; font-weight: 700; }
.cw-game .cw-dispatch { background: #265f55; color: #fffdf1; border-color: #21554b; font-size: .94rem; }
.cw-game .cw-dispatch:enabled:hover { background: #1a524a; }
.cw-auto { min-block-size: 44px; display: flex; gap: .46rem; align-items: center; font-size: .82rem; font-weight: 650; }
.cw-auto input { inline-size: 1.12rem; block-size: 1.12rem; margin: .08rem; accent-color: #255f55; }
.cw-auto-note { margin-block-start: -.32rem !important; }
.cw-packet ul { list-style: none; display: grid; gap: .25rem; padding: 0; margin: 0; }
.cw-packet li { display: flex; gap: .38rem; align-items: flex-start; font-size: .8rem; }
.cw-packet li span { min-inline-size: 1em; color: #337a66; font-weight: 800; }
.cw-packet li[data-done="true"] bdi { color: var(--cw-muted); }
.cw-packet .cw-permit-note { color: #1c6254; font-weight: 740; }
.cw-packet button:enabled { background: #e4f3e1; border-color: #3b7861; }
.cw-gear { min-inline-size: 0; display: grid; grid-template-columns: 1.44rem minmax(0, 1fr) minmax(5ch, max-content); align-items: center; gap: .35rem; }
.cw-gear div { min-inline-size: 0; }
.cw-gear strong, .cw-gear small { display: block; overflow-wrap: anywhere; }
.cw-gear strong { font-size: .82rem; }
.cw-gear small { color: var(--cw-muted); font-size: .7rem; }
.cw-gear-icon { display: grid; place-items: center; border-radius: .42rem; min-block-size: 1.45rem; background: #e7eadb; color: #4b6659; font-size: .96rem; font-weight: 850; }
.cw-gear[data-fitted="true"] .cw-gear-icon { background: #d8eee0; color: #225445; }
.cw-game .cw-save { margin-block-start: .52rem; }
.cw-notice { font-size: .79rem; color: #1e5345; }
.cw-notice.cw-has-notice { margin-block-start: .5rem; }

@media (max-width: 690px) {
  .cw-main { display: flex; flex-direction: column; align-items: stretch; gap: .55rem; }
  .cw-routearea { display: contents; }
  .cw-scene { order: 0; }
  .cw-terrain { order: 1; }
  .cw-control { order: 2; }
  .cw-packet { order: 3; }
  .cw-workshop { order: 4; }
}
@media (max-width: 375px) {
  .cw-cargo { gap: .23rem; }
  .cw-cargo select { font-size: .76rem; }
  .cw-stepper output { min-inline-size: 2.7em; }
  .cw-routepicker select { font-size: .8rem; }
}
