/* Glouball : tout est en gelée. Les boutons sont des bonbons, le logo aussi. */
:root {
  --ink: #13304a;        /* encre lagon : textes, panneaux */
  --ink-soft: #13304ad9;
  --coral: #ff4d5e;
  --lagoon: #2fd8c8;
  --mango: #ffb703;
  --sand: #fff3dc;
  --foam: #ffffff;
  --err: #ff8a8a;
  --display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --text: 'Fredoka', system-ui, sans-serif;
  --fg: var(--sand);
  --accent: var(--mango);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8ecae6; font-family: var(--text); color: var(--sand); }
#game { position: fixed; inset: 0; }
button { font-family: var(--text); cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--foam); outline-offset: 3px; }

/* ---------------------------------------------------------------- bonbons (boutons) */
.gummy {
  --c: var(--mango); --t: var(--ink);
  position: relative; overflow: hidden; /* le reflet reste dans le bonbon */ display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  padding: 13px 20px 15px; border: 0; border-radius: 18px 18px 20px 20px;
  font-family: var(--display); font-size: 21px; line-height: 1.05; color: var(--t); text-align: left;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 78%, white) 0%, var(--c) 45%, color-mix(in srgb, var(--c) 88%, black) 100%);
  box-shadow: inset 0 3px 0 #ffffff73, inset 0 -4px 0 #00000024, 0 6px 0 color-mix(in srgb, var(--c) 55%, black), 0 12px 18px #0d243a40;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.gummy::after { /* reflet de bonbon */
  content: ''; position: absolute; left: 14px; right: 40%; top: 6px; height: 7px; border-radius: 6px; background: #ffffff8c; pointer-events: none;
}
.gummy small { display: block; margin-top: 3px; font: 500 14px/1.2 var(--text); opacity: .8; }
.gummy:hover { filter: brightness(1.06) saturate(1.05); }
.gummy:active { transform: translateY(5px); box-shadow: inset 0 3px 0 #ffffff73, inset 0 -3px 0 #00000024, 0 1px 0 color-mix(in srgb, var(--c) 55%, black), 0 4px 8px #0d243a40; animation: squish .35s; }
@keyframes squish { 0% { scale: 1 1; } 30% { scale: 1.06 .9; } 60% { scale: .97 1.04; } 100% { scale: 1 1; } }
.gummy.coral { --c: var(--coral); --t: var(--foam); }
.gummy.lagoon { --c: var(--lagoon); }
.gummy.mango { --c: var(--mango); }
.gummy.foam { --c: #f4f8fb; }
.gummy.xl { font-size: 30px; padding: 16px 22px 18px; border-radius: 22px 22px 24px 24px; }
.gummy[hidden] { display: none; }

/* ---------------------------------------------------------------- menu */
#menu { position: fixed; inset: 0; display: flex; align-items: center; padding: 20px max(20px, 4vw); pointer-events: none; }
.slab {
  position: relative; pointer-events: auto; display: flex; flex-direction: column; gap: 14px; width: min(470px, 100%); max-height: 100%; overflow-y: auto;
  padding: 26px 28px 24px; border-radius: 36px 36px 40px 40px; scrollbar-width: none;
  background: #13304ab8; backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: inset 0 2px 0 #ffffff33, inset 0 0 0 2px #ffffff14, 0 24px 60px #0d243a59;
}
#menu[hidden] { display: none; }
.logo { margin: 0; font: 400 clamp(64px, 11vw, 112px)/.9 var(--display); letter-spacing: -1px; display: flex; transform: rotate(-4deg); transform-origin: left center; }
.logo span {
  display: inline-block; color: var(--c, var(--coral));
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink), 0 14px 22px #0006;
  animation: wobble-in .9s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: calc(var(--i) * 60ms);
}
.logo span:nth-child(3n + 1) { --c: var(--coral); }
.logo span:nth-child(3n + 2) { --c: var(--lagoon); }
.logo span:nth-child(3n) { --c: var(--mango); }
.logo span:nth-child(1) { --i: 0; } .logo span:nth-child(2) { --i: 1; } .logo span:nth-child(3) { --i: 2; } .logo span:nth-child(4) { --i: 3; }
.logo span:nth-child(5) { --i: 4; } .logo span:nth-child(6) { --i: 5; } .logo span:nth-child(7) { --i: 6; } .logo span:nth-child(8) { --i: 7; }
.logo b { display: inline-block; font-weight: 400; transition: translate .2s; }
.logo span:hover b { animation: jiggle .55s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes wobble-in { 0% { transform: translateY(-40px) scale(.4, 1.6); opacity: 0; } 55% { transform: translateY(4px) scale(1.25, .78); opacity: 1; } 80% { transform: scale(.94, 1.08); } 100% { transform: none; } }
@keyframes jiggle { 0%, 100% { transform: none; } 25% { transform: scale(1.18, .85); } 50% { transform: scale(.9, 1.12) translateY(-6px); } 75% { transform: scale(1.04, .97); } }
.tagline { margin: -2px 0 6px 6px; font-size: 19px; font-weight: 500; color: var(--sand); opacity: .92; }
.modes { display: flex; flex-direction: column; gap: 14px; max-width: 400px; }
.group { margin: 6px 0 -4px 4px; font-size: 15px; font-weight: 600; color: var(--lagoon); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair .gummy { font-size: 18px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 10px 0 0 4px; font-size: 14px; color: #fff3dccc; align-items: center; max-width: 420px; }
.keys dt { font-weight: 600; color: var(--sand); }
.keys dd { margin: 0; }
kbd {
  display: inline-block; min-width: 22px; margin-right: 3px; padding: 1px 6px 3px; border-radius: 6px; text-align: center;
  font: 600 13px/1.3 var(--text); color: var(--ink); background: var(--sand); box-shadow: 0 2px 0 #c9b38c;
}
@media (pointer: coarse) { .keys { display: none; } }
@media (max-width: 620px), (max-aspect-ratio: 1/1) {
  #menu { justify-content: center; }
  .slab { text-align: center; align-items: center; }
  #lang { align-self: center; margin-left: 0; }
  .logo { transform: rotate(-4deg); transform-origin: center; justify-content: center; }
  .tagline, .group { margin-left: 0; }
  .modes { width: 100%; }
  .gummy { align-items: center; text-align: center; }
}

/* ---------------------------------------------------------------- panneaux (en ligne, mon blob) */
.panel {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(430px, calc(100% - 32px));
  padding: 24px 24px 26px; border-radius: 28px; background: var(--ink-soft); backdrop-filter: blur(8px);
  box-shadow: 0 0 0 3px #ffffff1f, 0 20px 50px #0d243a66; display: flex; flex-direction: column; gap: 12px;
}
.panel[hidden] { display: none; }
.panel h2 { margin: 0 0 2px; font: 400 34px/1 var(--display); color: var(--mango); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); }
.panel p { margin: 0; line-height: 1.35; }
.err { margin: 0; color: var(--err); min-height: 1em; font-weight: 500; }
.big { margin: 4px 0; text-align: center; font: 400 64px/1 var(--display); letter-spacing: 4px; color: var(--mango); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); user-select: all; }
.big[hidden] { display: none; }
.digits { display: flex; justify-content: center; gap: 8px; }
.digits[hidden] { display: none; }
.digits input {
  width: min(48px, 11vw); height: 64px; padding: 0; text-align: center; font: 400 38px/1 var(--display); color: var(--ink);
  background: var(--sand); border: 0; border-radius: 14px; box-shadow: inset 0 -4px 0 #e2cfa9; caret-color: var(--coral);
}
.digits input:focus { outline: none; box-shadow: inset 0 -4px 0 #e2cfa9, 0 0 0 3px var(--mango); }
.digits .sep { width: 10px; }
#custom { left: auto; right: 16px; top: 70px; width: min(390px, calc(100% - 32px)); max-height: calc(100% - 86px); overflow-y: auto; transform: none; scrollbar-width: thin; scrollbar-color: #ffffff44 transparent; } /* sous le bouton son */
.label { margin: 4px 0 0; font-weight: 600; color: var(--lagoon); }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch { aspect-ratio: 1; padding: 0; border: 0; border-radius: 50% 50% 46% 46%; box-shadow: inset 0 3px 0 #ffffff66, inset 0 -3px 0 #0003, 0 3px 0 #0d243a66; }
.swatch.on { outline: 3px solid var(--foam); outline-offset: 2px; }
.hats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.hat { padding: 9px 4px; border: 0; border-radius: 12px; font: 500 13px/1.15 var(--text); background: #ffffff1c; color: var(--sand); }
.hat:hover { background: #ffffff2e; }
.hat.on { background: var(--mango); color: var(--ink); font-weight: 600; box-shadow: 0 3px 0 #b78200; }

/* ---------------------------------------------------------------- score */
#hud { position: fixed; top: 14px; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 10px; pointer-events: none; z-index: 3; }
.pill {
  --c: var(--coral);
  display: flex; align-items: center; gap: 10px; min-width: 104px; height: 58px; padding: 0 16px; border-radius: 30px 30px 32px 32px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 75%, white), var(--c) 50%, color-mix(in srgb, var(--c) 85%, black));
  box-shadow: inset 0 3px 0 #ffffff70, inset 0 -4px 0 #0000002a, 0 5px 0 color-mix(in srgb, var(--c) 50%, black), 0 10px 18px #0d243a40;
}
.pill.p0 { justify-content: flex-end; } .pill.p1 { justify-content: flex-start; }
.pill span { font: 400 40px/1 var(--display); color: var(--foam); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); }
.pill i { width: 18px; height: 14px; border-radius: 50% 50% 40% 40% / 70% 70% 30% 30%; background: #ffffffb0; } /* mini blob */
.target { font: 400 18px/1 var(--display); color: var(--ink); background: var(--sand); padding: 7px 9px 8px; border-radius: 12px; box-shadow: 0 3px 0 #c9b38c; }
.pill.bump { animation: pill-jelly .7s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pill-jelly { 0% { scale: 1 1; } 20% { scale: 1.28 .78; } 45% { scale: .88 1.16; } 70% { scale: 1.06 .95; } 100% { scale: 1 1; } }
@media (max-width: 520px) { .pill { min-width: 80px; height: 48px; } .pill span { font-size: 32px; } }

#rally {
  position: fixed; top: 84px; left: 50%; translate: -50% 0; rotate: -3deg; pointer-events: none; z-index: 3;
  font: 400 22px/1 var(--display); color: var(--foam); -webkit-text-stroke: 2px #8a2b00; paint-order: stroke fill;
}
#rally:not(:empty) { padding: 8px 14px 10px; border-radius: 14px; background: linear-gradient(180deg, #ffb35c, #ff6a1a); box-shadow: inset 0 2px 0 #fff7, 0 4px 0 #a83c00, 0 0 22px #ff5a00aa; }
#rally.bump { animation: pill-jelly .5s cubic-bezier(.2, 1.6, .4, 1); }

/* ---------------------------------------------------------------- messages de fin de partie */
#msg { position: fixed; top: 16%; width: 100%; text-align: center; pointer-events: none; z-index: 3; font-weight: 600; font-size: 22px; }
#msg .title { display: block; font: 400 clamp(52px, 9vw, 92px)/1 var(--display); color: var(--mango); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink), 0 16px 30px #0007; animation: wobble-in .8s cubic-bezier(.2, 1.6, .4, 1) both; }
#msg .sub { display: inline-block; margin-top: 14px; padding: 6px 14px 8px; border-radius: 12px; background: var(--ink-soft); font-size: 18px; opacity: 0; animation: fade .4s .8s forwards; }
@keyframes fade { to { opacity: 1; } }

#loading { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; font: 400 28px/1.2 var(--display); color: var(--mango); background: var(--ink); z-index: 10; }
#loading[hidden] { display: none; }

/* ---------------------------------------------------------------- boutons ronds (son, menu, émotes) */
button.icon { position: fixed; top: 12px; right: 12px; z-index: 5; width: 46px; height: 46px; padding: 0; border: 0; font-size: 22px; background: var(--ink-soft); border-radius: 50%; box-shadow: 0 3px 0 #0b1f31; }
#menu-btn { left: 12px; right: auto; }
#emote-btn { top: 66px; left: 12px; right: auto; }
#emote-bar { position: fixed; top: 66px; left: 66px; display: flex; gap: 6px; z-index: 6; }
#emote-bar[hidden] { display: none; }
#emote-bar button { width: 48px; height: 48px; padding: 0; border: 0; font-size: 26px; border-radius: 50%; background: var(--foam); box-shadow: 0 3px 0 #b9c6d2; }

#sound { position: fixed; top: 12px; right: 12px; z-index: 5; display: flex; align-items: center; gap: 8px; flex-direction: row-reverse; padding: 0 8px 0 0; border-radius: 26px; }
#sound #mute { position: static; }
#volume { width: 0; opacity: 0; transition: width .2s, opacity .2s; height: 8px; cursor: pointer;
  appearance: none; -webkit-appearance: none; border-radius: 4px; background: linear-gradient(90deg, var(--mango) var(--fill, 80%), #ffffff55 var(--fill, 80%)); }
#volume::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--foam); box-shadow: 0 2px 0 #b9c6d2, 0 1px 6px #0006; }
#volume::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--foam); box-shadow: 0 2px 0 #b9c6d2; }
#sound:hover #volume, #sound:focus-within #volume, #sound.open #volume { width: 110px; opacity: 1; }
#sound:hover, #sound:focus-within, #sound.open { background: var(--ink-soft); }
@media (pointer: coarse) { #volume { width: 90px; opacity: 1; } #sound { background: var(--ink-soft); } }

/* ---------------------------------------------------------------- tactile */
#touch[hidden], #stick-base[hidden] { display: none; }
#stick-zone { position: fixed; left: 0; top: 0; width: 55%; height: 100%; touch-action: none; z-index: 4; }
#stick-base { position: fixed; left: -60px; top: -60px; width: 120px; height: 120px; border-radius: 50%; background: #ffffff22; border: 2px solid #ffffff66; pointer-events: none; }
#stick-knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: #ffffffcc; box-shadow: 0 2px 8px #0005; }
#jump-btn, #dash-btn { position: fixed; border: 0; touch-action: none; z-index: 5; user-select: none; -webkit-user-select: none; font-family: var(--display); }
#jump-btn { right: max(24px, env(safe-area-inset-right)); bottom: max(28px, env(safe-area-inset-bottom)); width: 96px; height: 96px; border-radius: 50%; font-size: 40px; color: var(--ink); background: var(--mango); box-shadow: inset 0 4px 0 #fff8, 0 6px 0 #b78200; }
#dash-btn { right: max(132px, calc(env(safe-area-inset-right) + 108px)); bottom: max(36px, env(safe-area-inset-bottom)); width: 72px; height: 72px; border-radius: 50%; font-size: 34px; color: var(--foam); background: var(--lagoon); box-shadow: inset 0 4px 0 #fff8, 0 5px 0 #1a8f84; }
#jump-btn.on, #dash-btn.on { transform: translateY(4px) scale(.95); }

@media (prefers-reduced-motion: reduce) {
  .logo span, #msg .title, #msg .sub, .pill.bump, #rally.bump, .gummy:active { animation: none; opacity: 1; }
}

/* score et autocollant de rallye : seulement pendant une partie */
body:not(.playing) #hud, body:not(.playing) #rally { display: none; }

/* ---------------------------------------------------------------- sélecteur de langue */
#lang { display: flex; padding: 3px; gap: 2px; border-radius: 16px; background: var(--ink-soft); box-shadow: 0 3px 0 #0b1f31; }
#lang button { padding: 5px 9px 6px; border: 0; border-radius: 12px; font: 400 15px/1 var(--display); color: var(--sand); background: transparent; transition: background .15s, transform .15s; }
#lang button[aria-pressed="true"] { background: var(--mango); color: var(--ink); box-shadow: inset 0 2px 0 #fff8, 0 2px 0 #b78200; }
#lang button:hover { transform: translateY(-2px) rotate(-4deg); }
#lang { align-self: flex-start; margin: 2px 0 0 4px; } /* en bas de la plaque, dans le flux : ne recouvre rien */

/* ---------------------------------------------------------------- survols « juicy » */
@media (hover: hover) {
  .gummy { transition: transform .25s cubic-bezier(.3, 1.8, .5, 1), box-shadow .2s, filter .15s; }
  .gummy:hover { transform: translateY(-4px) rotate(-1deg); animation: jelly-hover .55s cubic-bezier(.3, 1.5, .5, 1); box-shadow: inset 0 3px 0 #ffffff8c, inset 0 -4px 0 #00000024, 0 10px 0 color-mix(in srgb, var(--c) 55%, black), 0 18px 26px #0d243a59; }
  .gummy:hover::after { animation: shine .6s ease-out; }
  .gummy:active { transform: translateY(5px); }
  .swatch { transition: transform .25s cubic-bezier(.3, 1.8, .5, 1); }
  .swatch:hover { transform: translateY(-4px) scale(1.12); animation: jelly-hover .5s; }
  .hat { transition: transform .2s cubic-bezier(.3, 1.8, .5, 1), background .15s; }
  .hat:hover { transform: translateY(-3px) scale(1.05) rotate(-2deg); }
  button.icon { transition: transform .25s cubic-bezier(.3, 1.8, .5, 1); }
  button.icon:hover { transform: scale(1.12) rotate(-8deg); }
  kbd { transition: transform .15s; }
  kbd:hover { transform: translateY(2px); box-shadow: 0 0 0 #c9b38c; }
}
@keyframes jelly-hover { 0% { scale: 1 1; } 30% { scale: 1.05 .93; } 55% { scale: .98 1.04; } 80% { scale: 1.01 .99; } 100% { scale: 1 1; } }
@keyframes shine { from { translate: -20% 0; opacity: 1; } 50% { opacity: .5; } to { translate: 40% 0; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .gummy:hover, .swatch:hover, .gummy:hover::after, .logo span:hover b { animation: none; }
}
.slab .keys { text-align: left; align-self: stretch; }
@media (max-height: 700px) {
  .slab { gap: 10px; padding: 18px 24px 18px; }
  .logo { font-size: clamp(56px, 11vh, 84px); }
  .gummy.xl { font-size: 26px; padding: 12px 20px 14px; }
  .keys { margin-top: 4px; gap: 4px 12px; }
}

/* « Prêt ? Go ! » */
#countdown { position: fixed; top: 30%; left: 0; right: 0; text-align: center; pointer-events: none; z-index: 3;
  font: 400 clamp(48px, 8vw, 86px)/1 var(--display); color: var(--foam); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill;
  text-shadow: 0 7px 0 var(--ink), 0 14px 26px #0006; animation: wobble-in .5s cubic-bezier(.2, 1.6, .4, 1) both; }
#countdown.go { color: var(--mango); font-size: clamp(64px, 11vw, 120px); animation: go-pop .65s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes go-pop { 0% { transform: scale(.3) rotate(-10deg); opacity: 0; } 35% { transform: scale(1.25) rotate(3deg); opacity: 1; } 70% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
body:not(.playing) #countdown { display: none; }
@media (prefers-reduced-motion: reduce) { #countdown, #countdown.go { animation: none; } }

/* « Mon blob » en portrait : tiroir en bas d'écran, le blob reste visible au-dessus */
@media (max-aspect-ratio: 1/1) {
  #custom { left: 8px; right: 8px; top: auto; bottom: max(8px, env(safe-area-inset-bottom)); width: auto; max-height: 50vh; padding: 16px 16px 18px; gap: 9px; border-radius: 24px; }
  #custom h2 { font-size: 26px; }
  #custom .label { margin: 0; font-size: 14px; }
  .swatches { gap: 6px; }
  .swatch { box-shadow: inset 0 3px 0 #ffffff66, inset 0 -3px 0 #0003, 0 2px 0 #0d243a66; }
  .hats { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 6px; scroll-snap-type: x proximity; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
  .hat { flex: 0 0 auto; padding: 10px 14px; white-space: nowrap; scroll-snap-align: start; }
  #custom-ok { padding: 11px 18px 13px; align-items: center; }
}

/* téléphone en paysage : écran très bas, tout doit tenir sans défiler */
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  #menu { padding: 8px 12px; }
  .slab { width: min(560px, 62vw); padding: 12px 16px; gap: 7px; border-radius: 24px; }
  .logo { font-size: 46px; }
  .tagline { display: none; }
  .modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: none; }
  .modes .gummy.xl, .modes .group, .modes .pair { grid-column: 1 / -1; }
  .gummy, .gummy.xl, .pair .gummy { font-size: 17px; padding: 9px 14px 11px; border-radius: 14px; }
  .gummy small { font-size: 12px; margin-top: 1px; }
  .group { margin: 0 0 -4px 2px; font-size: 13px; }
  #lang { margin-top: 0; }
  #custom { top: 8px; right: 8px; max-height: calc(100% - 16px); width: min(400px, 52vw); padding: 12px 14px 14px; gap: 7px; }
  #custom h2 { font-size: 24px; }
  #custom .label { margin: 0; font-size: 13px; }
  .swatches { grid-template-columns: repeat(12, 1fr); gap: 4px; }
  .hats { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; scrollbar-width: none; }
  .hat { flex: 0 0 auto; padding: 8px 12px; white-space: nowrap; }
  #custom-ok { padding: 9px 14px 11px; font-size: 17px; }
  .panel:not(#custom) { max-height: calc(100% - 16px); overflow-y: auto; padding: 14px 18px; gap: 8px; }
  .digits input { height: 52px; font-size: 32px; }
  .big { font-size: 48px; }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .slab .keys { display: none; } /* pas de place pour la légende : elle reste visible en grand écran */
  .slab { flex-direction: column; }
  .gummy::after { height: 4px; top: 4px; }
  .gummy.xl small { display: none; }
  #custom { top: 64px; max-height: calc(100% - 72px); } /* sous le bouton son */
}
