/* ── PUZZLE BATTLE ── */

/* ── Lobby ── */
.battle-lobby-content {
  flex: 1; padding: 28px 32px; max-width: 900px;
  margin: 0 auto; width: 100%;
  display: flex; flex-direction: column; gap: 24px;
}
.battle-lobby-header { text-align: center; }
.battle-room-list { padding: 18px; }
.battle-room-entry {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.battle-room-entry:last-child { border-bottom: none; }

.battle-room-entry.admin-event-room {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.06), rgba(184, 134, 11, 0.04));
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-left: 3px solid #ffd700;
  border-radius: 8px;
  padding: 14px 12px;
  margin-bottom: 6px;
  animation: eventPulse 3s ease-in-out infinite;
}
.battle-room-entry.admin-event-room:last-child { border-bottom: 1px solid rgba(255, 215, 0, 0.35); }

@keyframes eventPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
  50%       { box-shadow: 0 0 12px 2px rgba(255, 215, 0, 0.15); }
}
.battle-room-meta {
  flex: 1; font-family: 'IBM Plex Mono', monospace;
  font-size: 12px; color: var(--text2); min-width: 200px;
}
.battle-room-meta strong { color: var(--text); }
.battle-room-status {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  padding: 2px 8px; border-radius: 10px; border: 1px solid;
}
.battle-room-status.waiting     { color: var(--accent); border-color: var(--accent); }
.battle-room-status.in_progress { color: var(--warn);   border-color: var(--warn);   }
.battle-room-status.finished    { color: var(--text3);  border-color: var(--border);  }

/* ── Create Room Modal ── */
.battle-modal-overlay {
  position: fixed; inset: 0; background: #00000088;
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.battle-modal {
  background: var(--bg2); border: 1px solid var(--border);
  padding: 28px; width: 100%; max-width: 400px; border-radius: 2px;
}
.battle-modal-title {
  font-family: 'Playfair Display', serif; font-size: 20px;
  font-weight: 700; color: var(--text); margin-bottom: 20px;
}

/* ── Battle Room Layout ── */
.battle-room-layout {
  flex: 1; display: flex; gap: 20px;
  padding: 16px 20px; overflow: hidden;
}
.battle-room-left {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.battle-room-right {
  width: 260px; flex-shrink: 0;
  display: flex; flex-direction: column;
  gap: 12px; overflow-y: auto;
}

/* Chessground needs explicit height on its container */
.board-wrap { touch-action: none; }
#battle-board { width: 100%; aspect-ratio: 1 / 1; display: block; }
.battle-info-bar {
  display: flex; align-items: center; gap: 14px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--text2); width: 100%;
}
.battle-room-id { color: var(--text3); }
.battle-puzzle-counter { color: var(--accent); font-weight: 500; }
.battle-status-badge {
  padding: 2px 10px; border-radius: 10px;
  border: 1px solid var(--border); font-size: 10px; color: var(--text3);
}
.battle-status-badge.waiting     { color: var(--text3); }
.battle-status-badge.in_progress { color: var(--accent); border-color: var(--accent); }
.battle-status-badge.finished    { color: var(--warn);   border-color: var(--warn); }

/* ── Battle Timer ── */
.battle-timer {
  font-family: 'IBM Plex Mono', monospace; font-size: 13px;
  color: var(--text2); text-align: center; padding: 6px 0;
}
.battle-timer-val {
  font-size: 22px; font-weight: 700; color: var(--accent); transition: color 0.3s;
}
.battle-timer-val.urgent { color: var(--danger); }

/* ── Players list ── */
.battle-player-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
  font-family: 'IBM Plex Mono', monospace; font-size: 12px;
}
.battle-player-row:last-child { border-bottom: none; }
.battle-player-name  { flex: 1; color: var(--text); }
.battle-player-score { color: var(--accent); font-weight: 500; min-width: 40px; text-align: right; }
.battle-player-ready { font-size: 14px; }
.battle-spectator-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--text3); letter-spacing: 0.1em;
  text-transform: uppercase; margin-bottom: 4px;
}

/* ── Solve flash ── */
@keyframes solveFlash {
  0%   { background: rgba(173, 98, 255, 0.3); }
  100% { background: transparent; }
}
.battle-solve-flash { animation: solveFlash 0.8s ease; }

/* ── Final scoreboard ── */
.battle-final-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-family: 'IBM Plex Mono', monospace;
}
.battle-final-row:last-child { border-bottom: none; }
.battle-final-rank  { font-size: 18px; width: 28px; }
.battle-final-name  { flex: 1; color: var(--text); font-size: 13px; }
.battle-final-score { color: var(--accent); font-weight: 700; font-size: 15px; }

/* ── Battle source radio buttons ── */
.battle-source-row { display: flex; gap: 16px; margin-top: 4px; }
.battle-radio-label {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px;
  color: var(--text2); padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 2px;
  transition: border-color 0.15s, color 0.15s;
}
.battle-radio-label:has(input:checked) { border-color: var(--accent); color: var(--accent); }
.battle-radio-label input[type="radio"] { accent-color: var(--accent); }

/* ── Battle balloons ── */
#battle-balloon-container {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  z-index: 99998; display: flex; flex-direction: column;
  align-items: center; gap: 10px; pointer-events: none;
  width: 100%; max-width: 500px;
}
.battle-balloon {
  padding: 14px 28px; border-radius: 40px;
  font-family: 'IBM Plex Mono', monospace; font-size: 14px;
  font-weight: 600; text-align: center;
  animation: balloonIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 32px #00000066; max-width: 90vw;
}
.battle-balloon.solve {
  background: #1a2e1a; border: 2px solid var(--accent); color: var(--accent);
}
.battle-balloon.round {
  background: #2a2000; border: 2px solid #e5c050; color: #e5c050; font-size: 16px;
}
.battle-balloon.match {
  background: linear-gradient(135deg, #1a0a2e, #2a1a0e);
  border: 2px solid #c084fc; color: #e2c0ff;
  font-size: 18px; padding: 20px 40px;
  animation: balloonMatch 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes balloonIn {
  from { opacity: 0; transform: scale(0.5) translateY(-20px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}
@keyframes balloonMatch {
  0%   { opacity: 0; transform: scale(0.3) rotate(-5deg); }
  60%  { transform: scale(1.1) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
@keyframes balloonOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.8) translateY(-10px); }
}

@media (max-width: 900px) {
  .battle-room-layout { flex-direction: column; padding: 10px; }
  .battle-room-right  { width: 100%; }
}

/* ── Battle Recap Log ── */
.recap-entry { margin-bottom: 8px; }
.recap-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.recap-toggle {
  flex: 0 0 auto;
  width: 28px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  text-align: center;
  transition: background 0.15s;
  font-family: 'IBM Plex Mono', monospace;
}
.recap-toggle:hover { background: var(--bg3); }
.recap-toggle.won   { border-left: 3px solid var(--accent); }
.recap-label {
  flex: 1;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recap-lichess-link {
  flex: 0 0 auto;
  color: var(--accent);
  text-decoration: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}
.recap-lichess-link:hover { background: var(--bg3); text-decoration: underline; }
.recap-body {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 12px 14px;
  overflow-x: auto;
}
.recap-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.recap-table th {
  text-align: left;
  padding: 4px 10px;
  color: var(--text3);
  font-weight: 500;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.recap-table td { padding: 6px 10px; color: var(--text2); }
.recap-table tr:nth-child(even) td { background: var(--bg2); }
.recap-table tr.winner td { color: var(--accent); font-weight: 600; }
.recap-table tr.dnf td { color: var(--text3); font-style: italic; }
.recap-handicap-note {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--text3);
  font-size: 11px;
}
