:root {
  --ink: #3d2c6b;
  --soft: #7b6fa8;
  --accent: #7b2cbf;
  --pink: #ef476f;
  --gold: #ffd166;
  --ok: #2a9d8f;
  font-family: "Baloo 2", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(circle at 30% 0%, #ffe9f3, #d9ecff 60%, #c9b6f2) fixed;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

.icon-btn {
  width: 46px; height: 46px; border: none; border-radius: 15px; background: #fff; font-size: 22px; flex: none;
  box-shadow: 0 3px 0 #cdbdf0; display: grid; place-items: center;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #cdbdf0; }
.btn {
  border: none; border-radius: 999px; padding: 10px 22px; background: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 0 #cdbdf0;
}
.btn.primary { background: linear-gradient(#ff6b9a, var(--pink)); color: #fff; box-shadow: 0 4px 0 #b3264c; }
.btn.big { font-size: 22px; padding: 12px 30px; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b3264c; }

/* ---------- carte ---------- */
#map { height: 100dvh; overflow-y: auto; padding: 14px 16px 40px; }
.map-head { display: flex; align-items: center; gap: 8px; max-width: 560px; margin: 0 auto; }
.map-head h1 { flex: 1; margin: 0; font-size: clamp(30px, 7vw, 46px); color: var(--accent); text-shadow: 0 3px 0 #fff; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 560px; margin: 14px auto 24px; }
.mode {
  border: none; border-radius: 22px; padding: 12px; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 0 5px 0 rgba(0,0,0,.18);
}
.mode .big { font-size: 34px; line-height: 1; }
.mode b { font-size: 20px; }
.mode small { opacity: .9; font-size: 14px; }
.mode.rush { background: linear-gradient(135deg, #ff9a2e, #ef476f); }
.mode.daily { background: linear-gradient(135deg, #06d6a0, #118ab2); }
.mode:active { transform: translateY(3px); }
.path { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 560px; margin: 0 auto; }
.node {
  position: relative; transform: translateX(var(--x)); width: 112px; height: 112px; border-radius: 50%; border: none;
  background: radial-gradient(circle at 35% 30%, #fff, #e7dcff); box-shadow: 0 6px 0 #b9a5ea, 0 10px 20px rgba(80,50,140,.15);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.node .n { font-size: 34px; font-weight: 800; line-height: 1; color: var(--accent); }
.node .st { color: var(--gold); font-size: 18px; letter-spacing: 1px; text-shadow: 0 1px 0 #b58900; }
.node .nm { position: absolute; top: 100%; margin-top: 6px; white-space: nowrap; font-weight: 700; font-size: 14px; color: var(--soft); }
.node.next { animation: bob 1.2s ease-in-out infinite; background: radial-gradient(circle at 35% 30%, #fff, #ffd6e4); box-shadow: 0 6px 0 #e07a9a, 0 0 0 6px rgba(239,71,111,.25); }
.node.locked { opacity: .5; filter: grayscale(.6); cursor: default; }
.node.locked .n { font-size: 26px; }
.path .node:not(:last-child) { margin-bottom: 18px; }
@keyframes bob { 50% { transform: translateX(var(--x)) translateY(-6px) scale(1.04); } }
.v1link { text-align: center; margin-top: 30px; font-size: 14px; }
.v1link a { color: var(--soft); }

/* ---------- partie ---------- */
#play { height: 100dvh; display: flex; flex-direction: column; }
#hud {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin: 8px 8px 0;
  background: rgba(255,255,255,.75); border-radius: 22px; box-shadow: 0 4px 16px rgba(80,50,140,.12);
}
#hud .moves { display: flex; flex-direction: column; align-items: center; min-width: 62px; background: var(--accent); color: #fff; border-radius: 16px; padding: 2px 8px; }
#hud .moves b { font-size: 30px; line-height: 1.05; }
#hud .moves b.low { color: var(--gold); animation: beat .6s infinite; }
#hud .moves small { font-size: 12px; opacity: .85; margin-top: -2px; }
#hud.rush .moves { background: linear-gradient(135deg, #ff9a2e, #ef476f); }
@keyframes beat { 50% { transform: scale(1.18); } }
#hud .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
#hud .title { font-weight: 800; font-size: 14px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.goals { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.goal { display: flex; align-items: center; gap: 2px; font-weight: 800; font-size: 22px; }
.goal.ok b { color: var(--ok); }
.goal.big { font-size: 26px; gap: 6px; }
#hud .score { display: flex; flex-direction: column; align-items: flex-end; min-width: 92px; }
#hud .score b { font-size: 22px; }
.starbar { position: relative; width: 92px; height: 10px; border-radius: 5px; background: #e7dcff; margin-top: 4px; }
.starbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: linear-gradient(90deg, var(--gold), #ff9a2e); transition: width .3s; }
.starbar .mark { position: absolute; top: -8px; transform: translateX(-50%); color: #cdbdf0; font-size: 16px; line-height: 1; }
.starbar .mark.on { color: var(--gold); text-shadow: 0 0 6px #ff9a2e; }

#board { position: relative; flex: 1; min-height: 0; touch-action: none; }
.board-canvas { position: absolute; inset: 0; touch-action: none; }

#flash {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.5); opacity: 0; pointer-events: none;
  font-size: clamp(26px, 6vw, 44px); font-weight: 800; color: #fff; text-align: center;
  text-shadow: 0 3px 0 var(--accent), 0 0 20px rgba(123,44,191,.6); z-index: 5;
}
#flash.show { animation: flash 1.8s ease-out; }
@keyframes flash { 10% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; } }

/* ---------- fenêtre ---------- */
#modal { position: fixed; inset: 0; background: rgba(40,20,80,.4); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-card {
  background: #fff; border-radius: 28px; padding: 22px 24px; max-width: 460px; width: 100%; text-align: center;
  box-shadow: 0 20px 60px rgba(40,20,80,.35); animation: pop .35s;
}
.modal-card h2 { margin: 0 0 10px; font-size: 30px; color: var(--accent); }
.modal-card p { font-size: 18px; line-height: 1.4; }
.modal-card .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.modal-card .score { font-size: 46px; font-weight: 800; margin: 4px 0; color: var(--pink); }
.intro-goals { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.modal-card .moves b { color: var(--accent); }
.stars { font-size: 64px; letter-spacing: 6px; }
.stars span { color: #e7dcff; display: inline-block; }
.stars span.on { color: var(--gold); animation: starpop .5s both; text-shadow: 0 3px 0 #d4a017; }
@keyframes starpop { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

@media (max-width: 480px) {
  #hud { gap: 5px; padding: 6px; }
  #hud .score { min-width: 70px; }
  .starbar { width: 70px; }
  .icon-btn { width: 40px; height: 40px; font-size: 19px; }
}
