:root {
  --gold: #d9a54a;
  --gold-dim: #8a6427;
  --ember: #ff8a1f;
  --toxic: #7dff8a;
  --violet: #8d5bd6;
  --ink: #f1e4c8;
  --bg: #07050b;
  --sw: 960px;
  --slot: 64px;
  --font-title: "Cinzel Decorative", "Cinzel", serif;
  --font-ui: "Cinzel", serif;
  --font-text: "IM Fell English", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-text);
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
img { -webkit-user-drag: none; user-select: none; pointer-events: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

body { display: grid; place-items: center; }
.page-bg { position: fixed; inset: 0; background: url(../assets/bg_menu.jpg) center/cover; filter: blur(14px) brightness(.25) saturate(1.3); transform: scale(1.1); }

/* Cadre unique, de la taille du jeu, autour de tous les écrans */
.shell {
  position: relative; width: var(--fw); height: var(--fh);
  border-radius: 6px;
  background: linear-gradient(180deg, #1a0f12, #0b0710);
  border: 2px solid #5a3b17;
  box-shadow:
    0 0 0 1px #000, 0 0 0 5px #24160c, 0 0 0 6px #8a6427,
    0 0 40px rgba(255,138,31,.25), 0 30px 80px rgba(0,0,0,.9);
}

.screen {
  position: absolute; inset: 0; display: none; overflow: hidden; border-radius: 4px;
  align-items: center; justify-content: center;
}
.screen.active { display: flex; }

/* ---------- Préchargement ---------- */
#loader { background: radial-gradient(ellipse at 50% 42%, #1e1129 0%, #0a0610 55%, #030205 100%); z-index: 50; transition: opacity .5s; }
#loader.done { opacity: 0; }
.loader-fog {
  position: absolute; inset: -20%; pointer-events: none; opacity: .5;
  background:
    radial-gradient(ellipse 40% 25% at 20% 85%, rgba(125,255,138,.10), transparent 70%),
    radial-gradient(ellipse 45% 30% at 80% 90%, rgba(141,91,214,.16), transparent 70%),
    radial-gradient(ellipse 35% 20% at 50% 100%, rgba(255,138,31,.10), transparent 70%);
  animation: fogdrift 14s ease-in-out infinite alternate;
}
@keyframes fogdrift { to { transform: translateX(6%) scale(1.08); } }
.loader-embers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.loader-embers i {
  position: absolute; bottom: -10px; width: 3px; height: 3px; border-radius: 50%;
  background: #ffb347; box-shadow: 0 0 6px 2px rgba(255,138,31,.7);
  animation: ember linear infinite;
}
@keyframes ember {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--dx), -105vh); opacity: 0; }
}
.loader-inner { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; }
.loader-ring { position: relative; width: clamp(150px, 26vmin, 230px); aspect-ratio: 1; display: grid; place-items: center; }
.loader-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.loader-moon {
  width: 46%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #ffd38a, #ff8a1f 55%, #7a2600 100%);
  box-shadow: 0 0 40px 6px rgba(255,138,31,.45), 0 0 110px 30px rgba(141,91,214,.22);
  animation: pulse 2.6s ease-in-out infinite; opacity: .9;
}
.lr-runes { transform-origin: 100px 100px; animation: spin 40s linear infinite; }
.lr-runes text { font-family: "Noto Sans Runic", serif; font-size: 13px; letter-spacing: 3.2px; fill: #c99cff; opacity: .55; filter: drop-shadow(0 0 3px rgba(141,91,214,.9)); }
.lr-track { fill: none; stroke: rgba(217,165,74,.18); stroke-width: 1.5; }
.lr-arc {
  fill: none; stroke: #ffb347; stroke-width: 2.5; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
  transform: rotate(-90deg); transform-origin: 100px 100px;
  filter: drop-shadow(0 0 4px #ff8a1f) drop-shadow(0 0 10px rgba(255,138,31,.6));
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-pct {
  position: absolute; font-family: var(--font-ui); font-weight: 700; font-size: clamp(22px, 4.4vmin, 34px);
  color: #2a0e00; text-shadow: 0 1px 0 rgba(255,220,160,.5); font-variant-numeric: tabular-nums;
}
.loader-pct small { font-size: .55em; margin-left: 1px; }
.loader-title {
  margin-top: clamp(22px, 4.5vmin, 38px);
  font-family: var(--font-title); font-weight: 900; font-size: clamp(22px, 4.2vmin, 36px); letter-spacing: 1px;
  color: #ffb347; text-shadow: 0 0 14px rgba(255,120,20,.6), 0 3px 0 #3a1500;
}
.loader-title span { color: #c99cff; text-shadow: 0 0 14px rgba(141,91,214,.8), 0 3px 0 #1d0b33; }
.loader-txt {
  margin-top: 14px; font-style: italic; font-size: clamp(14px, 2.2vmin, 18px); letter-spacing: .5px; color: var(--ink);
  opacity: .7; animation: txtin .7s ease both;
}
.loader-txt::before, .loader-txt::after { content: "✦"; font-style: normal; font-size: .6em; color: var(--gold); margin: 0 .9em; vertical-align: middle; opacity: .8; }
@keyframes txtin { from { opacity: 0; transform: translateY(4px); } to { opacity: .7; transform: none; } }
@keyframes pulse { 50% { transform: scale(1.05); box-shadow: 0 0 60px 12px rgba(255,138,31,.55), 0 0 140px 40px rgba(141,91,214,.28); } }

/* ---------- Splash ---------- */
#splash { z-index: 45; background: radial-gradient(ellipse at 50% 45%, #1c0d22 0%, #050308 72%); cursor: pointer; }
#splash.out { animation: splashOut .9s ease-in forwards; }
.splash-glow {
  position: absolute; left: 50%; top: 50%; width: 120%; aspect-ratio: 1; translate: -50% -50%;
  background: radial-gradient(circle, rgba(255,120,20,.28) 0%, rgba(141,91,214,.12) 35%, transparent 60%);
  opacity: 0; animation: splashFade 2s .4s ease-out forwards, glowBreath 3.2s 2.4s ease-in-out infinite;
}
.splash-card {
  position: relative; width: min(72%, calc(var(--fh, 100vh) * .72 * 791 / 590)); aspect-ratio: 791 / 590;
  border-radius: 6px; overflow: hidden;
  border: 2px solid #8a6427;
  box-shadow:
    0 0 0 1px #000, 0 0 0 6px #1a0f0a, 0 0 0 7px #d9a54a55,
    0 0 50px rgba(255,138,31,.45), 0 0 120px rgba(141,91,214,.3), 0 30px 60px rgba(0,0,0,.9);
  opacity: 0; transform: scale(1.08); filter: blur(10px) brightness(2.2);
  animation: cardIn 1.6s .25s cubic-bezier(.2,.7,.2,1) forwards;
}
.splash-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Lueur surnaturelle qui s'échappe de la porte */
.splash-door {
  position: absolute; left: 39.5%; top: 35.5%; width: 22.5%; height: 42.5%;
  background:
    radial-gradient(ellipse at 50% 75%, rgba(255,190,90,.95) 0%, rgba(255,110,10,.75) 30%, rgba(120,30,140,.5) 65%, transparent 100%);
  mix-blend-mode: screen; opacity: 0;
  animation: splashFade 1.4s 1.3s forwards, doorFlicker 2.6s 2.7s infinite;
}
.splash-door::after {
  content: ""; position: absolute; left: -60%; right: -60%; top: 85%; height: 45%;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,140,40,.55), transparent 70%);
}
/* Étalonnage nocturne + vignette (le logo reste lisible) */
.splash-grade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 35%, rgba(10,3,18,.55) 75%, rgba(5,2,10,.92) 100%),
    linear-gradient(180deg, rgba(60,20,110,.35), rgba(110,40,0,.25));
  mix-blend-mode: multiply;
}
.splash-jack {
  position: absolute; left: 8%; bottom: 4%; width: 16%;
  filter: drop-shadow(0 0 14px rgba(255,140,30,.9)) drop-shadow(0 6px 6px rgba(0,0,0,.8));
  opacity: 0; transform: translateY(20%) scale(.8);
  animation: jackIn .9s 1.7s cubic-bezier(.3,1.6,.5,1) forwards, jackGlow 1.8s 2.6s ease-in-out infinite;
}
.splash-web { position: absolute; top: -2%; left: -2%; width: 22%; opacity: .85; filter: drop-shadow(0 0 4px #000); }
.splash-bat {
  position: absolute; width: 9%; opacity: 0; filter: brightness(.35) drop-shadow(0 0 6px rgba(255,138,31,.4));
}
.splash-bat.b1 { left: -12%; top: 30%; animation: batFly1 2.8s 1.2s ease-in-out forwards; }
.splash-bat.b2 { left: -12%; top: 22%; width: 6%; animation: batFly1 3.1s 1.5s ease-in-out forwards; }
.splash-bat.b3 { right: -12%; top: 62%; width: 7%; animation: batFly2 3s 1.9s ease-in-out forwards; }
.splash-fog {
  position: absolute; left: -20%; right: -20%; bottom: -8%; height: 38%; pointer-events: none;
  background:
    radial-gradient(ellipse at 25% 70%, rgba(190,170,220,.22), transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(190,170,220,.18), transparent 50%);
  filter: blur(10px); opacity: 0;
  animation: splashFade 2s .8s forwards, fogDrift 9s ease-in-out infinite alternate;
}
.splash-flash { position: absolute; inset: 0; background: #e8e0ff; opacity: 0; pointer-events: none; animation: lightning 1.1s .15s; }

@keyframes splashFade { to { opacity: 1; } }
@keyframes splashOut { to { opacity: 0; filter: brightness(.2); } }
@keyframes cardIn { to { opacity: 1; transform: scale(1); filter: blur(0) brightness(1); } }
@keyframes glowBreath { 50% { opacity: .65; transform: scale(1.05); } }
@keyframes doorFlicker { 0%,100% { opacity: 1; } 12% { opacity: .75; } 20% { opacity: .95; } 46% { opacity: .7; } 60% { opacity: 1; } 78% { opacity: .82; } }
@keyframes jackIn { to { opacity: 1; transform: none; } }
@keyframes jackGlow { 50% { filter: drop-shadow(0 0 24px rgba(255,160,40,1)) drop-shadow(0 6px 6px rgba(0,0,0,.8)); } }
@keyframes batFly1 {
  0% { opacity: 0; transform: translate(0,0) scale(.6); }
  15% { opacity: 1; }
  50% { transform: translate(70vw,-8vh) scale(1) rotate(-6deg); }
  100% { opacity: 0; transform: translate(130vw,-30vh) scale(.5) rotate(8deg); }
}
@keyframes batFly2 {
  0% { opacity: 0; transform: translate(0,0) scaleX(-1) scale(.6); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(-120vw,-45vh) scaleX(-1) scale(.4); }
}
@keyframes fogDrift { to { transform: translateX(10%); } }
@keyframes lightning { 0%,100% { opacity: 0; } 8% { opacity: .85; } 16% { opacity: .1; } 26% { opacity: .6; } 45% { opacity: 0; } }

/* ---------- Menu ---------- */
#menu { z-index: 40; overflow: hidden; }
.menu-bg {
  position: absolute; inset: -4%;
  background: url(../assets/bg_menu.jpg) center/cover;
  animation: drift 40s ease-in-out infinite alternate;
}
.menu-bg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(0,0,0,.1) 20%, rgba(0,0,0,.85) 100%); }
@keyframes drift { to { transform: scale(1.08) translate(-1.5%, 1%); } }
#menu-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.menu-content { position: relative; text-align: center; padding: 20px; }
.title {
  font-family: var(--font-title); font-weight: 900; line-height: .95;
  font-size: clamp(30px, 6vw, 84px); text-align: center; color: #ffb347;
  text-shadow: 0 0 10px rgba(255,120,20,.9), 0 0 40px rgba(255,90,0,.6), 0 4px 0 #3a1500, 0 8px 30px #000;
  display: flex; flex-direction: column; align-items: center;
  animation: flicker 6s infinite;
}
.title-sub { font-size: .55em; color: #c99cff; text-shadow: 0 0 14px rgba(141,91,214,.9), 0 3px 0 #1d0b33, 0 8px 30px #000; margin-top: .15em; }
.title.small { font-size: clamp(28px, 5vw, 60px); }
@keyframes flicker { 0%, 100% { opacity: 1; } 92% { opacity: 1; } 93% { opacity: .75; } 94% { opacity: 1; } 96% { opacity: .85; } }
.menu-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-top: clamp(24px, 6vh, 56px); }
.btn {
  font-family: var(--font-ui); font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  font-size: clamp(14px, 1.8vw, 18px); min-width: 260px; padding: 14px 30px;
  color: #ffe2b0; border: 1px solid var(--gold-dim); border-radius: 3px;
  background: linear-gradient(180deg, rgba(60,25,10,.85), rgba(20,8,20,.9));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.6), inset 0 0 20px rgba(255,138,31,.12), 0 6px 20px rgba(0,0,0,.6);
  transition: transform .15s, box-shadow .2s, color .2s;
}
.btn:hover { transform: translateY(-2px); color: #fff; box-shadow: inset 0 0 0 1px rgba(0,0,0,.6), inset 0 0 26px rgba(255,138,31,.35), 0 0 22px rgba(255,138,31,.35); }
.btn:active { transform: translateY(1px); }
.btn-small { min-width: 180px; padding: 9px 20px; font-size: 13px; opacity: .85; }

/* ---------- Intro ---------- */
#intro { background: #000; z-index: 45; }
.intro-text {
  max-width: 720px; padding: 30px; text-align: center;
  font-size: clamp(18px, 2.6vw, 28px); line-height: 1.6; color: #e8d6b0;
  text-shadow: 0 0 20px rgba(255,138,31,.25);
}
.intro-text p { opacity: 0; transform: translateY(10px); transition: opacity 1.4s, transform 1.4s; }
.intro-text p.show { opacity: 1; transform: none; }
.intro-text p.out { opacity: 0; transition: opacity .8s; }
.intro-skip { position: absolute; right: 20px; bottom: 20px; min-width: 0; }

/* ---------- Jeu ---------- */
#game { z-index: 10; }
.frame {
  position: relative; width: 100%; height: 100%;
  display: flex; flex-direction: column;
}
/* Décor du lieu étendu jusqu'aux bords (flouté), sous le HUD et l'inventaire */
.stage-fill {
  position: absolute; inset: -30px; background: #000 center/cover;
  filter: blur(18px) brightness(.5) saturate(1.2);
}
.stage-fill::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 60px rgba(0,0,0,.8); }
/* La scène remplit toute sa zone (rognage léger si besoin) ; le HUD passe par-dessus */
.stage-area { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.corner { position: absolute; width: clamp(50px, 9%, 110px); opacity: .45; z-index: 5; filter: drop-shadow(0 0 4px #000); }
.corner.tl { left: -6px; top: -6px; transform: scaleX(-1); }
.corner.tr { right: -6px; top: -6px; }

.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6; display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 12px 8px;
  background: linear-gradient(180deg, rgba(5,3,8,.75), rgba(5,3,8,.35) 60%, transparent);
}
.hud-scene { flex: 1; font-family: var(--font-ui); font-weight: 700; letter-spacing: 3px; text-transform: uppercase; font-size: clamp(11px, 1.5vw, 15px); color: var(--gold); text-shadow: 0 0 10px rgba(255,138,31,.4), 0 2px 4px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.hud-time { font-family: var(--font-ui); font-size: 14px; color: #c7b48d; min-width: 58px; text-align: right; }
.hud-btn {
  width: 36px; height: 36px; border-radius: 50%; font-size: 17px; line-height: 1;
  border: 1px solid var(--gold-dim); color: #ffd9a0;
  background: radial-gradient(circle at 40% 35%, #3a2414, #120a0c);
  box-shadow: 0 0 10px rgba(0,0,0,.6);
  transition: box-shadow .2s, transform .15s;
}
.hud-btn:hover { box-shadow: 0 0 14px rgba(255,138,31,.6); transform: scale(1.06); }
.hud-btn.off { opacity: .4; }
.hud-btn.hint { font-family: var(--font-title); color: var(--toxic); border-color: #2f6b39; }

.stage {
  position: relative; flex: none; width: var(--sw); aspect-ratio: 16 / 9; overflow: hidden;
  background: #000;
  box-shadow: 0 0 30px 10px rgba(0,0,0,.55);
  container-type: inline-size;
}
.scene { position: absolute; inset: 0; animation: breathe 18s ease-in-out infinite alternate; transform-origin: 50% 60%; }
.scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
@keyframes breathe { to { transform: scale(1.025); } }
.scene-anchor { position: absolute; inset: 0; pointer-events: none; }
.scene-dark { position: absolute; inset: 0; pointer-events: none; transition: opacity 1.5s; background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,.15), rgba(0,0,0,.75)); }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.65) 100%); }

.hs { position: absolute; cursor: pointer; border-radius: 10px; }
.hs.exit { cursor: pointer; }
.hs:focus { outline: none; }
.sprite { position: absolute; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(0,0,0,.7)); transition: opacity .6s, transform .6s; }
.sprite.glow { animation: itemglow 2.2s ease-in-out infinite; }
@keyframes itemglow { 50% { filter: drop-shadow(0 0 8px rgba(255,220,140,.85)) drop-shadow(0 4px 6px rgba(0,0,0,.7)); } }
.sprite.bob { animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4%) rotate(-3deg); } }
.light { position: absolute; pointer-events: none; border-radius: 50%; mix-blend-mode: screen; animation: candle 1.8s ease-in-out infinite alternate; }
@keyframes candle { 0% { opacity: .75; transform: scale(1); } 30% { opacity: .95; } 60% { opacity: .7; transform: scale(1.06); } 100% { opacity: .9; transform: scale(.97); } }
.flame { position: absolute; pointer-events: none; width: 3.2%; aspect-ratio: 1 / 1.6; transform: translate(-50%, -82%); -webkit-mask-image: linear-gradient(to top, transparent 4%, #000 30%); mask-image: linear-gradient(to top, transparent 4%, #000 30%); }
.flame::before, .flame::after { content: ""; position: absolute; inset: 0; border-radius: 50% 50% 35% 35% / 65% 65% 35% 35%; background: radial-gradient(ellipse at 50% 75%, #fff8d0 0%, #ffcc4a 25%, #ff7a12 55%, rgba(255,60,0,0) 75%); filter: blur(1px); animation: flame 0.5s ease-in-out infinite alternate; }
.flame::after { inset: 25% 20% 0; background: radial-gradient(ellipse at 50% 80%, #fff 0%, #ffe28a 40%, rgba(255,160,40,0) 75%); animation-duration: .35s; }
@keyframes flame { to { transform: scaleY(1.15) scaleX(.9) skewX(4deg); } }
.exit-arrow {
  position: absolute; display: flex; align-items: center; justify-content: center;
  font-size: clamp(16px, 3cqw, 34px); color: #ffd9a0; text-shadow: 0 0 10px #ff8a1f, 0 0 2px #000;
  pointer-events: none; animation: arrow 1.6s ease-in-out infinite;
}
@keyframes arrow { 50% { transform: translateY(12%); opacity: .6; } }

.fx-canvas, #fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.flash { position: absolute; inset: 0; pointer-events: none; background: #e9e6ff; opacity: 0; }
.fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .45s; }
.fade.on { opacity: 1; }

.msg {
  position: absolute; left: 50%; bottom: 3%; transform: translate(-50%, 10px);
  width: min(88%, 900px); padding: 1.1cqw 2cqw;
  font-size: clamp(12px, 1.75cqw, 21px); line-height: 1.4; text-align: center;
  color: #f5e8cc; text-shadow: 0 1px 2px #000;
  background: linear-gradient(180deg, rgba(14,8,16,.9), rgba(30,14,10,.92));
  border: 1px solid rgba(217,165,74,.45); border-radius: 4px;
  box-shadow: 0 0 24px rgba(0,0,0,.8), inset 0 0 18px rgba(255,138,31,.08);
  opacity: 0; pointer-events: none; transition: opacity .35s, transform .35s;
}
.msg.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; cursor: pointer; }
.tip {
  position: absolute; padding: 3px 9px; font-family: var(--font-ui); font-size: 13px; letter-spacing: 1px;
  color: #ffe0a8; background: rgba(10,6,12,.85); border: 1px solid rgba(217,165,74,.4); border-radius: 3px;
  pointer-events: none; white-space: nowrap; opacity: 0; transition: opacity .15s; z-index: 4;
}
.tip.show { opacity: 1; }

.inv-wrap { position: relative; z-index: 2; padding: 6px 12px 10px; }
.inv-label { height: 20px; font-family: var(--font-ui); font-size: 13px; letter-spacing: 1px; color: #e0c48f; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-label .hint-txt { color: #a99a80; font-family: var(--font-text); font-style: italic; letter-spacing: 0; }
.inv {
  display: flex; gap: 6px; padding: 7px; overflow-x: auto; overflow-y: hidden; min-height: calc(var(--slot) + 14px);
  background: linear-gradient(180deg, #120a0b, #1b1012);
  border: 1px solid #4b3214; border-radius: 4px; box-shadow: inset 0 0 18px #000;
  scrollbar-width: thin; scrollbar-color: #5a3b17 transparent;
}
.slot {
  position: relative; flex: 0 0 var(--slot); height: var(--slot); border-radius: 4px;
  background: radial-gradient(circle at 50% 40%, #2b1a1a, #0d0809 75%);
  border: 1px solid #3a2617; box-shadow: inset 0 0 10px #000;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform .15s, border-color .2s, box-shadow .2s;
}
.slot.empty { cursor: default; opacity: .45; }
.slot img { width: 82%; height: 82%; object-fit: contain; filter: drop-shadow(0 3px 4px rgba(0,0,0,.8)); }
.slot:not(.empty):hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.slot.sel { border-color: var(--ember); box-shadow: 0 0 14px rgba(255,138,31,.7), inset 0 0 14px rgba(255,138,31,.35); }
.slot.new { animation: newslot 1s ease-out; }
@keyframes newslot { 0% { box-shadow: 0 0 30px 6px #ffd38a; } 100% { box-shadow: inset 0 0 10px #000; } }
.slot .eye {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%;
  font-size: 13px; line-height: 22px; text-align: center;
  background: #2a1608; border: 1px solid var(--gold); color: #ffd9a0; box-shadow: 0 0 8px #000;
}
.cursor-item { position: fixed; width: 54px; height: 54px; object-fit: contain; pointer-events: none; z-index: 30; display: none; transform: translate(10px, 10px); filter: drop-shadow(0 0 8px rgba(255,180,80,.8)); }
.fly { position: fixed; z-index: 60; pointer-events: none; object-fit: contain; filter: drop-shadow(0 0 12px rgba(255,220,140,.9)); transition: all .8s cubic-bezier(.6,-0.2,.4,1); }

/* ---------- Panneaux ---------- */
.panel { position: fixed; inset: 0; z-index: 35; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.72); backdrop-filter: blur(3px); padding: 12px; }
.panel.show { display: flex; animation: fadein .3s; }
@keyframes fadein { from { opacity: 0; } }
.panel-box {
  position: relative; width: min(860px, 100%); max-height: 100%; overflow: auto; scrollbar-width: none;
  padding: clamp(18px, 3.5vw, 38px);
  border-radius: 6px; border: 2px solid #5a3b17;
  box-shadow: 0 0 0 5px #1a1009, 0 0 0 6px #8a6427, 0 20px 60px #000, 0 0 50px rgba(255,138,31,.2);
  animation: zoomin .35s cubic-bezier(.2,1.3,.4,1);
}
@keyframes zoomin { from { transform: scale(.88); opacity: 0; } }
.panel-box.stone { background: url(../assets/tex_pierre.jpg) center/cover; color: #e9e1d2; }
.panel-box.stone::before { content: ""; position: absolute; inset: 0; background: rgba(10,10,14,.55); pointer-events: none; border-radius: 4px; }
.panel-box.paper { background: url(../assets/tex_parchemin.jpg) center/cover; color: #2b1a0c; }
.panel-box.dark { background: radial-gradient(ellipse at center, #1f1426, #08050b); color: #e9e1d2; }
.panel-box::-webkit-scrollbar { display: none; }
.panel-body { position: relative; }
.panel-close { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; z-index: 3; font-size: 18px; border-radius: 50%; background: rgba(0,0,0,.55); color: #ffd9a0; border: 1px solid var(--gold-dim); }
.panel-close:hover { box-shadow: 0 0 12px rgba(255,138,31,.6); }
.p-title { font-family: var(--font-ui); font-weight: 700; letter-spacing: 3px; text-transform: uppercase; text-align: center; font-size: clamp(15px, 2.2vw, 22px); color: var(--gold); text-shadow: 0 0 10px rgba(255,138,31,.4), 0 2px 2px #000; margin-bottom: 14px; padding: 0 30px; }
.paper .p-title { color: #5a1d06; text-shadow: none; }
.p-text { font-size: clamp(15px, 1.9vw, 20px); line-height: 1.55; text-align: center; margin-bottom: 14px; }
.p-text.left { text-align: left; }
.p-text em { color: inherit; }
.p-doc { font-size: clamp(15px, 1.95vw, 21px); line-height: 1.6; padding: 6px 4px; }
.p-doc p { margin-bottom: .7em; }
.p-doc .sign { text-align: right; font-style: italic; }
.p-doc ol { margin: .4em 0 .8em 1.4em; }
.p-doc li { margin-bottom: .25em; }
.p-feedback { min-height: 1.6em; text-align: center; font-family: var(--font-ui); letter-spacing: 1px; margin-top: 10px; font-size: 15px; }
.p-feedback.ok { color: var(--toxic); text-shadow: 0 0 10px rgba(125,255,138,.6); }
.p-feedback.bad { color: #ff6b5a; }
.p-row { display: flex; gap: clamp(8px, 2vw, 22px); justify-content: center; flex-wrap: wrap; }
.p-btn { margin: 16px auto 0; display: block; min-width: 160px; }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* Examen d'objet */
.examine { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.examine img { width: min(220px, 45vw); height: min(220px, 45vw); object-fit: contain; filter: drop-shadow(0 0 20px rgba(255,180,80,.35)) drop-shadow(0 10px 12px #000); animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px) rotate(2deg); } }

/* Tombes */
.tombs { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(6px, 1.5vw, 16px); }
.tomb {
  padding: 14px 8px 18px; text-align: center; border-radius: 48% 48% 6px 6px / 28% 28% 6px 6px;
  background: linear-gradient(180deg, #6b6a66, #3e3d3a); color: #1b1a18;
  box-shadow: inset 0 0 18px rgba(0,0,0,.6), 0 8px 18px #000; border: 1px solid #2a2927;
  text-shadow: 0 1px 0 rgba(255,255,255,.18);
}
.tomb img { width: 58%; aspect-ratio: 1; object-fit: contain; margin: 4px auto 6px; display: block; filter: grayscale(1) brightness(.35) contrast(1.4) drop-shadow(0 1px 0 rgba(255,255,255,.3)); }
.tomb .name { font-family: var(--font-ui); font-weight: 700; font-size: clamp(10px, 1.5vw, 15px); letter-spacing: 1px; }
.tomb .dates { font-family: var(--font-ui); font-size: clamp(11px, 1.6vw, 16px); margin: 4px 0; }
.tomb .epi { font-style: italic; font-size: clamp(10px, 1.4vw, 14px); line-height: 1.3; }
@media (max-width: 560px) { .tombs { grid-template-columns: repeat(2, 1fr); } }

/* Molettes (cadenas, symboles, lettres) */
.dials { display: flex; justify-content: center; gap: clamp(6px, 1.6vw, 16px); margin: 10px 0; }
.dial { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dial-btn { width: clamp(46px, 9vw, 74px); height: 28px; font-size: 14px; border-radius: 4px; color: #ffd9a0; background: linear-gradient(180deg, #3a2414, #160c0a); border: 1px solid var(--gold-dim); }
.dial-btn:active { transform: scale(.95); }
.dial-face {
  width: clamp(46px, 9vw, 74px); height: clamp(58px, 11vw, 90px); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  font-family: var(--font-ui); font-weight: 700; font-size: clamp(26px, 5vw, 44px); color: #ffe7b8;
  background: linear-gradient(180deg, #1a100b, #3d2716 45%, #1a100b); border: 2px solid #8a6427;
  box-shadow: inset 0 0 14px #000, 0 0 10px rgba(0,0,0,.8); text-shadow: 0 2px 2px #000, 0 0 10px rgba(255,138,31,.4);
}
.dial-face img { width: 80%; height: 80%; object-fit: contain; filter: drop-shadow(0 2px 2px #000); }
.dial-face.roll-down { animation: roll-down .2s ease-out; }
.dial-face.roll-up { animation: roll-up .2s ease-out; }
@keyframes roll-down { from { transform: translateY(-20%); opacity: .3; } }
@keyframes roll-up { from { transform: translateY(20%); opacity: .3; } }
.inscription { font-style: italic; font-size: clamp(16px, 2.2vw, 22px); text-align: center; margin: 4px 0 14px; color: #f1e0c0; text-shadow: 0 0 10px rgba(255,138,31,.35); }
.fire-text { color: #ffb347; text-shadow: 0 0 8px #ff6a00, 0 0 18px #ff3c00; animation: flicker 3s infinite; }

/* Bocaux */
.jars { display: flex; justify-content: center; gap: clamp(8px, 3vw, 34px); padding: 10px 0 0; }
.jar { position: relative; width: clamp(90px, 22vw, 180px); aspect-ratio: 0.8; cursor: pointer; transition: transform .2s; }
.jar:hover { transform: translateY(-4px); }
.jar > img.glass { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; z-index: 2; opacity: .5; }
/* Fond éclairé (liquide trouble) pour que le contenu, même sombre, se détache */
.jar::before {
  content: ""; position: absolute; left: 18%; right: 18%; top: 17%; bottom: 4%; z-index: 0; border-radius: 14% / 9%;
  background: radial-gradient(ellipse at 50% 60%, rgba(215,185,120,.55), rgba(120,110,60,.4) 55%, rgba(40,45,25,.6) 100%);
}
.jar .content { position: absolute; left: 22%; right: 22%; top: 30%; bottom: 12%; z-index: 1; }
.jar .content img { position: absolute; width: 30%; filter: drop-shadow(0 0 1.5px rgba(255,235,190,.75)) drop-shadow(0 2px 2px rgba(0,0,0,.6)); }
.shelf { height: 14px; margin: -6px 4% 0; background: linear-gradient(180deg, #5a3a20, #2a180c); border-radius: 2px; box-shadow: 0 8px 14px #000; }

/* Braseros */
.braziers { display: flex; justify-content: center; gap: clamp(2px, 1vw, 12px); padding: 30px 0 4px; }
.brazier { position: relative; width: clamp(40px, 10vw, 92px); cursor: pointer; transition: transform .15s; }
.brazier:active { transform: scale(.94); }
.brazier img { width: 100%; filter: drop-shadow(0 6px 6px #000) brightness(.8); }
.brazier .fl { position: absolute; left: 50%; top: 6%; width: 70%; aspect-ratio: 1 / 1.5; transform: translate(-50%, -70%) scale(0); transform-origin: 50% 100%; transition: transform .35s cubic-bezier(.3,1.6,.5,1); }
.brazier.on .fl { transform: translate(-50%, -70%) scale(1); }
.brazier .fl::before, .brazier .fl::after { content: ""; position: absolute; inset: 0; border-radius: 50% 50% 35% 35% / 65% 65% 35% 35%; background: radial-gradient(ellipse at 50% 75%, #fff8d0 0%, #ffcc4a 25%, #ff7a12 55%, rgba(255,60,0,0) 75%); animation: flame .45s ease-in-out infinite alternate; }
.brazier .fl::after { inset: 30% 22% 0; background: radial-gradient(ellipse at 50% 80%, #fff 0%, #ffe28a 40%, rgba(255,160,40,0) 75%); animation-duration: .3s; }
.brazier.on img { filter: drop-shadow(0 0 16px rgba(255,138,31,.8)) drop-shadow(0 6px 6px #000); }

/* Cloches */
.bells { display: flex; justify-content: center; gap: clamp(10px, 4vw, 50px); padding: 10px 0; }
.bell { width: clamp(70px, 18vw, 150px); cursor: pointer; transform-origin: 50% 5%; }
.bell img { width: 100%; filter: drop-shadow(0 8px 10px #000); transition: filter .2s; }
.bell.ringing { animation: bellswing .7s ease-out; }
.bell.ringing img { filter: drop-shadow(0 0 22px rgba(255,210,120,.95)) brightness(1.4); }
@keyframes bellswing { 15% { transform: rotate(14deg); } 35% { transform: rotate(-11deg); } 55% { transform: rotate(7deg); } 75% { transform: rotate(-4deg); } }
.bells.locked { pointer-events: none; }
.dots { display: flex; justify-content: center; gap: 8px; margin-top: 6px; }
.dots span { width: 12px; height: 12px; border-radius: 50%; background: #2a2027; border: 1px solid #6b5a3a; }
.dots span.on { background: var(--toxic); box-shadow: 0 0 10px var(--toxic); }

/* Anneaux runiques */
.rings-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rings { position: relative; width: min(380px, 78vw, 58vh); aspect-ratio: 1; cursor: pointer; }
.ring { position: absolute; border-radius: 50%; transition: transform .5s cubic-bezier(.3,1.3,.5,1); }
.ring.r0 { inset: 0; background: radial-gradient(circle, transparent 66%, #2c2433 67%, #1a1420 99%); border: 2px solid #6b5a3a; }
.ring.r1 { inset: 17%; background: radial-gradient(circle, transparent 54%, #352a3e 55%, #1f1826 99%); border: 2px solid #6b5a3a; }
.ring.r2 { inset: 34%; background: radial-gradient(circle, #120c16 0%, #2f2238 99%); border: 2px solid #6b5a3a; }
.rune { position: absolute; left: 50%; top: 50%; font-family: "Noto Sans Runic", serif; color: #c9b8ff; text-shadow: 0 0 8px #8d5bd6; line-height: 1; }
.rings.solved .rune { color: #b9ffc0; text-shadow: 0 0 10px var(--toxic); }
.rings-marker { position: absolute; left: 50%; top: -6px; width: 0; height: 0; transform: translateX(-50%); border-left: 10px solid transparent; border-right: 10px solid transparent; border-top: 16px solid var(--ember); filter: drop-shadow(0 0 6px var(--ember)); z-index: 3; }
.rings-glow { position: absolute; left: 50%; top: 0; width: 13%; height: 50%; transform: translateX(-50%); background: linear-gradient(180deg, rgba(255,138,31,.18), transparent); pointer-events: none; z-index: 2; border-radius: 30px; }
.ring-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ring-btns .btn { min-width: 0; padding: 8px 14px; font-size: 12px; letter-spacing: 1px; }

/* Miroir */
.mirror {
  margin: 0 auto; width: min(320px, 70vw); aspect-ratio: .72; border-radius: 48% 48% 10px 10px / 30% 30% 10px 10px;
  border: 10px solid #9c7a2c; box-shadow: 0 0 0 3px #4a360f, 0 0 40px rgba(141,91,214,.5), inset 0 0 50px #000;
  background: radial-gradient(ellipse at 50% 40%, #4d3a6e, #120a1d 75%);
  display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
.mirror::after { content: ""; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.14) 45%, transparent 55%); animation: sheen 5s ease-in-out infinite; }
@keyframes sheen { from { transform: translateX(-60%); } to { transform: translateX(60%); } }
.mirror-runes { font-family: "Noto Sans Runic", serif; font-size: clamp(36px, 9vw, 64px); letter-spacing: .3em; color: #dcd0ff; text-shadow: 0 0 14px #8d5bd6, 0 0 30px #8d5bd6; transform: scaleX(-1); animation: ghost 3s ease-in-out infinite; }
@keyframes ghost { 50% { opacity: .55; filter: blur(1px); } }

/* Fin */
#ending { z-index: 42; overflow: hidden; }
.ending-bg { position: absolute; inset: 0; background: url(../assets/bg_fin.jpg) center/cover; animation: drift 30s ease-in-out infinite alternate; }
.ending-bg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(0,0,0,.2), rgba(0,0,0,.75)); }
.ending-content { position: relative; text-align: center; padding: 30px; max-width: 700px; }
.ending-content .title { color: #ffe0a0; }
#ending-text { font-size: clamp(16px, 2.2vw, 22px); line-height: 1.6; margin: 20px 0 30px; text-shadow: 0 2px 6px #000; }

/* Responsive */
@media (max-height: 520px) {
  .hud { height: 40px; padding: 0 8px 6px; }
  .hud-btn { width: 28px; height: 28px; font-size: 14px; }
  .inv-wrap { padding: 4px 8px 6px; }
  .inv-label { height: 16px; font-size: 11px; }
}

/* Éléments de scène dynamiques */
.sprite.door-open { background: radial-gradient(ellipse at 50% 70%, rgba(110,255,140,.35), rgba(0,0,0,.95) 65%); border-radius: 50% 50% 2px 2px / 17% 17% 2px 2px; box-shadow: 0 0 18px rgba(110,255,140,.35); animation: doorglow 3s ease-in-out infinite; }
@keyframes doorglow { 50% { box-shadow: 0 0 30px rgba(110,255,140,.55); } }
.sprite.gate-glow { background: radial-gradient(ellipse at center, rgba(255,230,160,.55), rgba(255,200,100,0) 70%); mix-blend-mode: screen; animation: doorglow 2.5s ease-in-out infinite; }
.sprite.coffin-open { background: linear-gradient(180deg, rgba(0,0,0,.95), rgba(20,40,25,.9)); border-radius: 4px; box-shadow: inset 0 0 14px #000, 0 0 16px rgba(110,255,140,.25); transform: skewX(-8deg); }
.sprite.circle-glow { border-radius: 50%; background: radial-gradient(ellipse at center, rgba(140,255,160,0) 45%, rgba(140,255,160,.4) 62%, rgba(140,255,160,0) 72%); mix-blend-mode: screen; animation: candle 1.6s ease-in-out infinite alternate; }
.sprite.crow { animation: crow 6s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes crow { 0%, 70%, 100% { transform: none; } 75% { transform: rotate(-8deg); } 80% { transform: rotate(4deg) translateY(-3%); } 85% { transform: none; } }

/* Confirmation nouvelle partie */
.confirm { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.72); backdrop-filter: blur(3px); padding: 24px; animation: fadein .3s; }
.confirm[hidden] { display: none; }
.confirm-box {
  max-width: 480px; padding: 28px 30px; text-align: center;
  font-size: clamp(16px, 2vw, 20px); line-height: 1.55; color: #e9e1d2;
  background: radial-gradient(ellipse at center, #1f1426, #08050b);
  border: 2px solid #5a3b17; border-radius: 6px;
  box-shadow: 0 0 0 5px #1a1009, 0 0 0 6px #8a6427, 0 20px 60px #000, 0 0 50px rgba(255,138,31,.2);
  animation: zoomin .35s cubic-bezier(.2,1.3,.4,1);
}
.confirm-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.confirm-btns .btn { min-width: 130px; }


/* Logo World Escape Games — taille et position fixées sur le cadre du jeu,
   identiques sur tous les écrans (menu, fin) et à toutes les tailles */
:root { --weg-w: clamp(110px, calc(min(var(--fw, 100vw), var(--fh, 100vh)) * .3), 200px); }
.weg { display: block; flex-shrink: 0; transition: transform .2s, filter .2s; filter: drop-shadow(0 4px 10px rgba(0,0,0,.8)); -webkit-tap-highlight-color: transparent; }
.weg img { display: block; width: 100%; height: 100%; object-fit: contain; }
@media (hover: hover) {
  .weg:hover { transform: scale(1.05); filter: drop-shadow(0 0 12px rgba(255,138,31,.6)) drop-shadow(0 4px 10px rgba(0,0,0,.8)); }
}
.weg-corner {
  position: absolute; z-index: 3; width: var(--weg-w); aspect-ratio: 299 / 107;
  right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
}
/* Le contenu centré ne passe jamais sous le logo */
.menu-content, .ending-content { margin-bottom: calc(var(--weg-w) * 107 / 299 + 14px); }
.inv-row { display: flex; align-items: center; gap: clamp(6px, 1.2vw, 12px); }
.inv-row .inv { flex: 1 1 auto; min-width: 0; }
.weg-inv { width: min(calc((var(--slot) + 14px) * 299 / 107), 30%); aspect-ratio: 299 / 107; }

/* Crédit développeur — bas gauche du menu, aligné sur le logo World Escape Games */
.credit {
  position: absolute; z-index: 3;
  left: max(16px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom));
  height: calc(var(--weg-w) * 107 / 299);
  display: flex; align-items: center; gap: .45em; white-space: nowrap; pointer-events: none;
  font-size: clamp(11px, calc(var(--weg-w) * .085), 16px);
}
.credit-by {
  font-family: var(--font-ui); font-weight: 500; letter-spacing: .22em; text-transform: uppercase;
  color: #d8c7a6; opacity: .85; text-shadow: 0 2px 6px #000;
}
.credit-name {
  font-family: "Great Vibes", cursive; font-size: 2.3em; line-height: 1.5; letter-spacing: .01em;
  background: linear-gradient(180deg, #ffb1c3 0%, #ff5c86 45%, #c2185b 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 8px rgba(255,70,130,.55)) drop-shadow(0 2px 3px rgba(0,0,0,.9));
  padding: .15em .15em .1em .25em; margin: -.3em 0 -.2em -.15em;
}

/* Inventaire en colonne à droite sur les écrans larges (classe posée par layout()) */
.frame.side { flex-direction: row; }
.frame.side .hud { right: var(--colw); }
.frame.side .corner.tr { right: calc(var(--colw) - 6px); }
.frame.side .inv-wrap {
  flex: 0 0 var(--colw); width: var(--colw); min-height: 0;
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
}
.frame.side .inv-label { height: auto; min-height: 3.6em; white-space: normal; font-size: 12px; line-height: 1.2; display: flex; align-items: flex-end; justify-content: center; }
.frame.side .inv-row { flex: 1; min-height: 0; flex-direction: column; align-items: stretch; }
.frame.side .inv { flex-direction: column; align-items: center; overflow-x: hidden; overflow-y: auto; min-height: 0; }
.frame.side .slot { flex: 0 0 var(--slot); width: var(--slot); }
.frame.side .weg-inv { width: 100%; }
