:root {
  --night: #0b1028; --indigo: #18204a; --panel: rgba(24, 32, 74, .72); --line: rgba(216, 180, 90, .28);
  --gold: #e2bd62; --gold-2: #f4dc95; --cream: #f6ecd2; --muted: #a9b0d6; --rose: #ef6f8e; --teal: #45c7b5;
  --radius: 14px; --card-w: 128px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse at 50% -10%, #2c3778 0%, var(--indigo) 38%, var(--night) 80%) fixed;
  color: var(--cream); font: 16px/1.4 Nunito, system-ui, sans-serif; -webkit-tap-highlight-color: transparent;
}
.stars { position: fixed; inset: 0; pointer-events: none; opacity: .55;
  background-image: radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent), radial-gradient(1px 1px at 72% 12%, #fff 50%, transparent),
    radial-gradient(1.5px 1.5px at 38% 62%, #f4dc95 50%, transparent), radial-gradient(1px 1px at 86% 48%, #fff 50%, transparent),
    radial-gradient(1px 1px at 22% 82%, #fff 50%, transparent), radial-gradient(1.5px 1.5px at 58% 34%, #fff 50%, transparent),
    radial-gradient(1px 1px at 92% 86%, #f4dc95 50%, transparent), radial-gradient(1px 1px at 6% 52%, #fff 50%, transparent);
  animation: twinkle 6s ease-in-out infinite alternate; }
@keyframes twinkle { to { opacity: .25; } }
#app { position: relative; max-width: 1100px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }

h1, h2, .clue, .code { font-family: Cinzel, Georgia, serif; }
h1 { font-size: clamp(2rem, 8vw, 3.4rem); margin: .2em 0 .1em; text-align: center; color: var(--gold-2);
  text-shadow: 0 0 24px rgba(226, 189, 98, .45); letter-spacing: .04em; }
h2 { color: var(--gold); margin: 0 0 .6em; font-size: 1.15rem; letter-spacing: .05em; }
.sub { text-align: center; color: var(--muted); margin: 0 0 1.4em; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 18px; backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
.stack > * + * { margin-top: 14px; }

input[type=text] { width: 100%; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); background: rgba(11, 16, 40, .7);
  color: var(--cream); font: inherit; font-size: 17px; outline: none; }
input[type=text]:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226, 189, 98, .2); }
.code-input { text-transform: uppercase; letter-spacing: .4em; text-align: center; font-family: Cinzel, serif; font-size: 22px !important; }

.btn { appearance: none; border: 0; border-radius: 999px; padding: 13px 22px; font: 800 16px Nunito, sans-serif; cursor: pointer;
  background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #2a1e05; box-shadow: 0 6px 18px rgba(226, 189, 98, .3);
  transition: transform .12s, box-shadow .12s, opacity .12s; width: 100%; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--gold-2); border: 1px solid var(--line); box-shadow: none; }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.or { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0; }

.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatar-opt { font-size: 28px; padding: 8px 0; border-radius: 12px; border: 2px solid transparent; background: rgba(255, 255, 255, .05); cursor: pointer; }
.avatar-opt.on { border-color: var(--gold); background: rgba(226, 189, 98, .16); transform: scale(1.06); }

.hero-card { display: block; width: 120px; margin: 0 auto 4px; border-radius: 12px; transform: rotate(-6deg);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .5), 0 0 30px rgba(226, 189, 98, .25); animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: rotate(-3deg) translateY(-8px); } }
.home { max-width: 440px; margin: 0 auto; }

/* lobby */
.code { font-size: 2.6rem; letter-spacing: .25em; color: var(--gold-2); text-align: center; margin: 0; }
.players { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.player { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); }
.player .av { font-size: 26px; }
.player .name { flex: 1; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #5a5f7d; }
.dot.on { background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.toggle { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, .06); }
.toggle .t { flex: 1; } .toggle small { display: block; color: var(--muted); }
.switch { width: 48px; height: 28px; border-radius: 99px; background: #3a4170; position: relative; flex: none; border: 0; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .18s; }
.switch.on { background: var(--teal); } .switch.on::after { left: 23px; }
.switch:disabled { opacity: .5; cursor: default; }
input[type=range] { width: 100%; accent-color: var(--gold); }
.lobby { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .lobby { grid-template-columns: 1fr 1fr; } }

/* game */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.top .meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.scores { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; padding: 2px; }
.chip { display: flex; align-items: center; gap: 5px; padding: 5px 10px 5px 6px; border-radius: 99px; background: rgba(255, 255, 255, .07);
  border: 1px solid transparent; white-space: nowrap; font-size: 14px; font-weight: 700; }
.chip .av { font-size: 18px; }
.chip.teller { border-color: var(--gold); background: rgba(226, 189, 98, .18); }
.chip.off { opacity: .45; }
.chip .ok { color: var(--teal); }
.banner { text-align: center; padding: 14px 16px; margin-bottom: 14px; }
.banner .who { color: var(--muted); font-size: 14px; }
.clue { font-size: clamp(1.3rem, 5vw, 2rem); color: var(--gold-2); margin: 4px 0 2px; text-shadow: 0 0 18px rgba(226, 189, 98, .35); }
.hint { color: var(--muted); font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr)); gap: 12px; }
.hand { display: flex; gap: 10px; overflow-x: auto; padding: 6px 2px 12px; scroll-snap-type: x mandatory; }
.hand .card { flex: 0 0 min(58vw, 260px); scroll-snap-align: center; }
@media (min-width: 820px) { :root { --card-w: 160px; } .hand { flex-wrap: wrap; justify-content: center; overflow: visible; } .hand .card { flex: 0 0 170px; } }
.card { position: relative; border-radius: 12px; overflow: hidden; cursor: pointer; aspect-ratio: 2/3; background: #222a55;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .45); transition: transform .18s, box-shadow .18s; border: 2px solid transparent; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card:hover { transform: translateY(-4px); }
.card.sel { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226, 189, 98, .35), 0 12px 30px rgba(0, 0, 0, .5); transform: translateY(-8px); }
.card.mine::before, .card.won::before { position: absolute; top: 6px; left: 6px; z-index: 2; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 800; }
.card.mine::before { content: "ta carte"; background: rgba(11, 16, 40, .8); color: var(--cream); }
.card.won { border-color: var(--gold); box-shadow: 0 0 26px rgba(226, 189, 98, .7); }
.card.won::before { content: "📖 carte du conteur"; background: var(--gold); color: #2a1e05; }
.card.voted { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(69, 199, 181, .35); }
.card .owner { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; background: linear-gradient(transparent, rgba(5, 8, 22, .92));
  font-size: 13px; font-weight: 800; }
.card .votes { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; font-size: 16px; }
.flip { animation: flip .6s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * .14s); }
@keyframes flip { from { transform: perspective(800px) rotateY(100deg) scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.backs { display: flex; justify-content: center; gap: 10px; margin: 8px 0 4px; }
.backs img { width: 64px; border-radius: 8px; box-shadow: 0 6px 16px rgba(0, 0, 0, .5); animation: bob 1.6s ease-in-out infinite; }
.backs img:nth-child(2) { animation-delay: .2s; } .backs img:nth-child(3) { animation-delay: .4s; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(2deg); } }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 18px 0 8px; }
.section-title h2 { margin: 0; white-space: nowrap; }
.section-title .hint { text-align: right; }
.tell-box { display: grid; gap: 10px; margin-top: 12px; }

.results { display: grid; gap: 6px; margin-top: 12px; }
.res { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, .05); }
.res .name { flex: 1; font-weight: 700; }
.plus { color: var(--teal); font-weight: 800; animation: pop .6s ease both; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.3); } 100% { transform: none; opacity: 1; } }
.anecdote { margin-top: 12px; padding: 12px 14px; border-left: 3px solid var(--gold); background: rgba(226, 189, 98, .08); border-radius: 8px; font-size: 14px; color: #e9dfc3; }
.host-bar { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 20px 0; }
.step { text-align: center; padding: 10px 14px 14px; border-radius: 14px 14px 0 0; background: rgba(226, 189, 98, .14); border: 1px solid var(--line); min-width: 90px; }
.step .av { font-size: 40px; } .step .n { font-weight: 800; } .step .s { color: var(--gold-2); font-family: Cinzel, serif; font-size: 1.4rem; }
.step.p1 { height: 190px; background: rgba(226, 189, 98, .28); } .step.p2 { height: 150px; } .step.p3 { height: 120px; }

/* overlays */
.zoom { position: fixed; inset: 0; z-index: 50; background: rgba(5, 8, 22, .88); backdrop-filter: blur(6px); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 20px; animation: fade .18s; }
.zoom .actions { display: flex; gap: 10px; width: min(420px, 92vw); }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; padding: 12px 18px;
  border-radius: 12px; background: #2b1530; border: 1px solid var(--rose); color: #ffd7e1; font-weight: 700; max-width: 90vw; animation: fade .2s; }
#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
#confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---- feel: no browser image menus, smooth images, transitions */
html { -webkit-text-size-adjust: 100%; }
body { touch-action: manipulation; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
input { -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; -webkit-touch-callout: none; }
.card img, .zcard img { pointer-events: none; opacity: 0; transition: opacity .3s ease; }
.card img.ok, .zcard img.ok { opacity: 1; }
.card { -webkit-tap-highlight-color: transparent; will-change: transform; }
.card:active { transform: scale(.97); }
.swap { animation: swap .38s ease both; }
@keyframes swap { from { opacity: 0; transform: translateY(8px); } }
.deal { animation: deal .55s cubic-bezier(.2, .9, .25, 1.15) both; animation-delay: calc(var(--i, 0) * .09s); }
@keyframes deal { from { opacity: 0; transform: translate(-30vw, -40px) rotate(-18deg) scale(.6); } }
.pop { display: inline-block; animation: pop .45s cubic-bezier(.3, 1.6, .5, 1) both; }
.slide { animation: slide .45s ease both; }
@keyframes slide { from { opacity: 0; transform: translateX(-14px); } }
.status.go { color: var(--gold-2); font-weight: 800; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.chip.teller { animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 14px rgba(226, 189, 98, .55); } }
.progress { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; max-width: 320px; margin: 6px auto 0; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width .5s ease; }
.mini { width: 110px; margin: 0 auto 6px; }
.icon-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); font-size: 18px; cursor: pointer; }
.top .meta { line-height: 1.25; }
.loading { margin-top: 40vh; animation: pulse 1.2s infinite; }
.table .card { box-shadow: 0 10px 26px rgba(0, 0, 0, .5); }

/* ---- zoom carousel */
.zoom { touch-action: pan-y; }
.zcard { position: relative; max-height: 70vh; aspect-ratio: 2/3; height: 70vh; max-width: 88vw; border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .7), 0 0 40px rgba(226, 189, 98, .15); background: #222a55; }
.zcard img { width: 100%; height: 100%; object-fit: cover; max-height: none; max-width: none; border-radius: 0; box-shadow: none; display: block; }
.zin { animation: zin .28s cubic-bezier(.2, .9, .3, 1.1) both; }
@keyframes zin { from { opacity: 0; transform: scale(.85); } }
.from-right { animation: fromR .26s ease both; } @keyframes fromR { from { opacity: 0; transform: translateX(60px) rotate(3deg); } }
.from-left { animation: fromL .26s ease both; } @keyframes fromL { from { opacity: 0; transform: translateX(-60px) rotate(-3deg); } }
.fly { animation: fly .38s cubic-bezier(.5, 0, .75, 0) forwards; }
@keyframes fly { to { opacity: 0; transform: translateY(-45vh) scale(.35) rotate(-8deg); } }
.znav { position: absolute; top: 42%; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: rgba(11, 16, 40, .7);
  color: var(--gold-2); font-size: 30px; line-height: 1; cursor: pointer; z-index: 2; }
.znav.prev { left: max(10px, calc(50% - 44vh)); } .znav.next { right: max(10px, calc(50% - 44vh)); }
@media (max-width: 600px) { .znav { display: none; } }
.zdots { display: flex; gap: 6px; }
.zdots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .25); }
.zdots i.on { background: var(--gold); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; } }
