/* ===== Party / Blitz mode ===== */

.battle-view { display: block; margin: 0 auto; }
.battle-view.hidden { display: none; }
/* Narrow column layouts (setup / lobby / reveal / final). The round view
   stays full-width so the grid keeps fixed-size cells like other modes. */
#battle-setup, #battle-lobby, #battle-reveal, #battle-leaderboard { max-width: 460px; }
/* Round view: keep header/opponents/banner centered in a sane column,
   but let the grid and keyboard size themselves naturally. */
.battle-round-header, .battle-opponents, .battle-word-banner, #battle-error-message {
  max-width: 620px; margin-left: auto; margin-right: auto;
}
.battle-guesses { width: fit-content; max-width: 100%; margin: 0 auto 1rem; }
/* Scoped visibility helper: the `hidden` class toggled in JS on lobby
   controls needs an actual rule, otherwise nothing hides. */
#party-screen .hidden { display: none !important; }
.battle-error { color: #ffd6dd; min-height: 1.2em; font-size: 0.9rem; margin-top: 0.6rem; text-align: center; }

/* ----- Party button on the home screen: flowing colored border -----
   A masked gradient ring whose colors flow horizontally. No rotation,
   so the border stays glued to the button outline. */
#party-btn { position: relative; }
#party-btn::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 28px;
  padding: 3px;
  background: linear-gradient(90deg,
    #e63946, #f4a261, #06d6a0, #457b9d, #b5179e, #e63946);
  background-size: 300% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask-composite: exclude;
  animation: party-border-flow 3s linear infinite;
  pointer-events: none;
}
@keyframes party-border-flow {
  to { background-position: 300% 0; }
}
.party-icon { grid-column: 1; color: var(--primary-color); }

/* ----- Setup view ----- */
.battle-avatar-wrapper {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.6rem; margin-bottom: 1.4rem;
}
.battle-avatar {
  width: 96px; height: 96px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 3px solid rgba(255, 255, 255, 0.35);
  padding: 4px;
}
.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.85rem; min-width: 0; min-height: 0; }

.battle-name-input, .battle-code-input {
  display: block; width: 100%; box-sizing: border-box;
  margin: 0 auto 0.9rem; padding: 0.7rem 1rem;
  border: 2px solid rgba(255, 255, 255, 0.3); border-radius: 12px;
  font-size: 1rem; text-align: center;
  background: rgba(255, 255, 255, 0.1); color: var(--text-color, #fff);
}
.battle-name-input::placeholder, .battle-code-input::placeholder { color: rgba(255,255,255,0.5); }
.battle-name-input:focus, .battle-code-input:focus {
  outline: none; border-color: var(--primary-color, #e63946);
}
.battle-setup-actions { display: flex; flex-direction: column; align-items: stretch; gap: 0.8rem; }
#battle-create-btn { width: 100%; }
.battle-join-row { display: flex; gap: 0.5rem; align-items: stretch; width: 100%; }
.battle-join-row .btn { flex: 0 0 auto; }
.battle-code-input { flex: 1 1 auto; width: auto; min-width: 0; margin: 0; text-transform: uppercase; letter-spacing: 0.08em; }
.battle-code-input::placeholder { letter-spacing: normal; }

/* ----- Lobby ----- */
.battle-room-code-display {
  font-size: 1.1rem; text-align: center; margin-bottom: 1.2rem; opacity: 0.8;
}
.battle-room-code-display strong {
  display: block; font-size: 2.4rem; letter-spacing: 0.25em;
  color: var(--primary-color, #e63946); margin-top: 0.2rem;
}
.battle-copy-link { display: block; margin: 0 auto 1.2rem; }
.battle-players-list {
  display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.4rem;
}
.battle-player-item {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.5rem 0.9rem; border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}
.battle-player-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}
.battle-player-name { font-size: 1rem; font-weight: 600; }
.battle-host-star { color: #ffd166; font-size: 0.85rem; margin-left: 0.15rem; }
.battle-waiting-msg { text-align: center; opacity: 0.55; }
#battle-start-btn { display: block; width: fit-content; margin: 0.4rem auto; }
#battle-start-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----- Round header ----- */
.battle-round-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.6rem;
}
.battle-round-label { font-size: 0.95rem; opacity: 0.7; }
.battle-timer {
  font-size: 1.9rem; font-weight: 700; min-width: 2.4ch; text-align: center;
  color: var(--text-color, #fff); transition: color 0.2s;
}
.battle-timer.urgent { color: #ff5c6c; }

/* ----- Opponents ----- */
.battle-opponents {
  display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center;
  margin-bottom: 0.7rem; min-height: 1px;
}
.battle-opponent-indicator {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.25rem 0.6rem; border-radius: 20px;
  background: rgba(255, 255, 255, 0.08); font-size: 0.8rem;
}
.battle-opponent-indicator.found { background: rgba(6, 214, 160, 0.22); }
.battle-opponent-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}
.battle-opponent-name { font-weight: 600; }
.battle-opponent-status { opacity: 0.75; }

/* ----- Word reveal banner (on the round view) ----- */
.battle-word-banner {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  margin: 0.4rem auto 0.8rem; animation: fadeIn 0.3s ease;
}
.battle-word-banner.hidden { display: none; }
.battle-word-banner-label { font-size: 0.8rem; opacity: 0.6; }
.battle-word-banner-word {
  font-size: 1.6rem; font-weight: 800; letter-spacing: 0.2em;
  color: var(--primary-color, #e63946);
}
.battle-word-banner-score {
  font-size: 1.4rem; font-weight: 800; color: var(--success-color, #06d6a0);
}
.battle-word-banner-score.bonus { transform: scale(1.12); transition: transform 0.2s; }

/* ----- Score bubbles ----- */
.score-bubble {
  position: fixed; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; line-height: 1.05;
  pointer-events: none; z-index: 9999;
  padding: 0.2rem 0.55rem; border-radius: 14px; color: #fff;
  animation: bubble-pop 1s ease-out forwards;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.score-bubble .bubble-label { font-size: 0.58rem; font-weight: 700; white-space: nowrap; opacity: 0.95; }
.score-bubble .bubble-pts { font-size: 1.05rem; font-weight: 800; }
.score-bubble.small { padding: 0.15rem 0.4rem; }
.score-bubble.small .bubble-label { font-size: 0.5rem; }
.score-bubble.small .bubble-pts { font-size: 0.85rem; }
.bubble-red    { background: var(--correct-color, #e63946); }
.bubble-yellow { background: var(--misplaced-color, #f4a261); }
.bubble-gray   { background: var(--absent-color, #457b9d); }
.bubble-bonus  { background: var(--success-color, #06d6a0); }
.bubble-bonus .bubble-pts { font-size: 1.2rem; }
.bubble-attempt { background: #9b5de5; }
@keyframes bubble-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  25%  { opacity: 1; transform: translate(-50%, -90%) scale(1.25); }
  60%  { opacity: 1; transform: translate(-50%, -150%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -230%) scale(0.9); }
}
.score-flash { animation: cell-flash 0.4s ease; }
@keyframes cell-flash {
  50% { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8); }
}

/* ----- Reveal scoreboard ----- */
.battle-reveal-word {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  margin-bottom: 1.2rem;
}
.battle-reveal-label { font-size: 0.85rem; opacity: 0.6; }
.battle-reveal-word-text {
  font-size: 1.9rem; font-weight: 800; letter-spacing: 0.2em;
  color: var(--primary-color, #e63946);
}
/* ----- Per-word score breakdown ----- */
.battle-score-detail {
  display: flex; flex-direction: column; gap: 0.3rem;
  background: rgba(255, 255, 255, 0.07); border-radius: 12px;
  padding: 0.7rem 0.9rem; margin-bottom: 1.2rem;
}
.battle-detail-row {
  display: grid; grid-template-columns: 1fr auto 3.2rem;
  align-items: center; gap: 0.6rem; font-size: 0.92rem;
}
.battle-detail-label { opacity: 0.9; }
.battle-detail-calc { opacity: 0.55; font-size: 0.82rem; }
.battle-detail-pts { font-weight: 700; text-align: right; color: var(--success-color, #06d6a0); }
.battle-detail-row.bonus .battle-detail-pts { color: #ffd166; }
.battle-detail-row.total {
  margin-top: 0.3rem; padding-top: 0.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.18); font-weight: 800;
}
.battle-detail-row.total .battle-detail-label { font-weight: 800; }
.battle-detail-row.total .battle-detail-pts { color: #fff; font-size: 1.05rem; }
/* Ligne unique (Sprint) : pas de séparateur au-dessus */
.battle-detail-row.total.solo { margin-top: 0; padding-top: 0; border-top: none; }

/* ----- Bar-chart race scoreboard (per word) ----- */
.battle-round-leaderboard { display: flex; flex-direction: column; gap: 0.7rem; }
.bcr-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.5rem; border-radius: 12px;
}
.bcr-row.me { background: rgba(230, 57, 70, 0.16); }
.bcr-head {
  flex: 0 0 60px; display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
}
.bcr-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.12);
}
.bcr-pname {
  font-size: 0.68rem; font-weight: 700; max-width: 60px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center;
}
.bcr-mid { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }

/* speech bubble of tried words */
.bcr-speech {
  position: relative; align-self: flex-start;
  display: flex; flex-wrap: wrap; gap: 0.25rem;
  background: rgba(255, 255, 255, 0.92); color: #1d3557;
  border-radius: 10px; padding: 0.3rem 0.5rem; max-width: 100%;
}
.bcr-speech::before {
  content: ''; position: absolute; left: -6px; top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent; border-right-color: rgba(255, 255, 255, 0.92);
}
.bcr-word {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  background: rgba(29, 53, 87, 0.1); border-radius: 5px; padding: 0.05rem 0.3rem;
}
.bcr-word.empty { background: none; opacity: 0.5; }

.bcr-track {
  height: 22px; background: rgba(255, 255, 255, 0.08);
  border-radius: 11px; overflow: hidden;
}
.bcr-bar {
  height: 100%; width: 0; border-radius: 11px;
  background: linear-gradient(90deg, #457b9d, #e63946);
  transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
  min-width: 2px;
}
.bcr-row.me .bcr-bar { background: linear-gradient(90deg, #f4a261, #e63946); }
.bcr-score {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end;
  min-width: 3.5ch;
}
.bcr-round { font-size: 0.72rem; font-weight: 800; color: var(--success-color, #06d6a0); }
.bcr-total { font-weight: 800; }

/* ----- Final podium ----- */
.battle-leaderboard-title { text-align: center; margin-bottom: 1rem; }
.battle-podium {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 0.8rem; margin-bottom: 1.4rem; min-height: 220px;
}
.battle-podium-col {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  width: 30%; animation: podium-rise 0.5s ease backwards;
}
.battle-podium-col.place-1 { animation-delay: 0.1s; }
.battle-podium-col.place-2 { animation-delay: 0.25s; }
.battle-podium-col.place-3 { animation-delay: 0.4s; }
@keyframes podium-rise {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.battle-podium-medal { font-size: 1.8rem; }
.battle-podium-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12); border: 2px solid rgba(255,255,255,0.3);
}
.battle-podium-col.place-1 .battle-podium-avatar { width: 70px; height: 70px; border-color: gold; }
.battle-podium-name { font-weight: 700; font-size: 0.9rem; text-align: center; }
.battle-podium-score { font-weight: 800; color: var(--primary-color, #e63946); font-size: 0.85rem; }
.battle-podium-base {
  width: 100%; border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.25), rgba(255,255,255,0.08));
}
.battle-podium-col.place-1 .battle-podium-base { height: 90px; background: linear-gradient(180deg, gold, rgba(255,215,0,0.25)); }
.battle-podium-col.place-2 .battle-podium-base { height: 64px; }
.battle-podium-col.place-3 .battle-podium-base { height: 42px; }
.battle-podium-col.me .battle-podium-name { color: var(--primary-color, #e63946); }

.battle-final-scores { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.4rem; }
.battle-final-row {
  display: grid; grid-template-columns: 1.6rem 30px 1fr auto;
  align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.8rem; border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
}
.battle-final-row.me { background: rgba(230, 57, 70, 0.22); }
.battle-final-rank { font-weight: 700; opacity: 0.7; text-align: center; }
.battle-final-avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.12); }
.battle-final-name { font-weight: 600; }
.battle-final-total { font-weight: 800; color: var(--primary-color, #e63946); }

.battle-leaderboard-actions { display: flex; gap: 0.8rem; justify-content: center; }

/* Sélecteur de mode à la création */
.battle-mode-select {
  display: flex;
  gap: 10px;
  margin: 16px 0;
  width: 100%;
}
.battle-mode-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 2px solid var(--border-color, #444);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.battle-mode-option:hover { border-color: #888; }
.battle-mode-option.active {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.12);
}
.battle-mode-name { font-weight: 700; font-size: 1rem; }
.battle-mode-desc { font-size: 0.78rem; opacity: 0.8; line-height: 1.2; }

/* Mode affiché au lobby */
.battle-lobby-mode {
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 8px;
}

/* Boomerang — vue de choix du mot à poser */
.battle-choose-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; margin-bottom: 0.6rem;
}
.battle-choose-prompt { text-align: center; margin: 0.4rem 0 1rem; opacity: 0.9; }
.battle-choose-list {
  display: flex; flex-direction: column; gap: 0.6rem; width: 100%;
}
.battle-choose-word {
  padding: 0.9rem 1rem; border: 2px solid var(--border-color, #444);
  border-radius: 10px; background: transparent; color: inherit;
  font-size: 1.1rem; font-weight: 700; letter-spacing: 0.06em;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.battle-choose-word:hover:not(:disabled) { border-color: #888; }
.battle-choose-word.selected { border-color: #e74c3c; background: rgba(231, 76, 60, 0.15); }
.battle-choose-word:disabled { opacity: 0.6; cursor: default; }
