/* StarMap player surface. Encounter imagery is painted by starmap-art.js on a
   fixed pixel grid; this file owns layout and interaction chrome only. */
/* Keep the captain's starting tile in the first viewport.  The map owns a
   bounded viewport instead of stretching to match the tallest lobby column. */
.lobby-main {
  /* Topbar (56px) plus the lobby grid's 18px top/bottom padding. */
  height: calc(100dvh - 92px);
  min-height: 0; align-self: start; overflow: hidden; padding: 0;
}
.starmap-root { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.starmap-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--panel-edge);
}
.starmap-title { color: var(--gold-bright); font-family: "Pirata One", serif; font-size: 30px; }
.starmap-ship-controls { display: flex; align-items: center; gap: 8px; min-width: 0; }
.starmap-ship-controls label { color: var(--ink-dim); font-size: 12px; }
.starmap-ship-controls select {
  max-width: 190px; background: rgba(8,13,26,.9); color: var(--ink);
  border: 1px solid var(--panel-edge); border-radius: 6px; padding: 5px 7px;
}
.starmap-coins {
  color: var(--gold-bright); font-weight: 600; font-size: 13px;
  background: rgba(8,13,26,.9); border: 1px solid var(--panel-edge);
  border-radius: 6px; padding: 4px 8px;
}
.starmap-stage {
  position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden;
  background: #070b16; cursor: grab; touch-action: none;
}
.starmap-stage.dragging { cursor: grabbing; }
.starmap-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* The ship has no element of its own: it is drawn into .starmap-canvas so it
   can rotate, scale with the zoom and trail a plume through the same world
   space the hexes live in. See starmap-ship.js. */
.starmap-controls {
  position: absolute; right: 12px; bottom: 12px; z-index: 6; display: flex; gap: 6px;
  padding: 6px; border: 1px solid var(--panel-edge); border-radius: 9px;
  background: rgba(7,11,22,.86);
}
.starmap-status {
  position: absolute; left: 12px; bottom: 12px; z-index: 5; max-width: 55%;
  color: var(--ink-dim); font-size: 12px; background: rgba(7,11,22,.78);
  border: 1px solid rgba(42,53,84,.7); border-radius: 7px; padding: 5px 8px;
}
/* Anchored above the zoom cluster it belongs to, so the 🔍 toggle button
   and the panel it opens read as one control. */
.starmap-search {
  position: absolute; right: 12px; bottom: 56px; z-index: 6;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border: 1px solid var(--panel-edge); border-radius: 9px;
  background: rgba(7,11,22,.9); max-width: min(320px, calc(100vw - 24px));
}
.starmap-search input {
  flex: 1 1 auto; min-width: 0; background: rgba(8,13,26,.9); color: var(--ink);
  border: 1px solid var(--panel-edge); border-radius: 6px; padding: 5px 7px; font-size: 12px;
}
.starmap-search-count { color: var(--ink-dim); font-size: 11px; white-space: nowrap; }
.starmap-loading { margin: auto; color: var(--ink-dim); }
.starmap-error { margin: auto; max-width: 420px; text-align: center; color: #ffb5a8; }
/* Encounter popup. `.picker` centers its text, but this one is a briefing —
   art beside the headline, roster columns, then a footer — so it opts out and
   lays everything out left-aligned instead. */
.starmap-encounter-picker {
  width: min(440px, calc(100vw - 28px)); text-align: left; display: grid; gap: 14px;
}
.starmap-encounter-picker.wide { width: min(620px, calc(100vw - 28px)); }
/* Grid only reserves the art column when art is actually there -- an
   artless caller (the queued/paused match popup) used to leave that 128px
   track empty with the headline squeezed into it. */
.starmap-encounter-head { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.starmap-encounter-head:has(.starmap-encounter-art) { grid-template-columns: 128px 1fr; }
.starmap-encounter-head h3 { margin: 0 0 6px; }
.starmap-encounter-art {
  width: 128px; height: 128px; display: grid; place-items: center;
  border: 1px solid var(--panel-edge); background: #070b16; image-rendering: pixelated;
}
.starmap-encounter-art canvas { width: 96px; height: 96px; image-rendering: pixelated; }
.starmap-encounter-copy { color: var(--ink); line-height: 1.45; margin: 0; }

/* Definition-style stat grid for the queued/paused match popup: a label over
   a value, same card treatment as a roster row. */
.starmap-encounter-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px;
}
.starmap-encounter-stat {
  display: grid; gap: 2px; border-left: 3px solid var(--panel-edge); border-radius: 4px;
  background: rgba(8,13,26,.55); padding: 5px 8px;
}
.starmap-encounter-stat-label {
  color: var(--gold-bright); font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
}
.starmap-encounter-stat-value { color: var(--ink); font-size: 13px; }

/* Footer: one primary action with a plain-language hint, everything else
   demoted to a small row beside it. */
.starmap-encounter-foot {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--panel-edge); padding-top: 12px;
}
.starmap-encounter-primary { display: grid; gap: 3px; }
.starmap-encounter-hint { color: var(--ink-dim); font-size: 11px; }
.starmap-encounter-secondary { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

/* Two crews side by side, each row flagged in its team color. */
.starmap-roster { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.starmap-roster h4 { margin: 0 0 6px; color: var(--gold-bright); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.starmap-roster ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.starmap-roster-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px;
  border-left: 3px solid var(--crew, var(--panel-edge)); border-radius: 4px;
  background: rgba(8,13,26,.55); padding: 5px 8px;
}
.starmap-roster-row.open { opacity: .55; border-left-style: dashed; }
.starmap-roster-name { color: var(--ink); }
.starmap-roster-detail { color: var(--ink-dim); font-size: 11px; }
.starmap-roster-note { color: var(--ink-dim); font-size: 12px; margin: 10px 0 0; }

@media (max-width: 560px) {
  .starmap-encounter-head { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .starmap-roster { grid-template-columns: 1fr; }
  .starmap-encounter-secondary { margin-left: 0; }
}
.lobby-side-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 22px; }
.lobby-side-tabpanel { padding-top: 2px; }
.lobby-side-tabpanel .match-row { align-items: flex-start; flex-direction: column; gap: 7px; }
.lobby-side-tabpanel .match-actions { width: 100%; justify-content: flex-end; }
.lobby-side-tabpanel .match-meta { line-height: 1.35; }

@media (max-width: 900px) {
  .lobby-main { height: calc(100dvh - 108px); }
  .starmap-head { align-items: flex-start; flex-direction: column; }
  .starmap-ship-controls { flex-wrap: wrap; }
}

/* Full-panel StarMap tab: the map fills everything between the topbar and
   the bottom StarMap/Comms tab shell. Sized as 100% of .lobby-grid, which is
   itself flex-grown to fill the screen below the topbar (pirate.css) — not a
   `calc(100dvh - <guessed topbar height>)`, so a taller (wrapped) topbar
   shrinks the map instead of pushing it under the fixed tab bar. */
:root[data-device="phone"] body.lobby-tab-starmap .lobby-main {
  display: block; padding: 0; border: 0; box-shadow: none; border-radius: 0;
  /* The fixed StarMap/Comms bar occupies this much of the viewport. Reserve
     it here rather than painting the canvas underneath its buttons: a tile in
     that strip cannot receive its pointer event at all. */
  height: calc(100% - var(--lobby-tab-space));
}
:root[data-device="phone"] .starmap-root { min-height: 0; }
:root[data-device="phone"] .starmap-stage { min-height: 0; }
:root[data-device="phone"] .starmap-status { max-width: 62%; bottom: 14px; }
:root[data-device="phone"] .starmap-controls { bottom: 14px; }
:root[data-device="phone"] #starmap-zoom-in,
:root[data-device="phone"] #starmap-zoom-out {
  /* Pinch-to-zoom already works via pointer events (starmap.js); the buttons
     just eat space and were part of what got hidden under the tab bar. */
  display: none;
}
