:root {
  --ink: #0c0f24;
  --box: #141a48;
  --gold: #ffd75e;
  --red: #d8262e;
  --white: #f8f8f0;
  --pixel: 'Press Start 2P', 'DotGothic16', monospace;
  --text: 'DotGothic16', 'PingFang SC', 'Microsoft YaHei', monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b2a1e; color: var(--white); font-family: var(--text); user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- HUD façon SNES ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; padding: max(12px, env(safe-area-inset-top)) 16px 0; display: flex; align-items: flex-start; gap: 16px; }
#item { display: flex; align-items: center; gap: 8px; }
#item .frame { width: 44px; height: 44px; border: 3px solid var(--gold); border-radius: 6px; background: rgba(12, 15, 36, .75); display: grid; place-items: center; box-shadow: 0 0 0 2px var(--ink); }
#item img { width: 24px; image-rendering: pixelated; }
#count { font-family: var(--pixel); font-size: 13px; text-shadow: 2px 2px 0 var(--ink); }
#buttons { margin-left: auto; display: flex; gap: 6px; pointer-events: auto; }
#buttons button { background: rgba(12, 15, 36, .7); color: var(--white); border: 2px solid var(--white); border-radius: 6px; height: 32px; min-width: 36px; font-size: 13px; padding: 0 8px; }
#buttons button.off { opacity: .5; }

#prompt { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(12, 15, 36, .8); border: 2px solid var(--white); border-radius: 6px; padding: 6px 12px; font-size: 16px; pointer-events: none; }
#prompt b { color: var(--gold); margin-right: 6px; }

/* ---------- Boîte de dialogue ---------- */
#dialog { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(720px, calc(100vw - 32px)); min-height: 120px; background: var(--box); border: 4px solid var(--white); border-radius: 10px; box-shadow: 0 0 0 3px var(--ink), 0 8px 0 rgba(0, 0, 0, .3); padding: 18px 22px 20px; font-size: 20px; line-height: 1.6; cursor: pointer; }
#dialog.narr { background: #1a1630; font-style: normal; color: #e8e0ff; }
#dname { position: absolute; top: -18px; left: 16px; background: var(--red); color: var(--white); border: 3px solid var(--white); border-radius: 6px; padding: 2px 10px; font-size: 15px; box-shadow: 0 0 0 2px var(--ink); }
#dtext { white-space: pre-wrap; min-height: 2em; }
#dnext { position: absolute; right: 16px; bottom: 6px; color: var(--gold); animation: bob .6s infinite alternate; font-size: 14px; }
#dchoices { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
#dchoices button { text-align: left; background: none; border: none; color: var(--white); font-size: 19px; padding: 4px 8px 4px 28px; position: relative; border-radius: 4px; }
#dchoices button.sel { color: var(--gold); background: rgba(255, 255, 255, .06); }
#dchoices button.sel::before { content: '▶'; position: absolute; left: 6px; font-size: 14px; top: 8px; }
@keyframes bob { to { transform: translateY(3px); } }

/* ---------- Blocage mobile ---------- */
#mobileBlock { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at center, #24402a, #10180f); z-index: 10; }
#mobileBlock .box { max-width: 340px; text-align: center; background: var(--box); border: 4px solid var(--white); border-radius: 10px; box-shadow: 0 0 0 3px var(--ink); padding: 28px 22px; }
#mobileBlock .pc { font-size: 48px; margin-bottom: 12px; }
#mobileBlock p { margin: 0 0 10px; font-size: 20px; line-height: 1.5; }
#mobileBlock .sub { color: var(--gold); font-size: 18px; margin: 0; }

/* ---------- Fondu au noir ---------- */
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .35s; }
#fade.on { opacity: 1; }


/* ---------- Contrôles tactiles ---------- */
#touch { position: fixed; inset: 0; pointer-events: none; }
#stickZone { position: absolute; left: 0; top: 30%; bottom: 0; width: 55%; pointer-events: auto; }
#stick { position: absolute; width: 96px; height: 96px; margin: -48px 0 0 -48px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .5); background: rgba(12, 15, 36, .3); left: 80px; top: calc(100% - 80px - env(safe-area-inset-bottom)); pointer-events: none; opacity: .5; }
#stick.on { opacity: 1; }
#knob { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(255, 255, 255, .75); }
#aBtn { position: absolute; right: calc(20px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); width: 76px; height: 76px; border-radius: 50%; background: var(--red); border: 4px solid var(--white); color: var(--white); font-family: var(--pixel); font-size: 22px; pointer-events: auto; box-shadow: 0 4px 0 #7a1016, 0 0 0 3px var(--ink); }
#aBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #7a1016, 0 0 0 3px var(--ink); }
body:has(#touch:not(.hidden)) #dialog { bottom: calc(150px + env(safe-area-inset-bottom)); }
body:has(#touch:not(.hidden)) #prompt { bottom: calc(150px + env(safe-area-inset-bottom)); }

@media (max-width: 520px) {
  #dialog { font-size: 17px; padding: 16px 16px 18px; }
  #item .frame { width: 36px; height: 36px; }
}
