@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 {
  --sky: #bde8ff;
  --cloud: #ffffff;
  --text: #1c3652;
  --accent: #2f7eea;
  --accent-dark: #1a5eb7;
  --ok: #2c9a3b;
  --warn: #c74444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "ScriptEcole2", "Trebuchet MS", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(to bottom, var(--sky), #d7f2ff);
  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;
}


.game-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: relative;
  z-index: 1;
}

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

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

.top-banner-row {
  margin: 0 0 -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.top-banner-title {
  margin: 0;
  text-align: center;
  font-size: clamp(1.65rem, 3.2vw, 2.35rem);
  font-weight: 900;
  color: #0b3c5a;
  font-family: "Vanilla Caramel", "Chewy", "Comic Sans MS", "Chalkboard SE", "Marker Felt", cursive;
}

.top-banner-image {
  width: 70px;
  height: auto;
  display: block;
}

.top-banner-row .top-banner-image:first-child {
  transform: scaleX(-1);
}

.top-zone {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
  align-items: center;
}

.target-buttons {
  display: grid;
  gap: 10px;
  transform: translateY(50px);
}

.target-btn {
  border: 2px solid #a4c9ef;
  background: #f0f8ff;
  border-radius: 12px;
  padding: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}

.target-btn:hover,
.target-btn:focus-visible {
  border-color: var(--accent);
}

.target-btn.active {
  background: #8ccff2;
  color: #114b82;
  border-color: #5faed9;
}

.cloud {
  background: var(--cloud);
  border-radius: 999px;
  padding: 22px 28px;
  box-shadow: 0 10px 20px rgba(20, 65, 120, 0.14);
}

.cloud-listen {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title title"
    "modes action";
  gap: 12px;
  min-height: 105px;
  position: relative;
  align-content: center;
  transform: translateY(-14px);
}

.mode-toggle {
  grid-area: modes;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.mode-btn {
  border: 2px solid #9fc6ea;
  background: #eef7ff;
  color: #1c3652;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mode-btn.active {
  background: #8ccff2;
  color: #114b82;
  border-color: #5faed9;
}

.mode-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.mode-action-row {
  grid-area: action;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.cloud-title {
  grid-area: title;
  margin: 0 0 2px;
  max-width: none;
  white-space: nowrap;
  justify-self: start;
  text-align: left;
  font-size: 1.2rem;
  font-weight: 800;
  transform: translateY(28px);
}

#listen-instruction {
  white-space: normal;
  max-width: 100%;
  line-height: 1.2;
}

.audio-btn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  transform: translateY(-4px);
}

.audio-btn:hover,
.audio-btn:focus-visible {
  background: var(--accent-dark);
}

.visual-number {
  min-width: 60px;
  border-radius: 14px;
  background: #ffffff;
  border: 3px solid #5faed9;
  color: #114b82;
  font-size: 2rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  padding: 2px 6px;
  box-shadow: 0 4px 10px rgba(31, 94, 178, 0.18);
  cursor: pointer;
}

.audio-next-hint {
  position: absolute;
  right: 86px;
  top: 12px;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #1f5eb2;
}

.audio-next-hint::after {
  content: "➜";
  display: inline-block;
  margin-left: 6px;
  font-size: 2rem;
  line-height: 1;
  font-weight: 900;
  transform: translateY(14px) rotate(26deg) scaleX(1.2);
  text-shadow: 0 0 1px currentColor;
}

.middle-zone {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 20px;
}

.cloud-answer {
  grid-column: 2;
  width: min(850px, 100%);
  min-height: 260px;
  border-radius: 60px;
  padding-bottom: 16px;
  margin-top: -46px;
  position: relative;
  z-index: 2;
}

.cloud-answer-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: -8px;
  margin-bottom: 0;
}

.cloud-answer-header .cloud-title {
  transform: translateY(2px);
  justify-self: center;
  text-align: center;
}

.answer-cloud-content {
  margin-top: 14px;
  min-height: 180px;
  border: 2px dashed #b9d2ee;
  border-radius: 24px;
  padding: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-content: flex-start;
}

.answer-cloud-content.drag-target-active {
  border-color: #4daede;
  background: #f4fbff;
}

.correct-answer-hint {
  position: absolute;
  right: 0;
  top: 0;
  margin: 0;
  text-align: right;
  font-size: 0.95rem;
  font-weight: 800;
  color: #9a2424;
}

.correct-answer-hint::before {
  content: "➜";
  display: inline-block;
  margin-right: 6px;
  font-size: 2rem;
  line-height: 1;
  font-weight: 900;
  transform: translateY(10px) rotate(162deg) scaleX(1.2);
  text-shadow: 0 0 1px currentColor;
}

.correct-answer-hint.hidden {
  display: none;
}

.error-cross {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 4.2rem;
  font-weight: 900;
  color: #cf2f2f;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  opacity: 0.9;
}

.error-retry-text {
  position: absolute;
  left: 50%;
  top: 66%;
  transform: translateX(-50%);
  margin: 0;
  color: #9a2424;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  padding: 0.2rem 0.5rem;
  font-size: 1rem;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
}

.cloud-item {
  border-radius: 10px;
  padding: 0;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}

.cloud-item.tens {
  background: transparent;
  border: none;
}

.cloud-item.hundreds {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  font-weight: 900;
  color: #4a358f;
}

.cloud-item.units {
  background: transparent;
  border: none;
}

.cloud-token-image {
  display: block;
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
}


.controls-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-left: 200px;
  width: calc(100% - 200px);
  margin-top: -6px;
}

.controls-zone.no-hundreds {
  justify-content: center;
  gap: 8px;
}

.controls-zone.no-hundreds > .counter-card {
  width: min(235px, 100%);
}

.counter-card {
  width: min(270px, 100%);
  background: #ffffffd8;
  border-radius: 20px;
  padding: 14px;
  box-shadow: 0 6px 16px rgba(23, 72, 132, 0.12);
}

.card-title {
  margin: 0 0 10px;
  font-weight: 800;
}

.image-placeholder {
  height: 120px;
  border-radius: 12px;
  border: none;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: #f6fbff;
  overflow: hidden;
}

.token-pool {
  cursor: pointer;
  touch-action: manipulation;
  transition: outline-color 120ms ease, background-color 120ms ease, opacity 120ms ease;
  outline: 2px dashed transparent;
  outline-offset: 2px;
}

.token-pool.drag-target-active {
  outline-color: #4daede;
  background: #eef9ff;
}

.token-pool.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1200;
}

.drag-ghost-hundreds {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.drag-ghost-tens {
  width: 64px;
  height: 48px;
  object-fit: contain;
}

.drag-ghost-units {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.token-image {
  max-height: 50%;
  width: auto;
  max-width: 50%;
  object-fit: contain;
}

#dizaine-image .token-image {
  transform: translateY(-22px);
}

#unite-image .token-image {
  transform: translateY(-8px);
}

#centaine-image .token-image {
  max-height: 62%;
  max-width: 62%;
  transform: translateY(-48px);
}

#centaine-image {
  overflow: hidden;
}

.centaine-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #efe8ff;
  border: 2px solid #b9a8f5;
  color: #4a358f;
  font-size: 1.1rem;
  font-weight: 900;
}

.counter-controls {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.round-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.7rem;
  color: #fff;
}

.plus {
  background: var(--ok);
}

.minus {
  background: var(--warn);
}

.count-value {
  min-width: 28px;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 900;
}

.bottom-zone {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-left: 200px;
  width: calc(100% - 200px);
}

.hidden {
  display: none;
}

.ok-btn {
  padding: 12px 30px;
  border: none;
  border-radius: 16px;
  background: #2c9a3b;
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  cursor: pointer;
}

#ok-btn {
  padding: 16px 44px;
  font-size: 1.5rem;
  min-width: 140px;
}

.ok-btn:hover,
.ok-btn:focus-visible {
  background: #1f7c2d;
}

.feedback {
  margin: 0;
  min-height: 26px;
  font-size: 1.1rem;
  font-weight: 800;
}

.feedback.ok {
  color: #137a2d;
}

.feedback.ko {
  color: #9a2424;
}

.round-report {
  background: #ffffffcf;
  border: 2px solid #a9ccec;
  border-radius: 12px;
  padding: 8px 14px;
  text-align: center;
  font-size: 0.9rem;
}

.middle-zone .round-report {
  grid-column: 1;
  align-self: center;
  transform: translateY(10px);
}

.report-line {
  margin: 4px 0;
  font-weight: 800;
}

#score-status {
  white-space: nowrap;
  font-size: 0.75rem;
}

.progress-wrap {
  width: min(320px, 90%);
  height: 14px;
  margin: 8px auto 4px;
  background: #e6f3ff;
  border: 2px solid #9fc6ea;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #57a8df, #2f7eea);
  transition: width 250ms ease;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

@media (min-width: 761px) and (max-width: 1366px) and (hover: none) and (pointer: coarse) {
  body {
    overflow: auto;
  }

  .game-page {
    max-width: 100%;
    min-height: 100svh;
    padding: 14px 16px;
    gap: 12px;
  }

  .top-zone,
  .middle-zone {
    grid-template-columns: 170px 1fr;
    gap: 12px;
  }

  .target-buttons {
    transform: translateY(20px);
    gap: 8px;
  }

  .target-btn {
    padding: 9px;
    font-size: 1rem;
  }

  .cloud-listen {
    min-height: 120px;
    padding: 16px 20px;
  }

  .cloud-title {
    font-size: 1rem;
  }

  .top-banner-row {
    margin-bottom: -2px;
  }

  .top-banner-image {
    width: 56px;
  }

  .top-banner-title {
    font-size: clamp(1.85rem, 3.8vw, 2.5rem);
  }

  .cloud-listen .cloud-title {
    max-width: none;
  }

  .audio-btn {
    width: 66px;
    height: 66px;
  }

  .mode-btn {
    font-size: 0.86rem;
    padding: 6px 8px;
  }

  .visual-number {
    min-width: 74px;
    font-size: 1.65rem;
    padding: 4px 8px;
  }

  .audio-next-hint {
    right: 96px;
    top: 8px;
    font-size: 0.9rem;
  }

  .audio-next-hint::after {
    font-size: 1.6rem;
    transform: translateY(7px) rotate(18deg) scaleX(1.15);
  }

  .middle-zone .round-report {
    transform: translateY(6px);
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  .report-line {
    margin: 2px 0;
    font-size: 0.95rem;
  }

  .progress-wrap {
    height: 12px;
    margin: 6px auto 3px;
  }

  .cloud-answer {
    min-height: 210px;
    margin-top: -50px;
    padding: 14px 20px 12px;
  }

  .answer-cloud-content {
    min-height: 130px;
    margin-top: 10px;
  }

  .controls-zone {
    margin-left: 182px;
    width: calc(100% - 182px);
    margin-top: -6px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .controls-zone.no-hundreds {
    grid-template-columns: repeat(2, minmax(0, 235px));
    justify-content: center;
    gap: 6px;
  }

  .counter-card {
    width: 100%;
    padding: 8px;
    border-radius: 14px;
  }

  .card-title {
    margin: 0 0 6px;
    font-size: 0.95rem;
  }

  .image-placeholder {
    height: 84px;
  }

  .token-image {
    max-height: 45%;
    max-width: 45%;
  }

  #centaine-image .token-image {
    max-height: 58%;
    max-width: 58%;
    transform: translateY(-38px);
  }

  #dizaine-image .token-image {
    transform: translateY(-20px);
  }

  #unite-image .token-image {
    transform: translateY(-6px);
  }

  .counter-controls {
    margin-top: 8px;
    gap: 8px;
  }

  .round-btn {
    width: 40px;
    height: 40px;
    font-size: 1.35rem;
  }

  .count-value {
    font-size: 1.25rem;
  }

  .cloud-item {
    width: 54px;
    height: 54px;
  }

  .bottom-zone {
    margin-left: 182px;
    width: calc(100% - 182px);
    gap: 6px;
  }

  #ok-btn {
    padding: 12px 34px;
    min-width: 120px;
    font-size: 1.3rem;
  }

  .feedback {
    min-height: 22px;
    font-size: 1rem;
  }
}

@media (max-width: 760px) {
  .top-zone {
    grid-template-columns: 1fr;
  }

  .middle-zone {
    grid-template-columns: 1fr;
  }

  .cloud-answer {
    grid-column: 1;
  }

  .cloud-answer-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .target-buttons {
    grid-template-columns: repeat(2, minmax(100px, 1fr));
    transform: none;
  }

  .controls-zone {
    margin-left: 0;
    width: 100%;
  }

  .bottom-zone {
    margin-left: 0;
    width: 100%;
  }

  .cloud-listen {
    min-height: 110px;
  }

  .top-banner-row {
    margin-bottom: -2px;
  }

  .top-banner-image {
    width: 46px;
  }

  .cloud-listen .cloud-title {
    max-width: none;
  }

  .mode-toggle {
    flex-wrap: wrap;
  }

  .visual-number {
    min-width: 96px;
  }
}

@media (min-width: 761px) and (max-width: 1366px) and (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .counter-card {
    min-height: 186px;
  }

  .card-title {
    margin-bottom: -6px;
  }

  .image-placeholder {
    height: 108px;
    margin-top: -14px;
  }

  .token-image {
    max-height: 40%;
    max-width: 40%;
  }

  #centaine-image .token-image {
    max-height: 52%;
    max-width: 52%;
    transform: translateY(-44px);
  }

  #dizaine-image .token-image {
    transform: translateY(-24px);
  }

  #unite-image .token-image {
    transform: translateY(-16px);
  }
}

@media (min-width: 761px) and (max-width: 1366px) and (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .cloud-listen .cloud-title {
    font-size: 0.9rem;
    line-height: 1.2;
    white-space: normal;
    max-width: 100%;
    transform: translateY(20px);
  }
}
