:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #26221f;
  --accent: #930000;
  --accent-soft: #cf5151;
  --accent-2: #00ca03;
  --muted: #7a746c;
  --line: #e5ddd2;
  --card: #ffffff;
  --tile-bg: #fffaf0;
  --card-radius: 2rem;
  /* Dégradé « évolution de niveau » (mauvais → bon) des barres de
     progression de déblocage, voir .progress-fill. */
  --level-gradient: linear-gradient(90deg, #ff9100, #ffc800, #d5c300, #029300, #00ca03);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1815;
    --fg: #f3efe9;
    --accent: #e67e6c;
    --accent-soft: #e39c93;
    --accent-2: #6fcf7a;
    --muted: #b5aca0;
    --line: #3a342d;
    --card: #262019;
    --tile-bg: #332822;
  }
}
@font-face {
  font-family: "Inter";
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  src: url("/assets/fonts/Inter-Variable.woff2") format("woff2");
}
* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  margin: 0;
  padding: 2rem 1.25rem 4rem;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

/* --- fond animé kana (voir /assets/kana-bg.js) --- */
.kana-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.kana-bg span {
  position: absolute;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "MS Mincho", serif;
  color: var(--fg);
  line-height: 1;
  user-select: none;
  will-change: transform;
  animation-name: kana-drift;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}
@keyframes kana-drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  50%  { transform: translate3d(0, -26px, 0) rotate(-2deg); }
  100% { transform: translate3d(0, 0, 0) rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) {
  .kana-bg span { animation: none; }
}
.wrap {
  max-width: 60rem;
  margin: 0 auto;
}
header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
header.top h1 {
  font-size: 1.4rem;
  margin: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
header.top a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}
.player-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.player-badge .player-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.player-badge .logout-icon {
  font-size: 1.05rem;
  line-height: 1;
  text-decoration: none;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.lang-switch {
  padding: 0.3rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  font-size: 0.85rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: 1.5rem;
}
.game-panels > .card + .card {
  margin-top: 1.5rem;
}
.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.panel-header-row h2 {
  margin: 0;
}
.progress-badge {
  position: relative;
  display: inline-block;
  overflow: hidden;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg);
  background: var(--tile-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  white-space: nowrap;
  min-width: 5rem;
  text-align: center;
}
.progress-fill {
  position: absolute;
  inset: 0;
  width: 0;
  background: var(--level-gradient);
  opacity: 0.3;
  transition: width 0.3s ease;
}
.progress-text {
  position: relative;
}

/* --- games.php landing --- */
.game-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.game-links a {
  display: block;
  text-align: center;
  padding: 1.5rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: var(--tile-bg);
  color: var(--fg);
  text-decoration: none;
  font-size: 1.1rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.game-links a:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.game-links .emoji {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.5rem;
}
.game-links .game-score {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.auth-forms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.auth-forms h2 {
  font-size: 1rem;
  margin: 0 0 1rem;
}
.auth-forms form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
input[type="text"], input[type="password"], select {
  padding: 0.55rem 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  font-size: 1rem;
}
button {
  padding: 0.55rem 1rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}
button:hover { opacity: 0.9; }
.form-error {
  color: var(--accent);
  font-size: 0.85rem;
  min-height: 1.2em;
}

/* --- Bouton pilule (CTA « Jouer », Connexion, Créer le compte) : au
   survol/focus, un halo crème grandit depuis le centre pour couvrir tout le
   bouton et le texte/l'icône passent au rouge (icône en fill="currentColor"
   pour suivre automatiquement). --- */
.btn-pill {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--tile-bg);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.25);
  opacity: 1;
  transition: box-shadow 0.2s ease, color 0.2s ease 0.15s;
}
.btn-pill::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 0;
  width: 250%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--tile-bg);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.35s ease;
}
.btn-pill:hover, .btn-pill:focus-visible {
  color: var(--accent);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}
.btn-pill:hover::before, .btn-pill:focus-visible::before {
  transform: translate(-50%, -50%) scale(1);
}
.btn-pill > * {
  position: relative;
  z-index: 1;
}
.btn-pill svg {
  width: 1.2em;
  height: 1.2em;
  flex-shrink: 0;
  fill: currentColor;
}
.btn-pill--lg {
  padding: 1rem 2.5rem;
  font-size: clamp(1.15rem, 3vw, 1.5rem);
}
.btn-pill--lg svg {
  width: 1.4em;
  height: 1.4em;
}
@media (prefers-reduced-motion: reduce) {
  .btn-pill, .btn-pill::before {
    transition: none;
  }
}

.site-logo {
  height: 1.6rem;
  width: auto;
  flex-shrink: 0;
}

/* --- quiz layout --- */
.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 40rem) {
  .quiz-layout { grid-template-columns: 1fr; }
}
.quiz-progress {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}
.quiz-score {
  font-size: 1rem;
  margin-bottom: 1rem;
}
.kana-display {
  font-size: 6rem;
  text-align: center;
  padding: 1.5rem 0;
  border-radius: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  margin-bottom: 1.25rem;
  transition: background 0.2s ease, transform 0.2s ease;
}
.kana-display.correct {
  animation: pulseGreen 0.6s ease;
}
.kana-display.wrong {
  animation: shakeRed 0.5s ease;
}
.kana-display.romaji-prompt {
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}
@keyframes pulseGreen {
  0% { background: var(--bg); transform: scale(1); }
  30% { background: rgba(0, 202, 3, 0.25); transform: scale(1.08); }
  100% { background: var(--bg); transform: scale(1); }
}
@keyframes shakeRed {
  0%, 100% { transform: translateX(0); background: var(--bg); }
  20% { transform: translateX(-8px); background: rgba(147, 0, 0, 0.25); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.answer-row {
  display: flex;
  gap: 0.6rem;
}
.answer-row input {
  flex: 1;
  text-align: center;
  font-size: 1.2rem;
}
.kana-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(3rem, 5rem));
  gap: 0.5rem;
  margin: 1.25rem auto 0;
  justify-content: center;
}
.kana-tile {
  font-size: 1.6rem;
  padding: 0.6rem 0;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.kana-tile:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.kana-tile:disabled {
  cursor: default;
}
.kana-tile.correct {
  animation: pulseGreen 0.6s ease;
  background: rgba(0, 202, 3, 0.25);
  border-color: var(--accent-2);
}
.kana-tile.wrong {
  animation: shakeRed 0.5s ease;
  background: rgba(147, 0, 0, 0.25);
  border-color: var(--accent);
}
/* --- Variantes larges (jeu Couleurs LEVEL 2) : les tuiles ne sont plus un
   seul caractère mais un mot français ou un kanji + sa lecture romaji. --- */
.kana-grid.wide-grid {
  grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
  max-width: 34rem;
}
.kana-tile.text-tile {
  font-size: 1rem;
}
.kana-tile.kanji-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 1.8rem;
}
.kana-tile.kanji-tile .tile-romaji {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}
.prompt-romaji {
  text-align: center;
  font-size: 1.1rem;
  color: var(--muted);
  margin: -1rem 0 1.25rem;
  font-weight: 500;
}
.feedback {
  min-height: 1.4em;
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.95rem;
}
.feedback.correct { color: var(--accent-2); }
.feedback.wrong { color: var(--accent); }
.quiz-done {
  text-align: center;
}
.quiz-done .final-score {
  font-size: 2.2rem;
  margin: 0.5rem 0 1.25rem;
}

/* --- leaderboard --- */
.leaderboard {
  background: var(--tile-bg);
}
.leaderboard h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}
.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 32rem;
  overflow-y: auto;
}
.lb-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.4rem;
}
.lb-list li:nth-child(odd) {
  background: var(--bg);
}
.lb-rank {
  color: var(--accent-soft);
  width: 1.4rem;
  text-align: right;
  flex-shrink: 0;
}
.lb-avatar { flex-shrink: 0; }
.lb-flag {
  flex-shrink: 0;
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--line);
  vertical-align: middle;
}
.flag-icon {
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--line);
  vertical-align: middle;
  margin: 0 0.15rem;
}
.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-points {
  font-weight: 700;
  color: var(--accent-soft);
  flex-shrink: 0;
}
.lb-empty {
  color: var(--muted);
  font-size: 0.85rem;
}

/* --- Confettis (LEVEL 2 débloqué), voir /assets/confetti.js --- */
.confetti-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow: hidden;
  pointer-events: none;
}
.confetti-piece {
  position: absolute;
  top: -1rem;
  width: 0.5rem;
  height: 0.9rem;
  opacity: 0.9;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  to {
    transform: translateY(110vh) rotate(720deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .confetti-piece {
    animation: none;
    display: none;
  }
}

/* --- Feux d'artifice (score parfait), voir /assets/fireworks.js --- */
.fireworks-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow: hidden;
  pointer-events: none;
}
.firework-burst {
  position: absolute;
  width: 0;
  height: 0;
}
.firework-particle {
  position: absolute;
  top: 0;
  left: 0;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  animation: firework-particle-fly 1s ease-out forwards;
}
@keyframes firework-particle-fly {
  0% {
    transform: translate(0, 0) scale(0.4);
    opacity: 1;
  }
  15% {
    transform: translate(calc(var(--dx) * 0.2), calc(var(--dy) * 0.2)) scale(1.5);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0.2);
    opacity: 0;
  }
}
.fireworks-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.18), transparent 60%);
  animation: fireworks-flash 0.5s ease-out;
}
@keyframes fireworks-flash {
  from { opacity: 1; }
  to { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .firework-particle {
    animation: none;
    display: none;
  }
  .fireworks-overlay::before {
    animation: none;
    opacity: 0;
  }
}
