:root {
  --primary: #1a2740;
  --accent: #2563eb;
  --accent2: #0ea5e9;
  --success: #16a34a;
  --danger: #dc2626;
  --gold: #d97706;
  --surface: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --sh: 0 2px 12px rgba(30, 41, 59, .10);
  --sh-lg: 0 8px 32px rgba(30, 41, 59, .16);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HEADER */
.app-header {
  background: var(--primary);
  border-bottom: 3px solid var(--accent);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.header-titles h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .03em;
}

.header-badge {
  display: inline-block;
  background: rgba(37, 99, 235, .25);
  color: #93c5fd;
  font-size: .72rem;
  font-weight: 700;
  padding: .18rem .7rem;
  border-radius: 20px;
  margin-top: .25rem;
  letter-spacing: .07em;
  text-transform: uppercase;
}

/* LAYOUT */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.75rem 2rem 3rem;
  flex: 1;
}

.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--sh);
  border: 1px solid var(--border);
}

/* TURN BAR */
.turn-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  padding: .75rem 1.5rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
}

.turn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  opacity: .8;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: .8
  }

  50% {
    transform: scale(1.5);
    opacity: 1
  }
}

/* TEAMS */
.teams-section {
  padding: 1.25rem 1.25rem 1rem;
  margin-bottom: 1.5rem;
}

.section-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .9rem;
}

.teams-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: .9rem;
}

.team-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem .75rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  border: 2px solid var(--border);
}

.team-card.active {
  border-color: var(--accent);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.team-card:hover:not(.active) {
  border-color: #93c5fd;
  transform: translateY(-2px);
}

.team-avatar {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: .5rem;
}

.team-name input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: .35rem .3rem;
  font-size: .8rem;
  text-align: center;
  font-weight: 700;
  background: transparent;
  color: var(--text);
  transition: border .2s;
}

.team-name input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.cheese-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: .55rem auto .4rem;
  width: 92px;
}

.cheese-part {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: #e2e8f0;
  transition: all .3s;
  border: 1.5px solid rgba(0, 0, 0, .07);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.cheese-part svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.team-score {
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
}

/* CATEGORIES */
.categories-section {
  padding: 1.25rem;
}

.section-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .9rem;
}

.category-card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.25rem 1rem;
  box-shadow: var(--sh);
  cursor: pointer;
  transition: all .2s;
  border: 1.5px solid var(--border);
  border-top: 4px solid;
  text-align: center;
}

.category-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg);
}

.cat-0 {
  border-top-color: #ef4444;
}

.cat-1 {
  border-top-color: #3b82f6;
}

.cat-2 {
  border-top-color: #f59e0b;
}

.cat-3 {
  border-top-color: #22c55e;
}

.cat-4 {
  border-top-color: #a855f7;
}

.cat-5 {
  border-top-color: #06b6d4;
}

.cat-6 {
  border-top-color: #f97316;
}

.cat-7 {
  border-top-color: #64748b;
}

.cat-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto .6rem;
}

.cat-0 .cat-icon {
  color: #ef4444;
}

.cat-1 .cat-icon {
  color: #3b82f6;
}

.cat-2 .cat-icon {
  color: #f59e0b;
}

.cat-3 .cat-icon {
  color: #22c55e;
}

.cat-4 .cat-icon {
  color: #a855f7;
}

.cat-5 .cat-icon {
  color: #06b6d4;
}

.cat-6 .cat-icon {
  color: #f97316;
}

.cat-7 .cat-icon {
  color: #64748b;
}

.category-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

/* MODAL */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .72);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card);
  border-radius: 18px;
  padding: 2.25rem 2.75rem 2rem;
  max-width: 900px;
  width: 94%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sh-lg);
  animation: modalIn .22s ease-out;
}

@keyframes modalIn {
  from {
    transform: scale(.95) translateY(16px);
    opacity: 0
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1
  }
}

.timer-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.4rem;
}

.timer {
  background: #f0f9ff;
  border: 2px solid #bae6fd;
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 900;
  padding: .5rem 1.75rem;
  border-radius: 50px;
  letter-spacing: .04em;
}

.timer.warning {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
  animation: shake .4s infinite;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0)
  }

  25% {
    transform: translateX(-4px)
  }

  75% {
    transform: translateX(4px)
  }
}

.q-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  padding: .3rem .85rem;
  border-radius: 20px;
  margin-bottom: .9rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.q-pill svg {
  width: 14px;
  height: 14px;
}

.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 1.35rem;
}

.answers {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-bottom: 1.25rem;
}

.answer-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  padding: .9rem 1.1rem;
  border-radius: 10px;
  font-size: .95rem;
  cursor: pointer;
  transition: all .17s;
  text-align: left;
  font-weight: 600;
  color: var(--text);
}

.answer-btn:hover:not(.disabled) {
  border-color: var(--accent);
  background: #eff6ff;
  transform: translateX(4px);
}

.answer-btn.correct {
  background: #f0fdf4;
  border-color: #22c55e;
  color: #15803d;
}

.answer-btn.incorrect {
  background: #fef2f2;
  border-color: #ef4444;
  color: #b91c1c;
}

.answer-btn.disabled {
  opacity: .65;
  cursor: not-allowed;
  transform: none;
}

.explanation {
  background: #f0fdf4;
  border-left: 4px solid #22c55e;
  padding: 1rem 1.1rem;
  border-radius: 0 10px 10px 0;
  font-size: .9rem;
  line-height: 1.6;
  color: #166534;
  display: none;
  margin-top: .5rem;
}

.explanation.show {
  display: block;
}

.explanation.timeout {
  background: #fef2f2;
  border-left-color: #ef4444;
  color: #991b1b;
}

/* Difficulty badge */
.difficulty-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  font-weight: 700;
  padding: .28rem .75rem;
  border-radius: 20px;
  margin-bottom: .9rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.difficulty-badge.easy   { background: #dcfce7; color: #15803d; border: 1.5px solid #bbf7d0; }
.difficulty-badge.medium { background: #fef9c3; color: #a16207; border: 1.5px solid #fde68a; }
.difficulty-badge.hard   { background: #fee2e2; color: #b91c1c; border: 1.5px solid #fca5a5; }

/* Wider answers grid for large modal */
@media(min-width:700px) {
  .answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .65rem;
  }
}

.close-btn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  padding: .9rem 1.5rem;
  border-radius: 9px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 1.1rem;
  width: 100%;
  letter-spacing: .02em;
  transition: opacity .2s;
}

.close-btn:hover {
  opacity: .88;
}

/* VICTORY */
.victory-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 30, .97);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.victory-overlay.show {
  display: flex;
}

.victory-content {
  text-align: center;
  animation: victoryPop .6s cubic-bezier(.34, 1.56, .64, 1);
  position: relative;
  z-index: 1;
  padding: 2rem;
}

@keyframes victoryPop {
  from {
    transform: scale(.5);
    opacity: 0
  }

  to {
    transform: scale(1);
    opacity: 1
  }
}

.v-trophy {
  width: 110px;
  height: 110px;
  color: #fbbf24;
  margin: 0 auto 1.5rem;
  filter: drop-shadow(0 0 30px rgba(251, 191, 36, .7));
  animation: trophyFloat 2s ease-in-out infinite;
}

@keyframes trophyFloat {

  0%,
  100% {
    transform: translateY(0)
  }

  50% {
    transform: translateY(-14px)
  }
}

.victory-title {
  font-size: 3rem;
  font-weight: 900;
  color: #fbbf24;
  margin-bottom: .5rem;
  letter-spacing: .04em;
}

.victory-team {
  font-size: 1.8rem;
  color: #fff;
  font-weight: 700;
  margin-bottom: 2rem;
}

.victory-btn {
  background: linear-gradient(135deg, #d97706, #fbbf24);
  color: #1a1a1a;
  border: none;
  padding: 1.1rem 2.75rem;
  border-radius: 11px;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform .2s;
}

.victory-btn:hover {
  transform: scale(1.05);
}

.confetti {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  animation: confettiFall 3s linear infinite;
  pointer-events: none;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-80px) rotate(0deg);
    opacity: 1
  }

  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0
  }
}

/* OVERLAYS */
.overlay-screen {
  display: flex;
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, var(--primary) 0%, #1e3a5f 100%);
  z-index: 4000;
  align-items: center;
  justify-content: center;
}

.overlay-screen.hidden {
  display: none;
}

.welcome-card,
.setup-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
  animation: fadeUp .45s ease-out;
}

@keyframes fadeUp {
  from {
    transform: translateY(24px);
    opacity: 0
  }

  to {
    transform: translateY(0);
    opacity: 1
  }
}

.welcome-card {
  padding: 3rem 2.75rem;
  max-width: 520px;
  width: 92%;
  text-align: center;
}

.w-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.w-icon svg {
  width: 46px;
  height: 46px;
}

.welcome-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: .4rem;
}

.welcome-sub {
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 1.5rem;
}

.w-badge {
  display: inline-block;
  background: #eff6ff;
  color: var(--accent);
  font-weight: 700;
  font-size: .85rem;
  padding: .35rem 1rem;
  border-radius: 20px;
  margin: .2rem;
  border: 1.5px solid #bfdbfe;
}

.welcome-btn,
.start-btn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  padding: 1rem 2.5rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  margin-top: 1.5rem;
  letter-spacing: .03em;
  transition: opacity .2s, transform .2s;
}

.welcome-btn:hover,
.start-btn:hover {
  opacity: .9;
  transform: translateY(-2px);
}

.setup-card {
  padding: 2.25rem 2.25rem 1.75rem;
  max-width: 500px;
  width: 92%;
}

.setup-title {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--primary);
  text-align: center;
  margin-bottom: .3rem;
}

.setup-sub {
  text-align: center;
  color: var(--muted);
  font-size: .88rem;
  margin-bottom: 1.35rem;
}

.team-inputs {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  margin-bottom: 1.35rem;
}

.team-input-row {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.team-number {
  font-size: .78rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 72px;
  text-align: right;
}

.team-input {
  flex: 1;
  padding: .65rem .9rem;
  border: 2px solid var(--border);
  border-radius: 9px;
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  transition: border .2s;
}

.team-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

/* FOOTER */
.app-footer {
  background: var(--primary);
  color: rgba(255, 255, 255, .4);
  text-align: center;
  font-size: .74rem;
  font-weight: 500;
  padding: .8rem;
  letter-spacing: .07em;
  border-top: 1px solid rgba(255, 255, 255, .07);
}

#glossary-fab {
  position: fixed;
  bottom: 1.1rem;
  right: 1.1rem;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: .45rem;
  background: var(--primary);
  color: #93c5fd;
  border: none;
  border-radius: 22px;
  padding: .55rem 1.1rem .55rem .75rem;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
  letter-spacing: .04em;
  transition: background .2s;
}

#glossary-fab:hover {
  background: #1e40af;
}

.glossary-entry {
  display: flex;
  gap: .75rem;
  align-items: baseline;
  padding: .42rem .6rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.glossary-abbr {
  font-weight: 800;
  font-size: .88rem;
  color: var(--accent);
  white-space: nowrap;
  min-width: 70px;
}

.glossary-def {
  font-size: .85rem;
  color: var(--text);
  line-height: 1.4;
}

.abbr-tooltip {
  position: relative;
  border-bottom: 2px dotted var(--accent);
  cursor: help;
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
  display: inline;
}

.abbr-tooltip::after {
  content: attr(data-full);
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%) scale(.9);
  background: #1e293b;
  color: #f8fafc;
  padding: .5rem .85rem;
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 9999;
}

.abbr-tooltip::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 9999;
}

.abbr-tooltip:hover {
  color: var(--accent);
}

.abbr-tooltip:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.abbr-tooltip:hover::before {
  opacity: 1;
}

/* Évite que le tooltip sorte à gauche sur les abbr en début de ligne */
.abbr-tooltip:first-child::after,
.abbr-tooltip.tip-right::after {
  left: 0;
  transform: translateX(0) scale(.9);
}

.abbr-tooltip:first-child:hover::after,
.abbr-tooltip.tip-right:hover::after {
  transform: translateX(0) scale(1);
}

.abbr-tooltip:first-child::before,
.abbr-tooltip.tip-right::before {
  left: 10px;
  transform: none;
}

@media(max-width:1100px) {
  .teams-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .game-board {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media(max-width:700px) {
  .teams-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .game-board {
    grid-template-columns: 1fr;
  }
}

/* ── TOOLTIPS RICHES ── */
[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) scale(.92);
  background: #1e293b;
  color: #f1f5f9;
  padding: .55rem .85rem;
  border-radius: 9px;
  font-size: .78rem;
  line-height: 1.45;
  white-space: pre-line;
  text-align: center;
  width: max-content;
  max-width: 220px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s, transform .18s;
  z-index: 9999;
}

[data-tip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s;
  z-index: 9999;
}

[data-tip]:hover::after,
[data-tip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Tooltip à gauche pour les éléments en bord droit */
[data-tip-left]::after {
  left: auto;
  right: 0;
  transform: translateX(0) scale(.92);
  bottom: calc(100% + 10px);
}

[data-tip-left]::before {
  left: auto;
  right: 12px;
  transform: none;
}

[data-tip-left]:hover::after {
  transform: translateX(0) scale(1);
}

/* Cheese part tooltip */
.cheese-part[data-tip]::after {
  white-space: nowrap;
  min-width: 120px;
  font-size: .73rem;
  bottom: calc(100% + 8px);
}

/* Answer buttons — amélioration hover */
.answer-btn:hover:not(.disabled) {
  border-color: var(--accent);
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  transform: translateX(6px);
  box-shadow: 3px 0 0 0 var(--accent);
}

/* Category card hover amélioré */
.category-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .14);
}

.category-card:hover .category-title {
  color: var(--accent);
}