:root {
  color-scheme: dark;
  font-family: Tahoma, Verdana, Arial, sans-serif;
  font-synthesis: none;
  --bar-dark: #335326;
  --bar-mid: #4b7536;
  --bar-light: #7da060;
  --canvas: #1b2917;
  --chrome: #a8a8a8;
  --chrome-light: #d4d4d4;
  --chrome-dark: #545454;
  --ink: #151515;
  --yellow: #fff06b;
  --red: #c52a24;
  --focus: #fff27a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
}

body {
  min-height: 100dvh;
  color: #f7f7f3;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

button {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--chrome-dark);
  border-top-color: #efefef;
  border-left-color: #efefef;
  color: var(--ink);
  background: var(--chrome);
  box-shadow: inset -1px -1px #707070, inset 1px 1px #d8d8d8;
  cursor: pointer;
}

button:hover {
  background: #bebebe;
}

button:active,
button[aria-pressed="true"] {
  border-color: #f0f0f0;
  border-top-color: #515151;
  border-left-color: #515151;
  background: #929292;
  box-shadow: inset 1px 1px #696969;
}

button:disabled {
  color: #5d5d5d;
  cursor: wait;
}

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

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--yellow);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: none;
}

.app-shell {
  position: fixed;
  inset: 0;
  isolation: isolate;
  display: grid;
  grid-template-rows: 38px minmax(0, 1fr);
  min-height: 100dvh;
  overflow: hidden;
  background: var(--canvas);
}

.game-toolbar {
  grid-row: 1;
  z-index: 5;
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 3px 6px;
  border-bottom: 2px solid #1d3017;
  color: #fff;
  background: var(--bar-dark);
  box-shadow: inset 0 1px var(--bar-light);
}

.game-brand {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  text-shadow: 1px 1px #13220f;
}

.game-brand__name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.game-brand__version {
  color: #d7e8c9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.desktop-actions {
  min-width: 0;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.desktop-actions button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 4px 8px;
  font-size: 0.78rem;
}

.mobile-menu-button {
  display: none;
}

.game-stage {
  grid-row: 2;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #080d07;
}

canvas.emscripten {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  image-rendering: pixelated;
  cursor: none !important;
  touch-action: none;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow: auto;
  background-color: #27451f;
  background-image:
    linear-gradient(30deg, rgb(255 255 255 / 3%) 12%, transparent 12.5%, transparent 87%, rgb(0 0 0 / 8%) 87.5%),
    linear-gradient(150deg, rgb(255 255 255 / 3%) 12%, transparent 12.5%, transparent 87%, rgb(0 0 0 / 8%) 87.5%),
    linear-gradient(30deg, rgb(255 255 255 / 3%) 12%, transparent 12.5%, transparent 87%, rgb(0 0 0 / 8%) 87.5%);
  background-position: 0 0, 0 0, 24px 42px;
  background-size: 48px 84px;
}

.boot-panel {
  width: min(590px, 100%);
  border: 2px solid #353535;
  outline: 1px solid #d3d3d3;
  color: var(--ink);
  background: var(--chrome);
  box-shadow: 12px 14px rgb(10 20 8 / 42%);
}

.boot-panel__titlebar,
.pixel-dialog__titlebar {
  min-height: 27px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 5px;
  color: #fff;
  background: var(--bar-mid);
  box-shadow: inset 1px 1px var(--bar-light), inset -1px -1px #243d1c;
  text-shadow: 1px 1px #1a2c15;
}

.boot-panel__titlebar {
  font-size: 0.78rem;
  font-weight: 700;
}

.boot-panel__body {
  display: grid;
  gap: 16px;
  padding: clamp(18px, 5vw, 34px);
  border-top: 1px solid #525252;
}

.edition-label {
  margin: 0;
  color: #34452d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
}

.openttd-wordmark {
  max-width: 14ch;
  margin: 0;
  color: #fff;
  font-size: clamp(2.8rem, 11vw, 5.3rem);
  font-weight: 700;
  letter-spacing: -0.08em;
  line-height: 0.9;
  text-shadow: 3px 3px #1d3c16, 5px 5px #101d0d;
}

.openttd-wordmark::first-letter {
  color: var(--yellow);
}

.boot-intro,
.boot-footnote,
.boot-readout p,
.about-dialog p,
.about-dialog li {
  text-wrap: pretty;
}

.boot-intro {
  max-width: 50ch;
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
}

.boot-readout {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid #686868;
  border-top-color: #4b4b4b;
  border-left-color: #4b4b4b;
  background: #8e8e8e;
  box-shadow: inset 1px 1px #747474, inset -1px -1px #c7c7c7;
}

.boot-readout__status,
.boot-readout__detail {
  margin: 0;
}

.boot-readout__status {
  font-size: 0.92rem;
  font-weight: 700;
}

.boot-readout__detail {
  min-height: 2.6em;
  color: #252525;
  font-size: 0.82rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

progress {
  width: 100%;
  height: 15px;
  overflow: hidden;
  border: 1px solid #424242;
  border-radius: 0;
  color: #4a7f36;
  background: #707070;
  accent-color: #4a7f36;
}

progress::-webkit-progress-bar {
  background: #707070;
}

progress::-webkit-progress-value {
  background: repeating-linear-gradient(90deg, #6fa14f 0 10px, #84b865 10px 20px);
}

progress::-moz-progress-bar {
  background: repeating-linear-gradient(90deg, #6fa14f 0 10px, #84b865 10px 20px);
}

.boot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-button {
  min-height: 38px;
  padding: 7px 16px;
  border-color: #173311;
  border-top-color: #a4ce89;
  border-left-color: #a4ce89;
  color: #fff;
  background: #4d7b39;
  box-shadow: inset -1px -1px #28451f, inset 1px 1px #7ca262;
  text-shadow: 1px 1px #1d3316;
}

.primary-button:hover {
  background: #5c8c46;
}

.build-ledger {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid rgb(0 0 0 / 18%);
}

.build-ledger div {
  min-width: 0;
  padding: 8px 10px;
  border-bottom: 1px solid rgb(0 0 0 / 18%);
}

.build-ledger div:nth-child(even) {
  border-left: 1px solid rgb(0 0 0 / 18%);
}

.build-ledger dt {
  color: #394435;
  font-size: 0.72rem;
}

.build-ledger dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.boot-footnote {
  max-width: 64ch;
  margin: 0;
  color: #dcebd4;
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
  text-shadow: 1px 1px #152711;
}

.toast {
  position: fixed;
  z-index: 20;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(420px, calc(100vw - 24px));
  padding: 9px 11px;
  border: 1px solid #f5d869;
  color: #fff7bb;
  background: #5e4f1c;
  box-shadow: 4px 5px rgb(0 0 0 / 35%);
  font-size: 0.82rem;
  line-height: 1.45;
}

.pixel-dialog {
  width: min(620px, calc(100vw - 24px));
  max-height: min(760px, calc(100dvh - 24px));
  padding: 0;
  overflow: hidden;
  border: 2px solid #303030;
  border-radius: 0;
  color: var(--ink);
  background: var(--chrome);
  box-shadow: 10px 12px rgb(0 0 0 / 45%);
}

.pixel-dialog::backdrop {
  background: rgb(7 14 6 / 72%);
}

.pixel-dialog__titlebar h2 {
  margin: 0;
  font-size: 0.85rem;
}

.pixel-dialog__titlebar button {
  min-width: 29px;
  min-height: 25px;
  padding: 0 7px;
  line-height: 1;
}

.about-dialog__body {
  max-height: calc(100dvh - 120px);
  display: grid;
  gap: 18px;
  padding: 18px;
  overflow: auto;
}

.about-dialog section {
  display: grid;
  gap: 8px;
}

.about-dialog h3,
.about-dialog p,
.about-dialog ul {
  margin: 0;
}

.about-dialog h3 {
  font-size: 1rem;
}

.about-dialog p,
.about-dialog li {
  font-size: 0.92rem;
  line-height: 1.5;
}

.about-dialog ul {
  display: grid;
  gap: 7px;
  padding-left: 20px;
}

.document-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
}

.document-links a {
  color: #154d83;
}

.pixel-dialog__footer {
  display: flex;
  justify-content: flex-end;
  padding: 8px;
  border-top: 1px solid rgb(0 0 0 / 24%);
}

.mobile-menu-dialog {
  width: min(360px, calc(100vw - 24px));
}

.mobile-menu-actions {
  display: grid;
  gap: 8px;
  padding: 14px;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-rows: 52px minmax(0, 1fr);
  }

  button {
    min-height: 48px;
    padding: 10px 12px;
    font-size: 1rem;
  }

  .game-toolbar {
    min-height: 52px;
    padding: 3px max(6px, env(safe-area-inset-right)) 3px max(6px, env(safe-area-inset-left));
  }

  .game-brand__version,
  .desktop-actions {
    display: none;
  }

  .mobile-menu-button {
    display: inline-block;
    min-height: 44px;
    padding: 8px 12px;
  }

  .boot-screen {
    align-content: start;
  }

  .boot-panel {
    box-shadow: 7px 8px rgb(10 20 8 / 42%);
  }

  .boot-panel__body {
    gap: 14px;
    padding: 18px;
  }

  .boot-intro,
  .boot-readout__detail,
  .build-ledger dd,
  .about-dialog p,
  .about-dialog li {
    font-size: 1rem;
  }

  .build-ledger {
    grid-template-columns: 1fr;
  }

  .build-ledger div:nth-child(even) {
    border-left: 0;
  }

  .boot-actions button {
    flex: 1 1 100%;
  }

  .toast {
    font-size: 1rem;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  .boot-screen {
    grid-template-columns: minmax(0, 620px) minmax(180px, 320px);
    align-content: center;
    align-items: end;
  }

  .boot-footnote {
    text-align: left;
  }

  .boot-panel__body {
    grid-template-columns: minmax(150px, 2fr) minmax(230px, 3fr);
    gap: 10px 18px;
    padding: 14px 18px;
  }

  .edition-label,
  .openttd-wordmark,
  .boot-intro {
    grid-column: 1;
  }

  .boot-readout,
  .boot-actions,
  .build-ledger {
    grid-column: 2;
  }

  .boot-readout {
    grid-row: 1 / span 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  progress::-webkit-progress-value,
  progress::-moz-progress-bar {
    background: #6fa14f;
  }
}

@media (forced-colors: active) {
  button,
  .boot-panel,
  .pixel-dialog,
  .boot-readout {
    border: 1px solid ButtonText;
    box-shadow: none;
  }

  canvas.emscripten {
    forced-color-adjust: none;
  }
}
