/* Game-specific UI on top of the OpenTTD window chrome in ttd-window.css (the prototypes). */
html, body { margin: 0; height: 100%; overflow: hidden; background: #101820; font: 16px/1.3 sans-serif; color: #000; }
#map { display: block; cursor: grab; }

/* ---------- window bodies ------------------------------------------------- */

.ttd-window__body {
  text-shadow: 2px 2px 0 var(--ttd-ink);
  max-height: calc(100vh - 150px);
  overflow: auto;
}

.ttd-window__body .ttd-text-black {
  position: relative;
  top: 1px;
  left: 1px;
}

/* Bevelled panel that holds the window content; contents keep their own padding. */
.ttd-pad { padding: 6px; }
.ttd-window--construction .ttd-pad { padding-bottom: 0; }

.ttd-window__body h4 {
  margin: 6px 0 2px;
  font: inherit;
  line-height: 20px;
  color: var(--ttd-white);
}

.ttd-window__body pre { margin: 0; font: inherit; line-height: 1.5; }
.ttd-window__body input { font: inherit; line-height: 20px; }

.ttd-btn, .ttd-titlebtn { text-shadow: none; }

/* A vertical stack of buttons. */
.ttd-btnrowcol { display: flex; flex-direction: column; gap: 2px; }
.ttd-btnrowcol .ttd-btn { flex: 0 0 auto; width: 100%; }

/* The bevelled panels of the finances window. */
.ttd-fin-ledger { padding: 0 4px 14px; }
.ttd-fin-funds { padding: 0 4px; }
/* Finance sits in a max-content window: fit-content/100% table sizing can feed back into the window's
   intrinsic width in Chromium. Pin its three-period ledger, rent ledger, and funds panel to compact grids. */
.ttd-fin-ledger .ttd-ledger { width: 682px; }
.ttd-fin-ledger .ttd-ledger col.ttd-col-label { width: 190px; }
.ttd-fin-ledger .ttd-ledger col.ttd-col-year { width: 156px; }
.ttd-fin-ledger .ttd-ledger col.ttd-col-gap { width: 12px; }
.ttd-fin-ledger .ttd-ledger th:first-child,
.ttd-fin-ledger .ttd-ledger td:first-child { width: 190px; }
.ttd-fin-rent__table { width: 658px; }
.ttd-fin-rent__table th:first-child,
.ttd-fin-rent__table td:first-child { width: 190px; }
.ttd-fin-funds .ttd-funds { width: 612px; }
.ttd-fin-funds .ttd-funds col.ttd-col-label { width: 164px; }
.ttd-fin-funds .ttd-funds col.ttd-col-value { width: 156px; }
.ttd-fin-funds .ttd-funds col.ttd-col-gap { width: 12px; }
.ttd-fin-funds .ttd-funds col.ttd-col-info { width: 280px; }

/* In-body button bars, styled like the bottom bar of the window. */
.ttd-btnrow { display: flex; flex: 0 0 auto; }
.ttd-btnrow .ttd-btn { flex: 1 1 0; min-width: 0; }

/* A grid of small buttons, e.g. 2x2 metric picker. */
.ttd-btngrid { display: grid; grid: repeat(2, 28px) / repeat(2, 1fr); gap: 2px; }
.ttd-btngrid .ttd-btn { flex: none; }

/* ---------- scrollable lists (towns, stations, vehicles, ...) ------------- */

.ttd-list {
  flex: 0 1 auto;
  max-height: 400px;
  min-height: 24px;
  overflow: auto;
  padding: 2px;
  background: var(--ttd-ink);
  border: 2px solid;
  border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light) var(--ttd-bevel-light) var(--ttd-bevel-dark);
}

.ttd-list .row {
  height: 24px;
  line-height: 20px;
  padding: 0 4px;
  cursor: pointer;
  white-space: nowrap;
}

.ttd-list .row:hover { background: #2f2f2f; }
.ttd-list .row.is-active { background: var(--ttd-gold); color: var(--ttd-ink); text-shadow: none; }
.new-ship-window .ttd-list .row { display: flex; align-items: center; gap: 8px; height: 32px; }
.ttd-list .company-directory-row { display: flex; align-items: center; gap: 6px; height: 30px; }
.ttd-list .company-directory-row.is-current { background: #2f2f2f; box-shadow: inset 3px 0 var(--ttd-gold); }
.company-directory-row__color { flex: 0 0 14px; width: 14px; height: 14px; border: 1px solid #ddd; }
.company-directory-row__text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.company-directory-row .ttd-btn { flex: 0 0 78px; }
.company-directory-row .ttd-btn { height: 28px; padding: 0 4px; }
.company-setup__results { max-height: 220px; overflow-y: auto; margin-top: 6px; }
.company-setup__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; padding: 2px 6px; }
.company-setup__row > span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.company-directory-window {
  --company-directory-bg: #98845c;
  --ttd-bg: var(--company-directory-bg);
  --company-directory-bevel-light: #d4bc94;
  --company-directory-bevel-dark: #68502c;
  background: var(--company-directory-bg);
  color: var(--ttd-ink);
}
.company-directory-window .ttd-window__caption {
  background: var(--company-directory-bg);
  border-color: var(--company-directory-bevel-light) var(--company-directory-bevel-dark)
                var(--company-directory-bevel-dark) var(--company-directory-bevel-light);
  box-shadow: inset 2px 2px 0 var(--company-directory-bevel-dark),
              inset -2px -2px 0 var(--company-directory-bevel-light);
}
.company-directory-window .ttd-window__body { background: var(--company-directory-bg); color: var(--ttd-ink); text-shadow: none; }
.company-directory-window .ttd-list {
  background: var(--company-directory-bg);
  border-color: var(--company-directory-bevel-dark) var(--company-directory-bevel-light)
                var(--company-directory-bevel-light) var(--company-directory-bevel-dark);
}
.company-directory-window .ttd-list .row:hover { background: #aa966d; }
.company-directory-window .ttd-list .company-directory-row.is-current {
  background: #a38f66;
  box-shadow: inset 3px 0 #68502c;
}
.company-directory-window .company-directory-row .ttd-btn {
  color: var(--ttd-ink);
  background: var(--company-directory-bg);
  border-color: var(--company-directory-bevel-light) var(--company-directory-bevel-dark)
                var(--company-directory-bevel-dark) var(--company-directory-bevel-light);
}
.company-directory-window .company-directory-row .ttd-btn:hover:not(:disabled) { background: #aa966d; }
.company-directory-window .company-directory-row .ttd-btn:disabled { color: #5d513b; }

.game-log-window { max-width: calc(100vw - 24px); }
.game-log-window.ttd-window--pinned .ttd-window__titlebar { cursor: default; }
.game-log-window .ttd-window__body { flex: 1 1 auto; min-height: 0; max-height: none; overflow: hidden; background: #424242; }
.game-log-list { flex: 1 1 auto; width: 100%; min-height: 0; max-height: none; font-size: 13px; background: #424242; }
.game-log-entry {
  min-height: 18px;
  padding: 2px 4px;
  line-height: 14px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.game-log-entry + .game-log-entry { border-top: 1px solid #343434; }
.game-log-entry--success { color: var(--ttd-white); }
.game-log-entry--warning { color: var(--ttd-gold); }
.game-log-entry--error { color: #ff7777; }
.game-log-entry.is-clickable { cursor: pointer; }
.game-log-entry.is-clickable:hover,
.game-log-entry.is-clickable:focus-visible { background: #2f2f2f; outline: none; }

/* Hint text, e.g. "Your company is being set up…". */
.ttd-empty { padding: 4px; color: var(--ttd-white); }

/* Station details use OpenTTD's wide, compact grey station-management layout. */
.station-window { --ttd-bg: #858585; background: #858585; color: var(--ttd-ink); }
.station-window .ttd-window__body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  background: #858585;
  color: var(--ttd-ink);
  text-shadow: none;
}
.station-window .ttd-titlebtn--locate { width: 28px; }
.station-window .ttd-titlebtn--locate .ttd-titlebtn__icon {
  font-size: 18px;
  -webkit-text-stroke: 0;
}
.station-window__content { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.station-window__filters { flex: 0 0 56px; }
.station-window__filter-row { display: grid; grid-template-columns: 43% 57%; height: 28px; }
.station-window__filter-button {
  position: relative;
  width: 100%;
  height: 28px;
  flex: 0 0 auto;
  justify-content: center;
  padding: 0 22px 2px 6px;
  color: var(--ttd-ink);
  text-shadow: none;
  font-weight: bold;
}
.station-window__filter-button::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 5px;
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-top-color: var(--ttd-ink);
  transform: translateY(3px);
}
.station-window__filter-button--value { justify-content: flex-start; }
.station-window__waiting {
  display: flex;
  flex: 1 1 auto;
  min-height: 80px;
  overflow: hidden;
  background: #858585;
  border-top: 2px solid var(--ttd-bevel-dark);
  border-bottom: 2px solid var(--ttd-bevel-light);
}
.station-window__waiting-rows { flex: 1 1 auto; min-width: 0; overflow: auto; padding: 1px 2px; }
.station-window__waiting .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 24px;
  padding: 0 2px;
  color: var(--ttd-white);
  line-height: 20px;
  text-shadow: 2px 2px 0 var(--ttd-ink);
  white-space: nowrap;
}
.station-window__cargo-icons { display: flex; flex: 0 0 auto; gap: 1px; margin-right: 10px; }
.station-window__cargo-sprite { display: block; width: 12px; height: 18px; }
.station-window__cargo-icons--passengers .station-window__cargo-sprite {
  background:
    linear-gradient(#39271f 0 0) 4px 0 / 4px 3px,
    linear-gradient(#e3b68e 0 0) 4px 3px / 4px 3px,
    linear-gradient(var(--station-passenger-shirt, #42739c) 0 0) 2px 6px / 8px 7px,
    linear-gradient(#242424 0 0) 3px 13px / 3px 5px,
    linear-gradient(#242424 0 0) 7px 13px / 3px 5px;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.station-window__cargo-icons--passengers .station-window__cargo-sprite:nth-child(4n + 2) { --station-passenger-shirt: #b83b32; }
.station-window__cargo-icons--passengers .station-window__cargo-sprite:nth-child(4n + 3) { --station-passenger-shirt: #d1b43b; }
.station-window__cargo-icons--passengers .station-window__cargo-sprite:nth-child(4n) { --station-passenger-shirt: #637c46; }
.station-window__scrollbar { display: flex; flex: 0 0 26px; flex-direction: column; border-left: 2px solid var(--ttd-bevel-light); }
.station-window__scroll-button { width: 24px; height: 24px; flex: 0 0 24px; padding: 0; font-size: 14px; }
.station-window__scroll-track { flex: 1 1 auto; min-height: 0; border: 2px solid; border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light); }
.station-window__accepts {
  flex: 0 0 62px;
  overflow: auto;
  padding: 2px 4px;
  color: var(--ttd-ink);
  font-weight: bold;
  line-height: 20px;
  text-shadow: none;
}
.station-window__accepts[hidden] { display: none; }
.station-window__ratings-heading { margin-bottom: 2px; }
.station-window__rating-row { display: flex; justify-content: space-between; gap: 12px; padding-left: 20px; }
.station-window .ttd-window__buttons { height: 28px; }
.station-window .ttd-window__buttons .ttd-btn.station-window__mode { flex: 0 0 36px; width: 36px; padding: 0; }
.station-window__mode canvas { width: 22px; height: 22px; image-rendering: pixelated; }

/* ---------- construction tool grids --------------------------------------- */

/* OpenTTD's construction windows use the olive-green build palette; ordinary dialogs and the main toolbar keep the grey chrome. */
.ttd-window--construction {
  --ttd-build-bg: #687c4c;
  --ttd-bg: var(--ttd-build-bg);
  --ttd-build-light: #98af6c;
  --ttd-build-dark: #39542d;
  --ttd-build-hover: #7b8f5a;
  --ttd-build-active: #50643c;
  background: var(--ttd-build-bg);
}
.ttd-window--construction .ttd-window__body { background: var(--ttd-build-bg); }
.ttd-window--construction .ttd-window__caption {
  background: var(--ttd-build-bg);
  border-color: var(--ttd-build-light) var(--ttd-build-dark)
                var(--ttd-build-dark) var(--ttd-build-light);
  box-shadow: inset 2px 2px 0 var(--ttd-build-dark),
              inset -2px -2px 0 var(--ttd-build-light);
}

.ttd-tools { display: grid; grid-template-columns: repeat(auto-fill, 44px); gap: 2px; width: 372px; }
.ttd-tools .ttd-btn { height: 42px; flex: none; padding: 2px; }
.ttd-tools .ttd-btn.is-active { background: #fcfcfc; }
.ttd-tools canvas { image-rendering: pixelated; }
.ttd-window--construction .ttd-tools:not(.ttd-tools--orient) .ttd-btn {
  background: var(--ttd-build-bg);
  border-color: var(--ttd-build-light) var(--ttd-build-dark)
                var(--ttd-build-dark) var(--ttd-build-light);
}
.ttd-window--construction .ttd-tools:not(.ttd-tools--orient) .ttd-btn:hover { background: var(--ttd-build-hover); }
.ttd-window--construction .ttd-tools:not(.ttd-tools--orient) .ttd-btn:active,
.ttd-window--construction .ttd-tools:not(.ttd-tools--orient) .ttd-btn.is-active {
  background: var(--ttd-build-active);
  border-color: var(--ttd-build-dark) var(--ttd-build-light)
                var(--ttd-build-light) var(--ttd-build-dark);
}

/* Road-stop directions keep the bay compass pair at left and through X/Y at right; depots use 2x2. */
.ttd-tools--orient { width: max-content; grid-template-columns: repeat(3, 82px); grid-auto-rows: 84px; }
.ttd-tools--orient.ttd-tools--orient--depot { grid-template-columns: repeat(2, 82px); }
.ttd-tools--orient.ttd-tools--orient--road-stop { grid-template-columns: repeat(2, 112px) 12px 112px; }
.ttd-tools--orient--road-stop .ttd-btn:nth-child(1) { grid-column: 1; grid-row: 1; }
.ttd-tools--orient--road-stop .ttd-btn:nth-child(2) { grid-column: 2; grid-row: 1; }
.ttd-tools--orient--road-stop .ttd-btn:nth-child(3) { grid-column: 1; grid-row: 2; }
.ttd-tools--orient--road-stop .ttd-btn:nth-child(4) { grid-column: 2; grid-row: 2; }
.ttd-tools--orient--road-stop .ttd-btn:nth-child(5) { grid-column: 4; grid-row: 1; }
.ttd-tools--orient--road-stop .ttd-btn:nth-child(6) { grid-column: 4; grid-row: 2; }
.ttd-tools--orient .ttd-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  width: 82px;
  height: 84px;
  padding: 0;
}
.ttd-tools--orient canvas { display: block; width: 100%; height: 100%; }
.ttd-tools--rail { grid-template-columns: repeat(18, 38px); width: 718px; }
.ttd-tools--rail .ttd-btn { width: 38px; }
.ttd-tools--orient--road-stop .ttd-btn {
  width: 112px;
}


/* ---------- charts and minimaps -------------------------------------------- */

.ttd-window canvas.chart, .ttd-window canvas.minimap {
  display: block;
  background: #000;
  border: 2px solid;
  border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light) var(--ttd-bevel-light) var(--ttd-bevel-dark);
}
.extra-viewport { width: 480px; height: 300px; border: 2px solid; border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light) var(--ttd-bevel-light) var(--ttd-bevel-dark); }
.extra-viewport__canvas { display: block; width: 100%; height: 100%; cursor: grab; }

/* ---------- ledger values (generic fall-back text colours) ----------------- */

.neg { color: var(--ttd-red); }
.pos { color: var(--ttd-gold); }

/* ---------- main toolbar ---------------------------------------------------- */

#toolbar {
  position: fixed; top: 0; left: 0; right: 0; height: 46px; z-index: 100000;
  display: flex; align-items: center; gap: 0; padding: 0 2px 2px;
  background: var(--ttd-bg);
  user-select: none;
}
#toolbar .group { display: flex; gap: 2px; }
#toolbar .group + .group { border-left: 2px solid #303030; padding-left: 4px; margin-left: 3px; }
#toolbar button {
  width: 44px; height: 44px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ttd-ink);
  background: var(--ttd-bg);
  border: 2px solid;
  border-color: var(--ttd-bevel-light) var(--ttd-bevel-dark) var(--ttd-bevel-dark) var(--ttd-bevel-light);
  cursor: pointer;
}
#toolbar button:hover { background: #8b8d8b; }
#toolbar button:active, #toolbar button.active {
  background: #777977;
  border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light) var(--ttd-bevel-light) var(--ttd-bevel-dark);
}
#toolbar button.menu-trigger { position: relative; }
#toolbar button.menu-trigger::after {
  position: absolute; right: 2px; bottom: 2px; width: 0; height: 0;
  border: 4px solid transparent; border-bottom: 0; border-top-color: #101010;
  content: '';
}
#toolbar button.menu-open { background: #777977; border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light) var(--ttd-bevel-light) var(--ttd-bevel-dark); }
#toolbar canvas { image-rendering: pixelated; }
#toolbar .spacer { flex: 1; }
.toolbar-menu {
  position: fixed; top: 46px; z-index: 300000;
  display: flex; flex-direction: column; min-width: 196px; max-width: calc(100vw - 8px);
  max-height: calc(100vh - 50px); overflow-y: auto; padding: 2px;
  color: #101010; background: #c0c0c0; border: 2px solid #303030;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .55);
  font: 20px/20px "OpenTTD Sans", Tahoma, sans-serif; text-shadow: none;
}
.toolbar-menu__item {
  box-sizing: border-box; display: block; flex: 0 0 20px; width: 100%; min-width: 0; height: 20px; padding: 0 4px;
  overflow: hidden; color: #101010; background: transparent; border: 0;
  font: inherit; line-height: 20px; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.toolbar-menu__item:hover, .toolbar-menu__item:focus-visible { color: #fff; background: #000; outline: none; }
#status {
  color: var(--ttd-white); font: 16px "OpenTTD Sans", Tahoma, sans-serif; line-height: 20px;
  text-shadow: 2px 2px 0 var(--ttd-ink);
  flex: 0 1 48%; padding: 0 6px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48%;
}
@media (max-width: 1000px) { #status { flex-basis: auto; max-width: calc(100vw - 300px); } }
@media (max-width: 650px) { #status { max-width: calc(100vw - 240px); padding-inline: 3px; } }

#game-statusbar {
  position: fixed; right: 0; bottom: 0; left: 0; z-index: 200000;
  display: grid; grid-template-columns: minmax(190px, 20%) minmax(0, 1fr) minmax(160px, 20%);
  box-sizing: border-box; height: 28px; color: var(--ttd-white); background: var(--ttd-bg);
  border: 2px solid; border-color: var(--ttd-bevel-light) var(--ttd-bevel-dark) var(--ttd-bevel-dark) var(--ttd-bevel-light);
  font: 20px/20px "OpenTTD Sans", Tahoma, sans-serif; text-shadow: 2px 2px 0 var(--ttd-ink);
  user-select: none;
}
.game-statusbar__clock, .game-statusbar__funds {
  display: flex; align-items: center; min-width: 0; padding: 0 8px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.game-statusbar__funds { justify-content: flex-end; border-left: 2px solid #303030; }
.game-statusbar__ticker {
  display: block; min-width: 0; padding: 0 6px 2px; overflow: hidden; color: #c7e7ff;
  font: inherit; text-align: left; text-shadow: 2px 2px 0 #17202a;
  background: transparent; border: 0; border-left: 2px solid var(--ttd-bevel-dark); cursor: pointer;
}
.game-statusbar__ticker:hover { background: #777977; }
.game-statusbar__ticker-text { display: inline-block; min-width: 100%; white-space: nowrap; }
.game-statusbar__ticker-text.is-moving { animation: game-news-scroll 22s linear infinite; }
.game-statusbar__ticker:hover .game-statusbar__ticker-text { animation-play-state: paused; }
@keyframes game-news-scroll { from { transform: translateX(100%); } to { transform: translateX(-100%); } }

.game-news-popup {
  position: fixed; z-index: 200001; left: 50%; bottom: 36px;
  display: flex; flex-direction: column; width: min(840px, calc(100vw - 32px)); min-height: min(300px, calc(100vh - 56px)); max-height: calc(100vh - 56px);
  overflow: hidden; color: #101010; background: #aaa; border: 2px solid #111; box-shadow: 2px 2px 0 #111;
  opacity: 0; transform: translate(-50%, calc(100% + 24px)); transition: transform 280ms ease-out, opacity 180ms linear;
  pointer-events: none;
}
.game-news-popup[hidden] { display: none; }
.game-news-popup.is-visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.game-news-popup__header {
  position: relative; display: flex; flex: 0 0 auto; min-height: 92px; align-items: center; justify-content: center;
  padding: 24px 42px 12px; background: #f7f7f7; border-bottom: 2px solid #777;
}
.game-news-popup__headline {
  margin: 0; font: bold clamp(26px, 4vw, 42px)/1.05 Georgia, "Times New Roman", serif; text-align: center;
}
.game-news-popup__close {
  position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; padding: 0;
  color: #111; font: bold 24px/20px sans-serif; background: #ddd; border: 1px solid #555; cursor: pointer;
}
.game-news-popup__date { position: absolute; top: 5px; right: 8px; font: 14px "OpenTTD Sans", Tahoma, sans-serif; }
.game-news-popup__illustration { display: grid; flex: 0 0 132px; place-items: center; background: #999; border-bottom: 2px solid #777; }
.game-news-popup__illustration canvas { image-rendering: pixelated; }
.game-news-popup__body { display: flex; flex: 1 1 auto; flex-direction: column; align-items: center; justify-content: center; min-height: 72px; padding: 16px 24px; overflow: auto; text-align: center; font: 20px/1.2 "OpenTTD Sans", Tahoma, sans-serif; }
.game-news-popup__body p { margin: 0; }
.game-news-popup__location { margin-top: 10px; padding: 2px 10px; color: #111; font: inherit; background: #c5c5c5; border: 2px solid; border-color: #eee #555 #555 #eee; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .game-statusbar__ticker-text.is-moving { animation: none; }
  .game-news-popup { transition: none; }
}

@media (max-width: 520px) {
  .game-log-window { width: calc(100vw - 24px) !important; }
  #game-statusbar { grid-template-columns: minmax(120px, 28%) minmax(0, 1fr) minmax(90px, 24%); font-size: 14px; }
  .game-statusbar__clock, .game-statusbar__funds { padding-right: 4px; padding-left: 4px; }
  .game-news-popup__header { min-height: 72px; padding-right: 34px; padding-left: 34px; }
  .game-news-popup__body { padding: 12px; font-size: 16px; }
  .game-news-popup__illustration { flex-basis: 96px; }
}

.player-options__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.player-option { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.player-option__input {
  box-sizing: border-box; width: 100%; min-width: 0; height: 24px; padding: 0 4px;
  color: var(--ttd-input); font: inherit; line-height: 20px; background: var(--ttd-ink);
  border: 2px solid; border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light) var(--ttd-bevel-light) var(--ttd-bevel-dark);
}
.player-option__value { text-align: right; font-size: 14px; line-height: 16px; }
.player-options__note { margin-top: 6px; font-size: 14px; line-height: 16px; }
.player-options__message { min-height: 20px; font-size: 14px; }
.auth-login-feedback { box-sizing: border-box; min-height: 20px; margin: 8px 2px 12px; color: #c00000; font-size: 14px; font-weight: 600; line-height: 18px; }
.ttd-pad > .ttd-input { box-sizing: border-box; width: 100%; margin: 3px 0; border-right: 2px solid var(--ttd-bevel-light); }
.auth-terms { display: flex; align-items: flex-start; gap: 6px; margin: 6px 0; padding: 2px 4px; border-radius: 3px; outline: 2px solid transparent; outline-offset: 2px; font-size: 14px; line-height: 16px; }
.auth-terms input { flex: 0 0 auto; margin: 2px 0 0; }
.auth-terms--attention { animation: auth-terms-blink 240ms ease-in-out 4; }
@keyframes auth-terms-blink {
  0%, 100% { background-color: transparent; outline-color: transparent; }
  50% { background-color: #ffe2e2; outline-color: #c00000; }
}
.auth-google-button { position: relative; display: flex; justify-content: center; min-height: 42px; margin: 6px 0; }
.auth-google-terms-gate {
  position: absolute; z-index: 2; top: 0; left: 50%; width: 280px; max-width: 100%; height: 42px; padding: 0;
  transform: translateX(-50%); border: 0; background: transparent; opacity: 0; cursor: pointer;
}
.auth-google-terms-gate:focus-visible { opacity: 1; color: #111; background: #fff; outline: 2px solid #c00000; font: inherit; }
@media (prefers-reduced-motion: reduce) {
  .auth-terms--attention { animation: none; background-color: #ffe2e2; outline-color: #c00000; }
}

.industry-window {
  --ttd-bg: #c98564;
  color: #160f0b; background: #c98564; font: 16px/18px "OpenTTD Sans", sans-serif; text-shadow: none;
}
.industry-window .ttd-window__body { background: var(--ttd-bg); text-shadow: none; }
.industry-window__preview {
  box-sizing: border-box; height: 176px; margin: 3px; overflow: hidden;
  border: 4px ridge #e3a27e; background: #243a25;
}
.industry-window__map { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.industry-window__details { padding: 0 4px 5px; }
.industry-window__section-title { margin-top: 2px; font-weight: bold; }
.industry-window__cargo-list { display: flex; flex-direction: column; }
.industry-window__cargo { display: flex; align-items: center; gap: 6px; min-height: 20px; color: #ffe46a; font-weight: bold; text-shadow: 1px 1px #332019; }
.industry-window__cargo-mark { width: 12px; height: 12px; flex: 0 0 12px; background: var(--industry-cargo-color); border: 1px solid #44352d; }
.industry-window__production-title { margin-top: 10px; }
.industry-window__production { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.industry-window__production > span { color: #ffe46a; font-weight: bold; text-shadow: 1px 1px #332019; }
.industry-window__empty, .industry-window__error { padding: 3px 0; }
.industry-window__error { color: #651717; }

@media (max-width: 520px) {
  .player-options__grid { grid-template-columns: 1fr; }
}

.route-manager { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.route-manager h4, .route-manager h5 { margin: 4px 0 0; }
.route-manager__form { display: grid; grid-template-columns: minmax(100px, 1.5fr) minmax(66px, .6fr) minmax(100px, 1fr) minmax(100px, 1fr) auto; align-items: end; gap: 5px; }
.route-manager__form label { display: flex; flex-direction: column; gap: 2px; }
.route-manager__list { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow: auto; }
.route-manager__route { display: flex; flex-direction: column; gap: 4px; padding: 5px; border-top: 1px solid var(--ttd-bevel-dark); }
.route-manager__title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.route-manager__title strong { color: var(--ttd-highlight); }
.route-manager__stops { color: var(--ttd-light); }
.route-manager__status { padding: 2px 4px; color: #aaffaa; background: #173817; }
.route-manager__status--waiting_for_lease { color: #ffe28a; background: #493600; }
.route-manager__status--waiting_for_alternative, .route-manager__status--unreachable { color: #ffaaaa; background: #481515; }
.route-manager__access, .route-manager__vehicle, .route-manager__rental { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; padding: 3px 0; }
.route-manager__choice { color: var(--ttd-highlight); }
.route-manager__actions, .route-manager__assign { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.route-manager__assign .ttd-input { flex: 1 1 180px; }
.route-manager__message { min-height: 18px; color: #ffaaaa; }

@media (max-width: 650px) {
  .route-manager__form { grid-template-columns: 1fr 1fr; }
  .route-manager__form > button { grid-column: 1 / -1; }
}

/* Directory/map windows use compact, beveled OpenTTD lists rather than the generic black inset panel. */
.open-ttd-directory-window, .subsidy-directory-window {
  --directory-bg: #98845c;
  --ttd-bg: var(--directory-bg);
  --directory-light: #d4bc94;
  --directory-dark: #68502c;
  color: #101010;
  background: var(--directory-bg);
}
.open-ttd-directory-window .ttd-window__body, .subsidy-directory-window .ttd-window__body {
  background: var(--directory-bg);
  color: #101010;
  text-shadow: none;
}
.open-ttd-directory-window .ttd-window__caption, .subsidy-directory-window .ttd-window__caption {
  background: var(--directory-bg);
  border-color: var(--directory-light) var(--directory-dark) var(--directory-dark) var(--directory-light);
  box-shadow: inset 2px 2px 0 var(--directory-dark), inset -2px -2px 0 var(--directory-light);
}
.open-ttd-directory-window .ttd-list, .subsidy-directory-window .ttd-list {
  background: var(--directory-bg);
  border-color: var(--directory-dark) var(--directory-light) var(--directory-light) var(--directory-dark);
}
.open-ttd-directory__sortbar, .station-directory__filterbar, .station-directory__modebar,
.world-map__controls { display: flex; align-items: center; gap: 3px; padding: 2px; }
.open-ttd-directory__sortbar { justify-content: flex-end; }
.open-ttd-directory__sort, .station-directory__filter {
  box-sizing: border-box; min-width: 0; height: 24px; padding: 0 4px;
  color: var(--ttd-ink); background: var(--ttd-bg); border: 2px solid;
  border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light) var(--ttd-bevel-light) var(--ttd-bevel-dark);
  font: inherit;
}
.industry-directory__filterbar {
  position: relative; z-index: 2; display: grid; flex: 0 0 auto; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 2px;
  border-top: 2px solid var(--ttd-bevel-light); border-bottom: 2px solid var(--ttd-bevel-dark);
}
.industry-directory__filter { position: relative; min-width: 0; }
.industry-directory__filter:focus-within { z-index: 3; }
.industry-directory__filter-button {
  box-sizing: border-box; width: 100%; height: 25px; overflow: hidden; padding: 0 5px;
  color: var(--ttd-ink); background: var(--ttd-bg); border: 2px solid;
  border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light) var(--ttd-bevel-light) var(--ttd-bevel-dark);
  font: inherit; text-align: left; text-overflow: ellipsis; white-space: nowrap;
}
.industry-directory__filter-menu {
  position: absolute; z-index: 30; top: calc(100% + 1px); left: 0; min-width: 100%; width: max-content;
  max-width: min(320px, calc(100vw - 32px)); max-height: min(320px, 50vh); overflow: auto; padding: 2px;
  color: var(--ttd-ink); background: var(--ttd-bg); border: 2px solid;
  border-color: var(--ttd-bevel-light) var(--ttd-bevel-dark) var(--ttd-bevel-dark) var(--ttd-bevel-light);
  box-shadow: 2px 2px 0 #302516;
}
.industry-directory__filter--type .industry-directory__filter-menu { right: 0; left: auto; }
.industry-directory__filter-option {
  display: grid; grid-template-columns: 18px 20px minmax(100px, 1fr); align-items: center; gap: 4px;
  min-height: 25px; padding: 1px 4px; white-space: nowrap; cursor: pointer;
}
.industry-directory__filter-option:hover { color: #fff; background: #6d5b3d; }
.industry-directory__filter-option input { width: 14px; height: 14px; margin: 0; accent-color: #604923; }
.industry-directory__filter-option canvas { width: 20px; height: 20px; image-rendering: pixelated; }
.industry-directory-window .ttd-window__body { flex: 1 1 auto; overflow: hidden; }
.industry-directory__sortbar { flex: 0 0 auto; justify-content: flex-start; }
.industry-directory__sort-direction { flex: 0 0 132px; width: 132px; }
.town-directory__list, .station-directory__list { width: 100%; max-height: min(420px, 55vh); }
.open-ttd-directory-window .town-directory__list .row,
.station-directory-window .station-directory__list .row {
  display: flex; align-items: center; gap: 5px; height: 22px; line-height: 20px; padding: 0 3px;
  white-space: nowrap; cursor: pointer;
}
.open-ttd-directory-window .town-directory__list .row { color: #ffbd43; text-shadow: 1px 1px #332819; }
.open-ttd-directory-window .town-directory__list .row:hover { background: #aa966d; }
.open-ttd-directory-window .industry-directory__list .industry-directory__row {
  box-sizing: border-box; height: auto; min-height: 22px; gap: 10px; padding: 1px 3px;
}
.open-ttd-directory-window .industry-directory__list { position: relative; z-index: 1; flex: 1 1 auto; max-height: none; min-height: 0; }
.industry-directory__production { flex: 0 1 auto; max-width: 72%; overflow: hidden; color: #f3e6aa; text-shadow: 1px 1px #332819; text-overflow: ellipsis; }
.town-directory__name, .station-directory__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.town-directory__population { flex: 0 0 auto; font-weight: bold; }
.town-directory__footer, .station-directory__footer {
  min-height: 22px; padding: 1px 4px; border-top: 2px solid var(--ttd-bevel-dark); font-weight: bold;
}
.station-directory-window { --ttd-bg: #858585; color: #101010; background: #858585; }
.station-directory-window .ttd-window__body { background: #858585; text-shadow: none; }
.station-directory-window .station-directory__list { background: #858585; }
.station-directory-window .station-directory__list .row { color: #fff7a8; text-shadow: 1px 1px #333; }
.station-directory-window .station-directory__list .row:hover { background: #777; }
.station-directory__modebar { border-bottom: 2px solid var(--ttd-bevel-dark); }
.station-directory__mode { display: grid; place-items: center; min-width: 34px; height: 30px; padding: 1px 3px; }
.station-directory__mode canvas, .station-directory__icons canvas { image-rendering: pixelated; }
.station-directory__mode.is-active { background: #d2d2a0; }
.station-directory__filterbar { gap: 4px; }
.station-directory__icons { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 1px; }
.station-directory__rating { flex: 0 0 34px; text-align: right; }
.world-map-window .ttd-window__body { background: var(--ttd-bg); }
.world-map__viewport {
  box-sizing: border-box; width: 840px; height: 460px; margin: 4px;
  border: 3px solid; border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light) var(--ttd-bevel-light) var(--ttd-bevel-dark);
  background: #101820;
}
.world-map__canvas { display: block; width: 100%; height: 100%; cursor: crosshair; image-rendering: pixelated; }
.world-map__controls { border-top: 2px solid var(--ttd-bevel-dark); }
.world-map__controls .ttd-btn { flex: 0 0 auto; min-height: 25px; padding-inline: 8px; }
.world-map__legend {
  display: grid; grid-template-columns: repeat(2, minmax(200px, 1fr)); gap: 1px 4px;
  max-height: 130px; overflow: auto; padding: 3px; background: var(--ttd-bg);
}
.world-map__legend-item {
  display: flex; align-items: center; gap: 4px; min-width: 0; height: 24px; padding: 1px 3px;
  overflow: hidden; color: var(--ttd-ink); background: var(--ttd-bg); border: 1px solid transparent;
  font: inherit; text-align: left; text-shadow: none; white-space: nowrap; cursor: pointer;
}
.world-map__legend-item.is-active { border-color: var(--ttd-bevel-dark) var(--ttd-bevel-light) var(--ttd-bevel-light) var(--ttd-bevel-dark); }
.world-map__legend-item canvas { flex: 0 0 22px; image-rendering: pixelated; }
.world-map__legend-swatch { flex: 0 0 18px; width: 18px; height: 18px; background: #4c9a3a; border: 1px solid #274a24; }
.world-map__legend-item span { overflow: hidden; text-overflow: ellipsis; }
.world-map__message { min-height: 18px; padding: 0 5px; color: #651717; text-shadow: none; }
.subsidy-directory__content { max-height: min(360px, 55vh); overflow: auto; padding: 4px; }
.subsidy-directory__section h4 { margin: 5px 0 1px; color: #17120b; font-weight: bold; }
.subsidy-directory__row { display: flex; align-items: center; gap: 5px; min-height: 22px; color: #ffbd43; font-weight: bold; text-shadow: 1px 1px #332819; }
.subsidy-directory__row.is-clickable { cursor: pointer; }
.subsidy-directory__row.is-clickable:hover { background: #aa966d; }
.subsidy-directory__cargo {
  display: inline-grid; place-items: center; flex: 0 0 20px; width: 20px; height: 18px;
  color: #101010; background: #e6d181; border: 1px solid #4d422c; font-size: 10px; text-shadow: none;
}
.subsidy-directory__cargo--CO, .subsidy-directory__cargo--IO { background: #858585; }
.subsidy-directory__cargo--PA, .subsidy-directory__cargo--MA { background: #e5e5b0; }
.subsidy-directory__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.subsidy-directory__empty { min-height: 22px; color: #16120b; }

@media (max-width: 760px) {
  .world-map-window { max-width: calc(100vw - 16px); }
  .world-map__viewport { width: min(840px, calc(100vw - 48px)); height: min(460px, 45vh); }
  .world-map__legend { grid-template-columns: 1fr; }
  .station-directory__filterbar { flex-wrap: wrap; }
}

.store-window { max-width: calc(100vw - 16px); }
.store-window .ttd-window__body { background: #858585; }
.store-window__body { display: flex; flex-direction: column; min-height: 0; height: 100%; color: #171717; text-shadow: none; }
.store-window__notice { padding: 5px 7px; color: #17212a; background: #d4d0c4; border-bottom: 1px solid #555; }
.store-window__notice[hidden] { display: none; }
.store-window__tabs { display: flex; gap: 3px; padding: 4px 5px 2px; border-bottom: 2px solid var(--ttd-bevel-dark); }
.store-window__tab { min-width: 94px; }
.store-window__tab[aria-pressed="true"] { background: #d2d2a0; }
.store-window__content { min-height: 0; flex: 1 1 auto; overflow: auto; padding: 5px; }
.store-window__product { display: flex; align-items: center; gap: 9px; min-height: 74px; padding: 6px 4px; border-bottom: 1px solid #5d5d5d; }
.store-window__swatch { flex: 0 0 38px; width: 38px; height: 38px; border: 2px solid; border-color: #dedede #444 #444 #dedede; box-shadow: inset 0 0 0 4px #ffffff26; }
.store-window__product-details { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.store-window__product-name { font-weight: bold; }
.store-window__product-description { color: #292929; }
.store-window__price { padding-top: 2px; font-weight: bold; }
.store-window__action { flex: 0 0 auto; min-width: 92px; }
.store-window__action:disabled { cursor: default; opacity: .72; }
.store-window__fine-print { margin: 6px 2px 1px; color: #303030; font-size: 12px; }
.store-window__empty { padding: 10px 5px; color: #242424; }
.store-window__history-wrap { overflow: auto; }
.store-window__history { width: 100%; border-collapse: collapse; }
.store-window__history th, .store-window__history td { padding: 4px 5px; border-bottom: 1px solid #626262; text-align: left; white-space: nowrap; }
.store-window__history th { font-weight: bold; background: #777; }
.store-window__history td:last-child { text-transform: capitalize; }

@media (max-width: 600px) {
  .store-window__product { align-items: flex-start; flex-wrap: wrap; }
  .store-window__product-details { flex-basis: calc(100% - 56px); }
  .store-window__action { margin-left: 47px; }
}

.toolbar-heart { display: block; image-rendering: pixelated; }
.store-window { width: 900px; max-width: calc(100vw - 16px); max-height: calc(100vh - 56px); }
.store-window .ttd-window__body { min-height: 0; background: #858585; }
.store-window__body { display: flex; flex-direction: column; min-height: 0; height: 100%; overflow: auto; padding: 8px; color: #171717; text-shadow: none; }
.store-window__notice { margin-bottom: 6px; padding: 5px 7px; color: #17212a; background: #d4d0c4; border-bottom: 1px solid #555; }
.store-window__notice[hidden] { display: none; }
.store-window__summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 4px 6px 8px; border-bottom: 2px solid var(--ttd-bevel-dark); }
.store-window__intro { max-width: 58%; margin: 0; color: #242424; }
.store-window__summary-label { color: #202020; font-weight: bold; }
.store-window__balance { padding-top: 3px; color: #8b1f2b; font-size: 24px; font-weight: bold; }
.store-window__fine-print { display: block; margin: 5px 0 0; color: #393939; font-size: 12px; }
.store-window__availability { margin: 6px 3px 2px; color: #303030; font-size: 12px; }
.store-window__section { margin-top: 6px; }
.store-window__section-title { margin: 4px 4px 2px; color: #171717; font-size: 15px; font-weight: bold; }
.store-window__support-row { display: grid; grid-template-columns: 30px minmax(160px, 1fr) 150px 150px; align-items: center; gap: 8px; min-height: 48px; padding: 4px 5px; border-bottom: 1px solid #666; }
.store-window__support-icon { display: grid; place-items: center; font-size: 19px; line-height: 24px; }
.store-window__product-details { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.store-window__product-name { font-weight: bold; }
.store-window__product-description { color: #343434; }
.store-window__support-price { text-align: right; white-space: nowrap; }
.store-window__action { min-width: 120px; }
.store-window__action:disabled { cursor: default; opacity: .72; }
.store-window__tier-select { width: 150px; min-width: 0; height: 28px; padding: 2px 4px; }
.store-window__support-row--high { min-height: 56px; }
.store-window__support-row--high .store-window__product-details { grid-column: 2; }
.store-window__support-row--high .store-window__tier-select { grid-column: 3; }
.store-window__support-row--high .store-window__action { grid-column: 4; }
.store-window__cosmetics { margin-top: 9px; border-top: 1px solid #666; }
.store-window__cosmetic-row .store-window__swatch { width: 28px; height: 28px; border: 2px solid #444; }
.store-window__history-wrap { overflow: auto; }
.store-window__history { width: 100%; border-collapse: collapse; }
.store-window__history th, .store-window__history td { padding: 4px 6px; border-bottom: 1px solid #666; text-align: left; white-space: nowrap; }
.store-window__history th { font-weight: bold; background: #777; }
.store-window__empty { margin: 4px; color: #292929; }

@media (max-width: 760px) {
  .store-window__summary { align-items: flex-start; flex-direction: column; gap: 5px; }
  .store-window__intro { max-width: none; }
  .store-window__support-row { grid-template-columns: 28px minmax(120px, 1fr) 120px; }
  .store-window__support-price { grid-column: 3; }
  .store-window__support-row > .store-window__action { grid-column: 3; }
  .store-window__support-row--high .store-window__tier-select { grid-column: 2; }
  .store-window__support-row--high .store-window__action { grid-column: 3; }
}
