/* La Pépé App : fond rose clair uni, épuré, police nette et petits détails en monospace. */
:root {
  --pink: #ff4f9a;
  --pink-soft: #ffd3e6;
  --pink-pale: #fff0f6;
  --ink: #1d1418;
  --grey: #6f5060;
  --bg: #ffc9e0;
  --line: #f3d9e5;
  --white: #ffffff;
  --shadow: 0 10px 30px rgba(190, 60, 120, 0.08);
  --sans: "Geist", "Inter", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font: 500 16px/1.45 var(--sans);
  background: var(--bg);
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--pink); }

/* ---------- Structure ---------- */
.app { max-width: 560px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.logo { display: flex; align-items: center; gap: 8px; font: 600 15px var(--mono); letter-spacing: -0.02em; white-space: nowrap; }
.logo i { width: 22px; height: 22px; border-radius: 7px; background: var(--pink); display: grid; place-items: center; }
.logo i::after { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--white); }

.tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 12px; background: var(--white); box-shadow: inset 0 0 0 1px var(--line); }
.tabs .slider { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 9px; background: var(--ink); transform: translateX(calc(var(--i, 0) * 100%)); transition: transform .35s cubic-bezier(.3, 1.3, .5, 1); }
.tabs button { position: relative; z-index: 1; border: 0; background: none; padding: 7px 12px; font: 600 13.5px var(--sans); letter-spacing: -0.01em; white-space: nowrap; color: var(--grey); transition: color .25s; }
.tabs button.active { color: var(--white); }
.tabs .count { font: 500 11px var(--mono); margin-left: 4px; opacity: .7; }

.label { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--grey); display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.label .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pink); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.hero { font-weight: 700; font-size: clamp(2.6rem, 12vw, 4rem); line-height: .95; letter-spacing: -0.055em; margin: 0 0 10px; }
.hero .pink, .title .pink { color: var(--pink); }
.sub { margin: 0 0 22px; font-size: 1.05rem; color: var(--grey); }
.mono { font-family: var(--mono); }
.switch { border: 0; background: none; padding: 0; margin-left: 4px; font: 500 .85rem var(--mono); color: var(--grey); text-decoration: underline; text-underline-offset: 3px; }
.small { font-size: .88rem; }
.muted { color: var(--grey); }

.panel { border-radius: 18px; background: var(--white); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); }

.btn {
  width: 100%; border: 0; border-radius: 14px; padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: var(--white); font: 600 1.08rem var(--sans); letter-spacing: -0.02em;
  box-shadow: 0 12px 28px rgba(29, 20, 24, .18);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn kbd { font: 500 12px var(--mono); padding: 4px 8px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .08); }
.btn:hover { transform: translateY(-1px); box-shadow: 0 16px 32px rgba(29, 20, 24, .22); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .7; }
.btn.light { background: var(--pink); color: var(--white); box-shadow: 0 10px 24px rgba(255, 79, 154, .3); }
.btn.outline { background: var(--white); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); justify-content: center; font-size: .98rem; padding: 14px 18px; }

/* ---------- Photo du jour : avant ---------- */
.mystery { position: relative; height: clamp(220px, calc(100vh - 430px), 420px); margin-bottom: 14px; overflow: hidden; display: grid; place-items: center; }
.mystery .q { font: 300 clamp(6rem, 22vh, 10rem)/1 var(--mono); letter-spacing: -0.08em; color: var(--pink); animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.mystery::before { content: ""; position: absolute; width: 60%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, var(--pink-soft), transparent 70%); animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.12); opacity: .7; } }

/* ---------- Photo du jour : après ---------- */
.title { font-weight: 700; font-size: clamp(2.2rem, 10vw, 3.4rem); line-height: .98; letter-spacing: -0.05em; margin: 0 0 18px; overflow-wrap: anywhere; }
.title .ch { display: inline-block; animation: rise-ch .5s cubic-bezier(.2, 1, .3, 1) both; }
@keyframes rise-ch { from { transform: translateY(.5em); opacity: 0; filter: blur(4px); } }
.photo { margin: 0 auto; max-width: min(100%, calc(62vh * .75)); border-radius: 20px; overflow: hidden; background: var(--white); box-shadow: inset 0 0 0 1px var(--line), 0 20px 50px rgba(190, 60, 120, .15); animation: reveal .9s cubic-bezier(.2, 1, .3, 1) both; }
.photo img { display: block; width: 100%; height: auto; cursor: zoom-in; background: var(--pink-pale); }
.photo figcaption { display: flex; justify-content: space-between; gap: 10px; padding: 11px 14px; font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--grey); }
@keyframes reveal { from { clip-path: inset(0 0 100% 0 round 20px); transform: translateY(10px); } to { clip-path: inset(0 0 0 0 round 20px); } }
.next { margin-top: 14px; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.next .time { font: 600 clamp(2rem, 10vw, 2.6rem)/1 var(--mono); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.next .bar { flex-basis: 100%; height: 4px; border-radius: 4px; background: var(--pink-pale); overflow: hidden; }
.next .bar i { display: block; height: 100%; background: var(--pink); border-radius: inherit; transition: width 1s linear; }

/* ---------- Collection ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile { border: 0; border-radius: 16px; overflow: hidden; background: var(--white); padding: 0; text-align: left; display: flex; flex-direction: column; justify-content: flex-start; align-self: start; box-shadow: inset 0 0 0 1px var(--line), var(--shadow); animation: tile-in .45s cubic-bezier(.2, 1, .3, 1) both; transition: transform .2s; }
.tile:hover { transform: translateY(-2px); }
@keyframes tile-in { from { opacity: 0; transform: translateY(10px); } }
.tile img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--pink-pale); }
/* Les cartes rares : cadre doré qui brille */
.tile.rare { box-shadow: 0 0 0 3px #f2c94c, 0 12px 30px rgba(214, 160, 20, .35); position: relative; }
.tile.rare .t::before { content: "✦ RARE"; display: block; font: 600 11px var(--mono); letter-spacing: .08em; color: #b8860b; margin-bottom: 3px; }
.tile.rare::after { content: ""; position: absolute; left: 0; right: 0; top: 0; aspect-ratio: 3 / 4; pointer-events: none; background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .55) 50%, transparent 65%); background-size: 250% 100%; animation: shine 3s ease-in-out infinite; }
@keyframes shine { from { background-position: 120% 0; } to { background-position: -120% 0; } }
.rare-label { color: #b8860b; }
.photo.rare { position: relative; box-shadow: 0 0 0 3px #f2c94c, 0 0 40px rgba(242, 201, 76, .6), 0 20px 50px rgba(190, 60, 120, .2); }
.photo.rare::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .5) 47%, rgba(255, 150, 230, .3) 52%, transparent 65%); background-size: 250% 100%; mix-blend-mode: screen; animation: shine 3.2s ease-in-out infinite; }
.rare-label .dot { background: #f2c94c; }
.tile .meta { display: block; padding: 9px 11px 11px; }
.tile .n { font: 500 11px var(--mono); color: var(--grey); letter-spacing: .04em; }
.tile .t { display: block; padding: 10px 12px 12px; font-weight: 600; font-size: .95rem; letter-spacing: -0.02em; line-height: 1.2; overflow-wrap: anywhere; }
.empty { padding: 28px 18px; text-align: center; }

/* ---------- Le tirage : un rouleau de machine à sous ---------- */
.spin {
  position: fixed; inset: 0; z-index: 40; display: grid; align-content: center; justify-items: center; gap: 22px; padding: 0 16px; text-align: center;
  background: var(--bg); animation: fade-in .25s ease both;
}
.spin.leaving { animation: fade-out .45s ease forwards; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.spin-text { font: 600 13px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--grey); min-height: 1.4em; margin: 0; }
.reel { position: relative; width: min(100%, 420px); height: calc(var(--h) * 3); overflow: hidden; border-radius: 22px; background: var(--white); box-shadow: inset 0 0 0 1px var(--line), 0 24px 60px rgba(190, 60, 120, .18); }
.reel::before, .reel::after { content: ""; position: absolute; left: 0; right: 0; height: var(--h); z-index: 2; pointer-events: none; }
.reel::before { top: 0; background: linear-gradient(var(--white), rgba(255, 255, 255, .4)); }
.reel::after { bottom: 0; background: linear-gradient(rgba(255, 255, 255, .4), var(--white)); }
.reel-window { position: absolute; left: 10px; right: 10px; top: var(--h); height: var(--h); border-radius: 14px; box-shadow: inset 0 0 0 2px var(--pink); z-index: 3; pointer-events: none; }
.reel-track { will-change: transform; }
.reel-item { height: var(--h); display: flex; align-items: center; gap: 14px; padding: 0 22px; text-align: left; }
.reel-item .thumb { width: calc(var(--h) - 22px); height: calc(var(--h) - 22px); border-radius: 12px; flex: none; background: var(--pink-soft) center / cover; filter: blur(5px); }
.reel-item .name { font-weight: 700; font-size: 1.35rem; letter-spacing: -0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reel-item.win .thumb { filter: none; transition: filter .5s ease; }
.reel-item.win .name { color: var(--pink); }
.reel.won { animation: thump .5s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes thump { 40% { transform: scale(1.04); } }

.confetti { position: fixed; z-index: 60; left: 50%; top: 45%; width: 8px; height: 8px; border-radius: 2px; pointer-events: none; animation: confetti 1.5s cubic-bezier(.15, .7, .3, 1) forwards; }
@keyframes confetti {
  from { transform: translate(-50%, -50%) rotate(0); opacity: 1; }
  to { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)); opacity: 0; }
}

/* ---------- En grand, on glisse pour passer à la suivante ---------- */
.viewer { position: fixed; inset: 0; z-index: 50; background: var(--bg); animation: fade-in .2s ease; }
.slides { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior: contain; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; margin: 0; scroll-snap-align: center; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 64px 16px 32px; }
.slide img { max-width: 100%; max-height: 72vh; border-radius: 18px; box-shadow: 0 20px 50px rgba(190, 60, 120, .2); }
.slide figcaption { font-weight: 700; font-size: 1.5rem; letter-spacing: -0.04em; text-align: center; }
.viewer-close { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px; z-index: 2; width: 42px; height: 42px; border: 0; border-radius: 12px; background: var(--white); box-shadow: inset 0 0 0 1px var(--line); font-size: 1rem; }
.viewer-nav { position: absolute; top: 50%; z-index: 2; width: 44px; height: 44px; margin-top: -22px; border: 0; border-radius: 12px; background: var(--white); box-shadow: inset 0 0 0 1px var(--line), var(--shadow); font: 600 1rem var(--mono); }
.viewer-nav.prev { left: 16px; }
.viewer-nav.next { right: 16px; }
@media (max-width: 700px), (hover: none) { .viewer-nav { display: none; } }

/* ---------- Grand écran, compte ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(255, 201, 224, .95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: grid; place-items: center; padding: 16px; animation: fade-in .2s ease; text-align: center; }
.lightbox img { max-width: 100%; max-height: 76vh; border-radius: 18px; box-shadow: 0 20px 50px rgba(190, 60, 120, .2); }
.lightbox .title { font-size: 1.8rem; margin: 14px 0 2px; }
.gate { min-height: 70vh; display: grid; align-content: center; gap: 12px; }
.logout { text-align: center; margin: 18px 0 0; }
.error { margin: 0; text-align: center; font-weight: 600; color: #c4125f; }
.field { width: 100%; font: 500 1.1rem var(--sans); color: var(--ink); text-align: center; border: 0; border-radius: 14px; padding: 17px 18px; background: var(--white); outline: none; box-shadow: inset 0 0 0 1px var(--line), var(--shadow); }
.field:focus { box-shadow: inset 0 0 0 2px var(--pink), var(--shadow); }
.shake { animation: shake .4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.swap-in { animation: swap-in .4s cubic-bezier(.2, 1, .3, 1) both; }
@keyframes swap-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Proposition d'installation ---------- */
.install {
  position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 35;
  max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--ink); color: var(--white); border-radius: 16px; padding: 12px 12px 12px 14px;
  box-shadow: 0 16px 40px rgba(29, 20, 24, .25); animation: slide-up .5s cubic-bezier(.2, 1.2, .4, 1) both;
}
.install.leaving { animation: slide-down .35s ease forwards; }
.install > img { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.install-text { flex: 1; font-size: .88rem; line-height: 1.3; }
.install-text > b { display: block; font-size: .98rem; margin-bottom: 2px; }
.install .share { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .3); font-size: .75rem; }
.install-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.install .btn-install { border: 0; background: var(--pink); color: var(--white); padding: 9px 14px; border-radius: 9px; font-weight: 600; }
.install-close { border: 1px solid rgba(255, 255, 255, .25); background: none; width: 32px; height: 32px; border-radius: 9px; }
body:has(.install) .app { padding-bottom: 120px; }
@keyframes slide-up { from { transform: translateY(150%); } }
@keyframes slide-down { to { transform: translateY(150%); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
