:root {
  --bg: #0b0f16;
  --panel: #121826;
  --card: #0e1420;
  --line: #243047;
  --text: #d7dde8;
  --muted: #8b94a7;
  --amber: #efb35b;
  --teal: #5dcaa5;
  --red: #f09595;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 16px;
}

.wrap { max-width: 1100px; margin: 0 auto; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 14px;
}
h1 { font-size: 19px; margin: 0 0 6px; }
.mono { font-family: "Courier New", monospace; font-size: 12px; color: var(--muted); }
.amber { color: var(--amber); }
.teal { color: var(--teal); }
.red { color: var(--red); }

button, input, select {
  background: #18213380;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 14px;
}
button { cursor: pointer; }
button.primary { background: var(--teal); color: #04342c; font-weight: 600; border: none; }
a { color: var(--teal); }

.statbar { display: flex; flex-wrap: wrap; gap: 8px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  font-family: "Courier New", monospace;
  font-size: 12px;
}
.stat b { font-size: 17px; display: block; color: var(--text); }

.layout { display: flex; gap: 14px; align-items: flex-start; }
.map-panel { flex: 1; min-width: 0; }
.side-panel { width: 290px; flex-shrink: 0; }

/* The game page is a fixed viewport app: the page never scrolls — the
   banner and map stay locked, and the right column is the one scroller. */
body.app {
  height: 100vh;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.app .wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}
body.app .layout { flex: 1; min-height: 0; align-items: stretch; }
body.app .map-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
body.app .map-panel > .panel:first-child {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.map-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
body.app #map { flex: 1; min-height: 0; }
body.app #map svg { height: 100%; }
body.app .map-panel > .panel:last-child {
  margin-bottom: 0;
  max-height: 24vh;
  overflow-y: auto;
}
body.app .side-panel {
  height: 100%;
  overflow-y: auto;
}
#map svg { width: 100%; display: block; }
#detail {
  font-family: "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  min-height: 60px;
  white-space: pre-wrap;
}
.gamelist a { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal.wide { width: min(760px, 92vw); }

.dispatch-reader { font-family: Georgia, serif; line-height: 1.55; }
.dispatch-reader h1 { font-size: 17px; color: var(--teal); }
.dispatch-reader h2 { font-size: 14px; color: var(--amber); }
.dispatch-reader li { margin-left: 1.2em; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  width: min(620px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
}

/* Drawer handle: phone-only control that raises the order sheet. */
.drawer-handle { display: none; }

/* ---- Phone layout (≤700px) ----------------------------------------
   The columns become a stack: banner on top, map filling the screen,
   and the order sheet living in a bottom drawer that slides up over
   the map. Desktop above the breakpoint is untouched. */
@media (max-width: 700px) {
  body { padding: 8px; }
  .panel { padding: 10px 12px; margin-bottom: 8px; }
  h1 { font-size: 16px; }
  button { min-height: 42px; }

  /* Stat chips scroll sideways instead of stacking four rows deep. */
  .statbar { flex-wrap: nowrap; overflow-x: auto; }
  .stat { white-space: nowrap; }

  body.app .wrap { padding-bottom: 50px; } /* room above drawer handle */
  body.app .layout { flex-direction: column; gap: 8px; }
  body.app .map-panel > .panel:last-child { max-height: 18vh; }

  /* No hover on touch: the coordinate readout is dead weight, and the
     zoom buttons float over the map instead of costing it a row. */
  body.app .map-panel > .panel:first-child { position: relative; }
  body.app .map-toolbar {
    position: absolute;
    top: 8px; right: 8px;
    z-index: 5;
    margin: 0;
  }
  body.app .map-toolbar #hexout { display: none; }
  body.app .map-toolbar button { background: #182133e6; }

  /* One-line banner status, and slimmer stat chips. */
  #status {
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .stat { padding: 5px 9px; }
  .stat b { font-size: 15px; }

  /* The order sheet: fixed drawer, collapsed to its handle bar. */
  body.app .side-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: auto;
    height: 72vh;
    z-index: 40;
    background: var(--bg);
    border-top: 1px solid var(--line);
    transform: translateY(calc(100% - 50px));
    transition: transform 0.22s ease-out;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }
  body.app .side-panel.open { transform: translateY(0); }
  body.app .side-panel #orders {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  .drawer-handle {
    display: block;
    height: 50px;
    border: none;
    border-radius: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    font-family: "Courier New", monospace;
    font-size: 13px;
    color: var(--teal);
    letter-spacing: 0.08em;
  }

  .modal { width: 94vw; max-height: 86vh; padding: 12px 14px; }
  .modal.wide { width: 94vw; }
}
