@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg-main:      #0f172a;
  --bg-card:      #1e293b;
  --bg-hover:     #263448;
  --border:       #334155;
  --border-light: #475569;
  --text-primary: #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:   #64748b;
  --accent:       #B6D8F2;
  --found-bg:     #14532d;
  --found-brd:    #22c55e;
}

html { font-size: clamp(12px, 1.1vw, 19px); }

body {
  font-family: 'Inter', -apple-system, sans-serif;
}

a { text-decoration: none; }

/* ---- TOP BAR ---- */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-center p {
  margin-top: 0.1rem;
}

.top-bar-right {
  gap: 0.75rem;
}

.score-counter { font-size: 1rem; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.score-counter strong { color: var(--accent); font-size: 1.15rem; }
.score-sep { color: var(--text-muted); }

.game-footer {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.abandon-btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.75rem 2.5rem;
  background: #dc2626;
  border: 2px solid #ef4444;
  color: #fff;
  border-radius: 0.625rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.45);
  transition: all 0.2s;
}
.abandon-btn:hover { background: #ef4444; border-color: #fca5a5; color: #fff; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(239, 68, 68, 0.55); }

.diff-wrapper {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.diff-lock {
  font-size: 0.8rem;
  line-height: 1;
  cursor: default;
}

.diff-control.locked {
  opacity: 0.4;
  pointer-events: none;
}

.diff-control {
  display: flex;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.175rem;
  gap: 0.175rem;
}

.diff-opt {
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.diff-opt:hover:not(.active) { color: var(--text-primary); }
.diff-opt.active[data-val="tous"]      { background: #1e293b; color: #f1f5f9; }
.diff-opt.active[data-val="facile"]    { background: #14532d; color: #22c55e; }
.diff-opt.active[data-val="difficile"] { background: #78350f; color: #f59e0b; }


.back-button {
  display: inline-block;
}

/* ---- ZONE DE JEU ---- */
.game-area {
  max-width: 82.5rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

/* ---- TITRE D'ÉCRAN ---- */
.screen-title {
  text-align: center;
  margin-bottom: 2rem;
  position: relative;
}
.screen-title h2 { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); }

.back-screen-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.55rem 1.1rem;
  background: var(--accent);
  border: none;
  color: var(--bg-main);
  border-radius: 0.6rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(182, 216, 242, 0.25);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}
.back-screen-btn:hover { background: #9dc8e8; transform: translateY(calc(-50% - 1px)); box-shadow: 0 6px 16px rgba(182, 216, 242, 0.35); }

/* =============================================
   ÉCRAN 1 — SÉLECTION DU MODE
   ============================================= */
.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  max-width: 56rem;
  margin: 0 auto;
}

.mode-card {
  font-family: inherit;
  background: rgba(10, 22, 40, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(170, 190, 215, 0.18);
  border-radius: 1.25rem;
  padding: 2rem 1.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  text-align: center;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  color: inherit;
}
.mode-card:hover {
  transform: translateY(-4px);
  background: rgba(15, 31, 52, 0.65);
  border-color: rgba(236, 172, 74, 0.65);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45), 0 0 28px rgba(236, 172, 74, 0.12);
}

.mode-card-count {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.mode-card-icon { font-size: 2rem; line-height: 1; }
.mode-card-label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.mode-card-sub   { font-size: 0.75rem; color: var(--text-muted); }

/* carte "par zone" prend 2 colonnes pour équilibrer si nombre impair */
.mode-card-zone { grid-column: span 1; }

@media (max-width: 700px) {
  .mode-cards { grid-template-columns: repeat(2, 1fr); }
  .mode-card-zone { grid-column: span 2; }
}

/* =============================================
   ÉCRAN 2 — SÉLECTION DE LA ZONE
   ============================================= */
.zone-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.75rem;
}

.zone-card {
  font-family: inherit;
  background: rgba(10, 22, 40, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(170, 190, 215, 0.18);
  border-radius: 0.875rem;
  padding: 1.25rem 1rem;
  cursor: pointer;
  text-align: center;
  color: inherit;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.zone-card:hover {
  transform: translateY(-2px);
  background: rgba(15, 31, 52, 0.65);
  border-color: rgba(236, 172, 74, 0.65);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4), 0 0 20px rgba(236, 172, 74, 0.12);
}
.zone-card-name  { font-size: 0.88rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.375rem; }
.zone-card-count { font-size: 0.75rem; color: var(--text-muted); }

/* =============================================
   ÉCRAN 3 — JEU
   ============================================= */
.characters-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}

.char-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  transition: border-color 0.35s, box-shadow 0.35s;
}
.char-card.found {
  border-color: var(--found-brd);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.25);
}

.char-img-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.char-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%) brightness(0.7);
  transition: filter 0.4s ease;
}
.char-card.found .char-img-wrapper img { filter: none; }

/* Input par carte */
.char-input {
  width: 100%;
  padding: 0.32rem 0.4rem;
  background: var(--bg-main);
  border: none;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
  display: block;
}
.char-input::placeholder { color: var(--text-muted); }
.char-input:focus { background: var(--bg-hover); border-color: var(--accent); }
.char-card.found .char-input { display: none; }

/* Nom révélé */
.char-found-name {
  padding: 0.35rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  background: var(--found-bg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--found-brd);
  animation: slideUp 0.3s ease;
}
.char-found-name.hidden { display: none; }

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

/* Cartes abandonnées (non trouvées après abandon) */
.char-card.abandoned {
  border-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}
.char-card.abandoned .char-img-wrapper img { filter: none; }
.char-card.abandoned .char-found-name {
  background: #7f1d1d;
  border-top-color: #ef4444;
  color: #fca5a5;
}

/* Bouton rejouer */
.replay-area {
  text-align: center;
  margin-top: 2rem;
}
.replay-btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.75rem 2.5rem;
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.replay-btn:hover { background: #9dc8e8; transform: translateY(-2px); }

/* Carte de victoire */
.victory-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  margin-top: 2rem;
  padding: 2rem 1.5rem 1.75rem;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-main) 100%);
  border: 1px solid var(--found-brd);
  border-radius: 1.25rem;
  box-shadow: 0 0 32px rgba(34, 197, 94, 0.18), 0 20px 45px rgba(0, 0, 0, 0.35);
  animation: victoryPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes victoryPop {
  0%   { opacity: 0; transform: scale(0.8) translateY(16px); }
  60%  { opacity: 1; transform: scale(1.03) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.victory-badge {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--found-brd);
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid var(--found-brd);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.victory-icon-wrap {
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 3px solid var(--found-brd);
  background: var(--bg-hover);
  margin-bottom: 0.35rem;
  animation: victoryGlow 2.4s ease-in-out infinite;
}

@keyframes victoryGlow {
  0%, 100% { box-shadow: 0 0 18px rgba(34, 197, 94, 0.3); }
  50%      { box-shadow: 0 0 32px rgba(34, 197, 94, 0.55); }
}

.victory-icon-wrap img {
  width: 65%;
  height: 65%;
  object-fit: contain;
}

.victory-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--found-brd);
}

.victory-sub {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Confettis */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 900;
}

/* === HELP BUTTON === */
.help-btn {
  border: 1px solid var(--border-light);
}

/* === MODAL === */
.modal-overlay {
  z-index: 2000;
}

@keyframes popIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
.modal-box {
  border-radius: 1.25rem;
  padding: 2rem;
  max-width: 520px;
  max-height: 82vh;
  overflow-y: auto;
}
.modal-box h3 {
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.modal-box p {
  font-size: 0.87rem;
  line-height: 1.7;
  margin-bottom: 0.4rem;
}

.modal-box strong { color: var(--text-primary); }
.modal-close {
  font-size: 1.1rem;
  color: var(--text-muted);
  padding: 0.25rem;
  line-height: 1;
}

/* =============================================
   UTILITAIRES
   ============================================= */

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .characters-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
  .characters-grid { grid-template-columns: repeat(3, 1fr); }
  .top-bar-center p { display: none; }
  .top-bar-center h1 { font-size: 1.1rem; }
}

/* Téléphone : bouton retour au-dessus du titre, zones sur 2 colonnes */
@media (max-width: 700px) {
  .screen-title { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
  .back-screen-btn { position: static; transform: none; align-self: flex-start; }
  .back-screen-btn:hover { transform: translateY(-1px); }
  .zone-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .zone-card { padding: 0.75rem 0.5rem; }
}
