/* heks.io — modern minimal HUD */

:root {
  --text: #e8eaed;
  --text-dim: rgba(232, 234, 237, 0.55);
  --line: rgba(255, 255, 255, 0.09);
  --panel-bg: rgba(15, 17, 21, 0.78);
  --accent: #f0b53c;
  --danger: #e05c50;
  --ally: #4fb26a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a131e;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

canvas#game {
  position: fixed;
  inset: 0;
  display: block;
  cursor: crosshair;
}

/* ---- shared bits ---- */

.brand {
  margin: 0;
  font: 700 16px 'Inter', sans-serif;
  letter-spacing: 0.26em;
  color: var(--text);
}

/* the game wordmark (heks.io) reads better tight than tracked out */
h1.brand { letter-spacing: 0.01em; }

.panel {
  position: fixed;
  z-index: 3;
  padding: 14px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.panel-label {
  font: 500 10px 'IBM Plex Mono', monospace;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* ---- HUD chrome layers ---- */

#hud.hidden { display: none; }

#vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(5, 8, 13, 0.45) 100%);
}

/* ---- leaderboard ---- */

#leaderboard {
  top: 180px;   /* refined each frame by drawMinimap() to sit under the minimap */
  right: 20px;
  width: 216px;
}

#lbList {
  margin: 0;
  padding: 0;
  list-style: none;
}

#lbList li {
  display: grid;
  grid-template-columns: 15px 11px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;   /* click a row to fly to that player */
  transition: background 0.12s;
}
#lbList li:hover { background: rgba(255, 255, 255, 0.07); }
#lbList li.dead { cursor: default; }
#lbList li.dead:hover { background: none; }

#lbList .rank {
  font: 400 10px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
}

#lbList .sw {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

#lbList .nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

#lbList .ct {
  font: 400 11px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
}

#lbList li.me .nm { color: var(--accent); font-weight: 600; }
#lbList li.me .ct { color: var(--accent); }
#lbList li.ally .nm { color: var(--ally); font-weight: 600; }

.you-tag { font-weight: 400; opacity: 0.65; }
#lbList li.dead { opacity: 0.32; }
#lbList li.dead .nm { text-decoration: line-through; }

/* ---- army panel ---- */

#armyPanel {
  left: 20px;
  top: 20px;
  width: 252px;
}

.commit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

#commitSlider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  cursor: pointer;
}

#commitSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

#commitSlider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}

#commitLabel {
  width: 38px;
  text-align: right;
  font: 400 11px 'IBM Plex Mono', monospace;
  color: var(--text);
}

.army-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.big-num {
  font: 600 30px 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
  transition: color 0.3s;
}

.big-num.flash { color: var(--danger); }

.regen {
  font: 400 11px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
}

/* population block sits under the army stats, separated by a hairline */
.pop-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.mult-badge {
  font: 600 11px 'IBM Plex Mono', monospace;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: rgba(240, 181, 60, 0.14);
  border: 1px solid rgba(240, 181, 60, 0.38);
  border-radius: 999px;
  padding: 2px 8px;
}

.gauge {
  margin-top: 12px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

#gaugeFill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.25s ease-out;
}

.costs {
  margin-top: 10px;
  font: 400 10.5px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
  line-height: 1.7;
}

.costs span { white-space: nowrap; }
.costs b { color: var(--text); font-weight: 600; }
.costs .dot { opacity: 0.5; margin: 0 6px; }

/* ---- minimap ---- */

#minimapPanel {
  right: 20px;
  top: 20px;
  padding: 8px;
  line-height: 0;
}

#minimap {
  display: block;
  cursor: pointer;
  border-radius: 6px;
  width: 150px;   /* slightly smaller on screen; internal resolution unchanged */
  height: auto;
}

/* ---- build bar ---- */

#buildBar {
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  /* size to the buttons' natural one-row width (so the bar widens as needed to
     keep them on a single row) but never past 95% of the viewport. Without an
     explicit width, left:50% would cap shrink-to-fit at ~50vw and force a wrap. */
  width: max-content;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;   /* room for the shortcut-number tabs that hover above each button */
  padding: 16px 14px 10px;   /* extra top room for the action-row key tabs */
}

#resRow {
  align-self: stretch;   /* span the bar so the actions can sit at its right */
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Bomb / Sabotage actions, pushed to the right end of the resource row */
#resActions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.act-btn {
  position: relative;   /* anchor the floating shortcut-key badge to the button */
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: 500 9px 'Inter', sans-serif;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.act-btn:disabled { opacity: 0.4; cursor: default; }
.act-btn .bb-cost { font: 400 8px 'IBM Plex Mono', monospace; }

.res-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 400 12px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
}

.res-chip b { color: var(--text); font-weight: 600; }

#buildBtns { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }

.build-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 46px;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font: 500 7.5px 'Inter', sans-serif;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

/* a one-per-realm building that's already built: MAX overlays the whole button
   (absolute, so it adds no width) and the button is locked */
.build-btn.at-max::after {
  content: 'MAX';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: rgba(15, 17, 21, 0.82);
  color: var(--accent);
  font: 600 9.5px 'IBM Plex Mono', monospace;
  letter-spacing: 0.14em;
}

/* keep the MAX overlay crisp even though the button is :disabled (which dims) */
.build-btn.at-max, .build-btn.at-max:disabled, .build-btn.at-max:disabled:hover { opacity: 1; }

.bb-title {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

/* the shortcut number hovers on the button's top edge, horizontally centered
   (out of flow) so it costs the title no horizontal space */
.bb-key {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 8px;
  padding: 0 3px;
  border-radius: 4px;
  background: #262930;   /* opaque, so a selected button's outline can't show through */
  border: 1px solid var(--line);
  z-index: 1;            /* keep the badge above the button's (selected) border */
  font: 600 6.5px 'IBM Plex Mono', monospace;
  line-height: 11px;
  text-align: center;
  color: var(--text-dim);
}

.build-btn.sel .bb-key { color: var(--accent); border-color: var(--accent); }

.build-btn:hover { background: rgba(255, 255, 255, 0.09); }
.build-btn.sel { border-color: var(--accent); background: rgba(240, 181, 60, 0.13); }
.build-btn:disabled { opacity: 0.4; cursor: default; }
.build-btn:disabled:hover { background: rgba(255, 255, 255, 0.04); }

.bb-cost { font: 400 6px 'IBM Plex Mono', monospace; color: var(--text-dim); }
.bb-own { color: var(--text); }

/* the Bomb action, with a danger accent */
.bomb-btn { border-color: rgba(224, 92, 80, 0.35); }
.bomb-btn:hover:not(:disabled) { background: rgba(224, 92, 80, 0.12); }
.bomb-btn.sel { border-color: var(--danger); background: rgba(224, 92, 80, 0.16); }
.bomb-btn.sel .bb-key { color: var(--danger); border-color: var(--danger); }
.bomb-btn .bb-cost { color: var(--danger); }

/* the Nuke action: a radioactive green so it reads as the doomsday option */
.nuke-btn { border-color: rgba(139, 224, 58, 0.4); }
.nuke-btn:hover:not(:disabled) { background: rgba(139, 224, 58, 0.12); }
.nuke-btn.sel { border-color: #8be03a; background: rgba(139, 224, 58, 0.18); }
.nuke-btn.sel .bb-key { color: #8be03a; border-color: #8be03a; }
.nuke-btn .bb-cost { color: #8be03a; }

/* the ICBM action: a warning amber — the biggest blast in the game */
.icbm-btn { border-color: rgba(255, 184, 77, 0.4); }
.icbm-btn:hover:not(:disabled) { background: rgba(255, 184, 77, 0.12); }
.icbm-btn.sel { border-color: #ffb84d; background: rgba(255, 184, 77, 0.18); }
.icbm-btn.sel .bb-key { color: #ffb84d; border-color: #ffb84d; }
.icbm-btn .bb-cost { color: #ffb84d; }

/* the Sabotage action: a cold intel-cyan to set it apart from bombing */
.sab-btn { border-color: rgba(132, 219, 230, 0.35); }
.sab-btn:hover:not(:disabled) { background: rgba(132, 219, 230, 0.12); }
.sab-btn.sel { border-color: #84dbe6; background: rgba(132, 219, 230, 0.16); }
.sab-btn.sel .bb-key { color: #84dbe6; border-color: #84dbe6; }
.sab-btn .bb-cost { color: #84dbe6; }

body.building canvas#game { cursor: crosshair; }

/* fps readout: a small, unobtrusive line centered just below the build bar */
#fps {
  position: fixed;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font: 400 9px 'IBM Plex Mono', monospace;
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  pointer-events: none;
}

/* ---- build button hover explainer ---- */

#buildTip {
  z-index: 6;
  width: max-content;
  max-width: 230px;
  padding: 10px 12px;
  pointer-events: none;
}

#buildTip.hidden { display: none; }

.bt-title { font: 600 12.5px 'Inter', sans-serif; color: var(--text); margin-bottom: 3px; }

.bt-desc {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.bt-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bt-lines li { font: 500 11px 'IBM Plex Mono', monospace; color: var(--text); }

.bt-lines li::before {
  content: '▪';
  margin-right: 6px;
  color: var(--accent);
  font-size: 9px;
  vertical-align: 1px;
}

.bt-cost {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font: 400 10px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
}

.bt-foot { margin-top: 6px; font-size: 10px; font-style: italic; color: var(--text-dim); }

/* ---- right-click menu ---- */

#ctxMenu {
  position: fixed;
  z-index: 6;
  padding: 5px;
  min-width: 170px;
}

#ctxMenu.hidden { display: none; }

#ctxMenu button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--text);
  font: 500 12.5px 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.12s;
}

#ctxMenu button:hover { background: rgba(255, 255, 255, 0.08); }
#ctxMenu button:disabled { opacity: 0.35; cursor: not-allowed; }
#ctxMenu button:disabled:hover { background: none; }

.ctx-force {
  font: 400 11px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
}

/* ---- alliances ---- */

/* incoming alliance proposals stack top-center: newest drops in below the last,
   so several can be answered at once */
#allyStack {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;   /* only the cards themselves catch clicks */
}

.ally-card {
  position: relative;   /* override .panel's fixed so cards flow in the stack */
  width: 260px;
  padding: 14px 16px;
  text-align: center;
  pointer-events: auto;
  animation: allyIn 0.18s ease-out;
}

@keyframes allyIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ally-msg { font-size: 13px; }
.ally-msg b { color: var(--accent); }

.ally-sub {
  margin-top: 4px;
  font: 400 11px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
}

.ally-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.ally-actions button {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 600 12px 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.ally-yes { background: var(--ally); border-color: var(--ally); color: #0c1710; }
.ally-yes:hover { opacity: 0.88; }
.ally-no { background: transparent; color: var(--text-dim); }
.ally-no:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }

/* leaderboard allies section */
#lbAllies {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

#lbAllies.hidden { display: none; }

.lb-allies-label {
  font: 500 10px 'IBM Plex Mono', monospace;
  letter-spacing: 0.18em;
  color: var(--ally);
  margin-bottom: 6px;
}

.lb-ally {
  display: grid;
  grid-template-columns: 11px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12px;
}

.lb-ally .ct {
  font: 400 10.5px 'IBM Plex Mono', monospace;
  color: var(--ally);
}

#ttAlly { color: var(--ally); }
#ttAllyRow.hidden { display: none; }

/* ---- hover tooltip ---- */

#tooltip {
  position: fixed;
  z-index: 5;
  min-width: 160px;
  padding: 11px 13px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
}

#tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

#tooltip.hidden { display: none; }

.tt-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
}

.tt-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.tt-name {
  font: 600 13.5px 'Inter', sans-serif;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tt-tag {
  font: 600 9px 'IBM Plex Mono', monospace;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px;
  flex: none;
}

.tt-tag.hidden { display: none; }

.tt-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tt-stats div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font: 400 11.5px 'IBM Plex Mono', monospace;
}

.tt-stats .dim { color: var(--text-dim); }
.tt-stats span:last-child { color: var(--text); font-weight: 600; }

/* ---- chat ---- */

#chatBox {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

#chatLog {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 150px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#chatLog:empty::after {
  content: 'Say hello. Everyone in this game can see the chat.';
  font-size: 11.5px;
  color: var(--text-dim);
  padding: 2px 0;
}

.chat-msg {
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-name {
  font-weight: 600;
  color: var(--text);
  margin-right: 6px;
}

.chat-text { color: var(--text); opacity: 0.88; }

.chat-text.big {
  display: inline-block;
  font-size: 21px;
  line-height: 1.25;
}

#quickRow {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.quick-chip {
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-dim);
  font: 500 11px 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.quick-chip:hover { background: rgba(255, 255, 255, 0.14); color: var(--text); }

.quick-chip.emoji { font-size: 14px; padding: 3px 8px; }

#chatInputRow { display: flex; gap: 6px; }

#chatInput {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: 400 12.5px 'Inter', sans-serif;
  outline: none;
}

#chatInput:focus { border-color: var(--accent); }
#chatInput::placeholder { color: rgba(232, 234, 237, 0.35); }

#chatSendBtn {
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: 600 11.5px 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s;
}

#chatSendBtn:hover { background: rgba(255, 255, 255, 0.16); }

/* lobby flavor: tucked into the room card */
#room #chatBox { margin-bottom: 20px; }
#room #chatLog { height: 108px; max-height: none; }

/* in-game flavor: its own HUD panel tucked under the army panel (top-left),
   nearly invisible until you press T */
#chatPanel {
  left: 20px;
  top: 272px;   /* sits just below the army + population panel (bottom ~258px) */
  width: 252px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background 0.2s, border-color 0.2s;
}

#chatPanel.idle {
  background: rgba(15, 17, 21, 0.4);
  border-color: rgba(255, 255, 255, 0.05);
}

#chatPanel.idle #quickRow,
#chatPanel.idle #chatInputRow { display: none; }

#chatHint {
  font: 400 9.5px 'IBM Plex Mono', monospace;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

#chatPanel.idle .active-hint { display: none; }
#chatPanel:not(.idle) .idle-hint { display: none; }

/* ---- toast ---- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 118px;
  z-index: 4;
  max-width: 280px;
  padding: 10px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 12px;
  color: var(--text);
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---- pregame screens (menu / room / loading) ----
   Same hex-grid + vignette treatment the in-game map sits behind, so the
   first thing you see already feels like this world rather than a form. */

/* pregame screens (menu, lobby, loading) are transparent so the shared animated
   hex backdrop shows through behind their vignette + card */
.pregame {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.pregame.hidden { display: none; }

/* shared animated hex-territory backdrop for every pregame screen, sitting just
   behind them (and above the game, but hidden by JS while a game is on) */
.menu-bg {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: block;
}

.pregame-vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(5, 8, 13, 0.72) 100%);
}

.menu-card {
  position: relative;
  z-index: 2;
  width: 400px;
  max-width: calc(100vw - 40px);
  padding: 32px 30px;
  margin: 24px 0;
}

.menu-card .brand {
  font-size: clamp(42px, 13vw, 60px);
  line-height: 1.05;
  margin-bottom: 4px;
  text-align: center;
}

.menu-sub {
  margin: 8px 0 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ---- lobby (waiting room) header ---- */
.lobby-badge {
  display: block;
  width: fit-content;
  margin: 0 auto 12px;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(240, 181, 60, 0.14);
  border: 1px solid rgba(240, 181, 60, 0.4);
  color: var(--accent);
  font: 700 12px 'IBM Plex Mono', monospace;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  text-align: center;
}

/* scoped under .menu-card so it beats the big `.menu-card .brand` size the
   title also carries — otherwise the game name renders at 42–60px */
.menu-card .lobby-title {
  margin: 0;
  text-align: center;
  font: 700 20px 'Inter', sans-serif;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.lobby-hint {
  margin: 10px 0 20px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

#menuStatus {
  min-height: 16px;
  margin-bottom: 6px;
  text-align: center;
  font: 400 11px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
}

#menuStatus.error { color: var(--danger); }

.menu-card input,
.menu-card select,
.help-inner input,
.help-inner select {
  width: 100%;
  padding: 10px 12px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: 400 13px 'Inter', sans-serif;
  outline: none;
}

/* strip the native select chrome so Safari honors our height/padding the same
   as Chrome (native selects ignore both), and draw our own dropdown arrow */
.menu-card select,
.help-inner select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='10'%20height='6'%3E%3Cpath%20d='M0%200h10L5%206z'%20fill='%238a8d90'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

/* the option list still renders with the OS palette, so keep it readable */
.menu-card select option,
.help-inner select option { background: #141821; color: var(--text); }

.menu-card input:focus,
.menu-card select:focus,
.help-inner input:focus,
.help-inner select:focus {
  border-color: var(--accent);
}

.menu-card input::placeholder,
.help-inner input::placeholder { color: rgba(232, 234, 237, 0.35); }

/* name + flag on one row; the flag image previews inside the select */
.name-row { display: flex; gap: 8px; margin-bottom: 22px; }
.name-row #playerName { flex: 1; margin-bottom: 0; }
.flag-pick { position: relative; flex: none; }
#flagPreview {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  height: 15px;
  width: auto;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
#flagSel { width: 142px; padding-left: 44px; }

/* flag image before a player name (leaderboard, allies, tooltip, room) */
.lb-flag, .tt-flag, .name-flag {
  width: auto;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  margin-right: 6px;
}
.lb-flag { height: 11px; vertical-align: -1px; }
.tt-flag { height: 13px; vertical-align: -2px; }
.name-flag { height: 12px; vertical-align: -1px; }

.menu-card .panel-label { margin-bottom: 10px; }

#gamesList {
  margin-bottom: 0;
  max-height: 200px;
  overflow-y: auto;
}

/* the two ways in: an "or" divider with a rule on each side makes it obvious
   that joining an open game and starting a new one are separate choices */
.menu-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-dim);
  font: 600 10px 'IBM Plex Mono', monospace;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.menu-or::before,
.menu-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.menu-links {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.menu-links .ghost:first-child { margin-top: 0; }

.menu-community-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 14px;
}
.menu-community {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}
.menu-community:hover { color: var(--accent); }
.reddit-icon, .discord-icon { width: 15px; height: 15px; flex: none; }

.games-empty {
  padding: 14px 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.game-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.game-row .game-name {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-row .game-count {
  font: 400 11px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
  white-space: nowrap;
}

.game-row button {
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: 600 11.5px 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s;
}

.game-row button:hover { background: rgba(255, 255, 255, 0.16); }

#gameName { margin-bottom: 8px; }

.new-game-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.new-game-row select { flex: 1; }

.new-game-wide { width: 100%; }

.option-hint {
  margin: 2px 0 12px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-dim);
}

.cta {
  width: 100%;
  padding: 11px 0;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #101317;
  font: 600 13px 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity 0.2s;
}

.cta:hover { opacity: 0.88; }
.cta:disabled { opacity: 0.5; cursor: default; }
.cta.hidden { display: none; }

/* ---- hex dot markers (echo the map's hex tiles in list rows) ---- */

.hex-dot {
  flex: none;
  width: 10px;
  height: 10px;
  background: var(--text-dim);
  opacity: 0.6;
  clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0% 50%);
}

.hex-dot.host { background: var(--accent); opacity: 1; }

/* ---- waiting room ---- */

/* two-column lobby: game details on the left, chat on the right, split by a
   thin rule. Stacks vertically on narrow screens (see the media query below). */
.lobby-card { width: 720px; }

.lobby-cols { display: flex; gap: 26px; align-items: stretch; }

.lobby-details {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
/* the players list takes the column's slack, but caps out and scrolls inside
   itself once it's full — so a crowded lobby never makes the card grow tall */
.lobby-details #roomPlayers {
  flex: 1;
  min-height: 0;
  max-height: 260px;
  overflow-y: auto;
}

.lobby-chat {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);   /* the thin divider */
  padding-left: 26px;
}
#room .lobby-chat #chatBox { flex: 1; margin-bottom: 0; }
/* the log fills the column but caps out and scrolls once it's full, so lots of
   messages never stretch the card tall (mirrors the players list) */
#room .lobby-chat #chatLog { flex: 1; min-height: 0; max-height: 440px; }

@media (max-width: 680px) {
  .lobby-card { width: 400px; }
  .lobby-cols { flex-direction: column; gap: 16px; }
  .lobby-chat {
    border-left: none;
    border-top: 1px solid var(--line);   /* divider becomes a horizontal rule when stacked */
    padding-left: 0;
    padding-top: 16px;
  }
  #room .lobby-chat #chatLog { flex: none; min-height: 0; height: 120px; }
}

#roomMeta {
  margin: 6px 0 18px;
  text-align: center;
  font: 400 11px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
}

#roomPlayers {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

#roomPlayers li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.room-name { flex: 1; }

.host-badge {
  font: 600 9px 'IBM Plex Mono', monospace;
  letter-spacing: 0.14em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
}

#roomWait {
  text-align: center;
  margin-bottom: 4px;
}

#roomWait.hidden { display: none; }

.ghost {
  width: 100%;
  margin-top: 10px;
  padding: 10px 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-dim);
  font: 500 12.5px 'Inter', sans-serif;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }

/* ---- loading ---- */

#loading {
  z-index: 100;
  transition: opacity 0.7s;
}

#loading.fade {
  opacity: 0;
  pointer-events: none;
}

.load-inner {
  position: relative;
  text-align: center;
}

.load-inner .brand {
  font-size: 26px;
  margin-bottom: 30px;
}

.load-bar {
  width: 240px;
  height: 3px;
  margin: 0 auto 14px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

#loadFill {
  height: 100%;
  width: 0%;
  background: var(--text);
  border-radius: 2px;
}

#loadStatus {
  font: 400 11px 'IBM Plex Mono', monospace;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

/* ---- exit button ---- */

#exitBtn {
  top: 20px;
  right: 292px;
  z-index: 3;
  padding: 7px 14px;
  border-radius: 8px;
  font: 500 12px 'Inter', sans-serif;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

#exitBtn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }

/* ---- defeat / exit confirm ---- */

#defeat, #exitConfirm {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 10, 0.72);
}

#defeat.hidden, #exitConfirm.hidden { display: none; }

.defeat-inner {
  position: relative;
  padding: 36px 44px;
  text-align: center;
}

.exit-inner {
  position: relative;
  max-width: 340px;
  padding: 30px 34px;
  text-align: center;
}

.exit-inner h2 { margin: 0 0 8px; font: 600 20px 'Inter', sans-serif; }
.exit-inner p { margin: 0 0 22px; font-size: 13px; line-height: 1.5; color: var(--text-dim); }

.exit-actions { display: flex; gap: 10px; justify-content: center; }

.exit-actions button {
  padding: 10px 18px;
  border-radius: 8px;
  font: 600 12.5px 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}

.exit-stay { background: var(--text); border: none; color: #101317; }
.exit-stay:hover { opacity: 0.85; }
.exit-go { background: transparent; border: 1px solid rgba(224, 92, 80, 0.5); color: var(--danger); }
.exit-go:hover { background: rgba(224, 92, 80, 0.12); }

.defeat-inner h2 {
  margin: 0 0 8px;
  font: 600 24px 'Inter', sans-serif;
  letter-spacing: 0.01em;
}

.defeat-inner p {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--text-dim);
}

.defeat-inner button {
  padding: 10px 24px;
  background: var(--text);
  border: none;
  border-radius: 8px;
  color: #101317;
  font: 600 12.5px 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity 0.2s;
}

.defeat-inner button:hover {
  opacity: 0.85;
}

.defeat-actions { display: flex; gap: 10px; justify-content: center; }

#defeatWatch.hidden { display: none; }

/* victory variant of the end screen */
#defeat.win .defeat-inner { border-color: rgba(240, 181, 60, 0.5); }
#defeat.win #endTitle {
  color: var(--accent);
  text-shadow: 0 0 24px rgba(240, 181, 60, 0.4);
  letter-spacing: 0.06em;
}

#defeatLeave {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
#defeatLeave:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }

:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

/* ---- help overlay ---- */

#hudHelpBtn {
  top: 20px;
  right: 248px;   /* just left of the leaderboard */
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font: 600 15px 'Inter', sans-serif;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

#hudHelpBtn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }

#help, #createModal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 7, 10, 0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  overflow-y: auto;
}

#help.hidden, #createModal.hidden { display: none; }

.help-inner {
  position: relative;
  width: 460px;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 30px 30px 26px;
}

.help-inner .brand { font-size: 20px; text-align: center; }

.help-tagline {
  margin: 8px 0 22px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
}

.help-section { margin-bottom: 18px; }

.help-section p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.help-section b { font-weight: 600; }

.help-keys {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 16px;
}

.help-keys li { font-size: 12.5px; color: var(--text-dim); }

.help-keys li span {
  display: inline-block;
  min-width: 74px;
  color: var(--text);
  font: 500 11px 'IBM Plex Mono', monospace;
}

.help-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.help-close:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }

.help-inner .cta { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  #gaugeFill, #toast, #loading { transition: none; }
}

@media (max-width: 760px) {
  #leaderboard { display: none; }
  #minimapPanel { display: none; }
  #chatPanel { display: none; }
  .brand { font-size: 14px; }
  #armyPanel { left: 14px; top: 14px; width: 210px; }
  #hudHelpBtn { top: 14px; right: 14px; }
  #exitBtn { top: 14px; right: 56px; }
  /* on a phone the bar spans nearly the full width and the buttons flex to
     fill it evenly (labels wrap to two lines) so all of them fit one row */
  #buildBar { bottom: 12px; gap: 14px; padding: 15px 8px 8px; width: calc(100vw - 12px); max-width: none; }
  #buildBtns { width: 100%; gap: 5px; }
  .build-btn { flex: 1 1 0; min-width: 0; padding: 6px 3px; }
  .build-btn .bb-title { white-space: normal; text-align: center; line-height: 1.12; }
  .bomb-btn { margin-left: 0; }
}
