@font-face {
  font-family: "Fredoka";
  src: url("fredoka.woff2") format("woff2");
  font-weight: 300 700;
  font-display: block;
}

:root {
  --plum: #3b2a3a;
  --plum-deep: #2a1d33;
  --pink: #ff8fc1;
  --pink-soft: #ffc7df;
  --pink-hot: #ff5fa2;
  --cream: #fff4e6;
  --pumpkin: #ff9a3c;
  --mint: #8fe3c8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--plum-deep);
  color: var(--cream);
  font-family: "Fredoka", ui-rounded, system-ui, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* ---------- Boutons ---------- */

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

.btn {
  min-width: 220px;
  padding: 14px 26px;
  border-radius: 999px;
  background: var(--cream);
  color: var(--plum);
  font-size: 20px;
  font-weight: 600;
  box-shadow: 0 6px 0 #c9a9b9, 0 10px 24px rgba(0, 0, 0, .3);
  transition: transform .08s ease, box-shadow .08s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: translateY(5px) scale(.98); box-shadow: 0 1px 0 #c9a9b9, 0 4px 12px rgba(0, 0, 0, .3); }
.btn.big { font-size: 26px; padding: 16px 34px; min-width: 250px; }
.btn.pink { background: var(--pink); color: #fff; box-shadow: 0 6px 0 #c4517f, 0 10px 24px rgba(0, 0, 0, .3); text-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.btn.pink:active { box-shadow: 0 1px 0 #c4517f; }
.btn.ghost { background: transparent; color: var(--pink-soft); box-shadow: none; min-width: 0; }
.btn:disabled { opacity: .45; }

.round-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 244, 230, .16);
  color: var(--cream);
  font-size: 20px;
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.round-btn:active { transform: scale(.92); }
.icon-btn { width: 52px; height: 52px; padding: 0; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .3)); }
.icon-btn img { width: 100%; height: 100%; object-fit: contain; }
.icon-btn:active { transform: scale(.9); }
.icon-btn.off { opacity: .35; filter: grayscale(.8); }
.round-btn.off { opacity: .4; text-decoration: line-through; }

.candy-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6b0 0 18%, #ffcf3a 40%, #e89a12 100%);
  box-shadow: 0 0 0 2px var(--plum);
  flex: none;
}

/* ---------- Écrans ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  padding: calc(var(--safe-top) + 24px) 16px calc(var(--safe-bottom) + 24px);
  background: radial-gradient(ellipse at 50% 30%, rgba(90, 50, 90, .88), rgba(30, 18, 36, .97));
  text-align: center;
  animation: fade-in .25s ease;
  overflow-y: auto;
}
#home { background: radial-gradient(ellipse at 50% 35%, #6b3d70 0%, #3b2440 55%, #22152a 100%); }

/* Centré verticalement, mais défilable sans rien couper quand l'écran est petit. */
.screen > :first-child { margin-top: auto; }
.screen > :last-child { margin-bottom: auto; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.stack { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.toggles { display: flex; gap: 12px; }

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: .9;
  font-weight: 700;
  transform: rotate(-4deg);
  animation: logo-bob 3s ease-in-out infinite;
}
.logo span {
  font-size: clamp(64px, 19vw, 110px);
  color: var(--pink);
  -webkit-text-stroke: 6px var(--plum);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--plum), 0 12px 24px rgba(0, 0, 0, .45);
  letter-spacing: 1px;
}
.logo .l2 { color: var(--pumpkin); margin-left: 70px; }
@keyframes logo-bob { 0%, 100% { transform: rotate(-4deg) translateY(0); } 50% { transform: rotate(-2deg) translateY(-6px); } }

#home-shinzo { width: 250px; height: 214px; }
.sheet { justify-content: flex-start; }
.sheet > :first-child { margin-top: 0; }

.home-best { color: var(--pink-soft); font-size: 16px; min-height: 20px; }

.hint { font-size: 14px; color: rgba(255, 244, 230, .65); line-height: 1.4; }

h2 {
  font-size: 40px;
  color: var(--pink);
  -webkit-text-stroke: 5px var(--plum);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--plum);
}
.sub { color: var(--pink-soft); }

.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(340px, 100%);
}
.results .cell { background: rgba(255, 244, 230, .1); border-radius: 18px; padding: 10px; }
.results .cell b { display: block; font-size: 24px; color: #fff; }
.results .cell span { font-size: 13px; color: var(--pink-soft); }
.results .cell.wide { grid-column: 1 / -1; }
.results .record { color: var(--pumpkin); font-weight: 700; }

.scene { width: min(220px, 55vw); height: auto; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .35)); animation: logo-bob 3s ease-in-out infinite; }
.scene.small { width: min(170px, 42vw); }

/* ---------- Boutique ---------- */

.tabs { display: flex; gap: 6px; background: rgba(0, 0, 0, .25); padding: 5px; border-radius: 999px; }
.tab { padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 16px; color: var(--pink-soft); }
.tab.on { background: var(--pink); color: #fff; }
.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; width: min(620px, 100%); }
.skin-card {
  position: relative;
  background: rgba(255, 244, 230, .1);
  border-radius: 20px;
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 3px solid transparent;
}
.skin-card.on { border-color: var(--pink); background: rgba(255, 143, 193, .22); }
.skin-card img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.skin-card.locked img { filter: brightness(.35) saturate(.4); }
.skin-card b { font-size: 14px; line-height: 1.1; }
.skin-card small { font-size: 12px; color: var(--pink-soft); }
.skin-card .btn { min-width: 0; width: 100%; padding: 6px 8px; font-size: 15px; box-shadow: 0 4px 0 #c9a9b9; }
.btn-ico { width: 22px; height: 22px; object-fit: contain; }
.shop-item .ico img { width: 44px; height: 44px; object-fit: contain; }

.wallet { display: flex; align-items: center; gap: 8px; font-size: 22px; font-weight: 600; }
.shop-list { display: flex; flex-direction: column; gap: 10px; width: min(420px, 100%); }
.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 244, 230, .1);
  border-radius: 20px;
  padding: 10px 12px;
  text-align: left;
}
.shop-item .ico { font-size: 30px; width: 44px; text-align: center; }
.shop-item .txt { flex: 1; }
.shop-item .txt b { display: block; font-size: 17px; }
.shop-item .txt small { color: var(--pink-soft); font-size: 13px; }
.shop-item .lvl { display: flex; gap: 3px; margin-top: 4px; }
.shop-item .lvl i { width: 10px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .2); }
.shop-item .lvl i.on { background: var(--pink); }
.shop-item .btn { min-width: 0; padding: 8px 14px; font-size: 16px; box-shadow: 0 4px 0 #c9a9b9; }

/* ---------- HUD ---------- */

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }

.hud-top {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wallet-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px 6px 8px;
  border-radius: 999px;
  background: rgba(30, 18, 36, .7);
  box-shadow: inset 0 0 0 3px var(--plum), 0 4px 12px rgba(0, 0, 0, .3);
  font-size: 26px;
  font-weight: 700;
  color: #ffcf3a;
  text-shadow: 0 2px 0 var(--plum);
}
.wallet-ico { width: 34px; height: 34px; object-fit: contain; }
.wallet-ico.big { width: 54px; height: 54px; }
.wallet-pill.pop .wallet-ico { animation: pop .18s ease; }
.hud-btns { display: flex; gap: 8px; }

.objective {
  position: absolute;
  top: calc(var(--safe-top) + 66px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(30, 18, 36, .6);
  color: #ffcf3a;
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  text-shadow: 0 2px 0 var(--plum);
}
.objective:empty { display: none; }

.hud-bottom {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 14px);
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.action-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 84px;
  padding: 8px 4px;
  border-radius: 22px;
  background: rgba(30, 18, 36, .7);
  box-shadow: inset 0 0 0 3px var(--plum), 0 5px 0 rgba(0, 0, 0, .3);
  font-size: 13px;
  font-weight: 600;
  color: var(--cream);
}
.action-btn .ico { width: 44px; height: 44px; object-fit: contain; }
.action-btn:active { transform: translateY(3px); }
.action-btn .dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--pink-hot);
  box-shadow: 0 0 0 3px var(--plum);
  animation: pop 1s ease infinite;
}

/* ---------- Retour d'absence ---------- */

.welcome-amount { display: flex; align-items: center; gap: 10px; font-size: 44px; font-weight: 700; color: #ffcf3a; text-shadow: 0 3px 0 var(--plum); }
.gold-pumpkin { width: 150px; height: 150px; filter: drop-shadow(0 0 24px rgba(255, 207, 58, .6)); }
.gold-pumpkin img { width: 100%; height: 100%; object-fit: contain; }
.gold-pumpkin.hit { animation: wobble .2s ease; }
.gold-pumpkin.done { opacity: .3; pointer-events: none; }
@keyframes wobble { 30% { transform: scale(1.15, .85); } 60% { transform: scale(.92, 1.08); } }

.banner {
  position: absolute;
  top: 32%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 30px;
  font-weight: 700;
  color: #fff;
  -webkit-text-stroke: 5px var(--plum);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--plum);
  opacity: 0;
  pointer-events: none;
  padding: 0 16px;
}
.banner small { display: block; font-size: 16px; color: var(--pink-soft); -webkit-text-stroke: 3px var(--plum); }
.banner.show { animation: banner 2.8s ease forwards; }
@keyframes banner {
  0% { opacity: 0; transform: scale(.4) rotate(-6deg); }
  12% { opacity: 1; transform: scale(1.12) rotate(2deg); }
  20% { transform: scale(1) rotate(0); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.9) translateY(-20px); }
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(20, 8, 28, 0) 55%, rgba(20, 8, 28, .5) 100%);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 90px);
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(30, 18, 36, .9);
  color: var(--pink-soft);
  font-size: 12px;
  pointer-events: none;
  z-index: 50;
}

#debug {
  position: fixed;
  left: 8px;
  bottom: calc(var(--safe-bottom) + 100px);
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .6);
  color: #8fe3c8;
  font: 12px ui-monospace, monospace;
  pointer-events: none;
  z-index: 50;
  white-space: pre;
}

@media (min-width: 700px) {
  .hud-top, .hud-bottom { left: 32px; right: 32px; }
}
