@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;
}

: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;
}




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


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

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

.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: inline-flex;
  align-items: center;
  gap: 0.7rem;
}

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

.title-row .title-icon:first-child {
  transform: scaleX(-1);
}

.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.45rem 0 0.8rem;
}

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

.range-row {
  margin-top: 1.8rem;
}

.level-row {
  margin-top: 1.2rem;
}

.range-btn,
.level-btn,
.action-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;
}

.level-sub {
  display: inline-block;
  font-size: 0.78em;
  line-height: 1.1;
}

.board,
.dice-panel,
.answer-panel {
  margin: 0.8rem auto 0;
  max-width: 760px;
  background: rgba(255, 255, 255, 0.76);
  border-radius: 18px;
  border: 2px solid rgba(0, 0, 0, 0.09);
  padding: 0.75rem 0.8rem 0.9rem;
}

.dice-panel {
  background: transparent;
  border: 0;
  padding-top: 0.2rem;
}

.play-row {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: 1.45fr 0.7fr 1.15fr;
  gap: 0.7rem;
  align-items: start;
}

.play-row .board,
.play-row .dice-panel,
.play-row .answer-panel {
  margin: 0;
  max-width: none;
}

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

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

.collection {
  margin: 0.6rem auto 0;
  min-height: 280px;
  max-width: 760px;
  border-radius: 14px;
  border: 2px solid rgba(0, 0, 0, 0.22);
  background: #f8f8f8;
  padding: 0.7rem;
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  overflow: hidden;
}

.collection .token + .token {
  margin-left: -16px;
}

.collection .token.tens + .token.tens {
  margin-left: -44px;
}

.collection .token.hundreds + .token.hundreds {
  margin-left: -86px;
}

.collection .token.hundreds {
  transform: translateY(-8px);
}

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

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

.collection.base-mixed .token + .token {
  margin-left: 0;
}

.final-collection .token.units {
  width: 72px;
  height: 72px;
}

.final-collection .token.hundreds {
  width: 108px;
  height: 100px;
  transform: translateY(-14px);
}

.final-collection .token.units + .token.units {
  margin-left: -52px;
}

.final-collection .token.tens + .token.tens {
  margin-left: -66px;
}

.final-collection .token.hundreds + .token.hundreds {
  margin-left: -94px;
}

.final-collection .token.units + .token.tens,
.final-collection .token.tens + .token.units,
.final-collection .token.tens + .token.hundreds,
.final-collection .token.hundreds + .token.tens,
.final-collection .token.hundreds + .token.units,
.final-collection .token.units + .token.hundreds {
  margin-left: -44px;
}

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

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

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

.die-face {
  margin: 0.6rem auto 0;
  min-height: 215px;
  width: min(100%, 320px);
  border: 0;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: center / contain no-repeat url("./de-transparent.png");
  padding: 1.7rem 0.7rem 0.7rem;
  position: relative;
  transform-origin: center center;
}

.die-face.die-rolling {
  animation: die-roll 620ms ease-in-out;
}

@keyframes die-roll {
  0% {
    transform: rotate(0deg) scale(1);
  }
  15% {
    transform: rotate(-14deg) scale(0.97);
  }
  35% {
    transform: rotate(12deg) scale(1.02);
  }
  55% {
    transform: rotate(-10deg) scale(0.99);
  }
  75% {
    transform: rotate(8deg) scale(1.01);
  }
  100% {
    transform: rotate(0deg) scale(1);
  }
}

.die-face.has-roll::before {
  content: "+";
  position: absolute;
  top: 1.62rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  font-weight: 900;
  color: #000;
  z-index: 2;
}

.die-face img {
  position: relative;
  z-index: 1;
}

.die-face img {
  object-fit: contain;
}

.die-face img + img {
  margin-left: -28px;
}

.die-face .ten + .ten {
  margin-left: -72px;
}

.die-face .unit {
  width: 74px;
  height: 74px;
}

.die-face .ten {
  width: 112px;
  height: 82px;
}

.die-label {
  text-align: center;
  margin: 0.38rem 0 0;
  font-weight: 800;
}

.answer-zone {
  margin: 0.6rem auto 0;
  display: flex;
  gap: 0.45rem;
  justify-content: center;
  flex-wrap: wrap;
}

.final-collection {
  margin-top: 0.6rem;
  min-height: 280px;
  border-style: dashed;
  border-width: 3px;
  background: #fff;
  position: relative;
}

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

.final-collection.retry-warning::after,
.final-collection.retry-message::after {
  content: attr(data-retry-message);
  position: absolute;
  left: 50%;
  top: 63%;
  transform: translate(-50%, -50%);
  font-size: 1.3rem;
  font-weight: 900;
  color: #c2473f;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  padding: 0.2rem 0.5rem;
  z-index: 3;
  pointer-events: none;
  white-space: nowrap;
}

.final-collection.retry-message::after {
  top: auto;
  bottom: 6%;
  transform: translateX(-50%);
}

.tray {
  margin: 0.7rem auto 0;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tray-token {
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  padding: 0.45rem 0.85rem;
  cursor: grab;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.tray-token:active {
  cursor: grabbing;
}

.tray-icon {
  object-fit: contain;
}

.tray-icon.hundreds {
  width: 100px;
  height: 88px;
}

.tray-icon.tens {
  width: 84px;
  height: 60px;
}

.tray-icon.units {
  width: 64px;
  height: 64px;
}

.tray-count {
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
  color: #0f344b;
}

.tray-token[data-kind="units"] .tray-count {
  margin-top: 0.35rem;
}

.tray-token[data-kind="tens"] .tray-count {
  margin-top: 0.58rem;
}

.tray-token[data-kind="hundreds"] .tray-icon.hundreds {
  transform: translateY(-14px);
}

.tray-token[data-kind="hundreds"] .tray-count {
  margin-top: -1.2rem;
}

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

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

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

.action-btn {
  background: #3da8df;
  color: #fff;
}

.launch-btn {
  display: block;
  margin: 0.7rem auto 0;
  min-width: 130px;
}

.action-btn.ghost {
  background: #fff;
  color: #1a4a68;
  border: 2px solid rgba(0, 0, 0, 0.2);
}

.feedback {
  width: 100%;
  text-align: center;
  margin: 0.18rem 0 0;
  min-height: 1.2rem;
  font-weight: 900;
}

.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: 44px;
    height: 44px;
  }

  .play-row {
    grid-template-columns: 1fr;
  }

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

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

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

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