@font-face {
  font-family: "Andika";
  src: url("../fonts/andika-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Andika";
  src: url("../fonts/andika-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #2b2b3a;
  --muted: #6d6a7c;
  --line: #eadfca;
  --accent: #ff8a3d;
  --accent-dark: #e06a1c;
  --good: #2ea86b;
  --good-bg: #e2f7ec;
  --bad: #e2514c;
  --bad-bg: #fde8e7;
  --trap-bg: #fff1a8;

  /* Same colours as the school word sheet */
  --nombre: #8a5cc2;
  --nom: #2f6fd0;
  --verbe: #d7372f;
  --adjectif: #2e8b4a;
  --autre: #2b2b3a;

  --radius: 20px;
  --shadow: 0 4px 0 rgba(0, 0, 0, 0.08), 0 8px 24px rgba(80, 50, 0, 0.08);
  font-size: 20px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }
/* signed-in check in progress (js/compte.js): don't flash the page before a redirect */
html.compte-attente main { visibility: hidden; }

body {
  font-family: "Andika", "Comic Sans MS", "Chalkboard SE", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

a { color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 3px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  flex: 1;
  min-width: 0;
}
.topbar .home {
  font-size: 1.6rem;
  text-decoration: none;
}
.stars {
  font-weight: 700;
  font-size: 1.1rem;
  background: #fff3c4;
  border-radius: 999px;
  padding: 4px 14px;
  white-space: nowrap;
}
.stars.bump { animation: bump 0.5s; }
.test-badge {
  font-weight: 700;
  font-size: 0.9rem;
  background: #e8e0ff;
  color: #5a3fb0;
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

main {
  max-width: 860px;
  margin: 0 auto;
  /* room for the owl's bubble, and for the on-screen keyboard when it's open */
  padding: 20px 16px calc(var(--mascot-h, 80px) + 60px + var(--kb-h, 0px));
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 4px 0 var(--accent-dark);
  transition: transform 0.08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-dark); }
.btn.soft {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--line);
  border: 2px solid var(--line);
}
.btn.soft:active { box-shadow: 0 1px 0 var(--line); }
.btn.big { font-size: 1.3rem; min-height: 68px; padding: 12px 32px; }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ---------- Mascot / feedback bubble ---------- */
.mascot {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translate(-50%, 160%);
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(640px, calc(100% - 32px));
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 3px solid var(--line);
  padding: 10px 16px;
  transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
  z-index: 20;
}
.mascot.show { transform: translate(-50%, 0); }
/* with the on-screen keyboard open, the bubble goes under the top bar instead of behind the keyboard */
.keyboard-open .mascot { bottom: auto; top: 70px; transform: translate(-50%, -250%); }
.keyboard-open .mascot.show { transform: translate(-50%, 0); }
.keyboard-open .rule { display: none; }
.mascot.good { border-color: var(--good); background: var(--good-bg); }
.mascot.bad { border-color: var(--bad); background: var(--bad-bg); }
.mascot .face { font-size: 2.6rem; line-height: 1; }
.mascot .msg { font-size: 1.1rem; font-weight: 700; flex: 1; }
.mascot .hear { font-size: 1.5rem; }

/* ---------- Animations ---------- */
@keyframes bump { 50% { transform: scale(1.3); } }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.shake { animation: shake 0.45s; }
.pop { animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

.hidden { display: none !important; }

@media (max-width: 520px) {
  :root { font-size: 18px; }
  .card { padding: 18px; }
}
