/* ---------- Cartes ---------- */
.card {
  background: var(--paper);
  border: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--pop);
  padding: 16px;
  margin-bottom: 16px;
}

.hero { text-align: center; margin: 8px 0 20px; }
.hero .logo { font-size: 2.6rem; letter-spacing: 4px; }
.hero h1 {
  display: inline-block;
  background: var(--sun);
  border: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--pop);
  padding: 6px 18px;
  transform: rotate(-2deg);
}
.hero p { margin-top: 14px; font-weight: bold; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; font-weight: bold; }

/* ---------- Boutons ---------- */
.btn {
  font: inherit;
  font-weight: bold;
  color: var(--ink);
  background: var(--paper);
  border: var(--line);
  border-radius: 999px;
  box-shadow: var(--pop);
  padding: 12px 20px;
  min-height: 48px;
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--sun); }
.btn.secondary { background: var(--sky); }
.btn.danger { background: var(--coral); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { padding: 6px 14px; min-height: 36px; }

/* ---------- Formulaires ---------- */
label { display: grid; gap: 6px; font-weight: bold; }
input, select {
  font: inherit;
  padding: 12px 14px;
  min-height: 48px;
  border: var(--line);
  border-radius: 12px;
  background: var(--paper-soft);
  color: var(--ink);
  width: 100%;
}
.code-input { text-align: center; text-transform: uppercase; letter-spacing: 8px; font-size: 1.4rem; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.tabs button {
  font: inherit; font-weight: bold; color: var(--ink);
  padding: 10px; cursor: pointer;
  border: var(--line); border-radius: 12px; background: var(--paper-soft);
}
.tabs button.active { background: var(--sun); }

/* ---------- Liste de parties ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.game-item {
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  width: 100%; display: grid; gap: 4px;
  padding: 12px 14px;
  background: var(--paper-soft);
  border: var(--line); border-radius: 12px;
}
.badge {
  justify-self: start;
  font-size: .8rem; font-weight: bold;
  background: var(--sky);
  border: 2px solid var(--ink); border-radius: 999px;
  padding: 2px 10px;
}
.badge.live { background: var(--grass); }

/* ---------- Salle d'attente ---------- */
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--paper-soft); border: 3px dashed var(--ink); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.code-box .code { font-size: 2rem; letter-spacing: 8px; font-weight: bold; }

.players { display: grid; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.player { display: flex; justify-content: space-between; align-items: center; background: var(--paper-soft); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 14px; }
.player.empty { border-style: dashed; color: var(--muted); }

.roles { display: grid; gap: 10px; }
.role-card {
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  display: grid; grid-template-columns: 48px 1fr; column-gap: 12px; align-items: center;
  padding: 12px 14px;
  background: var(--paper);
  border: var(--line); border-radius: var(--radius);
}
.role-card .emoji { grid-row: span 3; font-size: 2.2rem; text-align: center; }
.role-card em { font-style: normal; font-weight: bold; }
.role-card.selected { background: var(--sun); box-shadow: var(--pop); }
.role-card:disabled { opacity: .55; cursor: not-allowed; background: var(--paper-soft); }

.status-panel { text-align: center; }
.status-panel .big { font-size: 3rem; }

/* ---------- Messages ---------- */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); display: grid; gap: 8px; justify-items: center; padding: 0 16px; pointer-events: none; z-index: 10; }
.toast { max-width: 440px; padding: 12px 18px; border: var(--line); border-radius: var(--radius); box-shadow: var(--pop); background: var(--paper); font-weight: bold; }
.toast.error { background: var(--coral); }
.toast.ok { background: var(--grass); }

.notice { background: var(--paper-soft); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 14px; font-size: .95rem; }

/* ================= Interfaces de jeu ================= */
#app.in-game { max-width: 560px; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); }
.shell { --accent: var(--sun); }
.shell.role-keeper { --accent: var(--sky); }

.zbar { display: flex; align-items: center; gap: 8px; background: var(--accent); border: var(--line); border-radius: var(--radius); box-shadow: var(--pop); padding: 8px 10px; margin-bottom: 16px; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 5; }
.zbar-title { display: grid; flex: 1; min-width: 0; line-height: 1.2; }
.zbar-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money { font-weight: bold; background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.bell { position: relative; font-size: 1.3rem; background: var(--paper); border: 2px solid var(--ink); border-radius: 50%; width: 42px; height: 42px; cursor: pointer; }
.dot { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; font-style: normal; font-size: .75rem; font-weight: bold; line-height: 16px; text-align: center; background: var(--coral); color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; }

.view h2 { margin-top: 0; }
.view.enter { animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px; padding: 8px 8px calc(env(safe-area-inset-bottom, 0px) + 8px); background: var(--paper); border-top: var(--line); z-index: 6; }
.tabbar button { position: relative; flex: 1; min-width: 0; max-width: 110px; display: grid; justify-items: center; gap: 2px; font: inherit; font-size: .66rem; font-weight: bold; color: var(--ink); background: transparent; border: 2px solid transparent; border-radius: 12px; padding: 6px 2px; cursor: pointer; }
.tabbar button span { font-size: 1.35rem; }
.tabbar button.active { background: var(--accent); border-color: var(--ink); }
.tabbar .dot { top: -4px; right: 6px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.tile { display: grid; gap: 2px; justify-items: center; text-align: center; background: var(--paper); border: var(--line); border-radius: var(--radius); box-shadow: var(--pop); padding: 12px 8px; }
.tile-emoji { font-size: 1.6rem; }
.tile strong { font-size: 1.25rem; }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--paper-soft); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; }
.row-item > span:first-child { display: grid; min-width: 0; }
.row-item.stack-row { flex-wrap: wrap; }
.btn-pair { display: flex; gap: 8px; flex-wrap: wrap; }
.pos { color: #1f7a35; } .neg { color: #b3261e; }
.empty-state { color: var(--muted); margin: 0; }
.btn.wide { width: 100%; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 1.05rem; }

.meter { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 8px; font-size: .85rem; margin: 6px 0; }
.bar { height: 12px; background: var(--paper-soft); border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; transition: width .4s ease; }
.bar i.high { background: var(--grass); } .bar i.mid { background: var(--sun); } .bar i.low { background: var(--coral); }
.w0{width:0%}.w10{width:10%}.w20{width:20%}.w30{width:30%}.w40{width:40%}.w50{width:50%}.w60{width:60%}.w70{width:70%}.w80{width:80%}.w90{width:90%}.w100{width:100%}

.overlay { position: fixed; inset: 0; background: rgba(43,33,24,.45); display: grid; align-items: end; padding: 16px; z-index: 20; animation: fade .15s ease-out; }
.panel { max-width: 520px; width: 100%; margin: 0 auto; max-height: 75vh; overflow-y: auto; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.version { text-align: center; margin: 8px 0 0; }

#ver { position: fixed; top: 2px; left: 6px; font-size: 10px; opacity: .6; z-index: 30; pointer-events: none; }
#diag { position: fixed; left: 8px; right: 8px; bottom: 90px; max-height: 40vh; overflow: auto; margin: 0; padding: 10px; white-space: pre-wrap; background: var(--coral); border: var(--line); border-radius: 12px; font-size: 12px; z-index: 40; }

/* ================= Style et animations ================= */
.zoo-canvas { display: block; width: 100%; border: var(--line); border-radius: var(--radius); box-shadow: var(--pop); margin-bottom: 16px; background: var(--grass); touch-action: manipulation; }
.money.up { animation: flash-up .9s ease-out; } .money.down { animation: flash-down .9s ease-out; }
@keyframes flash-up { 0% { background: var(--grass); transform: scale(1.15); } 100% { background: var(--paper); transform: none; } }
@keyframes flash-down { 0% { background: var(--coral); transform: scale(.92); } 100% { background: var(--paper); transform: none; } }
.view.enter > .card, .view.enter > .tiles, .view.enter > .btn { animation: pop .3s ease-out both; }
.view.enter > :nth-child(3) { animation-delay: .05s; } .view.enter > :nth-child(4) { animation-delay: .1s; }
.view.enter > :nth-child(5) { animation-delay: .15s; } .view.enter > :nth-child(n+6) { animation-delay: .2s; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.tabbar button.active span { animation: hop .35s ease-out; }
@keyframes hop { 40% { transform: translateY(-6px) scale(1.15); } }
.tile { transition: transform .12s; } .tile:active { transform: scale(.96); }
.tile-emoji { display: inline-block; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-3px); } }
.dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.18); } }

/* ================= Zoo 3D ================= */
.zoo3d { position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 56vh; margin-bottom: 16px; overflow: hidden; display: grid; place-items: center; font-weight: bold;
  background: linear-gradient(#9fdcff, #cdeeff); border: var(--line); border-radius: var(--radius); box-shadow: var(--pop); }
.zoo3d-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
.zoo3d-tip { position: absolute; left: 0; top: 0; background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 4px 8px; font-size: .72rem; font-weight: bold; white-space: nowrap; pointer-events: none; z-index: 2; }
.zoo3d-float { position: absolute; left: 50%; top: 45%; transform: translateX(-50%); font-size: 2rem; font-weight: bold; color: #1f7a35; text-shadow: 0 2px 0 #fff, 0 -2px 0 #fff, 2px 0 0 #fff, -2px 0 0 #fff; pointer-events: none; animation: rise 1.9s ease-out forwards; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 20px) scale(.7); } 15% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -70px) scale(1.2); } }

/* ================= Habillage v8 : plus doux, plus vivant ================= */
body { background-color: #8fd16a; background-image: linear-gradient(180deg, #aee3ff 0, #d9f4c8 180px, rgba(143,209,106,0) 420px),
  radial-gradient(circle at 20% 30%, rgba(255,255,255,.16) 0 10px, transparent 11px), radial-gradient(circle at 70% 70%, rgba(0,0,0,.05) 0 14px, transparent 15px);
  background-size: 100% 100%, 90px 90px, 130px 130px; background-attachment: fixed, scroll, scroll; }
.card, .tile, .zbar, .zoo3d { border-radius: 22px; }
.card { box-shadow: 0 5px 0 rgba(43,33,24,.88), 0 10px 18px rgba(43,33,24,.12); }
.card h3 { display: inline-block; background: linear-gradient(transparent 60%, rgba(255,210,63,.65) 60%); padding: 0 4px; }
.view h2 { font-size: 1.4rem; text-shadow: 0 2px 0 rgba(255,255,255,.7); }
.zbar { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 55%, #fff), var(--accent)); box-shadow: 0 5px 0 var(--ink), 0 10px 18px rgba(43,33,24,.15); }
.lvl { background: var(--ink); color: var(--sun); border-radius: 999px; padding: 0 7px; font-size: .7rem; }
.money { background: linear-gradient(#fff, #fff4c8); font-size: 1.02rem; }
.btn { background-image: linear-gradient(rgba(255,255,255,.55), rgba(255,255,255,0) 55%); transition: transform .12s, box-shadow .12s, filter .12s; }
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); filter: brightness(1.04); }
.btn.primary { background-color: #ffcf33; } .btn.secondary { background-color: #7bd5f5; } .btn.danger { background-color: #ff7c6b; }
.tabbar { left: 10px; right: 10px; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); max-width: 540px; margin: 0 auto; padding: 8px 6px;
  border: var(--line); border-radius: 28px; background: rgba(255,255,255,.94); backdrop-filter: blur(6px); box-shadow: 0 6px 0 var(--ink), 0 14px 24px rgba(43,33,24,.2); }
.tabbar button { border-radius: 18px; transition: transform .2s cubic-bezier(.3,1.6,.5,1), background .2s; }
.tabbar button span { font-size: 1.55rem; transition: transform .25s cubic-bezier(.3,1.8,.5,1); display: block; }
.tabbar button.active { transform: translateY(-8px); background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 70%, #fff)); box-shadow: 0 4px 0 var(--ink); }
.tabbar button.active span { transform: scale(1.18); }
#app.in-game { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 112px); }
.tile:nth-child(6n+1) { background: #fff0c9; } .tile:nth-child(6n+2) { background: #d9f3ff; } .tile:nth-child(6n+3) { background: #ffe0e6; }
.tile:nth-child(6n+4) { background: #e2f8d4; } .tile:nth-child(6n+5) { background: #efe0ff; } .tile:nth-child(6n+6) { background: #ffe9d1; }
.tile-emoji { font-size: 1.9rem; filter: drop-shadow(0 2px 0 rgba(43,33,24,.18)); }
.tile strong { font-size: 1.35rem; }
.row-item { transition: transform .12s, background .12s; } .row-item:hover { transform: translateX(3px); background: #fff; }
.row-item.ready { background: #e6ffd9; animation: ready 1.6s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 0 4px rgba(124,196,85,.5); } }
.row-item .meter { grid-template-columns: 1fr; margin-top: 4px; } .row-item .meter > span { display: none; }
.level-card { background: linear-gradient(135deg, #fff6d6, #ffffff 60%); }
.role-card:hover:not(:disabled), .game-item:hover { transform: translateY(-2px); }
.bar i.high { background: linear-gradient(#9be36f, #55b83f); } .bar i.mid { background: linear-gradient(#ffe27a, #ffc21a); } .bar i.low { background: linear-gradient(#ff9a8c, #ff5a47); }

/* ================= v9 : carte fixe, panneau d'actions, suppression d'un zoo ================= */
.top-sticky { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 4px); z-index: 7; padding: 6px; margin: 0 -6px 14px; border-radius: 28px; background: rgba(255,255,255,.55); backdrop-filter: blur(6px); display: grid; gap: 8px; }
.top-sticky .zbar { position: static; margin: 0; }
.top-sticky .zoo3d { aspect-ratio: 16 / 10; max-height: 30vh; margin: 0; }
.sheet { position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 104px); max-width: 520px; margin: 0 auto; z-index: 9; display: grid; gap: 8px;
  background: #fff; border: var(--line); border-radius: 22px; box-shadow: var(--pop), 0 14px 26px rgba(43,33,24,.22); padding: 12px 14px; animation: sheet .28s cubic-bezier(.3,1.4,.5,1); }
@keyframes sheet { from { transform: translateY(34px); opacity: 0; } }
.sheet-bars .meter { margin: 3px 0; }
.game-row { display: flex; gap: 8px; align-items: stretch; } .game-row .game-item { flex: 1; } .game-row .btn { align-self: center; }

/* ================= v10 : cinématiques ================= */
.zoo3d.cinema::before, .zoo3d.cinema::after { content: ''; position: absolute; left: 0; right: 0; height: 12%; background: #000; z-index: 3; pointer-events: none; animation: bar .5s ease-out both; }
.zoo3d.cinema::before { top: 0; transform-origin: top; } .zoo3d.cinema::after { bottom: 0; transform-origin: bottom; }
@keyframes bar { from { transform: scaleY(0); } }
.zoo3d-caption { position: absolute; left: 50%; bottom: 15%; transform: translateX(-50%); z-index: 4; background: #fff; border: var(--line); border-radius: 999px; padding: 4px 14px; font-weight: bold; font-size: .85rem; white-space: nowrap; pointer-events: none; animation: pop .35s ease-out; }
