@import url("https://fonts.googleapis.com/css2?family=Chewy&family=Patrick+Hand:wght@400;700&display=swap");

@font-face {
  font-family: "ScriptEcole2";
  src: url("./ScriptEcole2.ttf") format("truetype");
  font-display: swap;
}

h1,
h2 {
  font-family: "Vanilla Caramel", "Chewy", "Comic Sans MS", "Chalkboard SE", "Marker Felt", cursive;
}

:root {
  --bg: #d7eff8;
  --ink: #163245;
  --card: #ffffff;
  --btn: #77c5ea;
  --btn-active: #2f9ed4;
  --good: #1d8f4d;
  --bad: #c2473f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "ScriptEcole2", "Trebuchet MS", Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg), #eef9ff);
  color: var(--ink);
  position: relative;
  overflow-x: hidden;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.46;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(circle at 9% 15%, rgba(255,255,255,0.92) 0 3.8%, transparent 4%),
    radial-gradient(circle at 13% 13%, rgba(255,255,255,0.94) 0 5.2%, transparent 5.4%),
    radial-gradient(circle at 17% 15%, rgba(255,255,255,0.92) 0 4.2%, transparent 4.4%),
    radial-gradient(ellipse at 13% 18%, rgba(255,255,255,0.85) 0 6.2%, transparent 6.4%),

    radial-gradient(circle at 80% 12%, rgba(255,255,255,0.9) 0 3.6%, transparent 3.8%),
    radial-gradient(circle at 84% 10%, rgba(255,255,255,0.94) 0 5.1%, transparent 5.3%),
    radial-gradient(circle at 88% 12%, rgba(255,255,255,0.9) 0 4%, transparent 4.2%),
    radial-gradient(ellipse at 84% 15%, rgba(255,255,255,0.84) 0 6%, transparent 6.2%),

    radial-gradient(circle at 12% 48%, rgba(255,255,255,0.9) 0 3.8%, transparent 4%),
    radial-gradient(circle at 16% 46%, rgba(255,255,255,0.94) 0 5.4%, transparent 5.6%),
    radial-gradient(circle at 20% 48%, rgba(255,255,255,0.9) 0 4.2%, transparent 4.4%),
    radial-gradient(ellipse at 16% 51%, rgba(255,255,255,0.84) 0 6.4%, transparent 6.6%),

    radial-gradient(circle at 78% 66%, rgba(255,255,255,0.9) 0 3.9%, transparent 4.1%),
    radial-gradient(circle at 82% 64%, rgba(255,255,255,0.94) 0 5.5%, transparent 5.7%),
    radial-gradient(circle at 86% 66%, rgba(255,255,255,0.9) 0 4.3%, transparent 4.5%),
    radial-gradient(ellipse at 82% 69%, rgba(255,255,255,0.84) 0 6.5%, transparent 6.7%),

    radial-gradient(circle at 24% 84%, rgba(255,255,255,0.88) 0 3.4%, transparent 3.6%),
    radial-gradient(circle at 27% 82%, rgba(255,255,255,0.92) 0 4.8%, transparent 5%),
    radial-gradient(circle at 31% 84%, rgba(255,255,255,0.88) 0 3.7%, transparent 3.9%),
    radial-gradient(ellipse at 27% 86.5%, rgba(255,255,255,0.8) 0 5.8%, transparent 6%),

    radial-gradient(circle at 70% 30%, rgba(255,255,255,0.86) 0 3%, transparent 3.2%),
    radial-gradient(circle at 73% 28%, rgba(255,255,255,0.9) 0 4.2%, transparent 4.4%),
    radial-gradient(circle at 76% 30%, rgba(255,255,255,0.86) 0 3.2%, transparent 3.4%),
    radial-gradient(ellipse at 73% 32.2%, rgba(255,255,255,0.78) 0 5%, transparent 5.2%);
}

body > * {
  position: relative;
  z-index: 1;
}



button,
input,
select,
textarea {
  font-family: "ScriptEcole2", "Trebuchet MS", Arial, sans-serif;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem 1rem 1.4rem;
}

.home-link {
  display: inline-flex;
  text-decoration: none;
  font-weight: 800;
  color: #0f5d8f;
  background: #ffffffcc;
  border: 2px solid #9ecded;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  margin-bottom: 0.35rem;
}

.home-link:hover,
.home-link:focus-visible {
  border-color: #4daede;
}

.header {
  text-align: center;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.title-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex: 0 0 auto;
}

.header h1 {
  margin: 0;
  font-family: "Vanilla Caramel", "Chewy", "Comic Sans MS", "Chalkboard SE", "Marker Felt", cursive;
  font-size: 2.7rem;
}

.header p {
  margin: 0.7rem 0 0.8rem;
}

.range-row,
.level-row {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin: 0.55rem 0;
}

.range-btn,
.level-btn {
  border: 0;
  border-radius: 999px;
  background: var(--btn);
  color: #06324a;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.52rem 1rem;
  cursor: pointer;
}

.range-btn.active,
.level-btn.active {
  background: var(--btn-active);
  color: #fff;
}

.board {
  margin: 0.8rem auto 0;
  max-width: 760px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  border: 2px solid rgba(0, 0, 0, 0.08);
  padding: 0.75rem 0.8rem 1rem;
}

.board h2 {
  margin: 0;
  text-align: center;
  font-size: 1.2rem;
}

.collection {
  margin: 0.65rem auto 0;
  min-height: 245px;
  border-radius: 16px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  background: #f8f8f8;
  padding: 0.7rem;
  display: flex;
  position: relative;
  align-content: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.16rem;
  max-width: 690px;
}

.collection.retry-warning::before,
.collection.correction-warning::before {
  content: "✖";
  position: absolute;
  top: 16%;
  left: 50%;
  transform: translateX(-50%);
  color: #c2473f;
  font-size: 5.2rem;
  font-weight: 900;
  z-index: 3;
  pointer-events: none;
}

.collection.retry-warning::after {
  content: "Réessaie encore une fois";
  position: absolute;
  left: 50%;
  top: 62%;
  transform: translate(-50%, -50%);
  color: #c2473f;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 10px;
  padding: 0.3rem 0.6rem;
  font-size: 1.28rem;
  font-weight: 800;
  white-space: nowrap;
  z-index: 3;
  pointer-events: none;
}

.collection.correction-warning::after {
  content: attr(data-correction);
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  color: #c2473f;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  padding: 0.35rem 0.65rem;
  font-size: 1.28rem;
  font-weight: 800;
  white-space: nowrap;
  z-index: 3;
  pointer-events: none;
}

.collection.end-summary .end-summary-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #163245;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  padding: 0.7rem 1.1rem;
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
  z-index: 4;
  pointer-events: none;
}

.collection.end-summary .end-summary-panel .ok {
  color: #1d8f4d;
}

.collection.end-summary .end-summary-panel .bad {
  color: #c2473f;
}

.collection.mixed {
  display: block;
  position: relative;
  overflow: hidden;
}

.collection.mixed .token {
  position: absolute;
}

.token {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.token.tens {
  width: 98px;
  height: 72px;
}

.token.hundreds {
  width: 130px;
  height: 122px;
}

.answer-panel {
  margin: 0.9rem auto 0;
  max-width: 350px;
  background: var(--card);
  border-radius: 16px;
  border: 2px solid rgba(0, 0, 0, 0.08);
  padding: 0.85rem 0.45rem 0.85rem 1.35rem;
}

.answer-panel h2 {
  margin: 0 0 0.55rem;
  text-align: center;
  font-size: 1.15rem;
}

.round-report {
  margin-top: 0.7rem;
  text-align: center;
  font-weight: 700;
}

.round-report p {
  margin: 0.15rem 0;
}

.answer-three-wrap {
  display: flex;
  justify-content: center;
  gap: 0;
  align-items: end;
  flex-wrap: wrap;
  width: fit-content;
  margin: 0 auto;
}

.field {
  text-align: center;
  min-width: 116px;
}

.answer-three-wrap .field + .field {
  margin-left: -22px;
}

.answer-three-wrap.no-hundreds #answer-field-hundreds + .field {
  margin-left: 0;
}

.answer-three-wrap.no-hundreds #answer-field-hundreds + .field + .field {
  margin-left: -12px;
}

.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.field img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin-bottom: 0.15rem;
}

.field:nth-child(1) img {
  width: 54px;
  height: 46px;
}

.field:nth-child(2) img {
  width: 64px;
  height: 44px;
}

.counter-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.32rem;
  width: 96px;
  margin-left: auto;
  margin-right: auto;
}

.answer-three-wrap .field:first-child .counter-controls {
  transform: none;
}

.answer-three-wrap .field:nth-child(2) .counter-controls {
  transform: none;
}

.answer-three-wrap .field:nth-child(3) .counter-controls {
  transform: none;
}

.count-btn {
  border: 0;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #05324b;
  background: var(--btn);
  cursor: pointer;
}

.count-value {
  width: 96px;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 72px;
  border-radius: 20px;
  border: 3px solid rgba(0, 0, 0, 0.75);
  background: #fff;
  font-size: 2rem;
  font-weight: 800;
}

.bottom {
  margin-top: 0.8rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.check-btn {
  border: 0;
  border-radius: 999px;
  background: #3da8df;
  color: #fff;
  font-weight: 700;
  font-size: 1.03rem;
  padding: 0.65rem 1.2rem;
  cursor: pointer;
}

.feedback {
  width: 100%;
  text-align: center;
  margin: 0.2rem 0 0;
  min-height: 1.25rem;
  font-weight: 800;
}

.feedback.ok {
  color: var(--good);
}

.feedback.bad {
  color: var(--bad);
}

.hidden {
  display: none;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}

.confetti-piece {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  opacity: 0.95;
  animation: confetti-fall 1200ms ease-in forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(640deg);
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .title-icon {
    width: 48px;
    height: 48px;
  }

  .header h1 {
    font-size: 2.1rem;
  }

  .token {
    width: 28px;
    height: 28px;
  }

  .token.tens {
    width: 84px;
    height: 62px;
  }

  .token.hundreds {
    width: 110px;
    height: 104px;
  }

  .round-report {
    font-size: 0.95rem;
  }
}
