/* ===================================================================
   BEER WARS — Dark Fantasy Hex Battle Arena
   =================================================================== */

/* ─── Variables & Reset ──────────────────────────────────────────── */
:root {
  --bg-deep:     #0a0a12;
  --bg-panel:    #10101e;
  --bg-card:     #181828;
  --bg-hover:    #22223a;
  --gold:        #c9a227;
  --gold-light:  #ffd700;
  --gold-dark:   #8b6914;
  --silver:      #a0a8b0;
  --red:         #c0392b;
  --green:       #2ecc71;
  --blue:        #3498db;
  --cyan:        #00e5ff;
  --border:      #2a2a44;
  --text-bright: #f0f0e8;
  --text-mid:    #a0a0b8;
  --text-dim:    #606080;
  --font-title:  'Cinzel Decorative', 'Cinzel', serif;
  --font-body:   'Cinzel', Georgia, serif;
  --font-mono:   'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: var(--bg-deep);
  color: var(--text-bright);
  font-family: var(--font-body);
  overflow: hidden;
}

#app {
  width: 100vw; height: 100vh;
  position: relative;
  display: flex;
  align-items: stretch;
}

/* ─── Screens ────────────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: var(--bg-deep);
  z-index: 10;
}
.screen.active { display: flex; }

.screen-bg {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at 20% 20%, #1a0a2e44, transparent 60%),
    radial-gradient(ellipse at 80% 80%, #0a1a2e44, transparent 60%),
    var(--bg-deep);
  overflow-y: auto;
}

/* ─── MAIN MENU ──────────────────────────────────────────────────── */
.menu-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  max-width: 600px;
  width: 100%;
}

.game-title {
  text-align: center;
  text-shadow: 0 0 30px var(--gold);
}

.title-line1 {
  font-family: var(--font-title);
  font-size: clamp(2.5rem, 8vw, 5rem);
  color: var(--gold);
  letter-spacing: 0.1em;
  animation: titlePulse 3s ease-in-out infinite;
}

.title-line2 {
  font-family: var(--font-title);
  font-size: clamp(1rem, 3vw, 1.8rem);
  color: var(--silver);
  letter-spacing: 0.3em;
  margin-top: 8px;
}

.title-tagline {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-top: 10px;
  font-style: italic;
  letter-spacing: 0.2em;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 20px var(--gold), 0 0 40px var(--gold-dark); }
  50%       { text-shadow: 0 0 35px var(--gold-light), 0 0 70px var(--gold); }
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 340px;
}

.menu-btn {
  width: 100%;
  padding: 14px 24px;
  font-family: var(--font-body);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  clip-path: polygon(8px 0%, 100% 0%, calc(100% - 8px) 100%, 0% 100%);
  text-transform: uppercase;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #0a0a12;
  font-weight: bold;
  box-shadow: 0 0 20px var(--gold-dark);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  box-shadow: 0 0 35px var(--gold);
  transform: translateY(-2px);
}

.btn-secondary {
  background: linear-gradient(135deg, #1a2a4a, #2a4a8a);
  color: #a0c8ff;
  border: 1px solid #3a5a9a;
}
.btn-secondary:hover {
  background: linear-gradient(135deg, #2a3a6a, #3a5aaa);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--silver);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--gold-dark);
  color: var(--gold);
  background: #1a1a2a;
}

.faction-parade {
  display: flex; gap: 12px; flex-wrap: wrap;
  justify-content: center; margin-top: 12px;
}

.parade-icon {
  font-size: 1.8rem;
  border: 2px solid;
  border-radius: 50%;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  background: var(--bg-card);
  animation: float 3s ease-in-out infinite;
}
.parade-icon:nth-child(2n)  { animation-delay: 0.4s; }
.parade-icon:nth-child(3n)  { animation-delay: 0.8s; }
.parade-icon:nth-child(4n)  { animation-delay: 1.2s; }
.parade-icon:hover { transform: scale(1.3); }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.credits { color: var(--text-dim); font-size: 0.8rem; margin-top: 12px; }

/* ─── FACTION SELECT ─────────────────────────────────────────────── */
.screen-title {
  font-family: var(--font-title);
  font-size: clamp(1.4rem, 4vw, 2.5rem);
  color: var(--gold);
  text-align: center;
  margin-bottom: 8px;
  text-shadow: 0 0 20px var(--gold-dark);
}

.player-label {
  color: var(--silver);
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  margin-bottom: 16px;
}

.faction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 900px;
  margin-bottom: 16px;
}

.faction-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.faction-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--faction-primary, transparent) 0%, transparent 60%);
  opacity: 0.3;
  pointer-events: none;
}
.faction-card:hover {
  border-color: var(--faction-accent, var(--gold));
  background: var(--bg-hover);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px var(--faction-primary, transparent);
}
.faction-card.selected-p0 {
  border-color: #3399FF;
  box-shadow: 0 0 18px #3399FF88;
  background: #0a1a3a;
}
.faction-card.selected-p1 {
  border-color: #FF6633;
  box-shadow: 0 0 18px #FF663388;
  background: #3a1a0a;
}
.fc-flag { font-size: 2.2rem; display: block; margin-bottom: 6px; }
.fc-name { font-size: 0.75rem; color: var(--text-bright); font-weight: bold; letter-spacing: 0.05em; }
.fc-ability { font-size: 0.65rem; color: var(--gold); margin-top: 4px; }
.fc-bonus { font-size: 0.65rem; color: var(--green); margin-top: 2px; }

.faction-detail {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 14px;
  max-width: 900px;
  width: 100%;
  min-height: 120px;
  margin-bottom: 14px;
  font-size: 0.85rem;
}
.detail-header { font-family: var(--font-title); font-size: 1.1rem; margin-bottom: 6px; }
.detail-lore   { color: var(--text-mid); font-style: italic; margin-bottom: 8px; line-height: 1.4; }
.detail-special{ color: var(--text-bright); margin-bottom: 6px; }
.detail-budget { color: var(--gold); font-weight: bold; margin-bottom: 6px; }
.detail-units  { display: flex; flex-direction: column; gap: 3px; }
.unit-row { display: flex; gap: 10px; align-items: center; font-size: 0.78rem; }
.unit-icon { font-size: 1rem; }
.unit-name { color: var(--text-bright); min-width: 140px; }
.unit-stats{ color: var(--text-dim); font-family: var(--font-mono); font-size: 0.72rem; }

/* ─── ARMY BUILD ─────────────────────────────────────────────────── */
.army-bg { gap: 10px; }

.faction-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card);
  padding: 10px 24px;
  border: 1px solid var(--faction-primary, var(--border));
  border-radius: 4px;
}
.banner-flag { font-size: 2rem; }
.banner-name { font-family: var(--font-title); font-size: 1.3rem; }

.budget-bar { font-size: 1rem; color: var(--text-mid); }
.budget-current { color: var(--gold-light); font-weight: bold; font-size: 1.2rem; }

/* ── Unit palette (top bar) ── */
.unit-palette {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 700px;
  padding: 10px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  justify-content: center;
}

.pal-card {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--bg-card);
  border: 1px solid var(--gold-dark);
  border-radius: 5px;
  padding: 8px 16px;
  cursor: grab;
  flex: 1;
  user-select: none;
  transition: all 0.15s;
}
.pal-card:hover       { background: var(--bg-hover); border-color: var(--gold); transform: translateY(-3px); box-shadow: 0 4px 12px rgba(201,162,39,0.25); }
.pal-card.pal-dim     { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.pal-card.pal-dragging{ opacity: 0.4; transform: scale(0.95); }
.pal-icon { font-size: 1.8rem; }
.pal-name { font-size: 0.8rem; font-weight: bold; color: var(--text-bright); }
.pal-cost { font-size: 0.7rem; color: var(--gold-dark); }

.army-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin: 0;
  align-self: flex-start;
}

/* ── Slots grid ── */
.army-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 700px;
}

.slot-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px;
  min-height: 88px;
  display: flex; flex-direction: column; gap: 7px;
  transition: all 0.15s;
}
.slot-empty {
  border-style: dashed;
  justify-content: center; align-items: center;
  opacity: 0.55;
}
.slot-empty:hover { opacity: 0.85; border-color: var(--gold-dark); }
.slot-filled { cursor: grab; }
.slot-filled:hover { border-color: var(--gold-dark); }
.slot-drop-over { border-color: var(--gold) !important; background: rgba(201,162,39,0.12) !important; opacity: 1 !important; }
.slot-dragging  { opacity: 0.35; }

.slot-num { font-size: 0.68rem; color: var(--text-dim); }
.slot-drop-hint { font-size: 0.72rem; color: var(--text-dim); text-align: center; }

.slot-header {
  display: flex; align-items: center; gap: 5px;
}
.slot-icon { font-size: 1.3rem; }
.slot-name { font-size: 0.82rem; font-weight: bold; color: var(--text-bright); flex: 1; }

.slot-controls {
  display: flex; align-items: center; gap: 4px;
  margin-top: auto;
}
.slot-count-info {
  flex: 1; display: flex; flex-direction: column; align-items: center;
}
.sc-stacks { font-size: 0.9rem; font-weight: bold; color: var(--gold); }
.sc-total  { font-size: 0.65rem; color: var(--text-dim); }

.slot-clear-btn {
  width: 22px; height: 22px;
  background: none; border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer;
  border-radius: 3px; font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.slot-clear-btn:hover { background: #8B0000; color: #fff; border-color: #8B0000; }

.cnt-btn {
  width: 26px; height: 26px;
  background: var(--bg-hover);
  border: 1px solid var(--gold-dark);
  color: var(--gold); font-size: 1rem;
  cursor: pointer; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.cnt-btn:hover { background: var(--gold-dark); color: #000; }

.army-actions { display: flex; gap: 12px; max-width: 400px; width: 100%; }
.army-actions .menu-btn { flex: 1; }

/* ─── BATTLE SCREEN ──────────────────────────────────────────────── */
#screen-battle {
  display: flex;
  flex-direction: column;
  background: #0a0a14;
  width: 100vw; height: 100vh;
  overflow: hidden;
}

.round-bar {
  height: 32px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px;
  font-family: var(--font-title);
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.15em;
  flex-shrink: 0;
}
#round-text { flex: 1; text-align: center; }

.surrender-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.surrender-btn:hover { border-color: #8B0000; color: #E74C3C; background: rgba(139,0,0,0.15); }

.battle-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.battle-left {
  width: 160px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.battle-center {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0d0d1a;
}

.battle-center canvas {
  display: block;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  cursor: crosshair;
}

.battle-right {
  width: 160px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px;
}

.battle-bottom {
  height: 110px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0;
}

/* Initiative Queue */
.initiative-queue {
  padding: 8px;
}
.queue-title {
  font-size: 0.7rem;
  color: var(--gold);
  text-align: center;
  letter-spacing: 0.15em;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.queue-unit {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 6px;
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.72rem;
  transition: all 0.2s;
}
.queue-unit.queue-active {
  border-width: 2px;
  box-shadow: 0 0 10px currentColor;
  background: #1a1a30;
}
.qu-icon { font-size: 1rem; }
.qu-name { font-size: 0.7rem; font-weight: bold; }
.qu-hp   { font-family: var(--font-mono); font-size: 0.65rem; }

/* Unit info panel */
.unit-info-panel {
  padding: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
}
.uinfo-header  { font-weight: bold; font-size: 0.85rem; margin-bottom: 3px; }
.uinfo-faction { font-size: 0.7rem; margin-bottom: 6px; }
.uinfo-hp      { margin-bottom: 6px; }
.hp-bar-bg     { height: 6px; background: #333; border-radius: 3px; margin-bottom: 3px; overflow: hidden; }
.hp-bar-fill   { height: 100%; border-radius: 3px; transition: width 0.3s; }
.uinfo-stats   { display: flex; flex-wrap: wrap; gap: 5px; font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--text-mid); margin-bottom: 4px; }
.uinfo-buff    { color: #FF9933; font-size: 0.72rem; }
.uinfo-spell   { color: var(--cyan); font-size: 0.72rem; }
.uinfo-special { font-size: 0.68rem; margin-top: 4px; }

/* Enemy list */
.panel-title {
  font-size: 0.7rem;
  color: var(--silver);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 3px;
}
.enemy-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  padding: 3px 4px;
  border: 1px solid;
  border-radius: 3px;
  margin-bottom: 4px;
  background: var(--bg-card);
}

/* Action buttons */
.action-buttons {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.action-btn {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  white-space: nowrap;
}
.action-btn:hover {
  background: var(--gold-dark);
  color: #000;
  box-shadow: 0 0 12px var(--gold-dark);
}
.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.action-key {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  background: var(--bg-deep);
  border: 1px solid var(--text-dim);
  border-radius: 3px;
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  vertical-align: middle;
  line-height: 1.4;
}
.action-btn:hover .action-key {
  border-color: #000;
  color: #000;
}

/* Battle log */
.battle-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.log-line {
  color: var(--text-mid);
  padding: 1px 0;
  border-bottom: 1px solid #ffffff08;
  line-height: 1.5;
}
.log-line:last-child { color: var(--text-bright); }

/* Flash message overlay */
.flash-message {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: bold;
  text-shadow: 0 0 20px currentColor;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  z-index: 100;
}

/* ─── RESULT SCREEN ──────────────────────────────────────────────── */
.result-bg { background: radial-gradient(ellipse at center, #1a0a2e, #0a0a12); }

.result-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 480px;
  text-align: center;
}

.result-title {
  font-family: var(--font-title);
  font-size: clamp(2rem, 8vw, 4rem);
  text-shadow: 0 0 40px currentColor;
}
.result-title.victory { color: var(--gold-light); animation: victoryPulse 1.5s ease-in-out infinite; }
.result-title.defeat  { color: var(--red); }
.result-title.draw    { color: var(--silver); }

@keyframes victoryPulse {
  0%, 100% { transform: scale(1);    text-shadow: 0 0 30px var(--gold); }
  50%       { transform: scale(1.05); text-shadow: 0 0 60px var(--gold-light); }
}

.result-beer {
  font-size: 1.25rem;
  color: var(--gold-light);
  background: rgba(201,162,39,0.1);
  border: 1px solid var(--gold-dark);
  border-radius: 6px;
  padding: 10px 24px;
  margin: 8px 0;
}
.result-subtitle { color: var(--text-mid); font-size: 1.1rem; }

.result-stats {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 28px;
  width: 100%;
}
.stat-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.stat-row:last-child { border-bottom: none; }

.result-buttons { display: flex; gap: 16px; width: 100%; }
.result-buttons .menu-btn { flex: 1; }

/* ─── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg-panel); }
::-webkit-scrollbar-thumb { background: var(--gold-dark); border-radius: 2px; }

/* ─── Stars background animation ─────────────────────────────────── */
.stars {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.stars::before, .stars::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 50% 60%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 80% 20%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 35% 75%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 65% 45%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 90% 70%, rgba(201,162,39,0.5), transparent),
    radial-gradient(1.5px 1.5px at 10% 90%, rgba(201,162,39,0.4), transparent);
  background-size: 200px 200px;
  animation: twinkle 6s ease-in-out infinite;
}
.stars::after { animation-delay: 3s; opacity: 0.6; }

@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* ─── Utility ──────────────────────────────────────────────────────── */
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Faction Stats Bar ─────────────────────────────────────────── */
.faction-stats-bar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin-bottom: 8px;
}
.fs-entry {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 52px;
}
.fs-flag  { font-size: 1.5em; line-height: 1; }
.fs-wins  { font-size: 0.75rem; color: var(--text-dim); }

/* ─── Online Connect Screen ──────────────────────────────────────── */
.online-connect-box {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 36px;
  width: 100%; max-width: 440px;
}
.online-name-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
}
.online-label { color: var(--text-mid); font-size: 0.9rem; white-space: nowrap; }
.online-input {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-bright);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
}
.online-input:focus { border-color: var(--gold-dark); }
.online-divider {
  color: var(--text-dim); font-size: 0.8rem;
  width: 100%; text-align: center;
  border-top: 1px solid var(--border);
  margin: 4px 0; padding-top: 12px;
}
.online-join-row { display: flex; gap: 8px; width: 100%; }
.online-code-input {
  text-transform: uppercase; letter-spacing: 4px;
  font-size: 1.1rem; text-align: center;
  flex: 1;
}
.online-rooms-list {
  width: 100%; display: flex; flex-direction: column; gap: 6px;
}
.oc-room-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
}
.oc-room-host    { flex: 1; color: var(--gold); font-size: 0.95rem; }
.oc-room-waiting { color: var(--text-dim); font-size: 0.8rem; font-style: italic; }
.oc-room-join { padding: 4px 12px !important; font-size: 0.8rem !important; margin: 0 !important; }
.oc-no-rooms  { color: var(--text-dim); font-size: 0.85rem; text-align: center; padding: 8px 0; }
.online-error {
  display: none; color: #E74C3C;
  background: rgba(231,76,60,0.1);
  border: 1px solid rgba(231,76,60,0.3);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 0.85rem;
  width: 100%; text-align: center;
}

/* ─── Lobby Screen ────────────────────────────────────────────────── */
.lobby-bg { flex-direction: column; gap: 16px; padding: 24px; }

.lobby-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 860px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 20px;
}
.lobby-title { font-family: var(--font-title); color: var(--gold); font-size: 1.2rem; }
.lobby-room-code { display: flex; align-items: center; gap: 8px; color: var(--text-mid); font-size: 0.9rem; }
.lobby-code-badge {
  font-family: var(--font-mono); color: var(--gold-light);
  background: var(--bg-card);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  padding: 2px 10px; letter-spacing: 3px; font-size: 1rem;
}
.lobby-copy-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 3px; cursor: pointer;
  padding: 2px 6px; color: var(--text-mid); font-size: 0.85rem;
  transition: all 0.15s;
}
.lobby-copy-btn:hover { border-color: var(--gold-dark); color: var(--gold); }

.lobby-main {
  display: flex; gap: 16px;
  width: 100%; max-width: 860px;
  flex: 1; min-height: 0;
}

.lobby-players {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px 20px;
  min-width: 200px;
}
.lobby-player-slot {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 16px 24px;
  width: 160px;
  transition: border-color 0.2s;
}
.lobby-player-slot.lp-me { border-color: var(--gold-dark); }
.lp-icon   { font-size: 1.8rem; }
.lp-name   { color: var(--text-bright); font-size: 0.95rem; text-align: center; }
.lp-status { font-size: 0.8rem; color: var(--text-mid); }
.lobby-vs  { color: var(--gold-dark); font-family: var(--font-title); font-size: 1.1rem; }

.lobby-chat-panel {
  display: flex; flex-direction: column;
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.lobby-chat-messages {
  flex: 1; overflow-y: auto;
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 5px;
  min-height: 200px; max-height: 340px;
}
.chat-msg { font-size: 0.88rem; color: var(--text-bright); line-height: 1.4; }
.chat-msg .chat-name { color: var(--gold); font-weight: bold; }
.chat-sys { color: var(--text-dim); font-style: italic; }
.lobby-chat-input-row {
  display: flex; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.lobby-chat-input-row .online-input { flex: 1; }

.lobby-actions {
  display: flex; gap: 16px;
  width: 100%; max-width: 860px;
}
.lobby-actions .menu-btn { flex: 1; }
.btn-danger {
  background: var(--red) !important;
  border-color: var(--red) !important;
  color: #fff !important;
}
.lobby-hint {
  color: var(--text-dim); font-size: 0.85rem; text-align: center;
}

@media (max-width: 768px) {
  .battle-left, .battle-right { width: 120px; }
  .action-buttons { flex-wrap: wrap; }
  .faction-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) {
  .battle-left, .battle-right { width: 90px; }
  .battle-bottom { height: 90px; }
  .faction-grid { grid-template-columns: repeat(3, 1fr); }
}
