:root {
  --bg: #14202b; --panel: #1c2b38; --panel2: #243646; --line: #34495e; --text: #ecf0f1; --muted: #9fb3c3;
  --accent: #ffd23f; --ok: #27ae60; --bad: #e74c3c; --blue: #2e86de;
  --tools: 112px; --bar: 64px;
  --safeL: env(safe-area-inset-left, 0px); --safeR: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
input { font: inherit; user-select: text; -webkit-user-select: text; }
.hidden { display: none !important; }
.hiddenSoft { display: none !important; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* top bar */
#topbar { height: var(--bar); flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 0 calc(10px + var(--safeR)) 0 calc(10px + var(--safeL)); background: var(--panel); border-bottom: 1px solid var(--line); }
.barButton { height: 48px; min-width: 48px; border-radius: 12px; background: var(--panel2); font-size: 22px;
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px; }
.barButton .lbl { font-size: 15px; font-weight: 600; }
.barButton:active { background: var(--line); }
#infobar { flex: 1; display: flex; align-items: center; gap: 18px; min-width: 0; }
.company { font-weight: 800; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.badge { margin-left: 8px; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--accent); color: #222; vertical-align: middle; }
.stat { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; }
.statLabel { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat > span:last-child { font-size: 17px; font-weight: 700; }
.money { color: #8ff0a4; }
.money.neg { color: #ff8a80; }
.segmented { display: flex; background: var(--panel2); border-radius: 12px; padding: 3px; gap: 2px; }
#speedButtons button { height: 42px; min-width: 46px; border-radius: 9px; background: transparent; font-size: 13px; letter-spacing: -2px; }
#speedButtons button.selected { background: var(--accent); color: #222; }

/* layout */
#wrapper { flex: 1; display: flex; min-height: 0; }
#tools { width: calc(var(--tools) + var(--safeL)); padding: 8px 8px 8px calc(8px + var(--safeL)); background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; overflow-y: auto; touch-action: pan-y; }
.tool { flex: 0 0 auto; min-height: 64px; border-radius: 14px; background: var(--panel2); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px; font-size: 13px; font-weight: 600; padding: 6px 2px; border: 2px solid transparent; }
.tool .ico { font-size: 26px; line-height: 1; }
.tool small { font-size: 11px; color: var(--muted); font-weight: 500; }
.tool.selected { border-color: var(--accent); background: #3a4a2a; }
.tool.big { background: #1f4e79; margin-top: 4px; }
.tool.big:active { background: var(--blue); }
.tool:active { transform: scale(.97); }
#view { flex: 1; position: relative; overflow: hidden; touch-action: none; }
#map { position: absolute; inset: 0; display: block; touch-action: none; }

/* over the map */
.round { width: 56px; height: 56px; border-radius: 50%; background: rgba(28,43,56,.92); font-size: 28px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.4); }
#mapButtons { position: absolute; right: calc(14px + var(--safeR)); bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
#hint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(20,32,43,.92); padding: 10px 18px;
  border-radius: 24px; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.4); max-width: 80%; text-align: center; pointer-events: none; }
#toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(192,57,43,.95); padding: 10px 18px;
  border-radius: 12px; font-weight: 600; pointer-events: none; max-width: 80%; text-align: center; }
#toast.good { background: rgba(39,174,96,.95); }
#news { position: absolute; left: 12px; top: 64px; background: #fdf6e3; color: #222; padding: 12px 20px;
  border-radius: 10px; font-weight: 700; box-shadow: 0 4px 16px rgba(0,0,0,.5); border-left: 6px solid var(--ok); max-width: calc(100% - 460px); min-width: 220px; pointer-events: none; }
#news.bad { border-left-color: var(--bad); }
#ghostBar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 10px; }
.okButton { height: 60px; padding: 0 26px; border-radius: 30px; background: var(--ok); font-size: 18px; font-weight: 700; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.buttonRow button:disabled { opacity: .45; }
.okButton:disabled { background: #7f8c8d; opacity: .7; }
.cancelButton { height: 60px; width: 60px; border-radius: 30px; background: var(--bad); font-size: 22px; font-weight: 700; }
#routeBar { position: absolute; left: 12px; right: 84px; bottom: 12px; background: rgba(20,32,43,.95); border-radius: 16px;
  padding: 12px 14px; box-shadow: 0 4px 16px rgba(0,0,0,.5); }
#routeTitle { font-weight: 700; margin-bottom: 8px; }
#routeStops { display: flex; flex-wrap: wrap; gap: 6px; min-height: 36px; margin-bottom: 8px; }
.stop { background: var(--panel2); padding: 6px 12px; border-radius: 18px; font-weight: 600; }
.stop b { color: var(--accent); margin-right: 4px; }
#card { position: absolute; right: calc(84px + var(--safeR)); top: 12px; width: 340px; max-width: calc(100% - 100px); max-height: calc(100% - 24px);
  overflow-y: auto; background: rgba(20,32,43,.96); border-radius: 16px; padding: 14px 16px; box-shadow: 0 4px 16px rgba(0,0,0,.5);
  touch-action: pan-y; }
#card h3 { margin: 0 0 6px; font-size: 19px; display: flex; align-items: center; gap: 8px; }
#card .x { margin-left: auto; width: 40px; height: 40px; border-radius: 50%; background: var(--panel2); font-size: 18px; flex: 0 0 auto; }
#card dl, #finList { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 8px 0; }
#card dt, #finList dt { color: var(--muted); }
#card dd, #finList dd { margin: 0; font-weight: 600; text-align: right; }
.bar { height: 10px; background: var(--panel2); border-radius: 5px; overflow: hidden; margin-top: 3px; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.cardButtons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.cardButtons button { height: 48px; border-radius: 12px; background: var(--panel2); font-weight: 600; }
.cardButtons button.danger { background: #5c2a26; }

/* sheets */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 20;
  padding: 16px; }
.sheetPanel { background: var(--panel); border-radius: 20px; padding: 20px 22px; width: 420px; max-width: 100%; max-height: 100%;
  overflow-y: auto; box-shadow: 0 8px 30px rgba(0,0,0,.6); touch-action: pan-y; }
.sheetPanel.wide { width: 760px; }
.sheetPanel h2 { margin: 0 0 14px; font-size: 24px; }
.sheetPanel h3 { margin: 16px 0 8px; }
.menuItem { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 0 16px; margin-bottom: 8px;
  border-radius: 14px; background: var(--panel2); font-size: 18px; font-weight: 600; text-align: left; }
.menuItem span { font-size: 24px; }
.menuItem.close { justify-content: center; background: var(--line); margin-top: 8px; margin-bottom: 0; }
.buttonRow { display: flex; gap: 10px; margin-top: 12px; }
.buttonRow button { flex: 1; white-space: nowrap; min-height: 54px; border-radius: 14px; background: var(--panel2); font-size: 17px; font-weight: 700; }
.buttonRow .dialogOK, .dialogOK { background: var(--ok); }
.buttonRow .cancel { background: var(--line); }
.label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }
#companyInput { width: 100%; height: 54px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--text);
  padding: 0 14px; font-size: 18px; }
.choice { display: grid; grid-template-columns: repeat(3, 1fr); }
.choice.five { grid-template-columns: repeat(5, 1fr); }
.choice input { display: none; }
.choice label { min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 10px;
  font-weight: 700; cursor: pointer; }
.choice label small { font-weight: 500; color: var(--muted); font-size: 12px; }
.choice input:checked + label { background: var(--accent); color: #222; }
.choice input:checked + label small { color: #444; }
.modelGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.model { background: var(--panel2); border-radius: 14px; padding: 12px; text-align: left; border: 2px solid transparent; }
.model:active { border-color: var(--accent); }
.model.locked { opacity: .45; }
.model canvas { width: 100%; height: 60px; display: block; margin-bottom: 6px; }
.model b { display: block; font-size: 16px; }
.model .specs { font-size: 13px; color: var(--muted); }
.model .price { font-size: 17px; font-weight: 800; color: #8ff0a4; margin-top: 4px; }
.vehRow { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; background: var(--panel2); border-radius: 12px;
  padding: 8px 14px; margin-bottom: 6px; text-align: left; }
.vehRow .ico { font-size: 26px; }
.vehRow .main { flex: 1; min-width: 0; }
.vehRow .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vehRow .profit { font-weight: 700; }
.pos { color: #8ff0a4; } .neg { color: #ff8a80; }
.helpGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.helpGrid div { background: var(--panel2); border-radius: 12px; padding: 10px 12px; font-size: 15px; }
.helpGrid b { display: block; margin-bottom: 2px; }
.steps li { margin-bottom: 6px; }
.note { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }

/* splash */
.screen { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 30%, #2b4d6b, #0f1820 70%); }
.splashInner { display: flex; gap: 60px; align-items: center; padding: 24px; }
.splashLeft { text-align: center; }
.logoArt { font-size: 72px; display: flex; gap: 20px; justify-content: center; }
.logo { font-size: 84px; margin: 0; font-weight: 900; letter-spacing: -2px; color: var(--accent);
  text-shadow: 0 4px 0 #b8860b, 0 8px 20px rgba(0,0,0,.6); }
.subtitle { color: var(--muted); font-size: 18px; margin: 6px 0 22px; }
.splashRight { display: flex; flex-direction: column; gap: 12px; width: 300px; }
.bigButton { height: 68px; border-radius: 18px; background: var(--panel2); font-size: 22px; font-weight: 800; }
.bigButton.primary { background: var(--ok); }
.linkButton { height: 48px; background: transparent; color: var(--muted); font-size: 17px; text-decoration: underline; }
.continueInfo { color: var(--muted); text-align: center; font-size: 15px; }
.brandBy { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); text-decoration: none; font-size: 15px;
  padding: 8px 12px; border-radius: 14px; }
.brandBy:active { background: rgba(255,255,255,.08); }
.brandSquare { width: 64px; height: 64px; border-radius: 14px; background: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,.4); padding: 6px; }
.brandSquare img { max-width: 100%; max-height: 100%; }
.brandBy.inline { margin: 6px 0; }

#updateBar { position: fixed; left: 50%; top: 74px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 10px;
  background: var(--panel); padding: 8px 10px 8px 16px; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,.5); font-weight: 600; }
#updateBar button { height: 44px; padding: 0 16px; border-radius: 12px; font-weight: 700; }
#updateBar .cancel { background: var(--line); }
.androidOnly { display: none; }
body.android .androidOnly { display: flex; }

/* phones and small heights */
@media (max-height: 520px) {
  :root { --tools: 92px; --bar: 54px; }
  .tool { min-height: 52px; font-size: 11px; }
  .tool .ico { font-size: 22px; }
  .tool small { display: none; }
  .barButton { height: 42px; }
  .barButton .lbl { display: none; }
  #speedButtons button { height: 36px; min-width: 38px; }
  .stat > span:last-child { font-size: 15px; }
  .company { font-size: 15px; }
  .logo { font-size: 56px; }
  .logoArt { font-size: 48px; }
  .splashInner { gap: 28px; }
  .bigButton { height: 56px; }
  .sheetPanel { padding: 14px 16px; }
  .sheetPanel h2 { font-size: 20px; margin-bottom: 8px; }
  .menuItem { min-height: 48px; font-size: 16px; margin-bottom: 6px; }
  .helpGrid div { font-size: 13px; }
  #routeBar { display: flex; align-items: center; gap: 8px; left: 8px; right: 76px; bottom: 8px; padding: 6px 8px; }
  #routeTitle { display: none; }
  .label { margin: 8px 0 4px; font-size: 12px; }
  #companyInput { height: 44px; }
  .choice label { min-height: 46px; }
  .sheetPanel .buttonRow { margin-top: 8px; }
  .sheetPanel .buttonRow button { min-height: 46px; }
  #news { top: 46px; left: 8px; padding: 8px 14px; font-size: 14px; max-width: calc(100% - 340px); min-width: 0; }
  #card { width: 300px; right: 76px; top: 8px; padding: 10px 12px; }
  #card h3 { font-size: 16px; }
  #card .x { width: 34px; height: 34px; }
  #card dl { gap: 1px 10px; margin: 4px 0; font-size: 14px; }
  #card .label { display: none; }
  .cardButtons { margin-top: 6px; gap: 6px; }
  .cardButtons button { height: 40px; font-size: 14px; }
  #hint { padding: 6px 14px; font-size: 14px; }
  #routeStops { flex: 1; margin: 0; min-height: 0; flex-wrap: nowrap; overflow-x: auto; touch-action: pan-x; }
  .stop { white-space: nowrap; padding: 5px 10px; font-size: 14px; }
  #routeBar .buttonRow { margin: 0; flex: 0 0 auto; gap: 6px; }
  #routeBar .buttonRow button { min-height: 44px; padding: 0 12px; font-size: 15px; }
  #ghostBar .okButton, #ghostBar .cancelButton { height: 50px; }
  #ghostBar .cancelButton { width: 50px; }
}
@media (max-width: 760px) {
  .hideNarrow { display: none; }
  #infobar { gap: 10px; }
  .company { max-width: 120px; }
}
@media (max-width: 600px) {
  .splashInner { flex-direction: column; gap: 16px; }
  .helpGrid { grid-template-columns: 1fr; }
}

/* TT edition */
.orders { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.stop { background: var(--panel2); padding: 6px 12px; border-radius: 18px; font-weight: 600; font-size: 14px; }
.stop.cur { background: #3a4a2a; outline: 2px solid var(--accent); }
.cardButtons button.go, #cBuy.go { background: #1f6b3a; }
.buyDetail canvas { width: 100%; height: auto; display: block; border-radius: 12px; margin-bottom: 8px; image-rendering: pixelated; }
.model canvas { image-rendering: pixelated; }
.detailRow { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; font-size: 17px; border-bottom: 1px solid var(--line); }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button { width: 52px; height: 46px; border-radius: 12px; background: var(--panel2); font-size: 26px; font-weight: 800; }
.stepper b { min-width: 26px; text-align: center; font-size: 22px; }
.depotList { margin: 6px 0; max-height: 40vh; overflow-y: auto; }
#map { image-rendering: pixelated; }

/* 0.4.0: station tracks, airport growth */
.seg { display: flex; align-items: center; gap: 6px; margin: 10px 0 4px; }
.seg span { color: var(--muted); font-size: 14px; margin-right: 4px; }
.seg button { min-width: 48px; min-height: 44px; border-radius: 10px; border: 0; background: var(--panel2); color: inherit; font-size: 18px; font-weight: 700; }
.seg button.on { background: #2e86de; color: #fff; }
.seg button:disabled { opacity: 0.45; }
button.wide { width: 100%; min-height: 46px; margin: 10px 0 4px; border-radius: 12px; border: 0; background: #2e86de; color: #fff; font-size: 16px; font-weight: 700; }
label.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 4px 0; }
label.chk input { width: 22px; height: 22px; }

/* 0.4.2: saved games */
.savesList { max-height: 52vh; overflow-y: auto; margin-bottom: 10px; }
.saveRow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel2); margin-bottom: 8px; }
.saveRow.current { outline: 2px solid #2e86de; }
.saveRow .saveInfo { flex: 1; min-width: 0; }
.saveRow .saveInfo b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saveRow .saveInfo small { color: var(--muted); }
.saveRow button { min-width: 44px; min-height: 44px; border-radius: 10px; border: 0; background: #2e86de; color: #fff; font-size: 15px; font-weight: 700; padding: 0 12px; }
.saveRow button.icon { background: var(--panel); font-size: 18px; }
.saveRow button.danger { background: #a93226; }
.textInput { width: 100%; box-sizing: border-box; font-size: 18px; padding: 12px 14px; border-radius: 12px; border: 1px solid #4a5a6a; background: var(--panel2); color: inherit; margin-bottom: 14px; }

/* 0.4.3: save list buttons with labels, wrapping on narrow screens */
.saveRow { flex-wrap: wrap; }
.saveRow .saveInfo { flex: 1 1 260px; }
.saveBtns { display: flex; gap: 6px; flex-wrap: wrap; }
.saveRow button { padding: 0 10px; font-size: 14px; }
.saveRow button.icon { font-size: 14px; }
.saveRow button.danger { color: #fff; }

/* 0.4.4: custom map */
.customMap { background: var(--panel2); border-radius: 12px; padding: 10px 14px; margin-top: 8px; }
.customMap .label { margin-top: 8px; }
.customMap .choice { background: var(--panel); }
.slider { display: flex; align-items: center; gap: 12px; margin: 6px 0; font-size: 15px; }
.slider span { min-width: 110px; }
.slider input[type=range] { flex: 1; height: 36px; }
.menuItem b { margin-left: 4px; }

/* 0.5.0: minimap */
#minimap { position: absolute; left: 12px; bottom: 12px; background: rgba(20,30,40,0.9); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
#minimap canvas { display: block; width: 200px; height: 140px; image-rendering: pixelated; border-radius: 6px; }
#miniLabel { font-size: 11px; color: var(--muted); text-align: center; padding-top: 2px; }
@media (max-height: 520px) { #minimap canvas { width: 140px; height: 98px; } }
#routeDone.dim { opacity: 0.55; }

.price.lockedPrice { color: #e0a44a; }
