/* ===== ZIGOUIGOUI — style arcade cartoon ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --pink: #ff6fa5;
  --pink-dark: #e04c85;
  --yellow: #ffd93d;
  --purple: #6c5ce7;
  --ink: #2d2440;
}

html, body {
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(1200px 700px at 15% 10%, rgba(255,255,255,.18), transparent 55%),
    radial-gradient(900px 600px at 90% 80%, rgba(255,120,180,.22), transparent 50%),
    radial-gradient(700px 500px at 50% 110%, rgba(255, 210, 80, .16), transparent 45%),
    linear-gradient(160deg, #2a1b5c 0%, #6b3fa8 42%, #c44d8c 100%);
  font-family: "Fredoka", "Segoe UI", "Trebuchet MS", sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
body::before, body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
  filter: blur(8px);
}
body::before {
  width: 42vw; height: 42vw;
  left: -12vw; top: -10vh;
  background: radial-gradient(circle, rgba(255, 130, 200, .35), transparent 68%);
  animation: blob-drift 11s ease-in-out infinite alternate;
}
body::after {
  width: 36vw; height: 36vw;
  right: -10vw; bottom: -12vh;
  background: radial-gradient(circle, rgba(255, 210, 90, .28), transparent 68%);
  animation: blob-drift 14s ease-in-out infinite alternate-reverse;
}
@keyframes blob-drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(4vw, -3vh) scale(1.12); }
}

#app {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

#stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  width: min(calc(100vw - 16px), calc((100vh - 16px) * 896 / 640));
  max-height: calc(100vh - 16px);
}
#stage:has(#hud:not(.hidden)) {
  width: min(calc(100vw - 16px), calc((100vh - 72px) * 896 / 640));
  gap: 8px;
}

#game-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 896 / 640;
  min-height: 0;
  flex: 1 1 auto;
  border-radius: 22px;
  box-shadow:
    0 36px 90px rgba(10, 4, 24, .62),
    0 0 0 4px color-mix(in srgb, var(--aura, #ff6fa5) 78%, #fff 12%),
    0 0 0 10px rgba(12, 6, 24, .45),
    0 0 42px color-mix(in srgb, var(--aura, #ff6fa5) 50%, transparent),
    inset 0 2px 0 rgba(255,255,255,.35);
  overflow: hidden;
  background: #120c22;
  container-type: size;
  container-name: stage;
  --aura: #ff6fa5;
}
#game-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  border-radius: inherit;
  box-shadow: inset 0 0 80px rgba(8, 2, 20, .28);
  background: linear-gradient(180deg, rgba(255,255,255,.08), transparent 18%, transparent 82%, rgba(0,0,0,.18));
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== HUD — barre au-dessus de la map ===== */
#hud {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
  pointer-events: none;
  z-index: 5;
  flex-shrink: 0;
}
#hud::before { display: none; }
.hud-left, .hud-right {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.hud-left { flex-direction: row; }
.hud-right { justify-content: flex-end; }
.hud-mood {
  color: #fff;
  font-size: clamp(12px, 1.6vw, 15px);
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.2;
  opacity: 1;
  white-space: nowrap;
  background: rgba(10, 6, 24, .86);
  border: 2px solid rgba(255,255,255,.4);
  border-radius: 999px;
  padding: 4px 12px;
  text-shadow: 0 1px 2px #000, 0 0 8px rgba(0,0,0,.7);
}

.hud-pill {
  background: rgba(10, 6, 24, .9);
  color: #fff;
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: clamp(13px, 1.7vw, 18px);
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000, 0 0 8px rgba(0,0,0,.65);
  box-shadow:
    0 6px 16px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.28);
}
.hud-pill.score {
  background: linear-gradient(180deg, #ffb0d0, #ff6fa5 55%, #e04c85);
  border-color: rgba(255,255,255,.75);
  text-shadow: 0 1px 0 rgba(90, 20, 50, .45);
}
.hud-pill.lives {
  background: linear-gradient(180deg, #fff1a8, #ffd93d 55%, #e8b020);
  color: #2a1804;
  border-color: rgba(255,255,255,.85);
  text-shadow: 0 1px 0 rgba(255,255,255,.45);
}
.hud-pill.goal {
  background: linear-gradient(180deg, #7ee0ff, #3aa8e8 55%, #1f7ab8);
  border-color: rgba(255,255,255,.75);
  text-shadow: 0 1px 0 rgba(20, 40, 80, .35);
}

#hud-bonuses { display: flex; gap: 6px; }
.bonus-chip {
  display: flex; flex-direction: column; align-items: center;
  background: rgba(10, 6, 24, .9);
  border: 2px solid var(--yellow);
  border-radius: 12px;
  padding: 4px 10px;
  color: #fff;
  font-size: clamp(12px, 1.6vw, 15px);
  font-weight: 800;
  text-shadow: 0 1px 2px #000;
  animation: chip-pop .25s ease-out;
}
.bonus-chip .bar {
  width: 40px; height: 5px;
  background: rgba(255,255,255,.25);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
}
.bonus-chip .bar > i {
  display: block; height: 100%;
  background: var(--yellow);
  border-radius: 3px;
}
@keyframes chip-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* ===== Écrans / overlays ===== */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.2cqi, 12px);
  text-align: center;
  background:
    radial-gradient(700px 420px at 50% 18%, rgba(255, 150, 200, .18), transparent 55%),
    rgba(10, 6, 24, .82);
  backdrop-filter: blur(14px) saturate(1.2);
  color: #fff;
  padding: clamp(10px, 2cqi, 20px);
  overflow-y: auto;
  animation: screen-in .3s ease-out;
}
@keyframes screen-in { from { opacity: 0; transform: scale(1.05); } to { opacity: 1; transform: scale(1); } }

.hidden { display: none !important; }

.game-title {
  font-family: "Bangers", "Fredoka", sans-serif;
  font-size: clamp(32px, 7.5cqi, 84px);
  letter-spacing: 3px;
  line-height: .92;
  margin-bottom: 0;
  color: #fff;
  background: linear-gradient(180deg, #fff7d1 0%, #ffe56a 28%, #ff8fbb 62%, #ff5aa0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #3a1848) drop-shadow(0 10px 22px rgba(255, 80, 140, .45));
  transform: none;
  animation: title-bounce 2.8s ease-in-out infinite;
}
@keyframes title-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.screen-title {
  font-family: "Bangers", "Fredoka", sans-serif;
  font-size: clamp(32px, 6cqi, 62px);
  letter-spacing: 2px;
  color: var(--yellow);
  text-shadow: 3px 4px 0 rgba(0,0,0,.4);
}
.rainbow-text { animation: rainbow 1.5s linear infinite; }
@keyframes rainbow { 0%{color:#ff6fa5} 25%{color:#ffd93d} 50%{color:#6ee86e} 75%{color:#6fc3ff} 100%{color:#ff6fa5} }

.tagline { font-size: clamp(13px, 2.1cqi, 22px); opacity: .92; line-height: 1.35; }
.tagline.small { font-size: clamp(12px, 1.8cqi, 16px); opacity: .75; }
.best-line { font-size: clamp(14px, 2.2cqi, 24px); font-weight: bold; color: var(--yellow); }
.best-line.small { font-size: clamp(12px, 1.8cqi, 16px); color: #9ef59e; }
.controls-hint { font-size: clamp(11px, 1.6cqi, 15px); opacity: .6; margin-top: 2px; }

.menu-buttons { display: flex; flex-direction: column; gap: clamp(6px, 1.2cqi, 10px); margin-top: 2px; }

.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(15px, 2.4cqi, 22px);
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff, #efe8ff 55%, #ddd0ff);
  border: 2px solid rgba(255,255,255,.85);
  border-bottom: 5px solid rgba(40, 16, 60, .22);
  border-radius: 999px;
  padding: clamp(8px, 1.3cqi, 12px) clamp(28px, 4.5cqi, 44px);
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0,0,0,.22), inset 0 1px 0 #fff;
  transition: transform .12s, filter .12s, box-shadow .12s;
}
.btn:hover, .btn:focus-visible { transform: translateY(-2px) scale(1.03); filter: brightness(1.04); outline: none; }
.btn:active { transform: translateY(1px) scale(.98); border-bottom-width: 2px; }
.btn.big {
  background: linear-gradient(180deg, #fff4b0, #ffe56a 40%, var(--yellow) 70%, #e8b020);
  font-size: clamp(18px, 3.2cqi, 32px);
  padding: clamp(10px, 1.6cqi, 16px) clamp(36px, 5.5cqi, 56px);
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
}
.btn.back { background: rgba(255,255,255,.85); margin-top: 8px; }

/* ===== Grilles de niveaux et skins ===== */
#level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: min(860px, 92%);
  max-height: 58%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 217, 61, .8) rgba(255, 255, 255, .12);
}
.level-card {
  background: linear-gradient(180deg, color-mix(in srgb, var(--aura, #fff) 28%, rgba(255,255,255,.16)), rgba(16, 8, 28, .42));
  border: 3px solid color-mix(in srgb, var(--aura, #fff) 62%, rgba(255,255,255,.4));
  border-radius: 18px;
  padding: 10px 8px 12px;
  cursor: pointer;
  color: #fff;
  font-family: inherit;
  font-weight: bold;
  box-shadow: 0 10px 22px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .1s;
  --aura: #ffd93d;
}
.level-card:hover:not(.locked), .level-card:focus-visible { transform: scale(1.04); border-color: var(--yellow); outline: none; }
.level-card .lv-emoji { font-size: clamp(24px, 4.4cqi, 40px); display: block; }
.level-card .lv-name { font-size: clamp(13px, 2.1cqi, 17px); display: block; margin-top: 4px; }
.level-card .lv-soul {
  display: block;
  margin-top: 4px;
  font-size: clamp(10px, 1.5cqi, 13px);
  color: var(--yellow);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.level-card .lv-mood {
  display: block;
  margin-top: 3px;
  font-size: clamp(10px, 1.45cqi, 12px);
  font-weight: 600;
  line-height: 1.25;
  opacity: .82;
  white-space: normal;
}
.level-card.locked { opacity: .4; cursor: not-allowed; filter: grayscale(1); }

.hud-actions {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.action-btn {
  pointer-events: auto;
  width: clamp(56px, 7cqi, 76px);
  height: clamp(56px, 7cqi, 76px);
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--pink);
  font-size: clamp(24px, 3.4cqi, 34px);
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,.25);
}
.action-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
#btn-puchita { background: #ff7eb3; }

#shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: min(860px, 94%);
  max-height: 46%;
  overflow: auto;
}
.shop-card {
  background: rgba(255,255,255,.12);
  border: 3px solid rgba(255,255,255,.35);
  border-radius: 14px;
  padding: 8px 10px;
  color: #fff;
  text-align: left;
  font-family: inherit;
}
.shop-card h3 {
  font-size: clamp(14px, 2.2cqi, 18px);
  margin: 0 0 4px;
}
.shop-card p {
  font-size: clamp(11px, 1.8cqi, 14px);
  opacity: .8;
  line-height: 1.35;
  margin: 0 0 6px;
}
.shop-card .shop-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: clamp(11px, 1.5vw, 13px);
  font-weight: bold;
}
.shop-card button {
  font-family: inherit;
  font-weight: bold;
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  background: var(--yellow);
  color: var(--ink);
}
.shop-card button:disabled {
  opacity: .45;
  cursor: not-allowed;
  background: #ccc;
}
.shop-card.locked { opacity: .55; }
.shop-card.locked button { background: #ccc; cursor: not-allowed; }

#unlock-list { width: min(520px, 90%); }
.unlock-item {
  background: rgba(255,255,255,.12);
  border: 2px solid rgba(255,217,61,.7);
  border-radius: 16px;
  padding: 12px 16px;
  margin: 8px 0;
  color: #fff;
  font-size: clamp(14px, 2.2cqi, 18px);
  line-height: 1.4;
}
.unlock-item span { font-size: 0.85em; opacity: .85; }

#skin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(980px, 94%);
  max-height: 52%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 217, 61, .8) rgba(255, 255, 255, .12);
}
#skin-grid::-webkit-scrollbar { width: 8px; }
#skin-grid::-webkit-scrollbar-track { background: rgba(255,255,255,.08); border-radius: 8px; }
#skin-grid::-webkit-scrollbar-thumb { background: rgba(255, 217, 61, .8); border-radius: 8px; }
.skin-card {
  background: rgba(255,255,255,.12);
  border: 3px solid rgba(255,255,255,.35);
  border-radius: 16px;
  padding: 10px 6px;
  cursor: pointer;
  color: #fff;
  font-family: inherit;
  font-weight: bold;
  transition: transform .1s;
}
.skin-card:hover:not(.locked), .skin-card:focus-visible { transform: scale(1.06); outline: none; }
.skin-card.selected { border-color: var(--yellow); background: rgba(255, 217, 61, .18); }
.skin-card.locked { opacity: .45; cursor: not-allowed; }
.skin-card canvas { width: 96px; height: 50px; display: block; margin: 0 auto 4px; }
.skin-card .sk-name { font-size: clamp(12px, 2cqi, 17px); display: block; }
.skin-card .sk-unlock { font-size: clamp(10px, 1.6cqi, 13px); opacity: .75; display: block; margin-top: 2px; }

/* ===== Toast ===== */
#toast {
  position: absolute;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: linear-gradient(180deg, #fff8c8, #ffd93d);
  color: #1a1028;
  font-weight: 800;
  font-size: clamp(15px, 2.5cqi, 22px);
  padding: 12px 22px;
  border-radius: 999px;
  border: 3px solid #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.5), 0 0 0 3px rgba(20, 8, 32, .45), inset 0 1px 0 #fff;
  animation: toast-in .3s ease-out;
  pointer-events: none;
  max-width: min(92%, 540px);
  white-space: normal;
  text-align: center;
  line-height: 1.25;
  text-shadow: 0 1px 0 rgba(255,255,255,.7);
}
@keyframes toast-in { from { transform: translateX(-50%) translateY(60px); } to { transform: translateX(-50%) translateY(0); } }

#menu-hero {
  width: min(200px, 42cqi);
  height: auto;
  max-height: 56px;
  margin: 0;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
}

@container stage (max-height: 480px) {
  #screen-menu {
    justify-content: flex-start;
    gap: 3px;
    padding: 8px 12px 40px;
  }
  #screen-menu .game-title { font-size: clamp(26px, 7.5cqi, 40px); }
  #screen-menu .controls-hint { display: none; }
  #menu-hero { max-height: 36px; width: min(150px, 36cqi); }
}

#screen-menu { overflow: hidden; }

.play-hint {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  z-index: 8;
  background: rgba(16, 8, 32, .78);
  color: #fff;
  font-weight: 700;
  font-size: clamp(13px, 2.1cqi, 18px);
  padding: 10px 18px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.35);
  pointer-events: none;
  text-align: center;
  max-width: 86%;
  animation: toast-in .35s ease-out;
}

.mute-btn {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 20;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4);
  background: rgba(16, 8, 32, .7);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
}
.mute-btn:hover { transform: scale(1.06); }
