/* ACID ALIEN — page du jeu. Tout est en pixels nets (pas de lissage du canvas). */
:root {
  --green: #39ff14;
  --pink: #ff28b4;
  --cyan: #3cf0ff;
  --ink: #0e061e;
  --violet: #9646ff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #000; color: #eee;
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}
#stage {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
}
#screen {
  display: block; background: #000;
  image-rendering: pixelated; image-rendering: crisp-edges;
  touch-action: none;
}

/* ------------------------------------------------------------------ chargeur */
#loader {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at 50% 40%, #1d0a3a 0%, #07020f 70%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: opacity .35s;
}
#loader.gone { opacity: 0; pointer-events: none; }
#loader.overlay { background: rgba(4, 1, 10, .88); }
.logo {
  margin: 0; font-size: clamp(34px, 9vmin, 84px); letter-spacing: .08em; line-height: 1;
  color: var(--green); font-weight: 900;
  text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--violet), 0 0 18px rgba(57, 255, 20, .35);
}
.logo span { margin-left: .35em; color: var(--pink); }
.sub { margin: 0; color: #87ff5a; font-size: clamp(11px, 2.4vmin, 18px); letter-spacing: .14em; }
.bar {
  width: min(420px, 70vw); height: 18px; margin-top: 18px;
  border: 3px solid var(--cyan); background: var(--ink); padding: 2px;
  box-shadow: 0 0 0 3px var(--ink), 0 0 16px rgba(60, 240, 255, .35);
}
.fill {
  height: 100%; width: 0%;
  background: repeating-linear-gradient(90deg, var(--pink) 0 10px, #ff6ad0 10px 12px);
  transition: width .15s linear;
}
.status { margin: 0; font-size: 14px; color: #cfc6ff; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.hint { margin: 0; font-size: 12px; color: #8a80b0; text-align: center; max-width: 90vw; min-height: 1em; }
#play {
  margin-top: 6px; padding: 12px 34px; font: inherit; font-size: 22px; font-weight: 900; letter-spacing: .12em;
  color: var(--ink); background: var(--green); border: 3px solid var(--ink);
  box-shadow: 0 0 0 3px var(--green), 0 6px 0 3px #128a10; cursor: pointer;
  animation: blink 1.1s steps(2, start) infinite;
}
#play:focus-visible { outline: 3px dashed var(--cyan); outline-offset: 6px; }
#play:active { transform: translateY(3px); box-shadow: 0 0 0 3px var(--green), 0 3px 0 3px #128a10; }
@keyframes blink { 50% { filter: brightness(1.25); } }

/* ------------------------------------------------------------------ téléphone en portrait */
#rotate {
  position: fixed; inset: 0; z-index: 30; background: #07020f;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  text-align: center; font-size: 18px; color: #cfc6ff;
}
#rotate[hidden] { display: none; }
.phone {
  width: 46px; height: 78px; border: 4px solid var(--green); border-radius: 8px;
  animation: turn 1.8s ease-in-out infinite;
}
@keyframes turn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

/* ------------------------------------------------------------------ manette tactile */
#pad { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#pad[hidden] { display: none; }
#pad button, #dpad { pointer-events: auto; touch-action: none; }
#pad button {
  font: inherit; font-weight: 900; color: #fff; padding: 0; cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
#dpad {
  position: absolute;
  left: calc(env(safe-area-inset-left) + 3vmin); bottom: calc(env(safe-area-inset-bottom) + 4vmin);
  width: var(--dpad, 150px); height: var(--dpad, 150px); border-radius: 50%;
  background: rgba(20, 10, 40, .32); border: 2px solid rgba(255, 255, 255, .18);
}
#dpad span {
  position: absolute; width: 34%; height: 34%; left: 33%; top: 33%;
  background: rgba(255, 255, 255, .22); border: 2px solid rgba(255, 255, 255, .35);
}
#dpad .u { top: 0; border-radius: 6px 6px 0 0; }
#dpad .d { top: 66%; border-radius: 0 0 6px 6px; }
#dpad .l { left: 0; border-radius: 6px 0 0 6px; }
#dpad .r { left: 66%; border-radius: 0 6px 6px 0; }
#dpad span.on { background: rgba(57, 255, 20, .6); }
#dpad .knob {
  position: absolute; left: 50%; top: 50%; width: 18%; height: 18%; margin: -9% 0 0 -9%;
  border-radius: 50%; background: rgba(255, 255, 255, .3); transition: transform .05s;
}
#face {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 3vmin); bottom: calc(env(safe-area-inset-bottom) + 4vmin);
  width: var(--face, 170px); height: var(--face, 170px);
}
#face button {
  position: absolute; width: 40%; height: 40%; border-radius: 50%;
  font-size: calc(var(--face, 170px) * .14);
  background: rgba(20, 10, 40, .42); border: 3px solid rgba(255, 255, 255, .45);
  text-shadow: 1px 1px 0 #000;
}
#face .a { right: 0; top: 30%; border-color: rgba(57, 255, 20, .85); }
#face .b { left: 30%; bottom: 0; border-color: rgba(255, 64, 196, .85); }
#face .x { left: 0; top: 30%; border-color: rgba(60, 240, 255, .85); }
#face button.on, #sys button.on { background: rgba(255, 255, 255, .45); transform: scale(.94); }
/* au-dessus de A / B / X : le bas de l'écran (au centre) porte l'aide des commandes de chaque scène */
#sys {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 3vmin);
  bottom: calc(env(safe-area-inset-bottom) + 4vmin + var(--face, 170px) + 2vmin);
  width: var(--face, 170px); display: flex; justify-content: space-between; gap: 8px;
}
.pill {
  font-size: 11px; letter-spacing: .1em; padding: 7px 12px; border-radius: 14px;
  background: rgba(20, 10, 40, .42); border: 2px solid rgba(255, 255, 255, .4);
}
#pad.faded { opacity: .35; transition: opacity .6s; }

/* ------------------------------------------------------------------ bouton plein écran */
#fs {
  position: fixed; z-index: 6; top: calc(env(safe-area-inset-top) + 8px); right: calc(env(safe-area-inset-right) + 8px);
  width: 34px; height: 34px; border: 2px solid rgba(255, 255, 255, .35); border-radius: 6px; cursor: pointer;
  background: rgba(10, 4, 24, .5) center / 18px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2'%3E%3Cpath d='M1 6V1h5M10 1h5v5M15 10v5h-5M6 15H1v-5'/%3E%3C/svg%3E");
  opacity: .55; transition: opacity .2s;
}
#fs:hover, #fs:focus-visible { opacity: 1; }
#fs[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  #play, .phone { animation: none; }
}
