:root { --s: 2; --ink: #1a1222; --gold: #ffcf6a; --cream: #f4e2b8; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #120c24; color: #fff;
  font-family: "VT323", ui-monospace, monospace;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }

#wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
body.portrait #wrap { align-items: flex-start; padding-top: calc(env(safe-area-inset-top) + 24px); }
#stage { position: relative; }
#screen { width: 100%; height: 100%; display: block; image-rendering: crisp-edges; image-rendering: pixelated; }

/* HUD */
#hud {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; font-size: max(calc(var(--s) * 7px), 18px); text-shadow: 2px 2px 0 var(--ink);
}
#quit {
  font-size: inherit; color: #fff; background: #1a123099; border: 2px solid #ffffff66; border-radius: 4px; padding: 0 10px;
}

/* Carte de titre de niveau */
#card {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #120c24cc; animation: card 2.4s ease forwards; text-align: center; padding: 0 16px;
}
#cardTag { color: var(--gold); font-size: max(calc(var(--s) * 9px), 22px); }
#cardTitle { font-size: max(calc(var(--s) * 16px), 34px); text-shadow: 3px 3px 0 #e0306a; }
@keyframes card { 0% { opacity: 0; } 15%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* Dialogue */
#dialog {
  position: absolute; left: 4%; right: 4%; bottom: 5%; min-height: 28%;
  background: #1a1230f0; border: 3px solid var(--cream); box-shadow: 0 0 0 3px var(--ink); border-radius: 4px;
  padding: 8px 14px 18px; font-size: max(calc(var(--s) * 8px), 22px); line-height: 1.05; cursor: pointer;
}
body.portrait #dialog { top: calc(100% + 16px); bottom: auto; left: 16px; right: 16px; min-height: 0; }
#who { color: var(--gold); margin-bottom: 4px; }
.more { position: absolute; right: 10px; bottom: 2px; font-size: .6em; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Ecrans de menu */
.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: #120c2499; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  text-align: center; overflow-y: auto;
}
h1 { font-size: min(32vw, 160px); line-height: .9; margin: 0; letter-spacing: .08em; text-shadow: 6px 6px 0 #e0306a, 10px 10px 0 var(--ink); }
h2 { font-size: 46px; margin: 0; text-shadow: 3px 3px 0 #e0306a; }
.sub { font-size: 24px; margin: 0; color: var(--cream); text-shadow: 2px 2px 0 var(--ink); }
.btn {
  font-size: 32px; padding: 6px 34px; color: var(--ink); background: var(--gold); border: none; border-radius: 4px;
  box-shadow: 0 5px 0 #c0782a, 0 0 0 3px var(--ink);
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #c0782a, 0 0 0 3px var(--ink); }
.link { background: none; border: none; color: var(--cream); font-size: 22px; text-decoration: underline; }

#heroList { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.hero {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 16px 8px;
  background: #1a1230e6; border: 3px solid var(--cream); border-radius: 6px; color: #fff; font-size: 26px;
}
.hero:active { border-color: var(--gold); }
.hero canvas { width: 70px; height: 105px; image-rendering: pixelated; }

#levelList { display: flex; flex-direction: column; gap: 10px; width: min(100%, 460px); }
.level {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; text-align: left;
  background: #1a1230e6; border: 3px solid var(--cream); border-radius: 6px; color: #fff; font-size: 24px;
}
.level .tag { color: var(--gold); }
.level .done { margin-left: auto; color: #7cd04e; font-size: 20px; }
.level.locked { opacity: .45; border-style: dashed; justify-content: center; cursor: default; }

/* Commandes tactiles */
#pad {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 calc(env(safe-area-inset-right) + 18px) calc(env(safe-area-inset-bottom) + 18px) calc(env(safe-area-inset-left) + 18px);
  pointer-events: none;
}
#pad button {
  pointer-events: auto; width: 72px; height: 72px; border-radius: 50%; font-size: 28px; color: #fff;
  background: #ffffff22; border: 3px solid #ffffff77; touch-action: none;
}
#pad button.on { background: #ffffff55; }
.dpad { display: flex; gap: 14px; }
#pad .act { width: 84px; height: 84px; background: #e0306a66; border-color: #ff8ab0; font-size: 34px; }
