:root {
  --ink: #10151c;
  --panel: rgba(16, 21, 28, 0.88);
  --panel-solid: #151d27;
  --line: rgba(255, 255, 255, 0.12);
  --paper: #f2f6fa;
  --muted: #9fb0c0;
  --lime: #a8e05f;
  --lime-dark: #6fae2b;
  --orange: #ffb454;
  --red: #ff6b57;
  --blue: #59c8d6;
  --purple: #9b8cff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a0e13;
  color: var(--paper);
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#game { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud { position: absolute; inset: 0; pointer-events: none; user-select: none; }

.hud-top {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.chip .k {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.chip b { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.chip.money b { color: var(--lime); }
.chip.level b { color: var(--orange); }

.clockbox {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 16px;
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(6px);
}
.clockbox b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.clockbox span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); }

.contract {
  margin-left: auto;
  width: 310px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--lime);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  font-size: 13px;
}
.contract.empty { border-left-color: rgba(255, 255, 255, 0.15); }
.contract-empty { color: var(--muted); font-size: 12px; line-height: 1.4; }
.contract-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.contract-head span:first-child { font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; }
.contract-head .pay { color: var(--lime); font-weight: 800; font-size: 15px; }
.contract-route { margin-top: 4px; color: #d6e2ec; display: flex; gap: 7px; align-items: center; }
.contract-route i { color: var(--muted); font-style: normal; }
.contract-route span:last-child { color: var(--orange); font-weight: 700; }
.contract-meta { margin-top: 6px; display: flex; gap: 12px; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.contract-meta span::before { content: "• "; color: rgba(255, 255, 255, 0.25); }
.contract-meta span:first-child::before { content: ""; }

.hud-bottom {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.minimap-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
#minimap { display: block; width: 200px; height: 200px; border-radius: 9px; }
.minimap-label {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px 0;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.minimap-label span:last-child { color: var(--orange); letter-spacing: 0.04em; }

.dash {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.speedo {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 18px 10px;
  text-align: right;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  min-width: 130px;
}
.speedo span { font-size: 44px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.speedo small { display: block; font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

.gauges {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 235px;
  backdrop-filter: blur(6px);
}
.gauge { display: grid; grid-template-columns: 1fr 74px; grid-template-rows: auto auto; gap: 3px 8px; align-items: center; }
.gauge .gk { font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.gauge b { font-size: 11px; text-align: right; color: #dbe6ef; font-variant-numeric: tabular-nums; grid-column: 2; grid-row: 1; }
.gauge .bar { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.09); overflow: hidden; }
.gauge .bar i { display: block; height: 100%; width: 100%; border-radius: 4px; background: var(--blue); transition: width 0.2s linear, background 0.3s; }
.gauge .bar.dmg i { background: var(--orange); }
.gauge .bar.cargo i { background: var(--lime); }

.prompt {
  position: absolute;
  left: 50%;
  bottom: 210px;
  transform: translateX(-50%);
  background: rgba(12, 16, 22, 0.92);
  border: 1px solid rgba(168, 224, 95, 0.5);
  color: var(--paper);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}
.prompt kbd {
  display: inline-block;
  background: var(--lime);
  color: #16200c;
  border-radius: 6px;
  padding: 1px 8px;
  margin-right: 7px;
  font-family: inherit;
  font-weight: 800;
}

.toasts {
  position: absolute;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: min(520px, 70vw);
}
.toast {
  background: rgba(12, 16, 22, 0.94);
  border: 1px solid var(--line);
  border-left: 4px solid var(--lime);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease-out;
  text-align: center;
}
.toast.warn { border-left-color: var(--orange); }
.toast.bad { border-left-color: var(--red); }
.toast.good { border-left-color: var(--lime); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(18, 26, 36, 0.55), rgba(6, 9, 13, 0.86));
  padding: 24px;
  pointer-events: auto;
  overflow: auto;
}

#screen-loading { background: #0b1016; }

.loader { text-align: center; width: min(420px, 80vw); }
.loader-title { font-size: 34px; font-weight: 900; letter-spacing: 0.22em; margin-bottom: 18px; }
.loader-bar { height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 4%; background: var(--lime); transition: width 0.3s; }
.loader p { color: var(--muted); font-size: 12px; margin-top: 12px; letter-spacing: 0.08em; }

.title-card {
  width: min(560px, 92vw);
  text-align: center;
  background: rgba(10, 14, 19, 0.66);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 38px 30px 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.logo { display: flex; flex-direction: column; line-height: 0.86; font-weight: 900; letter-spacing: -0.02em; }
.logo span:first-child { font-size: clamp(44px, 9vw, 82px); color: var(--paper); }
.logo span:last-child { font-size: clamp(44px, 9vw, 82px); color: var(--lime); }
.tag { color: var(--muted); letter-spacing: 0.32em; text-transform: uppercase; font-size: 11px; margin: 16px 0 28px; }
.menu { display: flex; flex-direction: column; gap: 10px; width: min(320px, 80%); margin: 0 auto; }
.hint { color: var(--muted); font-size: 11px; margin-top: 24px; }
.credit { color: rgba(159, 176, 192, 0.55); font-size: 10px; margin-top: 10px; }

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: var(--paper);
  border-radius: 11px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.13); border-color: rgba(255, 255, 255, 0.28); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--lime); border-color: var(--lime); color: #15200b; }
.btn.primary:hover { background: #b8ee74; }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffb0a5; border-color: rgba(255, 107, 87, 0.35); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.panel {
  width: min(720px, 94vw);
  background: linear-gradient(180deg, rgba(24, 33, 45, 0.98), rgba(14, 20, 27, 0.98));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 24px;
  max-height: 92vh;
  overflow: auto;
}
.panel.wide { width: min(860px, 94vw); }
.panel.narrow { width: min(460px, 94vw); }
.panel.center { text-align: center; }
.panel h2 { margin: 0; font-size: 22px; letter-spacing: 0.01em; }
.panel h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.13em; color: var(--lime); }
.panel p { color: #c6d3de; font-size: 13px; line-height: 1.55; margin: 0 0 10px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.sub { color: var(--orange); font-size: 13px; font-weight: 700; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; }
.note { color: var(--muted); font-size: 11px; }

.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin: 8px 0 22px; }
.help-grid p { font-size: 12.5px; }
.help-grid b { color: var(--paper); }

/* Offers */
.offers { display: flex; flex-direction: column; gap: 10px; }
.offer {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 14px;
  align-items: center;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px 14px;
  transition: border-color 0.15s, background 0.15s;
}
.offer:hover { background: rgba(255, 255, 255, 0.075); border-color: rgba(168, 224, 95, 0.45); }
.offer.locked { opacity: 0.45; }
.offer .swatch { width: 46px; height: 46px; border-radius: 9px; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.18); }
.offer .o-name { font-weight: 800; font-size: 14px; }
.offer .o-desc { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.offer .o-meta { color: var(--muted); font-size: 11px; margin-top: 5px; display: flex; gap: 10px; flex-wrap: wrap; }
.offer .o-meta b { color: #e3edf5; font-weight: 700; }
.offer .o-right { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.offer .o-pay { font-weight: 900; font-size: 17px; color: var(--lime); }
.offer .o-time { color: var(--muted); font-size: 11px; }
.offer .btn { padding: 8px 16px; font-size: 12px; }

/* Station / garage */
.station-body { display: flex; flex-direction: column; gap: 14px; }
.srow { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.srow .sname { font-weight: 700; font-size: 13px; }
.srow .sdesc { color: var(--muted); font-size: 11px; margin-top: 2px; max-width: 320px; }
.srow .sright { display: flex; align-items: center; gap: 12px; }
.srow .cost { font-weight: 800; font-size: 13px; color: var(--orange); white-space: nowrap; }
.lvl-dots { display: flex; gap: 4px; }
.lvl-dots i { width: 9px; height: 9px; border-radius: 2px; background: rgba(255, 255, 255, 0.14); display: block; }
.lvl-dots i.on { background: var(--lime); }

.delivery-badge { display: inline-block; font-size: 10px; letter-spacing: 0.3em; color: #16200c; background: var(--lime); padding: 4px 12px; border-radius: 999px; font-weight: 800; }
.delivery-lines { margin: 18px 0 22px; display: flex; flex-direction: column; gap: 8px; }
.dline { display: flex; justify-content: space-between; font-size: 13px; color: #c6d3de; border-bottom: 1px dashed rgba(255, 255, 255, 0.12); padding-bottom: 6px; }
.dline b { color: var(--paper); }
.dline.total { border: none; margin-top: 4px; font-size: 17px; }
.dline.total b { color: var(--lime); font-size: 20px; }

#fatal {
  position: absolute;
  inset: auto 16px 16px 16px;
  background: rgba(60, 10, 10, 0.95);
  border: 1px solid var(--red);
  color: #ffd9d3;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 12px;
  white-space: pre-wrap;
  z-index: 50;
  max-height: 30vh;
  overflow: auto;
}

@media (max-width: 900px) {
  .contract { width: 240px; }
  .gauges { width: 190px; }
  #minimap { width: 150px; height: 150px; }
  .speedo span { font-size: 34px; }
}
@media (max-width: 700px) {
  .contract { display: none; }
  .gauges { display: none; }
  .prompt { bottom: 130px; }
}
