/* ==========================================
   css/style.css - Interface v3 : thème « confiserie de nuit », HUD, dock, tiroir boutique, composants, responsive
   La scène (décor, bâtiments, Gelly) est dans scene.css.
   ========================================== */

:root {
    --bg-0: #12082a; --bg-1: #1d0d45; --bg-2: #351258;
    --glass: rgba(24, 10, 56, 0.62); --glass-strong: rgba(255, 255, 255, 0.12); --glass-border: rgba(255, 255, 255, 0.18);
    --ink: #ffffff; --muted: #c9bcee; --dim: #8f7fb8;
    --pink: #ff4fa3; --pink-deep: #c21a75; --mint: #46f0c1; --gold: #ffcf4a; --sky: #5cc8ff; --danger: #ff6b7a; --focus: #8ecbff;
    --radius: 18px; --radius-sm: 12px; --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    --anim-speed: 1;
    --ticker-h: 34px;
    --shop-w: 424px;        /* largeur occupée par le tiroir (marges comprises) */
    --sheet-h: 46dvh;       /* hauteur de la feuille inférieure sur mobile */
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Fredoka', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { color: var(--ink); background: var(--bg-0); overflow: hidden; -webkit-user-select: none; user-select: none; touch-action: manipulation; cursor: url('../assets/cursor.png'), auto; }
body.shop-collapsed { --shop-w: 0px; }

button, [role="button"], .pinata { cursor: url('../assets/pointer.png'), pointer; font: inherit; color: inherit; }
button { background: none; border: 0; }
input, textarea { -webkit-user-select: text; user-select: text; font: inherit; }
img { -webkit-user-drag: none; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.emoji { font-style: normal; line-height: 1; }
.candy-icon { width: 1.1em; height: 1.1em; vertical-align: middle; display: inline-block; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 6px; }

/* ---------- HUD (au-dessus de la scène) ---------- */
#hud {
    position: fixed; z-index: 20; top: 0; left: 0; right: var(--shop-w);
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 12px; padding: 12px 16px 0;
    pointer-events: none;
}
#hud > * { pointer-events: auto; }
#hud-left { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
h1#game-title { line-height: 0; cursor: pointer; }
#game-logo { height: 58px; width: auto; filter: drop-shadow(0 4px 14px rgba(255, 79, 163, 0.5)); transition: transform 0.2s; }
#game-logo:hover { transform: scale(1.04) rotate(-1.5deg); }
#chapter-label { font-size: 0.85rem; color: var(--muted); padding: 2px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--glass-border); backdrop-filter: blur(6px); }
#chapter-label .chapter-name { color: #fff; font-weight: 600; }

.score-board { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 0; }
.score { white-space: nowrap; font-size: clamp(2.2rem, 5vw, 4.2rem); font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; color: #fff; text-shadow: 0 0 24px rgba(255, 79, 163, 0.75), 0 4px 0 rgba(194, 26, 117, 0.6); }
.score .candy-icon { filter: drop-shadow(0 2px 8px rgba(255, 79, 163, 0.6)); }
.rate { font-size: 1rem; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.rate span { color: var(--mint); font-weight: 700; }
#hud-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 11px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--glass-border); color: var(--muted); backdrop-filter: blur(6px); }
.chip.gold { color: #3b2a00; background: linear-gradient(135deg, #ffe27a, var(--gold)); border-color: #ffe9a3; }
.chip.ticket { color: #3b2a00; background: linear-gradient(135deg, #ffd9a0, #ffb347); border-color: #ffe3b8; }
.chip-bar { width: 80px; height: 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
#prestige-progress-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #fff3b0); transition: width 0.5s; }
#buffs-strip { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.buff { display: inline-flex; gap: 8px; padding: 3px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; color: #3b2a00; background: linear-gradient(135deg, #fff1a8, var(--gold)); box-shadow: 0 0 16px rgba(255, 207, 74, 0.55); animation: pulseBanner 1.4s ease-in-out infinite; }
.buff-click { background: linear-gradient(135deg, #b8f5ff, var(--sky)); box-shadow: 0 0 16px rgba(92, 200, 255, 0.55); }
.buff-time { font-variant-numeric: tabular-nums; opacity: 0.8; }
@keyframes pulseBanner { 50% { transform: scale(1.04); } }

.menu-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.icon-btn { width: 44px; height: 44px; font-size: 1.3rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 14px; backdrop-filter: blur(8px); transition: transform 0.12s, background 0.12s; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.22); transform: translateY(-2px); }
.icon-btn:active { transform: translateY(1px) scale(0.96); }
.legacy-btn { border-color: rgba(70, 240, 193, 0.7); box-shadow: 0 0 14px rgba(70, 240, 193, 0.3); }
.ascension-btn { border-color: rgba(255, 207, 74, 0.8); box-shadow: 0 0 16px rgba(255, 207, 74, 0.4); animation: glowGold 2.4s ease-in-out infinite; }
.ascension-btn.disabled { opacity: 0.45; animation: none; box-shadow: none; }
@keyframes glowGold { 50% { box-shadow: 0 0 26px rgba(255, 207, 74, 0.7); } }
#network-status { width: 12px; height: 12px; border-radius: 50%; margin-right: 4px; cursor: help; transition: background 0.3s; }
#network-status.local { background: #7e93a8; box-shadow: 0 0 8px #7e93a8; }
#network-status.online { background: #4ade80; box-shadow: 0 0 10px #4ade80; }
#network-status.pending { background: #fbbf24; box-shadow: 0 0 10px #fbbf24; }
#network-status.offline { background: #f87171; box-shadow: 0 0 10px #f87171; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- Dock des activités ---------- */
#dock { position: fixed; z-index: 20; left: 14px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 10px; }
.dock-btn { position: relative; width: 74px; padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 18px; background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(10px); box-shadow: var(--shadow); transition: transform 0.12s, border-color 0.12s, background 0.12s; }
.dock-btn:hover:not(.locked) { transform: translateX(4px); border-color: var(--pink); background: rgba(255, 79, 163, 0.25); }
.dock-btn.locked { opacity: 0.5; filter: grayscale(0.6); }
.dock-icon { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.dock-icon img { width: 44px; height: 44px; object-fit: contain; }
.dock-label { font-size: 0.68rem; font-weight: 600; color: var(--muted); }
.dock-badge { position: absolute; top: -6px; right: -6px; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--mint); color: #05382c; font-size: 0.75rem; font-weight: 700; text-align: center; animation: pulseBanner 1.2s infinite; }
.tutorial-highlight { outline: 3px solid var(--gold) !important; outline-offset: 4px; animation: highlightPulse 1.2s ease-in-out infinite; }
@keyframes highlightPulse { 50% { outline-color: #fff; box-shadow: 0 0 24px rgba(255, 207, 74, 0.8); } }

/* ---------- Tiroir boutique ---------- */
#shop {
    position: fixed; z-index: 25; top: 12px; right: 12px; bottom: calc(var(--ticker-h) + 12px); width: calc(var(--shop-w, 424px) - 24px);
    min-width: 0; display: flex; flex-direction: column; border-radius: var(--radius);
    background: var(--glass); border: 1px solid var(--glass-border); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow);
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
body.shop-collapsed #shop { transform: translateX(calc(100% + 12px)); width: 400px; }
#shop-toggle { position: absolute; left: -40px; top: 50%; width: 40px; height: 72px; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; border-radius: 14px 0 0 14px; background: var(--glass); border: 1px solid var(--glass-border); border-right: 0; backdrop-filter: blur(10px); font-size: 1.3rem; transition: background 0.12s; }
#shop-toggle:hover { background: rgba(255, 79, 163, 0.35); }
body.shop-collapsed #shop-toggle span[aria-hidden] { transform: rotate(180deg); }
body.can-buy-something.shop-collapsed #shop-toggle { box-shadow: 0 0 18px var(--mint); border-color: var(--mint); }
#shop-body { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow: hidden; border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 16px 10px; }
.panel-head h2 { font-size: 1.35rem; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--mint); color: #05382c; font-size: 0.75rem; font-weight: 700; text-align: center; }

.segmented { display: inline-flex; background: rgba(0, 0, 0, 0.3); border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { padding: 5px 11px; border-radius: 9px; font-weight: 600; font-size: 0.9rem; color: var(--muted); transition: background 0.12s, color 0.12s; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: linear-gradient(135deg, #f03a94, var(--pink-deep)); color: #fff; box-shadow: 0 2px 10px rgba(255, 79, 163, 0.4); }
.center-seg { display: flex; justify-content: center; width: fit-content; margin: 0 auto 12px; }

#shop-tabs { display: flex; gap: 6px; padding: 0 12px 10px; }
#shop-tabs button { flex: 1; padding: 9px 8px; border-radius: 12px; font-weight: 600; color: var(--muted); background: rgba(0, 0, 0, 0.22); border: 1px solid transparent; transition: background 0.12s, color 0.12s; }
#shop-tabs button:hover { color: var(--ink); }
#shop-tabs button[aria-selected="true"] { color: #fff; background: var(--glass-strong); border-color: var(--glass-border); }
#buildings-list, #upgrades-container { flex: 1; overflow-y: auto; padding: 4px 12px 14px; min-height: 0; }
#buildings-list { list-style: none; }
#upgrades-container { display: grid; grid-template-columns: 1fr; gap: 10px; align-content: start; }
.shop-empty { text-align: center; color: var(--muted); padding: 24px 10px; line-height: 1.5; }

/* ---------- Bandeau d'actualités ---------- */
#ticker { position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; height: var(--ticker-h); display: flex; align-items: center; overflow: hidden; background: rgba(10, 4, 28, 0.78); border-top: 1px solid var(--glass-border); backdrop-filter: blur(8px); color: var(--muted); font-size: 0.9rem; }
.ticker-track { white-space: nowrap; will-change: transform; }
@keyframes tickerScroll { from { transform: translateX(100vw); } to { transform: translateX(-100%); } }


/* Boutons-cartes (bâtiments, bonus, choix) */
.buy-btn {
    position: relative; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    padding: 10px 14px 12px; margin-bottom: 10px; border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.05));
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
    transition: transform 0.1s, border-color 0.12s, background 0.12s, box-shadow 0.1s;
}
.buy-btn > * { pointer-events: none; }
.buy-btn:hover:not(.disabled) { border-color: var(--pink); background: linear-gradient(180deg, rgba(255, 79, 163, 0.22), rgba(255, 255, 255, 0.06)); transform: translateY(-1px); }
.buy-btn:active:not(.disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.buy-btn.disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.buy-btn.disabled .building-icon { filter: grayscale(0.5); }
.buy-btn.can-buy { border-color: rgba(70, 240, 193, 0.55); }
.buy-btn.can-buy .cost { color: var(--mint); }
.buy-btn.just-bought { animation: bought 0.35s ease-out; }
@keyframes bought { 40% { transform: scale(1.03); box-shadow: 0 0 22px rgba(70, 240, 193, 0.55); } }

.building-icon {
    flex: 0 0 62px; height: 62px; display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.22); border-radius: 14px; font-size: 1.6rem;
}
.building-icon img { width: 46px; height: 46px; object-fit: contain; }
.building-info { flex: 1; min-width: 0; }
.building-name { font-weight: 700; font-size: 1.02rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qty-chip { font-size: 0.72rem; padding: 1px 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); color: var(--muted); font-weight: 600; }
.building-detail { font-size: 0.9rem; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.building-detail .gain { color: var(--mint); font-weight: 600; }
.building-count {
    flex: 0 0 auto; min-width: 44px; text-align: center; font-weight: 700; font-size: 1.5rem; color: rgba(255, 255, 255, 0.85);
    font-variant-numeric: tabular-nums;
}
.milestone { position: absolute; left: 14px; right: 14px; bottom: 4px; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.milestone-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--sky), var(--mint)); transition: width 0.3s; }

/* Cartes d'amélioration */
.upgrade-btn {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.05));
    border: 1px solid var(--glass-border); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
    transition: transform 0.1s, border-color 0.12s;
}
.upgrade-btn > * { pointer-events: none; }
.upgrade-btn:hover:not(.disabled) { border-color: var(--gold); transform: translateY(-1px); }
.upgrade-btn:active:not(.disabled) { transform: translateY(3px); box-shadow: none; }
.upgrade-btn.disabled { opacity: 0.55; cursor: not-allowed; }
.upgrade-btn.can-buy { border-color: rgba(255, 207, 74, 0.6); }
.upgrade-icon-wrapper { flex: 0 0 54px; height: 54px; display: flex; align-items: center; justify-content: center; font-size: 1.9rem; background: rgba(0, 0, 0, 0.22); border-radius: 14px; position: relative; }
.upgrade-icon-wrapper img { width: 38px; height: 38px; object-fit: contain; }
.upgrade-badge { position: absolute; bottom: -5px; right: -5px; padding: 0 6px; border-radius: 99px; background: var(--pink-deep); color: #fff; font-size: 0.7rem; font-weight: 700; border: 2px solid var(--bg-1); }
.upgrade-text { flex: 1; min-width: 0; }
.upgrade-text > span { display: block; }
.upgrade-name { font-weight: 700; }
.upgrade-desc { font-size: 0.85rem; color: var(--muted); line-height: 1.25; margin-top: 1px; }
.upgrade-cost { flex: 0 0 auto; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; text-align: right; font-size: 0.95rem; }


/* ---------- Éléments flottants ---------- */
.particle {
    position: fixed; z-index: 950; pointer-events: none; color: #fff; font-size: 1.9rem; font-weight: 700; white-space: nowrap;
    text-shadow: 0 2px 0 var(--pink-deep), 0 0 16px rgba(255, 79, 163, 0.8); animation: floatUp 1s ease-out forwards;
}
@keyframes floatUp { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-90px) scale(1.3); } }

.reward-text {
    position: fixed; z-index: 2000; pointer-events: none; transform: translateX(-50%); white-space: nowrap;
    font-size: 2rem; font-weight: 700; color: var(--gold); text-shadow: 0 2px 0 #7a4d00, 0 0 18px rgba(255, 207, 74, 0.8);
    animation: floatUp 2s ease-out forwards;
}

.pinata {
    position: fixed; top: 20%; left: -100px; z-index: 5000; font-size: 5.5rem; line-height: 1; touch-action: none;
    animation: flyAcross 6s linear forwards; filter: drop-shadow(0 12px 14px rgba(0, 0, 0, 0.4));
}
.pinata:focus-visible { outline-offset: 6px; }
@keyframes flyAcross {
    0% { left: -100px; transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-40px) rotate(15deg); }
    75% { transform: translateY(40px) rotate(-15deg); }
    100% { left: 100vw; transform: translateY(0) rotate(0deg); }
}
#radar-signal { position: fixed; top: 90px; left: 50%; transform: translateX(-50%); font-size: 3rem; z-index: 200; animation: pulseBanner 0.5s infinite; }

#notice-region {
    position: fixed; bottom: 110px; left: 50%; transform: translate(-50%, 16px); z-index: 11000; pointer-events: none;
    max-width: min(90vw, 440px); padding: 10px 18px; border-radius: 14px; font-weight: 600; text-align: center;
    background: rgba(20, 10, 45, 0.94); border: 1px solid var(--glass-border); box-shadow: var(--shadow);
    opacity: 0; transition: opacity 0.3s, transform 0.3s;
}
#notice-region.visible { opacity: 1; transform: translate(-50%, 0); }

.achievement-popup {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 10000; text-align: center;
    min-width: 280px; max-width: 92vw; padding: 14px 40px 14px 22px; border-radius: 18px;
    background: linear-gradient(135deg, rgba(53, 18, 88, 0.97), rgba(29, 13, 69, 0.97));
    border: 1px solid var(--gold); box-shadow: 0 0 36px rgba(255, 207, 74, 0.35), var(--shadow);
    animation: slideDown 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.achievement-popup .close-toast-btn { position: absolute; top: 4px; right: 6px; width: 36px; height: 36px; font-size: 1.6rem; line-height: 1; color: var(--muted); }
.achievement-popup .close-toast-btn:hover { color: #fff; }
.achievement-popup .icon { font-size: 2.2rem; animation: bounce 1s infinite; }
.achievement-popup h3 { color: var(--gold); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 2px; }
.achievement-popup h4 { font-size: 1.15rem; margin: 2px 0; }
.achievement-popup p { font-size: 0.9rem; color: var(--muted); }
@keyframes slideDown { from { transform: translate(-50%, 150%); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes bounce { 50% { transform: translateY(-8px); } }

/* ---------- Fenêtres modales ---------- */
#modal-overlay {
    position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(10, 4, 28, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#modal-box {
    width: 100%; max-width: 520px; max-height: min(88vh, 900px); max-height: min(88dvh, 900px); overflow-y: auto; text-align: center;
    padding: 26px 24px 22px; border-radius: 24px;
    background: linear-gradient(180deg, rgba(53, 18, 88, 0.98), rgba(29, 13, 69, 0.98));
    border: 1px solid var(--glass-border); box-shadow: var(--shadow), 0 0 60px rgba(255, 79, 163, 0.15);
    animation: popIn 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#modal-box.wide { max-width: 780px; }
@keyframes popIn { from { transform: scale(0.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#modal-title { font-size: 1.7rem; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--glass-border); }
#modal-content { font-size: 1.05rem; line-height: 1.5; color: #ece6ff; margin-bottom: 20px; text-align: left; }
#modal-content > p { margin-bottom: 8px; }
#modal-close-btn {
    padding: 11px 34px; border-radius: 14px; font-weight: 700; font-size: 1.05rem; color: #fff;
    background: linear-gradient(135deg, #f03a94, var(--pink-deep)); box-shadow: 0 4px 0 #8c0f52; transition: transform 0.1s;
}
#modal-close-btn:hover { transform: translateY(-1px); }
#modal-close-btn:active { transform: translateY(3px); box-shadow: none; }

.hint { font-size: 0.9rem; color: var(--muted); margin: 6px 0; line-height: 1.4; }
.gold-text { color: var(--gold); font-size: 1.6rem; margin: 6px 0; }
.gold-text.big { font-size: 2.6rem; }
.error-text { color: var(--danger); font-weight: 600; margin-top: 10px; text-align: center; }
.big-crown { font-size: 3.6rem; }
.legacy-header, .center { text-align: center; margin-bottom: 14px; }
hr.dashed { border: 0; border-top: 1px dashed var(--glass-border); margin: 14px 0; }
.choice-list { display: flex; flex-direction: column; gap: 4px; margin: 14px 0; }
.button-row { display: flex; gap: 10px; margin-top: 10px; }
.button-row .buy-btn { margin-bottom: 0; justify-content: center; text-align: center; }
.danger-fill { justify-content: center; background: linear-gradient(135deg, #ff6b7a, #c0283a); color: #fff; font-weight: 700; border-color: transparent; }
.gold-fill { justify-content: center; text-align: center; color: #3b2a00; font-weight: 700; font-size: 1.2rem; background: linear-gradient(135deg, #ffe27a, var(--gold)); border-color: transparent; }
.gold-fill.disabled { background: var(--glass); color: var(--dim); }
.danger-btn { margin-top: 6px; padding: 10px 20px; border-radius: 12px; font-weight: 700; color: var(--danger); border: 2px solid var(--danger); background: transparent; transition: background 0.12s, color 0.12s; }
.danger-btn:hover { background: var(--danger); color: #2a0610; }

.audio-group { background: rgba(0, 0, 0, 0.22); border: 1px solid var(--glass-border); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; }
.audio-group h4 { margin-bottom: 8px; font-size: 1.05rem; color: var(--gold); }
.audio-group label { display: flex; align-items: center; gap: 10px; min-height: 32px; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--pink); cursor: pointer; flex: none; }
input[type="range"] { width: 100%; margin-top: 10px; accent-color: var(--pink); cursor: pointer; }
#save-code { width: 100%; padding: 8px; border-radius: 10px; border: 1px solid var(--glass-border); background: rgba(0, 0, 0, 0.35); color: var(--ink); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; resize: vertical; }
select { padding: 6px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.35); color: var(--ink); border: 1px solid var(--glass-border); }

/* Héritage (prestige) */
.prestige-tree { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.prestige-col { display: flex; flex-direction: column; gap: 8px; }
.prestige-branch { text-align: center; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--gold); padding-bottom: 6px; border-bottom: 1px dashed var(--glass-border); }
.prestige-upgrade-btn { flex-direction: column; align-items: stretch; gap: 4px; margin: 0; text-align: left; padding: 10px 12px; }
.prestige-upgrade-btn .building-name { font-size: 0.98rem; }
.prestige-upgrade-btn .building-detail { font-size: 0.82rem; }
.prestige-upgrade-btn .prestige-cost { text-align: left; font-size: 0.95rem; color: var(--gold); min-width: 0; }
.prestige-upgrade-btn.purchased { border-color: rgba(70, 240, 193, 0.6); background: rgba(70, 240, 193, 0.1); opacity: 1; }
.prestige-upgrade-btn.purchased .prestige-cost { color: var(--mint); }
.prestige-upgrade-btn.locked { opacity: 0.4; }
.prestige-upgrade-btn.affordable { border-color: var(--gold); }

/* Succès */
.achv-summary { margin-bottom: 10px; text-align: center; }
.achv-filters { display: flex; justify-content: center; margin-bottom: 12px; }
.achievement-list { list-style: none; max-height: 52vh; overflow-y: auto; padding-right: 6px; }
.achievement-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 8px; border-radius: 14px; background: rgba(0, 0, 0, 0.2); border: 1px solid transparent; }
.achievement-item.locked { opacity: 0.7; }
.achievement-item.unlocked { background: rgba(255, 207, 74, 0.1); border-color: rgba(255, 207, 74, 0.45); }
.achievement-icon { font-size: 1.8rem; min-width: 42px; text-align: center; }
.achievement-text { flex: 1; min-width: 0; }
.achievement-text h4 { font-size: 1rem; }
.achievement-text p { font-size: 0.85rem; color: var(--muted); }
.achievement-progress-bar { height: 7px; margin-top: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.achievement-progress-fill { height: 100%; background: linear-gradient(90deg, var(--pink), var(--gold)); }
.achievement-progress-text { font-size: 0.75rem; color: var(--muted); text-align: right; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* Statistiques */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: rgba(0, 0, 0, 0.22); border: 1px solid var(--glass-border); border-radius: 14px; padding: 10px 12px; }
.stat dt { font-size: 0.8rem; color: var(--muted); }
.stat dd { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Mini-jeux */

/* Connexion */
.auth-box { text-align: left; }
.auth-box label { display: block; font-size: 0.9rem; color: var(--muted); margin: 8px 0 4px; }
.auth-tabs { display: flex; margin-bottom: 14px; border-bottom: 1px solid var(--glass-border); }
.auth-tab { flex: 1; padding: 10px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.auth-tab.active { color: #fff; border-bottom-color: var(--pink); }
.auth-input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--glass-border); background: rgba(0, 0, 0, 0.35); color: var(--ink); font-size: 1rem; }
.auth-input:focus-visible { border-color: var(--pink); }
.auth-box .rgpd-text { display: flex; align-items: flex-start; gap: 10px; font-size: 0.82rem; color: var(--muted); margin: 12px 0; }
.auth-box .rgpd-text a { color: var(--sky); }
.discord-btn { justify-content: center; margin-bottom: 14px; background: #5865F2; color: #fff; border-color: transparent; font-weight: 600; }
.auth-separator { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; color: var(--muted); font-size: 0.85rem; }
.auth-separator::before, .auth-separator::after { content: ''; flex: 1; border-top: 1px dashed var(--glass-border); }
.auth-submit { justify-content: center; margin: 10px 0 0; font-weight: 700; background: linear-gradient(135deg, #f03a94, var(--pink-deep)); border-color: transparent; }
.auth-submit.register { background: linear-gradient(135deg, #2fb878, #1b7a4e); }
.auth-submit:disabled { opacity: 0.6; cursor: wait; }
#auth-error { color: var(--danger); font-weight: 700; font-size: 0.9rem; margin-top: 14px; min-height: 1.2em; }
#auth-error.ok { color: var(--mint); }



/* ==========================================
   Activités : commandes, moulage, serre, expéditions, artefacts
   ========================================== */
.progress { height: 9px; border-radius: 99px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.progress.thin { height: 5px; }
.progress-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--gold)); transition: width 0.4s; }
.big-emoji { font-size: 3.4rem; line-height: 1.1; margin-bottom: 8px; }
.section-title { margin: 18px 0 8px; font-size: 1.1rem; color: var(--gold); text-align: left; }
.found { margin: 10px 0; padding: 8px 12px; border-radius: 12px; background: rgba(255, 207, 74, 0.14); border: 1px solid rgba(255, 207, 74, 0.45); color: #ffe9a3; font-weight: 600; }
.story { font-style: italic; color: #e6dcff; line-height: 1.55; }

.order-list, .recipe-list, .zone-list, .seed-list, .journal { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.order-card { position: relative; display: flex; gap: 12px; align-items: stretch; padding: 12px; border-radius: 16px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--glass-border); }
.order-card.d2 { border-color: rgba(92, 200, 255, 0.5); } .order-card.d3 { border-color: rgba(255, 207, 74, 0.7); }
.order-card.done { border-color: var(--mint); background: rgba(70, 240, 193, 0.1); }
.order-client { flex: 0 0 76px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.order-client .emoji, .client-img { font-size: 2.6rem; width: 56px; height: 56px; object-fit: contain; display: flex; align-items: center; justify-content: center; }
.client-name { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.order-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.order-line { font-style: italic; color: var(--muted); font-size: 0.9rem; }
.order-goal { font-weight: 700; }
.order-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.order-reward { color: var(--gold); }
.claim-btn { align-self: center; width: auto; margin: 0; padding: 12px 20px; }
.recipe-btn { margin-bottom: 0; }
.recipe-btn.affordable { border-color: var(--gold); }
.recipe-btn.purchased { border-color: rgba(70, 240, 193, 0.6); background: rgba(70, 240, 193, 0.1); opacity: 1; }

.mould-game, .mould-intro, .mould-result { text-align: center; }
.mould-cells { list-style: none; display: flex; justify-content: center; gap: 8px; margin: 10px 0; }
.mould-cell { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: rgba(0, 0, 0, 0.3); border: 2px dashed var(--glass-border); font-size: 1.4rem; }
.mould-cell.active { border-style: solid; border-color: var(--gold); }
.mould-cell.perfect { border-color: var(--gold); background: rgba(255, 207, 74, 0.2); } .mould-cell.good { border-color: var(--mint); } .mould-cell.miss { border-color: var(--danger); opacity: 0.7; }
.pour-bar { position: relative; height: 52px; margin: 16px 0 8px; border-radius: 26px; background: linear-gradient(180deg, #2a1550, #1a0b38); border: 2px solid var(--glass-border); overflow: hidden; touch-action: none; }
.pour-zone { position: absolute; top: 0; bottom: 0; background: rgba(70, 240, 193, 0.35); border-left: 2px solid var(--mint); border-right: 2px solid var(--mint); }
.pour-perfect { position: absolute; top: 0; bottom: 0; background: rgba(255, 207, 74, 0.55); }
.pour-cursor { position: absolute; top: 4px; bottom: 4px; width: 8px; margin-left: -4px; border-radius: 4px; background: #fff; box-shadow: 0 0 14px #fff; }
.mould-feedback { min-height: 1.6em; font-weight: 700; font-size: 1.2rem; }
.mould-feedback.perfect { color: var(--gold); } .mould-feedback.good { color: var(--mint); } .mould-feedback.miss { color: var(--danger); }
.pour-btn { justify-content: center; font-size: 1.2rem; margin: 10px 0 0; }

.plot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 420px; margin: 12px auto; }
.plot { position: relative; aspect-ratio: 1; border-radius: 18px; display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg, #5b3a29, #3e2619); border: 2px solid #7a4f37; box-shadow: inset 0 6px 14px rgba(0, 0, 0, 0.4); transition: transform 0.1s, border-color 0.12s; overflow: hidden; }
.plot:hover:not(.locked) { transform: translateY(-2px); border-color: var(--gold); }
.plot.locked { opacity: 0.4; } .plot.selected { border-color: var(--pink); box-shadow: 0 0 18px var(--pink); }
.plot.ready { border-color: var(--gold); animation: pulseBanner 1s infinite; box-shadow: 0 0 20px rgba(255, 207, 74, 0.6); }
.plot-empty { font-size: 2rem; color: rgba(255, 255, 255, 0.4); } .plot-lock { font-size: 1.6rem; }
.plot-plant { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.plot-plant .progress { position: absolute; left: 10%; right: 10%; bottom: 8px; }
.plot-timer { position: absolute; top: 6px; font-size: 0.72rem; font-weight: 600; background: rgba(0, 0, 0, 0.5); padding: 1px 8px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.plant-sprite { display: block; width: 80%; aspect-ratio: 1; background-size: 300% 100%; background-repeat: no-repeat; }
.plant-emoji { font-size: 2.6rem; }
.seed-btn { margin-bottom: 0; }
.seed-btn .building-icon { flex-basis: 52px; height: 52px; } .seed-btn .plant-sprite { width: 100%; } .seed-btn .plant-emoji { font-size: 1.8rem; }

.zone-card { display: flex; gap: 12px; padding: 10px; border-radius: 16px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--glass-border); }
.zone-card.running { border-color: var(--sky); } .zone-card.locked { opacity: 0.5; }
.zone-art { flex: 0 0 120px; border-radius: 12px; overflow: hidden; background: linear-gradient(135deg, #3a1c7a, #16105f); display: flex; align-items: center; justify-content: center; min-height: 84px; font-size: 2.6rem; }
.zone-img { width: 100%; height: 100%; object-fit: cover; }
.zone-art .emoji { width: auto; height: auto; font-size: 3rem; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5)); }
.zone-card[data-zone="foret"] .zone-art { background: linear-gradient(135deg, #0f3d2a, #2d1b4e); }
.zone-card[data-zone="montagne"] .zone-art { background: linear-gradient(135deg, #5a4a6e, #c7b6d8); }
.zone-card[data-zone="ocean"] .zone-art { background: linear-gradient(135deg, #b8742a, #f0b64a); }
.zone-card[data-zone="grotte"] .zone-art { background: linear-gradient(135deg, #1a1f5a, #8b4bd6); }
.zone-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.zone-body h3 { font-size: 1.05rem; }
.zone-body .buy-btn { margin: 0; width: auto; align-self: flex-start; justify-content: center; }
.zone-run { display: flex; flex-direction: column; gap: 4px; } .zone-time { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.artifact-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.artifact { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 14px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--glass-border); opacity: 0.7; }
.artifact.owned { opacity: 1; border-color: rgba(255, 207, 74, 0.55); background: rgba(255, 207, 74, 0.08); }
.artifact-icon { flex: 0 0 52px; height: 52px; display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.artifact-img { width: 52px; height: 52px; object-fit: contain; }
.artifact-text { display: flex; flex-direction: column; min-width: 0; }
.journal-entry { text-align: left; padding: 10px 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.22); }
.journal-entry p { color: #e6dcff; font-size: 0.95rem; margin-top: 4px; }
.away-list { list-style: none; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.away-list li { padding: 6px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); }

/* Pluie de bonbons */
#rain-layer { position: fixed; inset: 0; z-index: 3000; background: radial-gradient(circle at 50% 0, rgba(255, 79, 163, 0.25), rgba(10, 4, 28, 0.55)); overflow: hidden; touch-action: none; }
.rain-title { position: absolute; top: 14px; left: 0; right: 0; text-align: center; font-size: 1.5rem; font-weight: 700; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); pointer-events: none; }
.rain-hud { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); display: flex; gap: 18px; align-items: center; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rain-skip { width: auto; margin: 0; padding: 6px 14px; font-size: 0.9rem; }
.candy { position: absolute; top: 0; width: 64px; height: 64px; margin-left: -32px; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; will-change: transform; touch-action: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4)); }
.candy img { width: 100%; height: 100%; object-fit: contain; }
.candy.golden { filter: drop-shadow(0 0 14px var(--gold)); }

.legacy-header, .center { text-align: center; }
.legacy-header { margin-bottom: 14px; }
.gold-text { color: var(--gold); font-size: 1.6rem; margin: 6px 0; } .gold-text.big { font-size: 2.6rem; }
.hint { font-size: 0.9rem; color: var(--muted); margin: 6px 0; line-height: 1.4; }
.error-text { color: var(--danger); font-weight: 600; margin-top: 10px; text-align: center; }
.big-crown { font-size: 3.6rem; }
hr.dashed { border: 0; border-top: 1px dashed var(--glass-border); margin: 14px 0; }

/* ---------- Adaptation : écrans moyens ---------- */
@media (max-width: 1180px) {
    :root { --shop-w: 372px; }
    #hud { grid-template-columns: 1fr auto; padding: 8px 12px 0; }
    #hud-center { grid-column: 1 / -1; grid-row: 2; }
    #game-logo { height: 46px; }
    .dock-btn { width: 64px; } .dock-icon, .dock-icon img { width: 36px; height: 36px; font-size: 1.7rem; }
    .prestige-tree { grid-template-columns: 1fr; }
}

/* ---------- Mobile : scène en haut, feuille inférieure ---------- */
@media (max-width: 900px) {
    :root { --shop-w: 0px; --ticker-h: 0px; --sheet-h: 42dvh; --dock-h: 88px; }
    body.shop-collapsed { --sheet-h: 56px; }
    #ticker { display: none; }
    #chapter-label .chapter-num { display: none; }
    #hud { right: 0; grid-template-columns: 1fr auto; padding: 8px 10px 0; }
    #hud-center { grid-column: 1 / -1; grid-row: 2; }
    #hud-left { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
    #game-logo { height: 36px; }
    #chapter-label { font-size: 0.72rem; }
    .score { font-size: clamp(2.1rem, 10vw, 3.1rem); }
    .icon-btn { width: 40px; height: 40px; font-size: 1.15rem; } .menu-controls { gap: 6px; }
    #buffs-strip { display: none; }
    #hud-chips .chip-bar { width: 56px; }

    #shop { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet-h); border-radius: 22px 22px 0 0; border-bottom: 0; transition: height 0.3s; }
    body.shop-collapsed #shop { transform: none; width: auto; }
    #shop-toggle { left: 50%; top: -22px; width: 76px; height: 26px; transform: translateX(-50%); border-radius: 14px 14px 0 0; border: 1px solid var(--glass-border); border-bottom: 0; }
    #shop-toggle span[aria-hidden] { transform: rotate(90deg); display: inline-block; font-size: 1rem; }
    body.shop-collapsed #shop-toggle span[aria-hidden] { transform: rotate(-90deg); }
    body.shop-collapsed #shop-body { display: none; }
    #shop-body .panel-head { padding: 10px 12px 6px; } .panel-head h2 { font-size: 1.1rem; }
    #shop-tabs { padding-bottom: 6px; } #shop-tabs button { padding: 6px 4px; font-size: 0.9rem; }
    .building-icon { flex-basis: 50px; height: 50px; } .building-icon img { width: 38px; height: 38px; }
    .buy-btn { padding: 8px 10px 11px; margin-bottom: 8px; gap: 10px; }

    #dock { top: auto; left: 0; right: 0; bottom: var(--sheet-h); height: var(--dock-h); transform: none; flex-direction: row; justify-content: center; align-items: flex-end; gap: 8px; padding: 0 8px 26px; pointer-events: none; }
    .dock-btn { pointer-events: auto; width: 62px; padding: 5px 2px 4px; border-radius: 16px; }
    .dock-icon, .dock-icon img { width: 32px; height: 32px; font-size: 1.5rem; } .dock-label { font-size: 0.62rem; }

    #modal-box { padding: 20px 16px 16px; } #modal-title { font-size: 1.45rem; }
    .button-row { flex-direction: column; }
    #notice-region { bottom: calc(var(--sheet-h) + 100px); }
    #speech { font-size: 0.85rem; max-width: 230px; padding: 6px 12px; }
    .achievement-popup { bottom: calc(var(--sheet-h) + 14px); }
    .order-card { flex-direction: column; } .order-client { flex-direction: row; flex-basis: auto; }
    .zone-card { flex-direction: column; } .zone-art { flex-basis: auto; min-height: 90px; }
}
@media (max-height: 640px) and (max-width: 900px) { #game-logo { display: none; } }

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