:root { --top: 96px; --bottom: 76px; font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; height: 100dvh; overflow: hidden; background: #bfeaff; user-select: none; -webkit-user-select: none; touch-action: none; }
#app { position: fixed; inset: 0; height: 100dvh; }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
[hidden] { display: none !important; }

button { font: inherit; border: 0; cursor: pointer; color: #fff; touch-action: manipulation; }
button:active { transform: scale(0.95); }
.round { width: 64px; height: 64px; min-width: 64px; border-radius: 50%; font-size: 30px; background: #fff; box-shadow: 0 4px 0 #0002; color: #333; }
.round.small { width: 64px; height: 64px; font-size: 28px; background: #ffb300; color: #fff; }
.big { min-height: 72px; min-width: 64px; padding: 0 28px; border-radius: 22px; font-size: 26px; font-weight: 700; box-shadow: 0 5px 0 #0003; }
.green { background: #43a047; } .blue { background: #1e88e5; } .orange { background: #fb8c00; }

#hud { position: absolute; top: 0; left: 0; right: 0; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 14px 14px 8px; pointer-events: none; }
#hud > * { pointer-events: auto; }
#prompt { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; background: #fffe; border-radius: 28px; padding: 6px 8px 6px 16px; box-shadow: 0 4px 0 #0002; }
#prompt-text { flex: 1; min-width: 0; font-size: clamp(18px, 5vw, 44px); font-weight: 800; color: #1b5e20; text-align: center; line-height: 1.1; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
#btn-repeat { flex-shrink: 0; }
#pips { display: flex; gap: 2px; font-size: 26px; background: #fffe; border-radius: 22px; padding: 8px 12px; box-shadow: 0 4px 0 #0002; }
#footer { position: absolute; bottom: 0; left: 0; right: 0; height: var(--bottom); display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; padding: 8px 14px 14px; pointer-events: none; }
#feedback { font-size: clamp(22px, 4.5vw, 36px); font-weight: 800; color: #fff; text-shadow: 0 3px 0 #0006; text-align: center; min-height: 1em; }

#home, #done { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(#6ec6ffcc, #e6f7d0cc); overflow-y: auto; padding: 16px; }
.panel { display: flex; flex-direction: column; align-items: center; gap: 18px; background: #fffd; border-radius: 32px; padding: 24px; box-shadow: 0 8px 0 #0002; max-width: 760px; width: 100%; }
.panel h1, .panel h2 { margin: 0; font-size: clamp(34px, 7vw, 56px); color: #e65100; text-align: center; }
.panel img.title { max-width: 80%; max-height: 28vh; }
.sub { margin: 0; font-size: clamp(20px, 3.6vw, 28px); font-weight: 700; color: #33691e; text-align: center; display: flex; gap: 10px; align-items: center; justify-content: center; }
.row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.theme { width: 120px; height: 120px; border-radius: 26px; background: #fff; border: 5px solid transparent; box-shadow: 0 5px 0 #0002; color: #333; font-size: 18px; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; overflow: hidden; padding: 0; }
.theme .ico { font-size: 52px; line-height: 1; }
.theme img { width: 100%; height: 76px; object-fit: cover; }
.theme.sel { border-color: #ffb300; background: #fff8e1; transform: scale(1.06); }
.lvl { min-width: 96px; height: 72px; border-radius: 20px; background: #fff; color: #f9a825; font-size: 28px; font-weight: 800; box-shadow: 0 5px 0 #0002; border: 5px solid transparent; }
.lvl.sel { border-color: #ffb300; background: #fff8e1; transform: scale(1.06); }
#done-stars { font-size: clamp(56px, 14vw, 110px); letter-spacing: 6px; }
.star-on { filter: drop-shadow(0 4px 0 #0003); } .star-off { opacity: 0.25; filter: grayscale(1); }

#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#debug { position: absolute; left: 8px; bottom: calc(var(--bottom) + 4px); background: #000a; color: #fff; padding: 4px 8px; border-radius: 8px; font: 14px monospace; pointer-events: none; }

#pager { display: flex; align-items: center; gap: 14px; pointer-events: auto; }
#pager-label { font-size: 32px; letter-spacing: 6px; color: #fff; text-shadow: 0 3px 0 #0006; }
body.listen { --bottom: 150px; }
@media (max-width: 560px) {
  :root { --top: 150px; }
  #hud { flex-wrap: wrap; align-content: flex-start; row-gap: 8px; }
  #prompt { order: 3; flex: 1 1 100%; }
  #pips { margin-left: auto; }
  .theme { width: 100px; height: 100px; font-size: 16px; }
  .theme .ico { font-size: 42px; }
  .big { font-size: 22px; padding: 0 18px; }
  #pips { font-size: 20px; padding: 6px 8px; }
}
#home { touch-action: pan-y; }

/* Responsive téléphone : accueil sans défilement quand possible */
#home .panel { margin: auto; }
#home, #done { -webkit-overflow-scrolling: touch; padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
@media (max-width: 480px) {
  #home, #done { padding: 8px; }
  #home .panel { gap: 8px; padding: 12px; border-radius: 24px; }
  .panel img.title { max-height: 14dvh; }
  .sub { font-size: 16px; }
  #themes { gap: 8px; }
  .theme { width: 72px; height: 72px; font-size: 13px; border-width: 3px; border-radius: 18px; }
  .theme .ico { font-size: 30px; }
  .theme img { height: 44px; }
  #levels { gap: 8px; }
  .lvl { min-width: 48px; height: 48px; font-size: 22px; border-width: 3px; }
  .big { min-height: 56px; font-size: 20px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  #home, #done { padding: 6px 12px; }
  #home .panel { gap: 6px; padding: 8px 16px; max-width: 900px; border-radius: 20px; }
  .panel img.title { max-height: 16dvh; }
  .sub { font-size: 14px; }
  #themes, #levels { gap: 8px; flex-wrap: nowrap; }
  .theme { width: 76px; height: 76px; font-size: 13px; border-width: 3px; border-radius: 16px; }
  .theme .ico { font-size: 30px; }
  .theme img { height: 46px; }
  .lvl { min-width: 48px; height: 48px; font-size: 22px; border-width: 3px; }
  .big { min-height: 52px; font-size: 20px; }
}
