:root { --font: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", system-ui, -apple-system, "Segoe UI", sans-serif; --ink: #243447; --green: #2fb857; --blue: #3d9bff; --orange: #ff8a2a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; height: 100dvh; overflow: hidden; font-family: var(--font); color: var(--ink); user-select: none; -webkit-user-select: none; background: #bfe6ff; }
.hidden { display: none !important; }
#bg { position: fixed; inset: 0; background: linear-gradient(180deg, #8fd3ff 0%, #c9ecff 55%, #e9f7d4 100%); background-size: cover; background-position: center; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui button, #ui .screen { pointer-events: auto; }
button { font-family: var(--font); color: var(--ink); cursor: pointer; border: none; transition: transform .08s; }
button:active:not(:disabled) { transform: scale(.94); }
button:disabled { opacity: .5; cursor: default; }
.round { width: 64px; height: 64px; border-radius: 50%; font-size: 30px; background: #fff; box-shadow: 0 5px 0 rgba(0,0,0,.18); display: grid; place-items: center; padding: 0; }
.big { min-height: 72px; min-width: 72px; padding: 0 30px; border-radius: 28px; font-size: 28px; background: #fff; box-shadow: 0 6px 0 rgba(0,0,0,.2); }
.big.green { background: var(--green); color: #fff; }
.big.blue { background: var(--blue); color: #fff; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.screen { position: fixed; inset: 0; height: 100dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 18px; padding: 16px; text-align: center; background: rgba(210, 238, 255, .78); background-size: cover; background-position: center; z-index: 10; }
.screen h1 { margin: 0; font-size: clamp(38px, 9vw, 80px); line-height: 1.05; color: #e8432e; text-shadow: 0 4px 0 #fff, 0 8px 0 rgba(0,0,0,.12); }
.screen h2 { margin: 0; font-size: clamp(30px, 6vw, 52px); }
#titre.img { color: transparent; background-size: contain; background-repeat: no-repeat; background-position: center; width: min(560px, 90vw); height: 180px; text-shadow: none; }
#mascotte { height: 120px; object-fit: contain; }
#btn-voice { position: absolute; top: 12px; right: 12px; }
#btn-voice.off { opacity: .55; }
#levels { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.level-card { width: 150px; min-height: 140px; border-radius: 28px; background: #fff; box-shadow: 0 6px 0 rgba(0,0,0,.18); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px; font-size: 19px; }
.level-card .ico { font-size: 44px; }
.level-card .st { font-size: 22px; letter-spacing: 2px; min-height: 28px; }
.level-card.locked { filter: grayscale(.9); opacity: .6; }

#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
#hud > * { pointer-events: auto; }
#hud-level, #hud-stars { background: #fff; border-radius: 22px; padding: 8px 14px; font-size: 20px; box-shadow: 0 4px 0 rgba(0,0,0,.15); white-space: nowrap; }
#hud-level { flex: 1; text-align: center; }

#bubble { display: flex; align-items: center; gap: 12px; position: fixed; left: 50%; top: 76px; transform: translateX(-50%); max-width: min(560px, 92vw); background: #fff; border-radius: 28px; padding: 8px 20px 8px 10px; font-size: clamp(18px, 2.8vw, 24px); line-height: 1.25; text-align: center; box-shadow: 0 6px 0 rgba(0,0,0,.15); z-index: 5; animation: pop .35s ease-out; }
#bubble.conseil { background: #fff3c4; border: 4px solid #ffc83d; }
@keyframes pop { from { opacity: 0; scale: .7; } to { opacity: 1; scale: 1; } }
#hint { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); background: #ffe14d; border-radius: 30px; padding: 12px 26px; font-size: 30px; box-shadow: 0 6px 0 rgba(0,0,0,.18); animation: pulse 1s infinite; z-index: 4; }

#bottom { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.act { min-width: 76px; min-height: 80px; flex: 1 1 0; max-width: 170px; border-radius: 26px; background: #fff; box-shadow: 0 6px 0 rgba(0,0,0,.2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 4px; position: relative; }
.act .e { font-size: 32px; line-height: 1; }
.act .l { font-size: 16px; }
.act.green { background: var(--green); color: #fff; }
.act.orange { background: var(--orange); color: #fff; }
.act.done::after { content: "✓"; position: absolute; top: -8px; right: -4px; background: #35e060; color: #fff; border-radius: 50%; width: 28px; height: 28px; font-size: 18px; line-height: 28px; }
.act.pulse { animation: pulse .8s infinite; outline: 6px solid #ffe14d; }
@keyframes pulse { 0%, 100% { transform: translateX(var(--tx, 0)) scale(1); } 50% { transform: translateX(var(--tx, 0)) scale(1.1); } }
#hint { --tx: -50%; }
#act-move { width: 100%; max-width: 760px; flex-wrap: nowrap; }
#act-choose .act { max-width: 220px; flex: 0 1 200px; }

#star-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.fly-star { position: absolute; font-size: 54px; animation: fly 1.3s ease-out forwards; }
@keyframes fly { 0% { transform: translate(-50%, 0) scale(.3); opacity: 0; } 20% { opacity: 1; transform: translate(-50%, -30px) scale(1.4); } 100% { transform: translate(-50%, -150px) scale(1); opacity: 0; } }

#end-stars, #diploma-stars { font-size: clamp(50px, 12vw, 90px); letter-spacing: 6px; }
.paper { background: #fffaf0; border: 8px double #e0b13c; border-radius: 26px; padding: 22px 34px; max-width: 92vw; box-shadow: 0 8px 0 rgba(0,0,0,.15); }
.paper p { font-size: 24px; margin: 8px 0; }
.deco { font-size: 60px; }
#debug { position: fixed; left: 6px; bottom: 150px; margin: 0; padding: 6px 8px; background: rgba(0,0,0,.65); color: #9f9; font: 11px/1.3 monospace; max-width: 60vw; max-height: 40vh; overflow: hidden; pointer-events: none; z-index: 30; }
@media (max-width: 520px) { .act .l { font-size: 13px; } .act { min-width: 70px; } }

#bubble img { height: 64px; width: auto; flex: none; }
#bubble span { text-align: left; }
.drow { font-size: clamp(26px, 6vw, 40px); } .dtotal { font-size: 28px; margin-top: 4px; }
#diploma-stars { letter-spacing: 2px; font-size: inherit; }

@media (max-width: 480px) {
  .screen { gap: 10px; padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); }
  #mascotte { height: 90px; }
  #titre.img { height: 120px; }
  .big { min-height: 56px; font-size: 24px; padding: 0 22px; }
  .round { width: 52px; height: 52px; font-size: 26px; }
  .level-card { width: 104px; min-height: 108px; font-size: 15px; padding: 6px; border-radius: 22px; }
  .level-card .ico { font-size: 34px; }
  .paper { padding: 14px 18px; } .paper p { font-size: 19px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .screen { gap: 6px; padding: 6px 12px; }
  .screen h1 { font-size: clamp(26px, 9dvh, 40px); }
  .screen h2 { font-size: 26px; }
  #mascotte { height: 56px; }
  #titre.img { height: 70px; }
  .big { min-height: 52px; font-size: 22px; padding: 0 22px; }
  .round { width: 48px; height: 48px; font-size: 24px; }
  #levels { flex-wrap: nowrap; gap: 10px; }
  .level-card { width: 120px; min-height: 84px; padding: 4px; font-size: 14px; border-radius: 20px; gap: 0; }
  .level-card .ico { font-size: 28px; }
  .level-card .st { font-size: 16px; min-height: 20px; }
  .deco { font-size: 36px; }
  .paper { padding: 8px 18px; } .paper p { font-size: 17px; margin: 3px 0; }
  #end-stars, #diploma-stars { font-size: 44px; }
  #bubble { top: 62px; font-size: 16px; padding: 4px 14px 4px 8px; }
  #bubble img { height: 40px; }
  .act { min-height: 56px; } .act .e { font-size: 24px; }
  #bottom { padding-top: 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
}
