/* ===== VARIABLES ===== */
:root {
  --bg:      #f5f2eb;
  --surface: #ffffff;
  --primary: #1b213e;
  --accent:  #d8135a;
  --accent2: #3a86ff;
  --text:    #1b213e;
  --muted:   #888;
  --border:  #ddd8cc;
  --radius:  12px;
  --shadow:  0 4px 24px rgba(0,0,0,0.08);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ===== NAVBAR ===== */
nav {
  flex-shrink: 0;
  background: var(--primary);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 2rem;
  position: relative;
  z-index: 100;
  animation: slideDown 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

nav img {
  height: 70px;
  object-fit: contain;
}

.nav-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: #fff;
  letter-spacing: -0.5px;
}

.nav-title span {
  color: var(--accent);
}

/* ===== INTRO ===== */
.intro {
  flex-shrink: 0;
  padding: 0.75rem 2rem 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.6s 0.2s both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.intro-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.intro-title .accent {
  color: var(--accent);
}

.intro-desc {
  font-size: 0.82rem;
  color: #666;
  line-height: 1.7;
  max-width: 820px;
  margin: 0 auto;
}

.intro-desc strong {
  color: var(--primary);
}

/* ===== APP WRAPPER ===== */
#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  overflow: hidden;
  min-height: 0;
}

/* ===== CARD ===== */
.card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 0.9rem 1rem;
  animation: fadeIn 0.5s 0.35s both;
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

/* ===== CHAPEAUX ===== */
.chapeaux-grid {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.chapeau-col {
  flex: 1;
  min-width: 0;
}

.chapeau-label {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.chapeau-equipe {
  font-size: 0.72rem;
  padding: 0.2rem 0.4rem;
  border-radius: 5px;
  margin-bottom: 0.2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: opacity 0.4s ease, transform 0.4s ease, background 0.3s ease;
}

.chapeau-equipe.tirée {
  opacity: 0.3;
  text-decoration: line-through;
  transform: scale(0.97);
}

/* Highlight du chapeau actif */
.chapeau-col.active-chapeau .chapeau-label {
  color: var(--accent);
  transition: color 0.3s;
}

.chapeau-col.active-chapeau .chapeau-equipe:not(.tirée) {
  background: #fff0f4;
  border-color: #f5a0bc;
}

.equipe-nom {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.equipe-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 2px;
}

/* ===== BOUTONS ===== */
.btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.btn-outline {
  background: transparent;
  border-color: var(--accent2);
  color: var(--accent2);
}

.btn-outline:hover {
  background: var(--accent2);
  color: #fff;
}

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-size: 0.9rem;
  padding: 0.5rem;
  position: relative;
  overflow: hidden;
}

/* Ripple effect on button */
.btn-primary::after {
  content: '';
  position: absolute;
  width: 200%;
  height: 200%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  transition: transform 0.5s ease, opacity 0.5s ease;
  opacity: 0;
}

.btn-primary:active::after {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  transition: 0s;
}

.btn-primary:hover {
  background: #b50f4c;
  border-color: #b50f4c;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(216,19,90,0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Pulse quand le tirage est disponible */
@keyframes pulseBtnGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(216,19,90,0.35); }
  50%       { box-shadow: 0 0 0 8px rgba(216,19,90,0); }
}

.btn-primary:not(:disabled) {
  animation: pulseBtnGlow 2.4s ease-in-out infinite;
}

/* ===== POULES ===== */
.poules-grid {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.group-card {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  text-align: left;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Poule qui vient de recevoir une équipe */
.group-card.just-updated {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(216,19,90,0.18);
  animation: flashPoule 0.7s ease both;
}

@keyframes flashPoule {
  0%   { background: #fff0f4; }
  100% { background: var(--bg); }
}

.group-header {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--border);
}

.group-header small {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.group-member {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.3rem;
  padding: 0.15rem 0;
  font-size: 0.75rem;
}

.group-member .equipe-logo {
  width: 16px;
  height: 16px;
}

.member-name {
  font-weight: 500;
  text-align: left;
}

/* Entrée d'une équipe dans une poule */
.group-member.new-entry {
  animation: slideInMember 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes slideInMember {
  from {
    opacity: 0;
    transform: translateX(-14px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.vide {
  color: #ccc;
  font-size: 0.75rem;
}

/* ===== OVERLAY TIRAGE ===== */
#tirage-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

#tirage-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

#tirage-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(27,33,62,0.65);
  backdrop-filter: blur(4px);
}

#tirage-card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  padding: 2rem 2.5rem;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  min-width: 280px;
  max-width: 90vw;
  animation: popCard 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popCard {
  from { transform: scale(0.7) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0);     opacity: 1; }
}

#tirage-chapeau-label {
  font-family: 'Syne', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

#tirage-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin: 0 auto 0.6rem;
  display: block;
  animation: logoSpin 0.5s ease both;
}

@keyframes logoSpin {
  from { transform: rotate(-15deg) scale(0.5); opacity: 0; }
  to   { transform: rotate(0deg) scale(1);     opacity: 1; }
}

#tirage-equipe-name {
  font-family: 'Syne', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.4rem;
  line-height: 1.2;
}

#tirage-poule-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: #666;
}

#tirage-poule-label strong {
  color: var(--primary);
}

/* Confettis */
.confetti-piece {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 1000;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0%   { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(120vh) rotate(720deg); }
}

/* ===== TIRAGE FIN ===== */
.tirage-fin {
  margin-top: 0.75rem;
  text-align: center;
  color: var(--accent);
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes bounceIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .chapeaux-grid,
  .poules-grid {
    flex-wrap: wrap;
  }
  .chapeau-col,
  .group-card {
    flex: 1 1 45%;
  }
}