:root {
  --bg: #07090b;
  --panel: rgba(10, 16, 20, 0.88);
  --line: #24323a;
  --text: #d6e2e8;
  --muted: #7d8f99;
  --accent: #4cf0ff;
  --warn: #f2c230;
  --danger: #e8402a;
  --life: #3ee06a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Chakra Petch', ui-monospace, monospace;
  overflow: hidden;
}

body.loading #stage::after {
  content: 'Chargement…';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  letter-spacing: 0.3em;
  color: var(--muted);
}

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  top: 50%;
  translate: 0 -50%;
  overflow: hidden;
  container-type: inline-size;
}

#view {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  background: #000;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  translate: -50% -50%;
  pointer-events: none;
  background:
    linear-gradient(var(--accent), var(--accent)) center / 2px 100% no-repeat,
    linear-gradient(var(--accent), var(--accent)) center / 100% 2px no-repeat;
  opacity: 0.75;
}

#flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.flash-hurt { animation: flash 0.35s ease-out; background: rgba(232, 64, 42, 0.45); }
.flash-pickup { animation: flash 0.25s ease-out; background: rgba(242, 194, 48, 0.25); }
.flash-life { animation: flash 0.8s ease-out; background: rgba(62, 224, 106, 0.4); }
.flash-dead { animation: dead 2.2s ease-out forwards; background: rgba(120, 0, 0, 0.6); }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
@keyframes dead { from { opacity: 0.2; } 30% { opacity: 1; } to { opacity: 0.7; } }

#hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 2px;
  padding: 0.6cqi 1cqi;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  font-size: max(11px, 1.3cqi);
  pointer-events: none;
}
#hud .cell {
  flex: 1;
  padding: 0.4em 0.8em;
  border-left: 2px solid var(--line);
}
#hud .cell.wide { flex: 2; }
#hud label {
  display: block;
  color: var(--muted);
  font-size: 0.7em;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
#hud strong { font-size: 1.5em; font-weight: 700; }
#hud .life { color: var(--life); }
#hud-ammo { margin-left: 0.6em; color: var(--warn); }

.bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.1);
  margin-top: 3px;
}
.bar > div {
  height: 100%;
  width: 100%;
  background: var(--life);
  transition: width 0.15s;
}
#hud-health-bar.low { background: var(--danger); }

#bossbar {
  position: absolute;
  top: 3cqi;
  left: 25%;
  right: 25%;
  text-align: center;
  font-size: max(11px, 1.3cqi);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #e0a0d0;
  pointer-events: none;
}
#bossbar .bar { height: 8px; border: 1px solid #5a2f5f; }
#bossbar-fill { background: #d04aa0 !important; }

#messages {
  position: absolute;
  top: 1.5cqi;
  left: 1.5cqi;
  font-size: max(11px, 1.2cqi);
  pointer-events: none;
}
.msg { animation: msg 3.5s forwards; text-shadow: 0 1px 2px #000; }
.msg.life { color: var(--life); font-weight: 700; }
.msg.danger { color: var(--danger); }
@keyframes msg { 0%, 80% { opacity: 1; } to { opacity: 0; } }

#center-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  font-size: max(24px, 5cqi);
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #fff;
  text-shadow: 0 0 20px var(--danger);
  pointer-events: none;
}
#center-msg small {
  display: block;
  font-size: 0.35em;
  letter-spacing: 0.3em;
  color: var(--text);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 1rem;
  background: radial-gradient(ellipse at center, rgba(10, 30, 36, 0.92), rgba(0, 0, 0, 0.97));
  overflow-y: auto;
}
.screen[hidden] { display: none; }

h1 {
  margin: 0;
  font-size: clamp(32px, 7cqi, 84px);
  letter-spacing: 0.15em;
  line-height: 1;
  text-align: center;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(76, 240, 255, 0.4);
}
h1 span { display: block; color: var(--text); font-size: 0.55em; letter-spacing: 0.4em; }
.tagline { margin: 0; color: var(--muted); text-align: center; }
h2 {
  margin: 0.8rem 0 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
}
.title { font-size: clamp(24px, 4cqi, 48px); letter-spacing: 0.2em; color: var(--text); margin: 0 0 0.5rem; }
.title.danger { color: var(--danger); }
.title.ok { color: var(--life); }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 2rem;
  width: min(760px, 100%);
}

.choices { display: flex; flex-direction: column; gap: 4px; }

button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.5rem 1rem;
  cursor: pointer;
  text-align: left;
  min-width: 220px;
}
button:hover { border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.choice small { display: block; color: var(--muted); font-size: 0.75em; }
button.choice[aria-pressed='true'] { border-color: var(--accent); background: rgba(76, 240, 255, 0.12); }
button.choice[aria-pressed='true'] span::before { content: '▸ '; color: var(--accent); }
button.primary {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #001014;
  background: var(--accent);
  border-color: var(--accent);
  margin-top: 0.6rem;
}
button.primary:hover { filter: brightness(1.15); }

.range { display: flex; justify-content: space-between; align-items: center; gap: 1rem; font-size: 0.9em; margin: 0.3rem 0; }
.range input { accent-color: var(--accent); width: 50%; }

.keys { list-style: none; padding: 0; margin: 0; font-size: 0.85em; color: var(--muted); line-height: 1.9; }
kbd { font: inherit; color: var(--text); border: 1px solid var(--line); padding: 0 0.35em; background: rgba(255, 255, 255, 0.04); }

.stats { display: grid; grid-template-columns: auto auto; gap: 0.3rem 2rem; margin: 0 0 0.5rem; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-weight: 600; }
.record { margin: 0; color: var(--warn); min-height: 1.2em; }
