/* ============================================================
   MULTIPLAYER.CSS — PvP, Teams and Tournament screens (v4.4.0)
   ============================================================ */

/* ============================================================
   PvP GAME
   ============================================================ */
.pvp-screen-container { display: flex; flex-direction: column; height: 100%; width: 100%; }

.pvp-split-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}
.pvp-player-section {
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  border-right: 1.5px solid var(--border);
  overflow-y: auto;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.pvp-player-section:last-child { border-right: none; }
.pvp-player-section.player1-section { background: color-mix(in srgb, var(--primary) 6%, transparent); }
.pvp-player-section.player2-section { background: color-mix(in srgb, var(--accent-pink) 6%, transparent); }

.pvp-player-section .player-header {
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.pvp-player-section .eq-card { margin-bottom: 0.75rem; padding: 1rem 0.875rem; }
.pvp-player-section .eq-card .equation { font-size: clamp(1.25rem, 3.5vw, 2.25rem); margin-bottom: 0.375rem; }
.pvp-player-section .eq-card .eq-hint { font-size: 0.75rem; }

.pvp-player-section .answers-grid { gap: 0.5rem; margin-bottom: 0.75rem; grid-template-columns: repeat(2, 1fr); }
.pvp-player-section .answer-btn {
  padding: 0.625rem 0.5rem;
  font-size: clamp(1rem, 1.8vw, 1.5rem);
  min-height: 3rem;
}

.marathon-track-pvp {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  margin-top: auto;
  overflow: hidden;
}
.marathon-track-pvp .track-label { font-size: 0.625rem; letter-spacing: 0.08em; margin-bottom: 0.375rem; color: var(--primary); }
.marathon-track-pvp .track-inner { height: 2rem; }
.marathon-track-pvp .track-dot { width: 1.25rem; height: 1.25rem; font-size: 0.5625rem; }
.marathon-track-pvp .runner { font-size: 1rem; }

/* ============================================================
   TEAM GAME
   ============================================================ */
.team-game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0.625rem;
  gap: 0.625rem;
}
.team-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  gap: var(--space-4);
}
.team-scores { display: flex; justify-content: center; align-items: center; gap: 1.25rem; flex: 1; }
.team-score { text-align: center; min-width: 5rem; }
.team-score .team-name { font-size: 0.8125rem; font-weight: 700; color: var(--text-muted); margin-bottom: 0.25rem; }
.team-score .team-points { font-family: var(--font-display); font-size: 1.125rem; font-weight: 700; color: var(--text); letter-spacing: 0.02em; margin-top: 0.125rem; }

.hp-bar-wrap {
  width: 6.25rem;
  height: 0.625rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: 0.25rem auto 0.125rem;
}
.hp-bar {
  height: 100%;
  width: 100%;
  background: var(--success);
  border-radius: var(--radius-pill);
  transition: width 0.4s var(--ease-out), background-color 0.4s var(--ease-out);
}
.hp-bar.hp-high { background: var(--success); }
.hp-bar.hp-mid  { background: var(--warn); }
.hp-bar.hp-low  { background: var(--error); }
.hp-label { font-family: var(--font-display); font-weight: 800; color: var(--text); letter-spacing: 0.02em; }

.round-info { color: var(--primary); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; }

.player-names-bar {
  display: flex;
  justify-content: space-around;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-weight: 700;
  color: var(--text);
  font-size: 0.8125rem;
  gap: 0.625rem;
}
.current-player { flex: 1; text-align: center; padding: 0.25rem 0.5rem; }

.team-split-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  flex: 1;
  min-height: 31.25rem;
  height: auto;
}
.team-player-section {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  gap: 0.5rem;
  min-height: 21.875rem;
}
.team-player-section.player1-section { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.team-player-section.player2-section { border-color: color-mix(in srgb, var(--accent-pink) 35%, var(--border)); }

.team-player-section .player-header {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text);
  text-align: center;
  margin-bottom: 0.25rem;
  flex-shrink: 0;
}
.team-player-section .eq-card {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem;
  text-align: center;
  min-height: 5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.team-player-section .eq-type-badge { font-size: 0.625rem; color: var(--primary); }
.team-player-section .equation {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.4vw, 1.5rem);
  color: var(--text);
  margin: 0.5rem 0;
  word-break: break-word;
  white-space: pre-line;
  line-height: 1.35;
}
.team-player-section .eq-hint { font-size: 0.6875rem; color: var(--text-muted); margin-top: 0.25rem; }

.team-player-section .answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.375rem; flex-shrink: 0; }
.team-player-section .answer-btn {
  background: var(--surface-2);
  border: 1.5px solid var(--border-strong);
  color: var(--text);
  padding: 0.5rem 0.375rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.875rem, 2vw, 1.25rem);
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.team-player-section .answer-btn:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.team-player-section .eq-card.correct { border-color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.team-player-section .eq-card.wrong   { border-color: var(--error);   background: color-mix(in srgb, var(--error) 14%, transparent); }

/* ============================================================
   TOURNAMENT
   ============================================================ */
.tournament-section {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  gap: 0.75rem;
  min-height: 18.75rem;
}
.tournament-section-1 { border-left: 5px solid var(--primary); }
.tournament-section-2 { border-left: 5px solid var(--accent-pink); }
.tournament-section .player-header { font-weight: 800; font-size: 0.875rem; color: var(--text); text-align: center; letter-spacing: 0.02em; }
.tournament-section .eq-card {
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  min-height: 6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.tournament-section .equation {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 2rem);
  color: var(--text);
  word-break: break-word;
  white-space: pre-line;
  line-height: 1.4;
  letter-spacing: 0.02em;
}
.tournament-section .answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; }
.tournament-section .answer-btn {
  background: var(--surface-2);
  border: 2px solid var(--border-strong);
  color: var(--text);
  padding: 0.875rem 0.625rem;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.4vw, 1.5rem);
  font-weight: 700;
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tournament-section .answer-btn:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.tournament-section .answer-btn.correct-ans { background: color-mix(in srgb, var(--success) 18%, transparent); border-color: var(--success); color: var(--success); }
.tournament-section .answer-btn.wrong-ans { background: color-mix(in srgb, var(--error) 18%, transparent); border-color: var(--error); color: var(--error); }
.tournament-section .eq-card.correct { border-color: var(--success); }
.tournament-section .eq-card.wrong { border-color: var(--error); animation: shake 0.4s; }

/* Tournament game top bar */
.t-name { font-family: var(--font-display); font-size: clamp(1rem, 2vw, 1.375rem); font-weight: 800; letter-spacing: 0.02em; }
.t-name--p1 { color: var(--primary); }
.t-name--p2 { color: var(--accent-pink); }
.t-timer {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  color: var(--error);
  display: none;
}
.t-timer-sub { font-size: 0.75rem; color: var(--text-muted); display: none; }
.tournament-stage-wrap { flex: 1; text-align: center; }

/* Bracket */
.bracket-round { display: flex; flex-direction: column; justify-content: space-around; gap: 1.25rem; }
.bracket-match {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  min-width: 8rem;
  text-align: center;
  transition: all var(--dur-base) var(--ease-out);
}
.bracket-match.is-current {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
  transform: scale(1.08);
  z-index: 10;
}
.bracket-player {
  font-size: 0.875rem;
  padding: 0.25rem 0;
  color: var(--text);
}
.bracket-player + .bracket-player { border-top: 1px solid var(--border); margin-top: 0.25rem; padding-top: 0.375rem; }
.bracket-player.is-winner { color: var(--success); font-weight: 800; }
.bracket-player.is-out { color: var(--text-faint); text-decoration: line-through; }

/* Versus splash */
.versus-name {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 800;
  position: absolute;
}
.versus-p1 { color: var(--primary); left: 10%; animation: slide-right 0.9s var(--ease-out) forwards; }
.versus-p2 { color: var(--accent-pink); right: 10%; animation: slide-left 0.9s var(--ease-out) forwards; }
.versus-vs {
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 12vw, 7rem);
  font-weight: 800;
  font-style: italic;
  color: var(--text);
  z-index: 10;
  animation: zoom-in 0.5s var(--ease-bounce) forwards;
}

@keyframes slide-right { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slide-left  { from { opacity: 0; transform: translateX(60px); }  to { opacity: 1; transform: translateX(0); } }
@keyframes zoom-in     { from { opacity: 0; transform: scale(0.4); }          to { opacity: 1; transform: scale(1); } }

/* Podium */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: var(--space-5); margin-top: 2.5rem; }
.podium-bar {
  width: 7.5rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-md);
}
.podium-bar--1 { width: 9rem; height: 16rem; background: linear-gradient(180deg, #FFD700, #E0A800); box-shadow: 0 0 40px color-mix(in srgb, var(--accent-yellow) 55%, transparent); }
.podium-bar--2 { height: 11rem; background: linear-gradient(180deg, #C9D2DD, #9AA6B5); }
.podium-bar--3 { height: 8rem;  background: linear-gradient(180deg, #D08C4E, #A6692F); }
.podium-name {
  position: absolute;
  top: -2.25rem;
  width: 100%;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.podium-bar--1 .podium-name { color: var(--accent-yellow); }
.podium-rank {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 800;
  color: #1a1200;
  margin-top: 1.25rem;
}
.podium-bar--1 .podium-rank { font-size: 4rem; }

/* ============================================================
   FORMS (players / teams / tournament input)
   ============================================================ */
.container-form h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.75rem, 4vw, 2.5rem); color: var(--text); margin-bottom: 0.5rem; letter-spacing: 0.02em; }
.container-form .subtitle { color: var(--text-muted); margin-bottom: 1.875rem; font-size: 0.9375rem; }
.teams-container { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.875rem; margin-bottom: 1.875rem; }
.team-form h2 { font-family: var(--font-display); font-size: 1.375rem; font-weight: 800; margin-bottom: 0.75rem; color: var(--text); }
.difficulty-selector { margin-bottom: 1.5rem; text-align: center; }
.difficulty-selector label { display: block; color: var(--warn); font-weight: 700; margin-bottom: 0.75rem; font-size: 0.875rem; }
.btn-group { display: flex; gap: 0.625rem; justify-content: center; flex-wrap: wrap; }

.start-btn.danger {
  background: color-mix(in srgb, var(--error) 18%, transparent);
  border: 2px solid var(--error);
  color: var(--error);
}
.start-btn.danger:hover { background: color-mix(in srgb, var(--error) 28%, transparent); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .pvp-split-container,
  .team-split-container { grid-template-columns: 1fr; }
  .pvp-player-section,
  .team-player-section { border-right: none; border-bottom: 1.5px solid var(--border); }
  .pvp-player-section:last-child,
  .team-player-section:last-child { border-bottom: none; }
  .teams-container { grid-template-columns: 1fr; }
  .podium { gap: var(--space-3); }
  .podium-bar { width: 5.5rem; }
  .podium-bar--1 { width: 6.5rem; height: 12rem; }
  .podium-bar--2 { height: 9rem; }
  .podium-bar--3 { height: 7rem; }
}

@media (min-width: 1024px) {
  .team-player-section .equation { font-size: 1.75rem; }
  .team-player-section .answer-btn { font-size: 1.25rem; min-height: 3.25rem; }
  .pvp-player-section .answer-btn { font-size: 1.375rem; min-height: 3.5rem; }
  .tournament-section .answer-btn { font-size: 1.5rem; min-height: 3.5rem; }
}
