/* ==========================================================================
   Frontline Battle — HUD, overlays, panel
   ========================================================================== */
:root {
  --bg: #050608; --panel: #14161f; --panel-border: #252a3a; --text: #e8eaf2; --muted: #8b90a6;
  --accent: #fe2c55; --accent-2: #25f4ee; --gold: #ffd84d; --ok: #3ddc84; --warn: #ffb02e; --err: #ff5c6c;
  --red: #ff5a4d; --blue: #4aa8ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 14px; overflow: hidden; }
body { display: flex; }
#stage { position: relative; flex: 1; min-width: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background: #000; }
#viewport { position: relative; overflow: hidden; container-type: size; font-size: 2.2cqmin; width: 100%; height: 100%; }
#game-canvas { display: block; width: 100%; height: 100%; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9); }
.topbar { position: absolute; top: 1.8cqmin; left: 50%; transform: translateX(-50%); width: min(70cqw, 110cqmin); text-align: center; }
.names { display: flex; justify-content: space-between; align-items: baseline; font-weight: 900; font-size: 2.8cqmin; padding: 0 1cqmin; }
.names .vs { color: var(--gold); font-style: italic; }
#score-bar { position: relative; height: 4cqmin; margin-top: 0.6cqmin; border-radius: 99px; overflow: hidden; border: 2px solid rgba(255, 255, 255, 0.8); box-shadow: 0 0 2cqmin rgba(0, 0, 0, 0.5); }
#score-left { height: 100%; width: 50%; transition: width 0.4s ease-out; box-shadow: 0.4cqmin 0 1.4cqmin rgba(255, 255, 255, 0.6); }
#pts-left, #pts-right { position: absolute; top: 50%; transform: translateY(-50%); font-weight: 900; font-size: 2.6cqmin; }
#pts-left { left: 1.6cqmin; }
#pts-right { right: 1.6cqmin; }
#timer { display: inline-block; margin-top: 0.8cqmin; padding: 0.3cqmin 2cqmin; border-radius: 99px; background: rgba(0, 0, 0, 0.55); font-weight: 900; font-size: 3cqmin; letter-spacing: 0.2cqmin; }
#timer.urgent { color: #ff5a4d; animation: pulse 0.5s infinite alternate; }

.side { position: absolute; top: 15cqmin; width: 30cqmin; display: flex; flex-direction: column; gap: 0.8cqmin; }
.side.left { left: 2cqmin; }
.side.right { right: 2cqmin; align-items: flex-end; text-align: right; }
.hq, .likes { display: flex; align-items: center; gap: 1cqmin; width: 100%; font-weight: 800; }
.hq .lbl { font-size: 1.8cqmin; opacity: 0.8; }
.hq b { font-size: 2.4cqmin; min-width: 6cqmin; }
.bar { flex: 1; height: 2.2cqmin; background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 0.6cqmin; overflow: hidden; }
.side.right .bar { transform: scaleX(-1); } /* drain toward the center */
.bar.small { height: 1.1cqmin; }
.fill { height: 100%; width: 100%; transition: width 0.3s; }
.likes-fill { background: #ff6b9a; }
.likes { font-size: 1.8cqmin; }
.top { font-size: 1.9cqmin; font-weight: 700; }
.top b { color: var(--gold); }

#feed { position: absolute; bottom: 3cqmin; left: 2cqmin; max-width: 55%; display: flex; flex-direction: column-reverse; gap: 0.5cqmin; }
.feed-line { align-self: flex-start; padding: 0.5cqmin 1.2cqmin; border-radius: 0.6cqmin; background: rgba(0, 0, 0, 0.6); font-weight: 700; font-size: 2.1cqmin; animation: slideIn 0.25s; transition: opacity 0.5s; }
.feed-line.fade { opacity: 0; }

#banner { position: absolute; top: 34%; left: 0; right: 0; text-align: center; font-size: 6.5cqmin; font-weight: 900; font-style: italic; opacity: 0; -webkit-text-stroke: 0.15cqmin #000; }
#banner.big { font-size: 14cqmin; }
#banner.show { animation: banner 1.2s ease-out forwards; }

/* ---------- Overlays ---------- */
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2cqmin; background: radial-gradient(ellipse at center, rgba(15, 18, 28, 0.75), rgba(0, 0, 0, 0.9)); text-align: center; }
.overlay[hidden] { display: none; }
.big-title { font-size: 9cqmin; font-weight: 900; font-style: italic; letter-spacing: 0.5cqmin; background: linear-gradient(90deg, var(--red), var(--gold), var(--blue)); -webkit-background-clip: text; background-clip: text; color: transparent; }
#res-title { background: none; -webkit-background-clip: initial; background-clip: initial; text-shadow: 0 0 3cqmin rgba(0, 0, 0, 0.6); }
.sub { color: #c8cbd8; font-size: 2.4cqmin; font-weight: 700; letter-spacing: 0.15cqmin; }
.lobby-box { display: flex; flex-direction: column; gap: 1.4cqmin; width: min(80cqw, 60cqmin); }
.or { color: var(--muted); font-size: 1.9cqmin; }
.code { font-size: 12cqmin; font-weight: 900; letter-spacing: 1.5cqmin; color: var(--gold); font-family: "Consolas", monospace; }
.seats { display: flex; align-items: center; gap: 4cqmin; margin: 1cqmin 0; }
.seat { min-width: 30cqmin; padding: 1.6cqmin; border-radius: 1.2cqmin; border: 2px solid; background: rgba(0, 0, 0, 0.4); font-size: 2.6cqmin; font-weight: 800; }
.seat.red { border-color: var(--red); }
.seat.blue { border-color: var(--blue); }
.seat-lbl { font-size: 1.8cqmin; opacity: 0.8; }
.seat.red .seat-lbl { color: var(--red); }
.seat.blue .seat-lbl { color: var(--blue); }
.seat .empty { color: var(--muted); font-weight: 600; font-style: italic; }
.seats .vs { font-size: 4cqmin; font-weight: 900; color: var(--gold); font-style: italic; }
.overlay .hint { color: var(--muted); font-size: 2cqmin; }
.overlay .row { display: flex; gap: 1.4cqmin; justify-content: center; }
.overlay button { font-size: 2.2cqmin; padding: 1.2cqmin 2.4cqmin; }
.overlay button.big { font-size: 2.8cqmin; padding: 1.6cqmin 4cqmin; font-weight: 900; }
.overlay input { font-size: 2.6cqmin; text-transform: uppercase; letter-spacing: 0.6cqmin; text-align: center; }
.error { color: var(--err); font-size: 2cqmin; min-height: 2.4cqmin; }

#res-cols { display: flex; gap: 3cqmin; }
.res-col { min-width: 30cqmin; padding: 2cqmin; border-radius: 1.4cqmin; border: 2px solid; background: rgba(0, 0, 0, 0.45); font-size: 2.2cqmin; line-height: 1.7; text-align: left; }
.res-col h3 { margin: 0 0 1cqmin; font-size: 3cqmin; }
.res-col b { color: #fff; }
.mvp { margin-top: 1cqmin; padding-top: 1cqmin; border-top: 1px solid rgba(255, 255, 255, 0.15); }
.mvp b { color: var(--gold); }
.mvp .none { color: var(--muted); }

.loading-track { width: 50%; height: 1cqmin; background: #1c1f2a; border-radius: 99px; overflow: hidden; }
#loading-bar { width: 0; height: 100%; background: var(--accent-2); transition: width 0.3s; }
.loading-sub { color: var(--muted); font-size: 2.2cqmin; }

@keyframes banner { 0% { opacity: 0; transform: scale(1.5); } 15% { opacity: 1; transform: scale(1); } 70% { opacity: 1; } 100% { opacity: 0; transform: scale(0.9); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-2cqmin); } to { opacity: 1; transform: none; } }
@keyframes pulse { from { opacity: 0.6; } to { opacity: 1; } }

/* ==========================================================================
   Panel
   ========================================================================== */
#panel { width: 330px; flex-shrink: 0; height: 100vh; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--panel-border); padding: 16px; }
body.panel-hidden #panel { display: none; }
#show-panel-btn { display: none; position: absolute; top: 8px; right: 8px; opacity: 0.25; flex: none; z-index: 5; }
#show-panel-btn:hover { opacity: 1; }
body.panel-hidden #show-panel-btn { display: block; }
body:not(.in-room) .only-in-room { display: none; }
body.is-spectator #panel .connect-section { display: none; }

.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
h1 { font-size: 17px; margin: 0; }
h2 { font-size: 14px; margin: 0 0 10px; color: var(--accent-2); }
h3 { font-size: 12px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
section { padding: 14px 0; border-top: 1px solid var(--panel-border); }
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row.mt { margin-top: 8px; }
.at { color: var(--muted); font-weight: 600; }
input { width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--panel-border); background: #0d0f16; color: var(--text); font-size: 14px; }
input:focus { outline: 2px solid var(--accent-2); outline-offset: -1px; }
button { flex: 1; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--panel-border); background: #20243a; color: var(--text); font-size: 13px; cursor: pointer; }
button:hover:not(:disabled) { filter: brightness(1.25); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); font-weight: 600; }
button.small { flex: none; padding: 4px 8px; font-size: 12px; }
button.active { background: #1f6f4a; border-color: var(--ok); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid .wide { grid-column: span 2; }
.room-info { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; padding: 8px 10px; border-radius: 6px; background: #0d0f16; }
.room-info b { color: var(--gold); letter-spacing: 2px; }
.status { margin: 4px 0 0; padding: 8px 10px; border-radius: 6px; background: #0d0f16; font-size: 13px; }
.status::before { content: "● "; }
.status-idle::before, .status-off::before, .status-disconnected::before { color: var(--muted); }
.status-connecting::before { color: var(--warn); }
.status-connected::before { color: var(--ok); }
.status-error::before { color: var(--err); }
.status-error { color: var(--err); }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.hint a { color: var(--accent-2); }
.hint b { color: var(--text); }
code { background: #0d0f16; padding: 1px 4px; border-radius: 4px; font-size: 11px; }

/* Home button (panel header) */
.panel-header { gap: 8px; }
.panel-header h1 { flex: 1; }
.home-btn {
  flex: none;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--accent-2, #25f4ee);
  background: rgba(37, 244, 238, 0.12);
  color: var(--text, #e8eaf2);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.home-btn:hover { background: rgba(37, 244, 238, 0.25); }

/* Name box on the lobby screen */
.overlay input.name-input { text-transform: none; letter-spacing: normal; font-size: 2.2cqmin; }
