/* Ironway - interface styling.
   The map is the board; the panel is the traffic office: gunmetal, ruled,
   with company colours as the only bright things on it. */

:root {
  --ink: #14202a;
  --office: #1d2a33;
  --office-2: #24333d;
  --rule: #3a4c58;
  --parch: #e9e2cd;
  --parch-2: #d8cdb0;
  --sea: #96bacd;
  --paper: #f2ecdb;
  --text: #dfe6ea;
  --dim: #9fb0bb;
  --brass: #d8b062;
  --good: #6fbf73;
  --bad: #e2705f;
  --panel-w: 348px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--ink); color: var(--text);
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; -webkit-text-size-adjust: 100%;
}

#app { display: flex; height: 100%; width: 100%; }

/* ---------------------------------------------------------------- map */
#board { position: relative; flex: 1 1 auto; min-width: 0; background: #7ea6bb; }
#map { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

#hint {
  position: absolute; left: 12px; bottom: 12px; max-width: 44ch;
  background: rgba(20, 32, 42, .88); border: 1px solid var(--rule);
  border-radius: 3px; padding: 7px 11px; color: var(--text);
  font-size: 12.5px; line-height: 1.45; pointer-events: none;
}
#hint b { color: var(--brass); font-weight: 600; }

#zoom {
  position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px;
}
#zoom button {
  width: 34px; height: 34px; font-size: 17px; line-height: 1;
  background: rgba(20, 32, 42, .9); color: var(--text);
  border: 1px solid var(--rule); border-radius: 3px; cursor: pointer;
}
#zoom button:hover { background: var(--office-2); }

#banner {
  position: absolute; top: 0; left: 0; right: 0; text-align: center;
  padding: 7px 12px; font-family: Georgia, "Iowan Old Style", serif;
  letter-spacing: .12em; text-transform: uppercase; font-size: 12.5px;
  background: linear-gradient(180deg, rgba(20, 32, 42, .93), rgba(20, 32, 42, 0));
  color: var(--parch); pointer-events: none;
}
#banner .turnno { color: var(--brass); }

/* ---------------------------------------------------------------- panel */
#panel {
  width: var(--panel-w); flex: 0 0 var(--panel-w); height: 100%;
  background: var(--office); border-left: 1px solid #0d151b;
  display: flex; flex-direction: column; overflow: hidden;
}

.brandbar {
  padding: 10px 14px 8px; border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, #26343e, #1d2a33);
}
.brandbar h1 {
  margin: 0; font-family: Georgia, "Iowan Old Style", serif; font-weight: 600;
  font-size: 21px; letter-spacing: .22em; text-transform: uppercase; color: var(--parch);
}
.brandbar .sub {
  margin-top: 3px; font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--dim);
}
/* the milepost lattice, echoed as a rule */
.dots {
  height: 7px; margin-top: 7px;
  background-image: radial-gradient(currentColor 1px, transparent 1.2px);
  background-size: 9px 7px; color: #465d6b; opacity: .9;
}

#panelScroll { flex: 1 1 auto; overflow-y: auto; padding: 0 0 10px; }

section.blk { border-bottom: 1px solid var(--rule); padding: 11px 14px; }
section.blk > h2 {
  margin: 0 0 8px; font-size: 10.5px; letter-spacing: .19em; text-transform: uppercase;
  color: var(--dim); font-weight: 700;
}

/* company strip */
.co { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.co .swatch { width: 12px; height: 12px; border-radius: 2px; flex: 0 0 auto; box-shadow: 0 0 0 1px #0c1319; }
.co .nm { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co .money { font-variant-numeric: tabular-nums; color: var(--parch); }
.co .gc { font-variant-numeric: tabular-nums; color: var(--dim); width: 32px; text-align: right; }
.co.active { background: #2b3d48; margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.co.active .nm { color: #fff; font-weight: 600; }

/* status readout */
.readout { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; }
.readout div { background: var(--office-2); border: 1px solid var(--rule); border-radius: 3px; padding: 6px 8px; }
.readout .k { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.readout .v { font-size: 16px; font-variant-numeric: tabular-nums; color: var(--parch); }
.readout .v small { font-size: 11px; color: var(--dim); }

/* waybills - the signature element */
.bill {
  position: relative; background: var(--paper); color: #23303a;
  border-radius: 2px; margin-bottom: 9px; padding: 7px 9px 7px 20px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  font-family: Georgia, "Iowan Old Style", serif;
}
.bill::before {
  content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 3px;
  background-image: radial-gradient(#a99f86 1.4px, transparent 1.6px);
  background-size: 3px 7px;
}
.bill .hdr {
  font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase;
  color: #6b7a85; border-bottom: 1px solid #cfc5aa; padding-bottom: 3px; margin-bottom: 4px;
}
.bill .row {
  display: flex; align-items: baseline; gap: 6px; padding: 3px 0; font-size: 13px;
  border-radius: 2px;
}
.bill .row .to { flex: 1 1 auto; }
.bill .row .to em { font-style: normal; color: #6b7a85; }
.bill .row .pay { font-variant-numeric: tabular-nums; font-weight: 600; }
.bill .row.can { background: #dcecd8; cursor: pointer; margin: 0 -4px; padding-left: 4px; padding-right: 4px; }
.bill .row.can:hover { background: #c9e4c3; }
.bill .row.hot .to { color: #1d5c2a; font-weight: 600; }

/* actions */
.acts { display: flex; flex-wrap: wrap; gap: 7px; }
button.act {
  flex: 1 1 auto; min-width: 96px; padding: 9px 10px; cursor: pointer;
  background: var(--office-2); color: var(--text);
  border: 1px solid var(--rule); border-radius: 3px;
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
}
button.act:hover:not(:disabled) { background: #31444f; border-color: #587284; }
button.act:disabled { opacity: .4; cursor: default; }
button.act.primary { background: var(--brass); border-color: #b9924a; color: #26200f; }
button.act.primary:hover:not(:disabled) { background: #e6c078; }
button.act:focus-visible { outline: 2px solid #8fd0ff; outline-offset: 2px; }

.loadrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  padding: 4px 8px; border-radius: 11px; font-size: 11.5px; cursor: pointer;
  background: #33454f; border: 1px solid var(--rule); color: var(--text);
}
.chip:hover { background: #3d525e; }
.chip.full { opacity: .45; cursor: default; }
.chip.load { background: #45372a; border-color: #6b5537; color: #f0dcbb; }

/* log */
#log { max-height: 190px; overflow-y: auto; font-size: 12px; line-height: 1.5; }
#log div { padding: 3px 0; border-bottom: 1px dotted #33454f; color: var(--dim); }
#log div.me { color: var(--text); }
#log div.ev { color: #f0c987; }

/* ---------------------------------------------------------------- overlays */
.veil {
  position: fixed; inset: 0; background: rgba(10, 16, 21, .72);
  display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px;
}
.sheet {
  width: min(560px, 100%); max-height: 92vh; overflow-y: auto;
  background: var(--office); border: 1px solid var(--rule); border-radius: 4px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
}
.sheet header {
  padding: 16px 20px 12px; border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, #26343e, #1d2a33);
}
.sheet header h2 {
  margin: 0; font-family: Georgia, "Iowan Old Style", serif; font-size: 26px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--parch); font-weight: 600;
}
.sheet header p { margin: 6px 0 0; color: var(--dim); font-size: 12.5px; line-height: 1.5; }
.sheet .body { padding: 16px 20px 20px; }
.sheet .body h3 {
  margin: 16px 0 8px; font-size: 10.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--dim);
}
.seat { display: flex; align-items: center; gap: 9px; padding: 5px 0; }
.seat .swatch { width: 14px; height: 14px; border-radius: 2px; }
.seat input[type=text] {
  flex: 1 1 auto; min-width: 0; background: #16222b; border: 1px solid var(--rule);
  color: var(--text); border-radius: 3px; padding: 6px 8px; font-size: 13px;
}
.seat select, #seedbox input {
  background: #16222b; border: 1px solid var(--rule); color: var(--text);
  border-radius: 3px; padding: 6px 8px; font-size: 13px;
}
#seedbox { display: flex; gap: 9px; align-items: center; }
#seedbox input { width: 130px; font-variant-numeric: tabular-nums; }
.sheet .foot { display: flex; gap: 9px; margin-top: 18px; }
.rules { font-size: 12.5px; line-height: 1.6; color: var(--dim); }
.rules b { color: var(--parch); font-weight: 600; }
.rules ul { margin: 6px 0 0; padding-left: 18px; }
.rules li { margin: 3px 0; }

.win { text-align: center; }
.win .co-name { font-size: 20px; color: var(--brass); font-family: Georgia, serif; letter-spacing: .1em; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  #panel {
    width: 100%; flex: 0 0 auto; max-height: 46%;
    border-left: none; border-top: 1px solid #0d151b; order: 2;
  }
  #board { order: 1; flex: 1 1 auto; }
  .brandbar h1 { font-size: 17px; }
  #log { max-height: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
