/* Subway Chess — MTA-signage identity.
   Not a dark dashboard. A service board. */

:root {
  --navy:     #0B1220;
  --navy-2:   #1A2338;
  --cream:    #F2ECE0;
  --cream-2:  #DCD3C2;
  --grey:     #7A8395;
  --rule:     #26314A;
  --alert:    #EE352E;

  /* Route bullet colors — grounded, kept from the original. */
  --r-1:  #EE352E; --r-2:  #EE352E; --r-3:  #EE352E;
  --r-4:  #00933C; --r-5:  #00933C; --r-6:  #00933C;
  --r-7:  #B933AD;
  --r-A:  #0039A6; --r-C:  #0039A6; --r-E:  #0039A6;
  --r-B:  #FF6319; --r-D:  #FF6319; --r-F:  #FF6319; --r-M: #FF6319;
  --r-G:  #6CBE45;
  --r-J:  #996633; --r-Z:  #996633;
  --r-L:  #A7A9AC;
  --r-N:  #FCCC0A; --r-Q:  #FCCC0A; --r-R:  #FCCC0A; --r-W: #FCCC0A;
  --r-S:  #808183;
  --r-SI: #053F7A;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--navy);
  color: var(--cream);
  font-family: 'Helvetica Neue', Helvetica, Inter, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { min-height: 100vh; padding: 20px 22px 40px; }

::selection { background: var(--alert); color: var(--cream); }

/* --------------------------------------------- Header / service board */
.board-head { margin-bottom: 10px; }
.line {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.mark {
  font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; font-size: 20px;
}
.ident {
  text-transform: uppercase; letter-spacing: 0.14em;
  font-size: 12px; color: var(--grey);
}
.link { color: var(--grey); text-decoration: none; transition: color 160ms ease; }
.link:hover { color: var(--cream); }
.dot { color: var(--rule); font-size: 14px; }
.grow { flex: 1 1 auto; }

.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 12px 0;
}
.rule.tight { margin: 6px 0 14px; }

.strap {
  color: var(--grey);
  font-size: 13px;
  max-width: 60ch;
}
.strap em { color: var(--cream); font-style: normal; font-weight: 500; }

/* --------------------------------------------- Route bullet strip */
.routes {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0;
}
.bullet {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  color: #fff;
  font-weight: 700; font-size: 12px; letter-spacing: 0;
  border-radius: 999px;   /* MTA bullets are circles */
}
.bullet.sq { border-radius: 0; }   /* Shuttle uses a square */
.bullet.y  { color: #000; }         /* Yellow lines have black text */

/* --------------------------------------------- Main grid */
.grid {
  display: grid;
  grid-template-columns: minmax(340px, 460px) 1fr;
  gap: 22px;
}
@media (max-width: 960px) {
  .grid { grid-template-columns: 1fr; }
}

.col-left, .col-right { display: flex; flex-direction: column; gap: 16px; }

/* --------------------------------------------- Panels */
.panel {
  background: var(--navy-2);
  border: 1px solid var(--rule);
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
}
.lbl {
  text-transform: uppercase; letter-spacing: 0.14em;
  font-size: 11px; color: var(--grey); font-weight: 500;
}
.lbl.right { text-align: right; }
.lbl.mono { font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace; letter-spacing: 0; text-transform: none; color: var(--cream); }
.lbl .num { color: var(--cream); font-weight: 600; }
.lbl.announce { color: var(--alert); }

/* Board wrap: keep chessboard.js styling; give it a cream frame that hints at print. */
.board-wrap { padding: 14px; }
#board { max-width: 100%; }

/* --------------------------------------------- Service status bar */
.service {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 4px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}
.service .dash {
  color: var(--rule); letter-spacing: -0.15em; font-size: 12px;
  white-space: nowrap;
}
.service .dash.short { color: var(--rule); }
.service .dash.grow { flex: 1 1 auto; overflow: hidden; }
.service .hud .phase {
  text-transform: uppercase; letter-spacing: 0.14em;
  font-weight: 700; font-size: 12px; color: var(--cream);
}
.service .hud.thinking .phase { color: var(--alert); }

/* --------------------------------------------- Controls */
.controls {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.ctrl-select { display: flex; flex-direction: column; gap: 4px; }
#side {
  appearance: none;
  background: transparent; color: var(--cream);
  border: 1px solid var(--rule);
  padding: 8px 12px;
  font-family: inherit; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.14em;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}
#side:hover { border-color: var(--cream-2); }

.ctrl-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  appearance: none;
  background: transparent; color: var(--cream);
  border: 1px solid var(--rule);
  padding: 10px 16px;
  font-family: inherit; font-size: 12px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}
.btn.small { padding: 6px 10px; font-size: 11px; }
.btn:hover:not(:disabled) { border-color: var(--cream); background: rgba(242, 236, 224, 0.04); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
  border-color: var(--cream);
  background: var(--cream); color: var(--navy);
}
.btn.primary:hover:not(:disabled) {
  background: var(--alert); border-color: var(--alert); color: var(--cream);
}

/* --------------------------------------------- Moves timetable */
.moves-panel {
  background: var(--navy-2);
  border: 1px solid var(--rule);
}
.moves-empty {
  padding: 24px 14px;
  color: var(--grey);
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
}
.moves-list {
  padding: 4px 0;
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
  max-height: 240px; overflow-y: auto;
}
.moves-list .row {
  display: grid;
  grid-template-columns: 3.5rem 1fr 1fr 4rem;
  align-items: baseline; gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--rule);
}
.moves-list .row:last-child { border-bottom: 0; }
.moves-list .row .idx { color: var(--grey); }
.moves-list .row .w   { color: var(--cream); }
.moves-list .row .b   { color: var(--cream); }
.moves-list .row .m   { color: var(--grey); text-align: right; font-size: 11px; }

/* --------------------------------------------- Map */
.map-panel { display: flex; flex-direction: column; min-height: 620px; }
.map-wrap {
  flex: 1 1 auto;
  position: relative;
  padding: 8px;
}
#mapsvg { width: 100%; height: 100%; display: block; }
.move-badge {
  position: absolute; pointer-events: none;
  padding: 6px 10px;
  background: var(--cream); color: var(--navy);
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0; transition: opacity 160ms ease, transform 160ms ease;
  transform: translateY(4px);
}
.move-badge.show { opacity: 1; transform: translateY(0); }

/* Map SVG element styles — kept close to original but signage-fied. */
.station        { fill: var(--cream); stroke: var(--navy); stroke-width: 1; cursor: default; }
.station.hot    { fill: var(--alert); }
.station.piece  { stroke: var(--cream); stroke-width: 2; }
.segment        { stroke-width: 3; fill: none; opacity: 0.85; }
.label          { fill: var(--grey); font-size: 10px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; pointer-events: none; }

/* --------------------------------------------- Footer */
.board-foot { margin-top: 22px; }
.foot-line {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  color: var(--grey); font-size: 12px;
}
.foot-line .meta { color: var(--grey); font-size: 12px; }

/* --------------------------------------------- Banner (game over / dialog) */
.banner {
  position: fixed; inset: 0;
  background: rgba(11, 18, 32, 0.85);
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  z-index: 30;
}
.banner.show { display: flex; }
.banner-inner {
  background: var(--navy);
  border: 1px solid var(--alert);
  padding: 28px 26px;
  max-width: 460px; width: 100%;
  display: flex; flex-direction: column; gap: 12px;
}
.banner-inner h2 {
  font-size: 28px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--cream);
}
.banner-inner p { color: var(--grey); font-size: 14px; }
.banner-inner .btn { align-self: flex-start; }

/* --------------------------------------------- Classes emitted by app.js
   (kept from the original DOM; styled to fit the signage identity). */
.move-row {
  display: grid;
  grid-template-columns: 3.2rem auto 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 8px 14px;
  border-bottom: 1px solid var(--rule);
}
.move-row:last-child { border-bottom: 0; }
.move-row .num { color: var(--grey); font-size: 12px; }
.move-row .san { color: var(--cream); font-weight: 600; font-size: 13px; }
.move-row.mta .san { color: var(--alert); }
.move-row .subway {
  color: var(--grey); font-size: 11px;
  display: inline-flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.move-row .subway .station { color: var(--cream-2); }
.move-row .subway .arrow { color: var(--rule); }

/* Move badge (over the map). */
.move-badge .san {
  font-weight: 700; margin-right: 8px; letter-spacing: 0.02em;
}
.move-badge .details {
  color: var(--grey); font-weight: 400; font-size: 11px; margin-top: 2px;
}

/* Force badge visibility whenever it has content. */
.move-badge:not(:empty) { opacity: 1; transform: translateY(0); top: 12px; right: 12px; }

/* SVG move-layer elements. */
.segment.route-1, .segment.route-2, .segment.route-3 { stroke: var(--r-1); }
.segment.route-4, .segment.route-5, .segment.route-6 { stroke: var(--r-4); }
.segment.route-7  { stroke: var(--r-7); }
.segment.route-A, .segment.route-C, .segment.route-E { stroke: var(--r-A); }
.segment.route-B, .segment.route-D, .segment.route-F, .segment.route-M { stroke: var(--r-B); }
.segment.route-G  { stroke: var(--r-G); }
.segment.route-J, .segment.route-Z { stroke: var(--r-J); }
.segment.route-L  { stroke: var(--r-L); }
.segment.route-N, .segment.route-Q, .segment.route-R, .segment.route-W { stroke: var(--r-N); }
.segment.route-S  { stroke: var(--r-S); }
.segment.route-SI { stroke: var(--r-SI); }

.last-move        { stroke-width: 2.5; }
.last-move.human  { stroke: var(--cream); stroke-dasharray: 4 3; }
.last-move.mta    { stroke: var(--alert); }
.last-move-pt.human { fill: var(--cream); }
.last-move-pt.mta   { fill: var(--alert); }
.move-label {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-size: 11px; font-weight: 700; fill: var(--cream);
}
.move-label.mta { fill: var(--alert); }
.move-station-name {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 10px; fill: var(--grey);
}
.square-label {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-size: 9px; fill: var(--grey);
}

/* --------------------------------------------- Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--grey); }

/* --------------------------------------------- Chessboard.js overrides
   Give the board a print-serif feel — cream squares, ink accents. */
.white-1e1d7 { background: var(--cream) !important; }
.black-3c85d { background: #B2A88F !important; }
.highlight1-32417,
.highlight2-9c5d2 {
  box-shadow: inset 0 0 0 3px var(--alert) !important;
}

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