/*! Copyright (c) 2026 BamByte (bambyte.net). All rights reserved.
 * Proprietary code: no copying, redistribution, or use to train or prompt
 * AI / machine-learning systems without written permission from BamByte. */
/* BAMBARD -- online mode (game.html?mode=online). Copied from Hover Blast's.
   The site's shared online chrome: the control cluster and account strip at
   the top of the sidebar HUD panel, the lobby card with its seat cards, and the
   room chat (Chat / Players / Info) under the HUD. Same class names
   (.cn-online-*) and shared button art as every other online game; ported
   from Boom Boats' styles.css. The lobby card covers the table only (it lives
   in .bmd-stage), so the sidebar stays usable and follows the dock side with
   no gutter maths. Every rule is gated on body.online-mode, or names markup
   that only exists online. */

/* ---- The bar itself never shows: its contents live in the sidebar ---------- */
.cn-online-control-bar,
body.online-mode .cn-online-control-bar { display: none; }
body.online-mode .bb-toolbar,
body.online-mode .bmd-pause { display: none !important; }
/* No coaching and no offline-only keys in a game against people. */
body.online-mode #hud-hint,
body.online-mode .bmd-offline-only { display: none; }

/* ---- Control cluster, at the top of the HUD panel ------------------------- */
body.online-mode #rightPanel .cn-online-control-bar-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 16px;
  background: #4a4a4a;
  border: 2px solid #6d6d6d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.45);
}
.cn-online-control-bar-icon-btn {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  padding: 0;
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.cn-online-control-bar-icon-btn img { display: block; width: 100%; height: 100%; }
.cn-online-control-bar-icon-btn[hidden] { display: none; }
.cn-online-control-bar-icon-btn:hover,
.cn-online-control-bar-icon-btn:focus-visible { filter: brightness(1.18); transform: translateY(-1px); }
.cn-online-control-bar-icon-btn:disabled { opacity: 0.45; cursor: var(--bmd-cursor, default); filter: none; transform: none; }

/* "Hide HUD" / the chat view collapse the panel to just the cluster. */
body.online-mode #rightPanel .hud-collapsed > *:not(.cn-online-control-bar-controls) { display: none; }

/* ---- Account strip (name / avatar / Boins), above the cluster ------------- */
.cn-online-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 8px;
}
.cn-online-profile[hidden] { display: none; }
.cn-online-profile__name {
  color: #eef2f5;
  font-weight: 700;
  font-size: 15px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cn-online-profile__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--game-accent);
  background: #222;
}
.cn-online-profile__badge {
  position: relative;
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 10px 0 30px;
  border: 2px solid var(--game-accent);
  border-radius: 17px;
  background: rgba(0, 0, 0, 0.35);
}
.cn-online-profile__badge-coin {
  position: absolute;
  left: -6px;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translateY(-50%);
}
.cn-online-profile__badge-value { display: flex; align-items: center; gap: 3px; }
.cn-online-profile__badge-sign { height: 14px; width: auto; }
.cn-online-profile__badge-amount { color: #fff; font-weight: 800; font-size: 14px; }

/* ---- Layout menu (Dock Left / Right) and Quick Switch popover ------------- */
.cn-online-layout-menu {
  position: fixed;
  z-index: 610;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: #242323;
  border: 2px solid var(--game-accent);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}
.cn-online-layout-menu[hidden] { display: none; }
.cn-online-layout-menu-item {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #eef2f5;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid #2b2b2b;
  border-radius: 8px;
  cursor: pointer;
}
.cn-online-layout-menu-item:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }
.cn-online-layout-menu-item:disabled { opacity: 0.45; cursor: var(--bmd-cursor, default); }

.cn-online-switch-menu {
  position: fixed;
  z-index: 610;
  min-width: 260px;
  max-height: calc(var(--bb-vh, 100dvh) - 24px);
  overflow-y: auto;
  background: #242323;
  border: 3px solid var(--game-accent);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.cn-online-switch-menu[hidden] { display: none; }
.cn-online-switch-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  padding: 8px 10px;
  color: #eeeeee;
  font-size: 15px;
  font-weight: 600;
  transition: background .15s ease, transform .15s ease;
}
.cn-online-switch-item:hover,
.cn-online-switch-item:focus-visible { background: rgba(255, 255, 255, 0.08); transform: scale(1.02); outline: none; }
.cn-online-switch-item img {
  display: block;
  width: 46px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  border: 2px solid var(--game-accent);
}

/* ---- Lobby card, over the table ------------------------------------------- */
.cn-online-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cn-online-overlay[hidden] { display: none; }
.cn-online-card {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 28px;
  background:
    /* The logo, washed well back so the white seat names read over it. */
    radial-gradient(ellipse at center, rgba(13, 6, 32, 0.84) 0%, rgba(13, 6, 32, 0.74) 55%, rgba(13, 6, 32, 0.6) 100%),
    url("../assets/img/bambard_logo.webp") center / min(80%, 640px) auto no-repeat,
    radial-gradient(ellipse at 50% 40%, #241046, #05030c 85%);
  border: 4px solid rgba(var(--game-accent-rgb), 0.85);
  border-radius: 8px;
  padding: 40px 32px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
  overflow-y: auto;
}
.cn-online-roster-group {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.cn-online-roster {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(16px, 3vw, 48px);
  row-gap: 32px;
}
.cn-online-seat {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: clamp(110px, 13vw, 200px);
}
.cn-online-seat-actions { height: 40px; display: flex; align-items: center; justify-content: center; }
.cn-online-seat-btn {
  display: block;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  width: 36px;
  height: 36px;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.cn-online-seat-btn[hidden] { display: none; }
.cn-online-seat-btn img { display: block; width: 100%; height: 100%; }
.cn-online-seat-btn:hover,
.cn-online-seat-btn:focus-visible { filter: brightness(1.15); transform: translateY(-2px); }
.cn-online-seat-avatar {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  box-sizing: content-box;
  border-radius: 10px;
  border: 5px solid var(--game-accent);
  object-fit: contain;
  background: #fff;
}
.cn-online-seat--me .cn-online-seat-avatar {
  border-color: #5cc8ff;
  box-shadow: 0 0 0 3px rgba(92, 200, 255, 0.5);
}
/* Empty seat: the INVITE box (markup from /net/invite_dialog.js), the same
   footprint as an avatar (content-box + the same 5px border). */
.cn-online-seat-invite {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  box-sizing: content-box;
  border: 5px solid rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 700;
  font-size: clamp(12px, 1.2vw, 16px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.cn-online-seat-invite:hover,
.cn-online-seat-invite:focus-visible { border-color: var(--game-accent); color: #fff; transform: translateY(-2px); outline: none; }
.cn-online-seat-label {
  color: #fff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 900;
  font-size: clamp(14px, 1.6vw, 20px);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.cn-online-seat-sub,
.cn-online-spectators { display: none; }
.cn-online-status {
  margin-top: auto;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  text-align: center;
}

/* ---- Chat panel under the HUD ---------------------------------------------- */
body.online-mode #sb-content {
  display: block;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background-color: rgba(12, 16, 24, 0.4);
  border: 3px solid var(--game-accent);
  border-radius: 8px;
  padding: 8px;
}
/* The HUD panel shares the column with the chat: it may scroll, never crowd it out. */
body.online-mode #rightPanel > .hud-panel { flex: 0 1 auto; max-height: 60%; }

.sidebar-tabs-overlay {
  position: absolute;
  inset: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}
.sidebar-tabs { display: flex; gap: 8px; }
.sidebar-tabs .tab {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #2b2b2b;
  background: rgba(0, 0, 0, .25);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.sidebar-tabs .tab.active { outline: 2px solid rgba(var(--game-accent-rgb), .6); }
.tab-panels { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tab-panel { flex: 1; min-height: 0; }
.tab-panel .pad { padding: 8px; opacity: .8; }

.chat-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: 8px; }
.chat-messages { flex: 1; min-height: 0; overflow: auto; border-radius: 8px; padding: 8px; background: rgba(0, 0, 0, .08); }
.chat-row { padding: 6px 8px; border: 2px solid #00000072; border-radius: 8px; margin: 4px 0; background: rgba(255, 255, 255, .04); }
.chat-row.mine { background: rgba(255, 255, 255, .1); }
.chat-row-meta { display: flex; gap: 6px; font-size: 12px; opacity: .75; margin-bottom: 2px; }
.chat-row-text { word-wrap: break-word; overflow-wrap: anywhere; }
/* Emoji / GIF on their own line, input + Send under them: four across never
   fit the sidebar's width. */
.chat-input-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  grid-template-areas:
    "emoji gif   .     .   "
    "input input input send";
  gap: 6px;
  align-items: center;
  min-width: 0;
}
.chat-input-row .btn-emoji { grid-area: emoji; }
.chat-input-row .btn-gif { grid-area: gif; }
.chat-input-row #chat-send { grid-area: send; }
.chat-input-row input[type="text"] { grid-area: input; min-width: 0; box-sizing: border-box; padding: 8px 10px; border-radius: 8px; border: 1px solid #2b2b2b; }
.chat-input-row button { padding: 8px 12px; border-radius: 8px; border: 1px solid #2b2b2b; cursor: pointer; background: rgba(0, 0, 0, .06); }
.chat-input-row .btn-emoji { background: url('/assets/img/yellow_glass_button.webp') center/100% 100% no-repeat; border: none; }
.chat-input-row .btn-gif { background: url('/assets/img/red_glass_button.webp') center/100% 100% no-repeat; border: none; color: #fcfcfc; font-weight: 700; }
.chat-input-row #chat-send { background: url('/assets/img/green_glass_button.webp') center/100% 100% no-repeat; border: none; color: #0a0a0a; font-weight: 700; }

.chat-toolbar { display: flex; gap: 8px; margin-bottom: 6px; }
.chat-toolbar button { padding: 6px 10px; border-radius: 8px; border: 3px solid #9f0e0e; background: rgba(0, 0, 0, .06); cursor: pointer; }
.popover {
  position: absolute;
  top: 70px; left: 8px; right: 8px;
  max-height: calc(var(--bb-vh, 100vh) * .8); overflow: auto;
  background: rgba(0, 0, 0, .85);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px; padding: 8px; z-index: 999;
  backdrop-filter: blur(2px);
}
.emoji-mart, .emoji-mart * { box-sizing: border-box; }
.gif-search { margin-bottom: 8px; }
.gif-search input { width: 50%; padding: 8px 10px; border-radius: 8px; border: 1px solid #2b2b2b; background: #111; color: #eee; }
.gif-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gif-item { border: 0; background: transparent; padding: 0; cursor: pointer; border-radius: 8px; overflow: hidden; }
.gif-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-img { max-width: 100%; border-radius: 8px; display: block; }

/* ---- Players tab (/net/players_list.js) ------------------------------------ */
#panel-players { display: flex; flex-direction: column; min-height: 0; }
#panel-players[hidden] { display: none; }
.bb-players-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.bb-players-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 13px;
}
.bb-players-avatar { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #4a4949; }
.bb-players-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
  color: var(--bb-chat-name-color, #fff);
}
.bb-players-role { flex: 0 0 auto; font-size: 11px; color: #fff; opacity: 0.75; }
.bb-players-bump {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.bb-players-bump img { display: block; width: 100%; height: 100%; }
.bb-players-bump:hover,
.bb-players-bump:focus-visible { opacity: 1; transform: scale(1.12); outline: none; }

/* ---- Info tab (net/info_tab.js: the rules) --------------------------------- */
#panel-info,
#game-info-panel { overflow-y: auto; }
.game-info { padding: 4px 6px; color: #fff; }
.game-info h3 { margin: 0 0 10px; font-size: 15px; color: var(--game-accent); }
.game-info dt { margin-top: 10px; font-weight: 800; font-size: 13px; color: var(--game-accent); }
.game-info dd { margin: 2px 0 8px; font-size: 12.5px; line-height: 1.45; color: #fff; }

/* ==== Phones and tablets ==================================================== */
@media (orientation: portrait) and (max-width: 1024px) {
  /* The chat needs a height of its own in the scrolling stack. */
  body.online-mode #rightPanel { height: min(640px, calc(var(--bb-vh, 100dvh) * .85)); }
  body.online-mode #rightPanel > .hud-panel { max-height: none; }
  body.online-mode #sb-content { min-height: 260px; }
  .cn-online-card { padding: 20px 12px; gap: 16px; }
  .cn-online-roster { row-gap: 18px; }
  .cn-online-seat { width: clamp(96px, 28vw, 180px); }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.online-mode #sb-content { flex: 1 0 auto; min-height: 240px; }
  .cn-online-card { padding: 12px; gap: 10px; }
  .cn-online-roster { row-gap: 10px; }
  .cn-online-seat { width: clamp(80px, 14vw, 120px); gap: 4px; }
  .cn-online-seat-label { font-size: 13px; }
}

/* ---- BAMBARD: the host's rules + each seat's tank ----------------------- */

/* The card scrolls on a short stage rather than overlapping the seats. */
.cn-online-roster-group { flex: 1 0 auto; }
.bmd-lobby-opts { flex: none; display: grid; gap: 8px; justify-items: center; width: 100%; }
.bmd-lobby-row { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; }
.bmd-lobby-row__label { font: 800 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif; color: rgba(255, 255, 255, 0.78); margin-right: 4px; min-width: 76px; text-align: right; }
.bmd-lobby-opts .bmd-mode { flex: 0 1 auto; min-width: 58px; }
.bmd-lobby-opts .bmd-mode:disabled { cursor: var(--bmd-cursor, default); }
.bmd-lobby-opts .bmd-mode:disabled:not(.is-on) { opacity: 0.5; }
.bmd-lobby-opts .bmd-select { width: auto; min-width: 170px; }
.bmd-lobby-opts .bmd-select:disabled { opacity: 0.7; cursor: var(--bmd-cursor, default); }
.bmd-lobby-note { margin: 0; font-size: 13px; color: rgba(255, 255, 255, 0.72); text-align: center; }

/* Each seat wears its tank: a ring in the tank's colour round the avatar, and
   the tank itself under the name (BYNGO's bottle). Yours is a button. */
.cn-online-seat[data-tank] .cn-online-seat-avatar { box-shadow: 0 0 0 4px var(--tank-glow), 0 0 18px var(--tank-glow); }
.bmd-seat-tank {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 92px;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font: 900 12px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}
.bmd-seat-tank .bmd-tankfig {
  width: clamp(84px, 8vw, 128px);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 8px var(--tank-glow, transparent));
}
.bmd-seat-tank.is-picking { justify-content: center; color: rgba(255, 255, 255, 0.65); font-weight: 700; }
button.bmd-seat-tank { cursor: pointer; transition: transform 0.15s ease; }
button.bmd-seat-tank:hover,
button.bmd-seat-tank:focus-visible { transform: translateY(-3px); outline: none; }
button.bmd-seat-tank:focus-visible span { outline: 2px solid #fff; outline-offset: 2px; }

/* The tank chooser sits over the lobby card. */
body.online-mode .bmd-tankpick { z-index: 4200; }

/* Online: the single-player-only sidebar parts (tank pickers, Bambot, new
   match, Target Practice, statistics) and the result card's buttons. */
body.online-mode #hud-tanks,
body.online-mode .bmd-subhead:has(+ #hud-tanks),
body.online-mode #hud-bot-wrap,
body.online-mode .bmd-actions { display: none !important; }
.bmd-result-actions button[hidden] { display: none; }

/* Invisible anchors over the canvas name badges, so chat speech bubbles
   (/net/chat_bubbles.js) pop up beside the right player. */
.bmd-seat-anchors { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.bmd-seat-anchor {
  position: absolute;
  top: 4%;
  width: 1px;
  height: 1px;
  overflow: hidden;
  color: transparent;
  font-size: 1px;
}
.bmd-seat-anchor--left { left: 8%; }
.bmd-seat-anchor--right { right: 8%; }

@media (orientation: portrait) and (max-width: 1024px) {
  .bmd-lobby-opts { order: -1; }
  .bmd-lobby-row__label { min-width: 0; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .bmd-seat-tank { min-height: 64px; }
  .bmd-seat-tank .bmd-tankfig { width: 72px; }
}
