/* ===== CINÉPHIX — Style Popcorn 🍿 ===== */

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

:root {
  --rouge: #FF3B30;
  --rouge-fonce: #C8261E;
  --beurre: #FFBE0B;
  --beurre-fonce: #D49800;
  --creme: #FFF4D6;
  --creme-clair: #FFFCF4;
  --blanc: #FFFFFF;
  --noir: #2D1B0E;
  --brun: #5C3A1E;
  --brun-clair: #8C6547;
  --gris-clair: #F0E4D3;
  --gris: #B8A088;
  --succes: #2E8B57;
  --succes-bg: #D4F5DD;
  --echec: #E74C3C;
  --echec-bg: #FFD6D0;
  --ombre: 0 4px 12px rgba(92, 58, 30, 0.08);
  --ombre-forte: 0 8px 24px rgba(92, 58, 30, 0.12);
  --radius: 16px;
  --radius-pill: 999px;
}

body {
  font-family: 'Nunito', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--creme);
  background-image: radial-gradient(circle at 10% 20%, rgba(255, 190, 11, 0.08) 0%, transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(255, 59, 48, 0.06) 0%, transparent 40%);
  color: var(--noir);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  background: var(--creme-clair);
  border-bottom: 2px solid var(--creme);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo-wrap { display: flex; align-items: center; gap: 10px; flex: 1; }
.logo-clap {
  width: 32px; height: 32px;
  background: var(--rouge);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  transform: rotate(-4deg);
  box-shadow: 0 2px 0 var(--rouge-fonce);
}
.logo-clap::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 12px;
  background: repeating-linear-gradient(45deg, var(--creme-clair) 0 4px, var(--noir) 4px 8px);
}
.logo-clap::after {
  content: '';
  position: absolute;
  bottom: 5px; left: 5px;
  width: 8px; height: 8px;
  background: var(--beurre);
  border-radius: 2px;
  box-shadow: 10px 6px 0 var(--beurre);
}
.logo-title {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--rouge);
  letter-spacing: -0.8px;
}
.icon-btn {
  background: var(--creme);
  border: none;
  cursor: pointer;
  font-size: 16px;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brun);
  font-weight: 700;
  transition: transform 0.15s, background 0.15s;
  margin-left: 6px;
}
.icon-btn:hover { background: var(--beurre); transform: scale(1.05); }
.icon-btn:active { transform: scale(0.95); }

/* ===== Sélecteur de langue ===== */
.lang-switch {
  display: flex;
  gap: 2px;
  background: var(--creme);
  border-radius: var(--radius-pill);
  padding: 3px;
  margin-right: 4px;
}
.lang-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  opacity: 0.45;
  filter: grayscale(0.5);
}
.lang-btn:hover { opacity: 0.8; filter: grayscale(0); }
.lang-btn.active {
  background: var(--blanc);
  opacity: 1;
  filter: grayscale(0);
  box-shadow: 0 1px 3px rgba(92, 58, 30, 0.15);
}

/* ===== Main ===== */
.main {
  flex: 1;
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 40px;
}
.day-label {
  text-align: center;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--beurre-fonce);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 6px;
}
.tagline {
  text-align: center;
  font-size: 15px;
  color: var(--brun);
  margin-bottom: 28px;
  font-weight: 500;
}

/* ===== Indices ===== */
.clues {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.clue {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--gris-clair);
  border-radius: var(--radius);
  font-size: 14px;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}
.clue.revealed {
  background: var(--creme-clair);
  border-color: var(--beurre);
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--ombre);
}
@keyframes pop {
  0% { opacity: 0; transform: scale(0.8) translateY(-10px); }
  60% { transform: scale(1.05) translateY(2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.clue-num {
  flex: 0 0 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blanc);
  color: var(--gris);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}
.clue.revealed .clue-num {
  background: var(--beurre);
  color: var(--noir);
  box-shadow: 0 2px 0 var(--beurre-fonce);
}
.clue-label {
  flex: 0 0 110px;
  font-weight: 700;
  color: var(--brun-clair);
  font-size: 13px;
}
.clue.revealed .clue-label { color: var(--brun); }
.clue-value { flex: 1; color: var(--gris); font-weight: 500; }
.clue.revealed .clue-value { color: var(--noir); font-weight: 700; }

/* ===== Essais ===== */
.attempts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
  min-height: 8px;
}
.attempt {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: shake 0.35s;
  border: 2px solid transparent;
}
.attempt.right { animation: bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
@keyframes bounce {
  0% { opacity: 0; transform: scale(0.5); }
  60% { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}
.attempt.wrong {
  background: var(--echec-bg);
  color: var(--echec);
  border-color: var(--echec);
}
.attempt.right {
  background: var(--succes-bg);
  color: var(--succes);
  border-color: var(--succes);
}
.attempt-icon { font-weight: 800; font-size: 18px; }
.attempt-text { flex: 1; }

/* ===== Input ===== */
.input-zone {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}
.autocomplete-wrap { flex: 1; position: relative; }
#guess-input {
  width: 100%;
  padding: 14px 18px;
  border: 2.5px solid var(--creme);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.2s;
  background: var(--blanc);
  color: var(--noir);
}
#guess-input::placeholder { color: var(--gris); font-weight: 500; }
#guess-input:focus {
  outline: none;
  border-color: var(--beurre);
  box-shadow: 0 0 0 4px rgba(255, 190, 11, 0.2);
}
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--blanc);
  border: 2px solid var(--creme);
  border-radius: var(--radius);
  max-height: 240px;
  overflow-y: auto;
  z-index: 5;
  box-shadow: var(--ombre-forte);
}
.suggestions:empty { display: none; }
.sugg-item {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--brun);
  border-bottom: 1px solid var(--creme);
  transition: background 0.12s;
}
.sugg-item:last-child { border-bottom: none; }
.sugg-item:hover, .sugg-item.active {
  background: var(--creme-clair);
  color: var(--rouge);
}

.btn-primary {
  padding: 14px 24px;
  background: var(--rouge);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, background 0.15s;
  box-shadow: 0 4px 0 var(--rouge-fonce);
}
.btn-primary:hover { background: var(--rouge-fonce); }
.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--rouge-fonce);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== Fin de partie ===== */
.end-zone {
  text-align: center;
  padding: 28px 24px;
  background: var(--blanc);
  border-radius: var(--radius);
  border: 3px solid var(--beurre);
  box-shadow: var(--ombre-forte);
  position: relative;
  overflow: hidden;
  animation: pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.end-zone::before {
  content: '🎬';
  position: absolute;
  top: -10px; left: 20px;
  font-size: 40px;
  opacity: 0.1;
  transform: rotate(-15deg);
}
.end-zone::after {
  content: '🍿';
  position: absolute;
  bottom: -10px; right: 20px;
  font-size: 40px;
  opacity: 0.15;
  transform: rotate(15deg);
}
.end-zone h2 {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--rouge);
  margin-bottom: 10px;
}
.end-zone p {
  color: var(--brun);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 18px;
}
.share-box {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 18px;
  background: var(--creme);
  color: var(--brun);
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  white-space: pre-line;
  line-height: 1.9;
  font-weight: 700;
}
.next-game {
  font-size: 13px;
  color: var(--brun-clair);
  margin-top: 16px;
  font-weight: 600;
}

/* ===== Modales ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(45, 27, 14, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-content {
  background: var(--blanc);
  border-radius: var(--radius);
  padding: 32px 28px;
  max-width: 440px;
  width: 100%;
  position: relative;
  max-height: 80vh;
  overflow-y: auto;
  border: 3px solid var(--beurre);
  animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-content h2 {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--rouge);
  margin-bottom: 16px;
}
.modal-content p { margin-bottom: 12px; line-height: 1.65; font-size: 14px; color: var(--brun); font-weight: 500; }
.modal-content ol { padding-left: 20px; margin-bottom: 12px; }
.modal-content ol li { margin-bottom: 8px; font-size: 14px; color: var(--brun); font-weight: 600; }
.modal-content .small { font-size: 12px; color: var(--brun-clair); font-weight: 500; }
.close-btn {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--creme);
  border: none;
  width: 36px; height: 36px;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brun);
  transition: transform 0.15s;
}
.close-btn:hover { background: var(--rouge); color: white; transform: rotate(90deg); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 6px;
  background: var(--creme);
  border-radius: var(--radius);
  text-align: center;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.stat:hover { border-color: var(--beurre); }
.stat-val { font-size: 26px; font-weight: 800; color: var(--rouge); font-family: 'Fredoka', sans-serif; }
.stat-label { font-size: 11px; color: var(--brun); margin-top: 2px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== Footer ===== */
.footer {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--brun-clair);
  font-weight: 600;
  border-top: 2px solid var(--creme);
  background: var(--creme-clair);
}
.footer a {
  color: var(--rouge);
  margin-left: 12px;
  text-decoration: none;
  font-weight: 700;
}
.footer a:hover { text-decoration: underline; }

.footer-link {
  background: none;
  border: none;
  color: var(--rouge);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  margin-left: 12px;
  padding: 0;
}
.footer-link:hover { text-decoration: underline; }

/* ===== Modale de soutien ===== */
.modal-soutien-content {
  text-align: center;
  max-width: 400px;
}
.soutien-emoji {
  font-size: 48px;
  margin-bottom: 8px;
  animation: bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-soutien {
  display: inline-block;
  text-decoration: none;
  margin: 8px 0 12px;
  min-width: 220px;
}
.btn-soutien:hover { text-decoration: none; }
.btn-plus-tard {
  display: block;
  margin: 0 auto;
  background: none;
  border: none;
  color: var(--brun-clair);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 16px;
  text-decoration: underline;
}
.btn-plus-tard:hover { color: var(--brun); }

/* ===== Confettis (fin victoire) ===== */
.confetti {
  position: fixed;
  width: 10px; height: 10px;
  top: -10px;
  z-index: 1000;
  pointer-events: none;
  animation: fall 3s linear forwards;
}
@keyframes fall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* ===== Responsive mobile ===== */
@media (max-width: 480px) {
  .header { padding: 12px 14px; }
  .logo-title { font-size: 22px; }
  .logo-clap { width: 28px; height: 28px; }
  .main { padding: 18px 12px 32px; }
  .tagline { font-size: 14px; margin-bottom: 22px; }
  .clue { padding: 12px 14px; }
  .clue-label { flex: 0 0 90px; font-size: 12px; }
  .clue-value { font-size: 13px; }
  .clue-num { flex: 0 0 28px; height: 28px; font-size: 13px; }
  .end-zone { padding: 24px 18px; }
  .end-zone h2 { font-size: 24px; }
  .stat-val { font-size: 22px; }
  .btn-primary { padding: 12px 20px; font-size: 14px; }
  #guess-input { padding: 12px 16px; font-size: 14px; }
  .modal-content { padding: 24px 20px; }
}

@media (max-width: 360px) {
  .stats-grid { gap: 6px; }
  .stat { padding: 10px 4px; }
  .stat-val { font-size: 20px; }
}

/* ===== Dark mode ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --creme: #2D1B0E;
    --creme-clair: #3D2818;
    --blanc: #2D1B0E;
    --noir: #FFF4D6;
    --brun: #E8D4B8;
    --brun-clair: #B8A088;
    --gris-clair: #3D2818;
    --gris: #8C6547;
  }
  body {
    background: #1A0F05;
    background-image: radial-gradient(circle at 10% 20%, rgba(255, 190, 11, 0.04) 0%, transparent 40%),
                      radial-gradient(circle at 90% 80%, rgba(255, 59, 48, 0.03) 0%, transparent 40%);
  }
  .header { background: #2D1B0E; border-color: #3D2818; }
  .footer { background: #2D1B0E; }
}
