* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: #020106; overflow: hidden; overscroll-behavior: none; touch-action: none; }
body { display: flex; align-items: center; justify-content: center; color: #f4ecd8; font-family: Georgia, 'Times New Roman', serif; user-select: none; -webkit-user-select: none; }

#stage { position: relative; --u: 3px; overflow: hidden; background: #000; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; cursor: crosshair; }
#stage > div, #prompt { position: absolute; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
small { opacity: .72; font-size: .82em; }
.ok { color: #9be8a8; } .ko { color: #ff8a9a; }

/* ATH */
#hud { inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s; font-family: ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace; font-size: calc(var(--u) * 6.4); }
#hud.show { opacity: 1; }
#hudMain { position: absolute; left: calc(var(--u) * 6); top: calc(var(--u) * 5); display: flex; align-items: center; gap: calc(var(--u) * 6); text-shadow: 0 calc(var(--u) * .5) 0 #000; }
.hearts { display: flex; gap: calc(var(--u) * 1.5); }
.hearts i { width: calc(var(--u) * 6); height: calc(var(--u) * 6); background: #2a1a2a; border: calc(var(--u) * .7) solid #6a3a4a; transform: rotate(45deg); }
.hearts i.full { background: #ff5c7a; border-color: #ffd0d8; box-shadow: 0 0 calc(var(--u) * 3) #ff5c7a88; }
.stat { display: flex; align-items: center; gap: calc(var(--u) * 2); }
.stat .cendre { width: calc(var(--u) * 4); height: calc(var(--u) * 4); background: #ffd27a; box-shadow: 0 0 calc(var(--u) * 3) #ffd27a; }
.slot { display: inline-block; width: calc(var(--u) * 5); height: calc(var(--u) * 5); border-radius: 50%; background: #1a1626; border: calc(var(--u) * .7) solid #6a6480; vertical-align: middle; }
.chance { opacity: .8; }
#btnPause { position: absolute; right: calc(var(--u) * 5); top: calc(var(--u) * 4); pointer-events: auto; width: calc(var(--u) * 14); height: calc(var(--u) * 12); font-family: inherit; font-size: calc(var(--u) * 6); font-weight: 700; background: #0008; border: calc(var(--u) * .6) solid #f4ecd855; border-radius: calc(var(--u) * 2); }
#boss { position: absolute; left: 20%; right: 20%; bottom: calc(var(--u) * 8); text-align: center; opacity: 0; transition: opacity .5s; font-family: Georgia, serif; font-style: italic; text-shadow: 0 1px 0 #000; }
#boss.show { opacity: 1; }
#boss .bar { margin-top: calc(var(--u) * 1.5); height: calc(var(--u) * 3); background: #1a1020cc; border: calc(var(--u) * .6) solid #b98ad0; }
#bossBar { height: 100%; width: 100%; background: linear-gradient(90deg, #ff9a4c, #fff1c2); transition: width .2s; }

#banner { left: 0; right: 0; top: 36%; text-align: center; pointer-events: none; opacity: 0; text-shadow: 0 calc(var(--u) * .7) calc(var(--u) * 3) #000; }
#banner.show { animation: ban 4.2s ease both; }
@keyframes ban { 0% { opacity: 0; transform: translateY(8%); } 15%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.b-title { font-size: calc(var(--u) * 17); letter-spacing: .12em; font-variant: small-caps; }
.b-sub { font-size: calc(var(--u) * 7.5); font-style: italic; opacity: .85; margin-top: calc(var(--u) * 2); }

#toasts { left: 0; right: 0; top: calc(var(--u) * 19); display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 2); pointer-events: none; }
.toast { max-width: 76%; padding: calc(var(--u) * 2.5) calc(var(--u) * 6); font-size: calc(var(--u) * 6.6); font-style: italic; text-align: center; background: #0a0714d9; border: calc(var(--u) * .5) solid #f4ecd844; border-radius: calc(var(--u) * 2); animation: tin .35s ease both; transition: opacity .6s; }
.toast.out { opacity: 0; }
@keyframes tin { from { opacity: 0; transform: translateY(-40%); } }

#prompt { left: 50%; bottom: calc(var(--u) * 26); transform: translateX(-50%); padding: calc(var(--u) * 2) calc(var(--u) * 6); font-size: calc(var(--u) * 7); background: #0a0714e6; border: calc(var(--u) * .6) solid #ffe9b0; border-radius: calc(var(--u) * 10); opacity: 0; pointer-events: none; transition: opacity .15s; white-space: nowrap; }
#prompt.show { opacity: 1; pointer-events: auto; }
kbd { font-family: ui-monospace, monospace; font-size: .8em; padding: 0 .45em; border: 1px solid #ffe9b0; border-radius: .3em; margin-right: .3em; }
body.touch kbd { display: none; }

/* Livre-jeu */
#dialog { inset: 0; display: none; align-items: flex-end; justify-content: center; padding: calc(var(--u) * 8); background: linear-gradient(#0000 30%, #04030bb0); }
#dialog.show { display: flex; }
.dlg-box { width: 100%; max-width: calc(var(--u) * 320); max-height: 92%; overflow-y: auto; padding: calc(var(--u) * 7) calc(var(--u) * 9); background: #f1e7cf; color: #2a2030; border-radius: calc(var(--u) * 1.5); box-shadow: 0 0 0 calc(var(--u) * 1) #2a2030, 0 0 0 calc(var(--u) * 1.8) #d9a441, 0 calc(var(--u) * 4) calc(var(--u) * 14) #000a; animation: tin .25s ease both; }
.dlg-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: calc(var(--u) * 2.5); font-size: calc(var(--u) * 6.4); }
.who { font-variant: small-caps; letter-spacing: .08em; font-weight: 700; color: #8a3c1c; }
.par { font-style: italic; opacity: .55; }
.dlg-text { font-size: calc(var(--u) * 7.6); line-height: 1.42; white-space: pre-wrap; min-height: 2.8em; }
.dlg-choices { margin-top: calc(var(--u) * 4); display: flex; flex-direction: column; gap: calc(var(--u) * 1.6); }
.choice { text-align: left; padding: calc(var(--u) * 2.4) calc(var(--u) * 4); font-size: calc(var(--u) * 7); font-style: italic; color: #2a2030; border-left: calc(var(--u) * 1) solid #2a203033; background: #2a20300d; }
.choice.sel, .choice:hover { border-left-color: #d9a441; background: #d9a44138; }
.choice b { font-style: normal; color: #8a3c1c; }
.dice { font-size: calc(var(--u) * 7); line-height: 1.5; }
.dice .pips { font-size: 2em; vertical-align: middle; }
.dice .ok { color: #2f7a3c; } .dice .ko { color: #a0283c; }

/* Menus */
#menu { inset: 0; display: none; align-items: center; justify-content: center; background: #04030ba6; }
#menu.show { display: flex; }
.title { text-align: center; text-shadow: 0 calc(var(--u) * 1) calc(var(--u) * 4) #000; padding-top: 22%; }
#menu:has(.title) { background: none; }
.title h1 { font-size: calc(var(--u) * 30); font-weight: 400; letter-spacing: .22em; color: #fff1c2; }
.title h2 { font-size: calc(var(--u) * 9); font-weight: 400; font-style: italic; opacity: .8; margin-bottom: calc(var(--u) * 10); }
.col { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 2.5); margin-top: calc(var(--u) * 5); }
#menu button { padding: calc(var(--u) * 2.6) calc(var(--u) * 9); font-size: calc(var(--u) * 7.4); background: #0a0714cc; border: calc(var(--u) * .6) solid #f4ecd84d; border-radius: calc(var(--u) * 1.5); min-width: calc(var(--u) * 120); }
#menu button.sel, #menu button:hover:not([disabled]) { border-color: #ffe9b0; background: #2a1c3ccc; box-shadow: 0 0 calc(var(--u) * 5) #ffb35c55; }
#menu button[disabled] { opacity: .38; cursor: default; }
.keys { margin-top: calc(var(--u) * 8); font-size: calc(var(--u) * 5.6); opacity: .62; line-height: 1.6; font-family: ui-monospace, monospace; text-align: center; }
.panel { width: 86%; max-height: 94%; overflow-y: auto; padding: calc(var(--u) * 7) calc(var(--u) * 10); background: #0c0918f2; border: calc(var(--u) * .7) solid #d9a441; border-radius: calc(var(--u) * 2); font-size: calc(var(--u) * 6.6); }
.panel.small { width: 60%; }
.panel h3 { font-size: calc(var(--u) * 12); font-weight: 400; font-variant: small-caps; letter-spacing: .1em; color: #fff1c2; }
.panel h4 { margin: calc(var(--u) * 5) 0 calc(var(--u) * 2); font-size: calc(var(--u) * 6.4); font-weight: 400; letter-spacing: .14em; text-transform: uppercase; color: #d9a441; }
.lead { font-style: italic; opacity: .85; margin-top: calc(var(--u) * 1.5); }
.row { display: flex; align-items: center; justify-content: space-between; gap: calc(var(--u) * 6); padding: calc(var(--u) * 3.5) 0; border-bottom: 1px solid #f4ecd822; }
#menu .row button { min-width: 0; }
#menu button.wide { display: flex; align-items: center; gap: calc(var(--u) * 4); width: 100%; text-align: left; margin-bottom: calc(var(--u) * 1.6); padding: calc(var(--u) * 2.4) calc(var(--u) * 5); }
#menu button.wide span { flex: 1; }
#menu button.wide em { font-style: normal; font-family: ui-monospace, monospace; font-size: .85em; opacity: .8; white-space: nowrap; }
#menu button.wide.on { border-color: #9be8a8; }
.dot { width: calc(var(--u) * 6); height: calc(var(--u) * 6); border-radius: 50%; flex: none; box-shadow: 0 0 calc(var(--u) * 3) currentColor; }
.syn { list-style: none; line-height: 1.6; opacity: .9; }
.syn li.ok { color: #9be8a8; }
.poem { font-style: italic; line-height: 1.7; font-size: calc(var(--u) * 7.2); }
.miss { opacity: .3; letter-spacing: .2em; }

#err { left: 0; right: 0; bottom: 0; display: none; padding: 4px 8px; background: #a0283c; font: 12px monospace; z-index: 9; }

/* Commandes tactiles */
#touch { display: none; position: fixed; inset: 0; pointer-events: none; }
body.touch #touch { display: block; }
.pad { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: flex-end; pointer-events: none; }
.pad.left { left: max(14px, env(safe-area-inset-left)); }
.pad.right { right: max(14px, env(safe-area-inset-right)); }
.pad button { pointer-events: auto; width: 64px; height: 64px; border-radius: 50%; font-size: 24px; color: #f4ecd8; background: #f4ecd81f; border: 2px solid #f4ecd866; touch-action: none; }
.pad button.b { width: 76px; height: 76px; }
.pad button.s { width: 52px; height: 52px; }
.pad button.down { background: #ffe9b066; }
@media (max-height: 420px) { .pad button { width: 54px; height: 54px; } .pad button.b { width: 64px; height: 64px; } .pad button.s { width: 46px; height: 46px; } }
