@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

#creeper-typer-wrapper {
    width: 100%;
    height: 100%;
    min-height: 600px;
    max-height: 90vh; /* S'adapte à la hauteur max de la fiche Ergo'Land */
    background: #000;
    font-family: 'Press Start 2P', monospace;
    user-select: none;
    -webkit-user-select: none;
    color: #fff;
    position: relative;
    overflow: hidden;
    border-radius: 15px; /* Arrondi propre Ergo'Land */
}

#creeper-typer-wrapper:fullscreen { 
    width: 100vw; 
    height: 100vh; 
    max-height: 100vh; 
    border-radius: 0; 
    padding: 0; 
}

#creeper-typer-wrapper button { font-family: inherit; }
#creeper-typer-wrapper .hidden { display: none !important; }
#creeper-typer-wrapper canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

/* --- CORRECTION ESSENTIELLE : absolute au lieu de fixed --- */
#creeper-typer-wrapper #game {
    position: absolute;
    inset: 0;
    overflow: hidden;
}
#creeper-typer-wrapper #game.shake { animation: ct-shake .32s; }
@keyframes ct-shake {
    0%,100%{transform:translate(0,0)}
    20%{transform:translate(-8px,5px)}
    40%{transform:translate(7px,-6px)}
    60%{transform:translate(-6px,3px)}
    80%{transform:translate(5px,-2px)}
}

/* ---------- CIEL ---------- */
#creeper-typer-wrapper #sky { position: absolute; inset: 0; transition: background 2.5s; }
#creeper-typer-wrapper .sky-day { background: linear-gradient(#69b7ff, #bfe6ff 70%, #dff3ff); }
#creeper-typer-wrapper .sky-sunset { background: linear-gradient(#2c3e7a, #ff9e5e 72%, #ffd29e); }
#creeper-typer-wrapper .sky-night { background: linear-gradient(#050716, #1b2450 72%, #28355f); }
#creeper-typer-wrapper .sky-dawn { background: linear-gradient(#3a4a8c, #e8a3b8 70%, #ffe9c9); }
#creeper-typer-wrapper #stars { position: absolute; inset: 0; opacity: 0; transition: opacity 2.5s; }
#creeper-typer-wrapper .sky-night #stars { opacity: 1; }
#creeper-typer-wrapper .star { position: absolute; background: #fff; animation: ct-twinkle 2s infinite; }
@keyframes ct-twinkle { 0%,100%{opacity:.25} 50%{opacity:1} }
#creeper-typer-wrapper #sun, #creeper-typer-wrapper #moon { position: absolute; transition: opacity 2.5s; }
#creeper-typer-wrapper #sun { top: 9%; right: 13%; width: 64px; height: 64px; background: #fff3a1; box-shadow: 0 0 46px 14px rgba(255,243,161,.55); }
#creeper-typer-wrapper #moon { top: 11%; right: 15%; width: 54px; height: 54px; background: #e8e8d8; box-shadow: inset -14px -10px 0 #b9b9ac, 0 0 26px rgba(255,255,255,.35); }
#creeper-typer-wrapper .sky-night #sun { opacity: 0; }
#creeper-typer-wrapper .sky-day #moon, #creeper-typer-wrapper .sky-sunset #moon, #creeper-typer-wrapper .sky-dawn #moon { opacity: 0; }

#creeper-typer-wrapper .cloud { position: absolute; height: 26px; width: 160px; background: rgba(255,255,255,.92); animation: ct-drift linear infinite; }
#creeper-typer-wrapper .cloud::before { content: ""; position: absolute; left: 26px; top: -16px; width: 74px; height: 16px; background: inherit; }
#creeper-typer-wrapper .cloud::after { content: ""; position: absolute; left: 96px; top: -10px; width: 40px; height: 10px; background: inherit; }
#creeper-typer-wrapper .sky-night .cloud, #creeper-typer-wrapper .sky-sunset .cloud { opacity: .4; }
@keyframes ct-drift { from{transform:translateX(-340px)} to{transform:translateX(calc(100vw + 340px))} }

#creeper-typer-wrapper .hill { position: absolute; bottom: 72px; transition: filter 2.5s; }
#creeper-typer-wrapper .h1 { left: -6%; width: 58%; height: 190px; background: #6fae57; clip-path: polygon(0 100%, 0 55%, 8% 55%, 8% 38%, 18% 38%, 18% 22%, 34% 22%, 34% 38%, 46% 38%, 46% 60%, 60% 60%, 60% 76%, 100% 76%, 100% 100%); }
#creeper-typer-wrapper .h2 { right: -8%; width: 62%; height: 150px; background: #4e8a3f; clip-path: polygon(0 78%, 12% 78%, 12% 52%, 26% 52%, 26% 34%, 44% 34%, 44% 52%, 58% 52%, 58% 68%, 74% 68%, 74% 84%, 100% 84%, 100% 100%); }
#creeper-typer-wrapper .sky-night .hill { filter: brightness(.4); }
#creeper-typer-wrapper .sky-sunset .hill { filter: brightness(.7) saturate(1.15); }
#creeper-typer-wrapper .sky-dawn .hill { filter: brightness(.65); }

#creeper-typer-wrapper #ground {
    position: absolute; bottom: 0; left: 0; right: 0; height: 72px; border-top: 3px solid #90d465; transition: filter 2.5s;
    background:
      repeating-linear-gradient(90deg, rgba(0,0,0,.10) 0 3px, transparent 3px 48px),
      repeating-linear-gradient(0deg, rgba(0,0,0,.06) 0 4px, transparent 4px 16px),
      linear-gradient(#71b74e 0 12px,#5d9c3e 12px 15px,#7a5638 15px);
}
#creeper-typer-wrapper .sky-night #ground { filter: brightness(.4); }
#creeper-typer-wrapper .sky-sunset #ground { filter: brightness(.72); }
#creeper-typer-wrapper .sky-dawn #ground { filter: brightness(.62); }

/* ---------- ENTITÉS ---------- */
#creeper-typer-wrapper #playfield { position: absolute; inset: 0; z-index: 2; }
#creeper-typer-wrapper .entity { position: absolute; top: 0; left: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; will-change: transform; animation: ct-spawnIn .3s; }
@keyframes ct-spawnIn { from{opacity:0} to{opacity:1} }
#creeper-typer-wrapper .entity canvas { width: 56px; height: 56px; filter: drop-shadow(0 5px 0 rgba(0,0,0,.18)); }
#creeper-typer-wrapper .tag { background: rgba(18,18,18,.78); color: #fff; padding: 6px 9px; font-size: 10px; letter-spacing: 2px; border-radius: 3px; white-space: nowrap; box-shadow: 0 3px 0 rgba(0,0,0,.28); }
#creeper-typer-wrapper .tag span.ok { color: #7cf24a; }
#creeper-typer-wrapper .entity.target .tag { background: rgba(45,70,18,.95); box-shadow: 0 0 0 2px #b9f24a, 0 3px 0 rgba(0,0,0,.28); }
#creeper-typer-wrapper .entity.target canvas, #creeper-typer-wrapper .entity.target .tntbox { filter: drop-shadow(0 0 7px #d0ff70); }
#creeper-typer-wrapper .entity.flash .tag { background: #8a1f1f !important; box-shadow: 0 0 0 2px #ff5f4a !important; }
#creeper-typer-wrapper .tntbox { width: 56px; height: 56px; position: relative; border: 2px solid #7e2a1c; background: repeating-linear-gradient(90deg, #c8442f 0 8px, #b03a28 8px 16px); }
#creeper-typer-wrapper .tntbox::before { content: "TNT"; position: absolute; left: 0; right: 0; top: 17px; height: 17px; background: #e8e0d0; color: #222; font-size: 8px; display: flex; align-items: center; justify-content: center; }
#creeper-typer-wrapper .tntbox::after { content: ""; position: absolute; top: -9px; left: 24px; width: 7px; height: 7px; background: #ffd83d; animation: ct-spark .18s infinite alternate; }
@keyframes ct-spark { from{background:#ffd83d;box-shadow:0 0 6px #ffd83d} to{background:#ff7b2d;box-shadow:0 0 10px #ff7b2d} }

#creeper-typer-wrapper .pop { position: absolute; z-index: 4; transform: translate(-50%, -100%); font-size: 13px; color: #fff; text-shadow: 2px 2px #000; animation: ct-rise .9s forwards; pointer-events: none; }
#creeper-typer-wrapper .pop.heal { color: #ff9d94; }
#creeper-typer-wrapper .pop.boom { color: #ffb03d; font-size: 15px; }
@keyframes ct-rise { to{transform:translate(-50%,-210%);opacity:0} }

#creeper-typer-wrapper #fx { position: absolute; inset: 0; z-index: 6; pointer-events: none; }

/* ---------- HUD ---------- */
#creeper-typer-wrapper #hud { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
#creeper-typer-wrapper #hearts { position: absolute; top: 14px; left: 14px; display: flex; gap: 3px; }
#creeper-typer-wrapper #hearts canvas { width: 21px; height: 21px; }
#creeper-typer-wrapper #topBtns { position: absolute; top: 10px; right: 12px; display: flex; gap: 8px; pointer-events: auto; }
#creeper-typer-wrapper #topBtns button { width: 40px; height: 40px; font-size: 16px; cursor: pointer; background: rgba(0,0,0,0.4); border: 2px solid #555; color: #fff; display: flex; align-items: center; justify-content: center; }
#creeper-typer-wrapper #topBtns button:hover { border-color: #fff; }
#creeper-typer-wrapper #scoreBox { position: absolute; top: 60px; right: 14px; text-align: right; }
#creeper-typer-wrapper #scoreBox .row { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
#creeper-typer-wrapper #scoreBox canvas { width: 22px; height: 22px; }
#creeper-typer-wrapper #score { font-size: 20px; text-shadow: 2px 2px #000; }
#creeper-typer-wrapper #bestLabel { display: block; margin-top: 6px; font-size: 8px; color: #ffe27a; text-shadow: 1px 1px #000; }
#creeper-typer-wrapper #toolBonus { display: block; margin-top: 5px; font-size: 8px; color: #8dfc3f; text-shadow: 1px 1px #000; }
#creeper-typer-wrapper #comboBox { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); font-size: 14px; color: #ffd23d; text-shadow: 2px 2px #000; opacity: 0; transition: opacity .25s; }
#creeper-typer-wrapper #comboBox.show { opacity: 1; }
#creeper-typer-wrapper #comboBox b { font-size: 24px; color: #ff9d2d; }
#creeper-typer-wrapper #comboBox.pulse { animation: ct-cpulse .25s; }
@keyframes ct-cpulse { 50%{transform:translateX(-50%) scale(1.3)} }

#creeper-typer-wrapper #lvlWrap { position: absolute; bottom: 88px; left: 50%; transform: translateX(-50%); width: min(430px, 72vw); text-align: center; }
#creeper-typer-wrapper #lvlNum { display: block; margin-bottom: 5px; font-size: 13px; color: #8dfc3f; text-shadow: 2px 2px #000; }
#creeper-typer-wrapper #xpbar { height: 12px; background: rgba(0,0,0,.55); border: 2px solid #0e2007; }
#creeper-typer-wrapper #xpfill { height: 100%; width: 0%; background: linear-gradient(#b8ff5e, #4ecf1f); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }

#creeper-typer-wrapper #hotbar { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 3px; background: rgba(0,0,0,.35); border: 2px solid #111; }
#creeper-typer-wrapper .slot { position: relative; width: 46px; height: 46px; background: rgba(90,90,90,.45); border: 2px solid; border-color: #2a2a2a #6e6e6e #6e6e6e #2a2a2a; display: flex; align-items: center; justify-content: center; }
#creeper-typer-wrapper .slot canvas { width: 32px; height: 32px; }
#creeper-typer-wrapper .slot.locked { opacity: .22; filter: grayscale(1); }
#creeper-typer-wrapper .slot.sel { border-color: #fff; background: rgba(150,150,150,.55); }
#creeper-typer-wrapper .slot.glint::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 32%, rgba(255,110,255,.5) 47%, transparent 62%); background-size: 220% 220%; animation: ct-glint 1.5s linear infinite; mix-blend-mode: screen; }
@keyframes ct-glint { from{background-position:130% 0} to{background-position:-130% 0} }

#creeper-typer-wrapper #hurt { position: absolute; inset: 0; z-index: 15; pointer-events: none; opacity: 0; transition: opacity .12s; background: radial-gradient(ellipse at center, transparent 38%, rgba(205,20,10,.6)); }
#creeper-typer-wrapper #hurt.on { opacity: 1; }
#creeper-typer-wrapper #flash { position: absolute; inset: 0; z-index: 15; background: #fff; opacity: 0; pointer-events: none; }
#creeper-typer-wrapper #flash.on { animation: ct-lvlflash .5s; }
@keyframes ct-lvlflash { 0%{opacity:.75} 100%{opacity:0} }
#creeper-typer-wrapper #bigmsg { position: absolute; top: 34%; left: 50%; transform: translateX(-50%); z-index: 18; font-size: clamp(20px, 4vw, 38px); color: #ffe27a; text-shadow: 3px 3px #000; opacity: 0; pointer-events: none; white-space: nowrap; }
#creeper-typer-wrapper #bigmsg.go { animation: ct-big 1.4s; }
@keyframes ct-big { 0%{opacity:0;transform:translateX(-50%) scale(.4)} 15%{opacity:1;transform:translateX(-50%) scale(1.1)} 25%{transform:translateX(-50%) scale(1)} 75%{opacity:1} 100%{opacity:0} }

#creeper-typer-wrapper #toasts { position: absolute; top: 64px; right: 14px; z-index: 20; display: flex; flex-direction: column; gap: 8px; }
#creeper-typer-wrapper .toast { background: #212121e6; border: 3px solid; border-color: #5a5a5a #101010 #101010 #5a5a5a; padding: 10px 14px; min-width: 250px; transform: translateX(120%); animation: ct-tin .4s forwards; }
#creeper-typer-wrapper .toast b { display: block; font-size: 10px; color: #ffe27a; margin-bottom: 6px; }
#creeper-typer-wrapper .toast span { font-size: 8px; color: #cfcfcf; }
#creeper-typer-wrapper .toast.out { animation: ct-tout .4s forwards; }
@keyframes ct-tin { to{transform:translateX(0)} }
@keyframes ct-tout { to{transform:translateX(130%);opacity:0} }

/* ---------- ÉCRANS ---------- */
#creeper-typer-wrapper .screen { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; padding: 20px; }
#creeper-typer-wrapper #title {
    background-color: #7a5638;
    background-image:
      repeating-linear-gradient(0deg, rgba(0,0,0,.14) 0 8px, transparent 8px 16px),
      repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 8px, transparent 8px 16px),
      radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,.62));
}
#creeper-typer-wrapper .logoWrap { position: relative; margin-bottom: 6px; }
#creeper-typer-wrapper .tlogo { font-size: clamp(28px, 6vw, 58px); line-height: 1.25; color: #fff; text-shadow: 4px 4px 0 #3a3a3a, 8px 8px 0 rgba(0,0,0,.35); }
#creeper-typer-wrapper .tlogo em { font-style: normal; color: #7cf24a; }
#creeper-typer-wrapper #splash { position: absolute; right: -70px; bottom: -6px; transform: rotate(-12deg); color: #ff0; font-size: clamp(9px, 1.4vw, 13px); text-shadow: 2px 2px #3f3f00; animation: ct-splash .5s infinite alternate; white-space: nowrap; max-width: 280px; }
@keyframes ct-splash { from{transform:rotate(-12deg) scale(1)} to{transform:rotate(-12deg) scale(1.09)} }
#creeper-typer-wrapper .tagline { font-size: 10px; color: #ffd; text-shadow: 2px 2px #000; }
#creeper-typer-wrapper .btn { font-size: 13px; padding: 14px 28px; color: #fff; text-shadow: 2px 2px #3f3f3f; cursor: pointer; background: linear-gradient(#8b8b8b, #6f6f6f 45%, #5a5a5a); border: 3px solid; border-color: #c6c6c6 #3f3f3f #3f3f3f #c6c6c6; }
#creeper-typer-wrapper .btn:hover { filter: brightness(1.15); outline: 2px solid #fff; }
#creeper-typer-wrapper .btn:active { transform: translateY(2px); }
#creeper-typer-wrapper .btn.sel { outline: 3px solid #ffe27a; }
#creeper-typer-wrapper .btn.small { font-size: 9px; padding: 10px 14px; }
#creeper-typer-wrapper .btn.big { font-size: 16px; padding: 18px 46px; }
#creeper-typer-wrapper #diffs { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
#creeper-typer-wrapper #bestTitle { font-size: 10px; color: #ffe27a; text-shadow: 2px 2px #000; }
#creeper-typer-wrapper .hint { font-size: 8px; color: #ddd; line-height: 2; text-shadow: 1px 1px #000; }
#creeper-typer-wrapper #mobRow { display: flex; gap: 26px; margin-top: 6px; }
#creeper-typer-wrapper #mobRow canvas { width: 52px; height: 52px; animation: ct-bob 1.6s ease-in-out infinite; }
@keyframes ct-bob { 50%{transform:translateY(-9px)} }

#creeper-typer-wrapper #pause { background: rgba(0,0,0,.6); }
#creeper-typer-wrapper #pause .sub { font-size: 9px; color: #ccc; }
#creeper-typer-wrapper #over { background: radial-gradient(ellipse at center, rgba(90,0,0,.55), rgba(20,0,0,.88)); }
#creeper-typer-wrapper .dead { font-size: clamp(22px, 4.5vw, 42px); color: #fff; text-shadow: 4px 4px #500; }
#creeper-typer-wrapper #newRec { font-size: 13px; color: #ffe27a; animation: ct-splash .5s infinite alternate; }
#creeper-typer-wrapper .panel { background: rgba(20,20,20,.82); border: 3px solid; border-color: #565656 #101010 #101010 #565656; padding: 18px 26px; min-width: min(420px, 86vw); }
#creeper-typer-wrapper .panel .row { display: flex; justify-content: space-between; gap: 30px; font-size: 10px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
#creeper-typer-wrapper .panel .row:last-child { border: none; }
#creeper-typer-wrapper .panel .v { color: #7cf24a; }
#creeper-typer-wrapper #tip { font-size: 8px; color: #ffd9a0; max-width: 520px; line-height: 1.8; }
#creeper-typer-wrapper .rowBtns { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
#creeper-typer-wrapper #pause h1 { font-size: 34px; text-shadow: 4px 4px #000; }

@media (max-width: 600px) {
    #creeper-typer-wrapper .slot { width: 35px; height: 35px; }
    #creeper-typer-wrapper .slot canvas { width: 24px; height: 24px; }
}