:root { --ink: #ece4cf; --dim: #9b927e; --amber: #e2a72e; --red: #ff4a3a; --cyan: #7ff0ff; --panel: rgba(18, 16, 15, 0.86); --line: #5a5144; }
html, body { margin: 0; height: 100%; background: #17161a; color: var(--ink); overflow: hidden;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; -webkit-user-select: none; user-select: none; touch-action: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  /* keep bottom UI clear of floating mobile browser toolbars (Arc, Safari) */
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 72px); }
.screen[hidden], [hidden] { display: none !important; }
h1 { margin: 0; font-size: clamp(48px, 13vw, 120px); line-height: 0.85; letter-spacing: 0.04em; text-align: center; font-weight: 900;
  color: var(--ink); text-shadow: 4px 4px 0 #000, -1px -1px 0 #000, 0 0 0 transparent; font-style: italic; }
h2 { margin: 0; font-size: 22px; letter-spacing: 0.2em; }
.foot { margin: 0; color: var(--dim); font-size: 12px; text-shadow: 1px 1px 0 #000; }
button { font: inherit; color: inherit; cursor: pointer; }
button.big { font-size: 18px; font-weight: 800; letter-spacing: 0.18em; padding: 14px 36px; border: 2px solid #000; border-radius: 0;
  background: var(--amber); color: #1a1408; box-shadow: 4px 4px 0 #000; }
button.big:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
button.ghost { background: none; border: 0; color: var(--dim); letter-spacing: 0.15em; padding: 10px; text-decoration: underline; }
#title .big { animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.55; } }

/* garage */
#garage { align-items: flex-end; justify-content: center; padding-right: max(16px, env(safe-area-inset-right)); }
.g-panel { width: min(400px, 100%); background: var(--panel); border: 2px solid var(--line); box-shadow: 6px 6px 0 #000; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.g-panel header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--line); padding-bottom: 8px; }
#credits { color: var(--amber); font-size: 13px; }
.slot { display: grid; grid-template-columns: 74px 36px 1fr 36px; align-items: center; gap: 4px; font-size: 13px; }
.slot label { color: var(--dim); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.slot span { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot button { height: 32px; background: #2a2622; border: 1px solid var(--line); color: var(--amber); font-size: 12px; }
.slot.fixed span { color: var(--dim); font-size: 11px; }
.slot button:disabled { color: #4a443c; }
.slot button:active { background: var(--amber); color: #000; }
#gstats { display: flex; flex-direction: column; gap: 4px; border-top: 2px solid var(--line); padding-top: 8px; }
.stat { display: grid; grid-template-columns: 74px 1fr 84px; align-items: center; gap: 8px; font-size: 12px; }
.stat label { color: var(--dim); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.stat i { height: 8px; background: #2a2622; border: 1px solid #000; }
.stat s { display: block; height: 100%; background: var(--cyan); }
.stat em { font-style: normal; text-align: right; }
.stat.bad s { background: var(--red); } .stat.bad em { color: var(--red); }
.overweight { margin: 0; color: var(--red); font-size: 12px; animation: blink 0.8s steps(2) infinite; }
#sortie { align-self: stretch; }
@media (max-aspect-ratio: 1/1) {
  #garage { align-items: center; justify-content: flex-end; }
  .g-panel { padding: 10px; gap: 6px; }
  .slot button { height: 30px; }
}

/* hud */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 2px 2px 0 #000; }
#hud .bars { position: absolute; left: max(14px, env(safe-area-inset-left)); top: calc(env(safe-area-inset-top) + 12px); display: flex; flex-direction: column; gap: 6px; }
#hud .bars > div { display: grid; grid-template-columns: 26px min(46vw, 240px) auto; align-items: center; gap: 8px; font-size: 12px; }
#hud .bars i { height: 10px; background: rgba(0, 0, 0, 0.6); border: 1px solid #000; }
#hud .bars s { display: block; height: 100%; background: var(--ink); transition: width 0.1s linear; }
#hud .en s { background: var(--cyan); }
#hud .low s { background: var(--red); animation: blink 0.5s steps(2) infinite; }
#hud em { font-style: normal; font-size: 14px; font-weight: 800; }
#hud .wave { position: absolute; top: calc(env(safe-area-inset-top) + 14px); right: 62px; font-size: 12px; letter-spacing: 0.12em; color: var(--amber); }
#pausebtn { pointer-events: auto; position: absolute; top: calc(env(safe-area-inset-top) + 6px); right: max(10px, env(safe-area-inset-right)); width: 40px; height: 34px;
  background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line); font-weight: 900; }
#callout { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: clamp(22px, 6vw, 44px); font-weight: 900; font-style: italic;
  letter-spacing: 0.12em; color: var(--ink); text-shadow: 3px 3px 0 #000; opacity: 0; transition: opacity 0.2s; }
#callout.pop { animation: pop 0.25s steps(3); }
@keyframes pop { from { transform: scaleY(0.2); } }
.legend { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; margin: 0; font-size: 11px; color: var(--dim); letter-spacing: 0.08em; }
.legend b { color: var(--ink); margin-left: 10px; }
body.touch .legend { display: none; }

/* touch pad */
#pad { position: fixed; inset: 0; display: none; touch-action: none; }
body.touch[data-screen="play"] #pad { display: block; }
.stick-zone { position: absolute; left: 0; top: 18%; bottom: 0; width: 50%; }
.ring, .knob { position: absolute; left: 0; top: 0; display: none; pointer-events: none; border-radius: 50%; }
.ring { width: 120px; height: 120px; margin: -60px 0 0 -60px; border: 2px solid rgba(236, 228, 207, 0.5); background: rgba(0, 0, 0, 0.25); }
.knob { width: 52px; height: 52px; margin: -26px 0 0 -26px; background: rgba(236, 228, 207, 0.75); border: 2px solid #000; }
#pad button { position: absolute; border: 2px solid #000; border-radius: 50%; background: rgba(30, 26, 22, 0.7); color: var(--ink);
  font-weight: 900; font-size: 11px; letter-spacing: 0.08em; box-shadow: 3px 3px 0 #000; touch-action: none; }
#pad button.on { background: var(--amber); color: #000; transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.b-slash { width: 96px; height: 96px; right: calc(max(18px, env(safe-area-inset-right)) + 0px); bottom: calc(env(safe-area-inset-bottom) + 96px); font-size: 14px !important; border-color: var(--amber) !important; }
.b-boost { width: 66px; height: 66px; right: calc(max(18px, env(safe-area-inset-right)) + 104px); bottom: calc(env(safe-area-inset-bottom) + 78px); }
.b-shoot { width: 66px; height: 66px; right: calc(max(18px, env(safe-area-inset-right)) + 30px); bottom: calc(env(safe-area-inset-bottom) + 200px); }

/* pause / result */
#pause, #result { background: rgba(10, 9, 8, 0.72); }
#r-body { width: min(320px, 100%); border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); padding: 8px 0; }
#r-body p { display: flex; justify-content: space-between; margin: 6px 0; font-size: 14px; }
#r-body span { color: var(--dim); }
#r-body .net b { color: var(--amber); }

#errline { position: fixed; left: 0; right: 0; top: 0; z-index: 99999; background: #a00; color: #fff;
  font: 12px/1.3 monospace; padding: 4px 8px; white-space: pre-wrap; pointer-events: none; }

@media (max-width: 560px) {
  #hud .wave { top: calc(env(safe-area-inset-top) + 56px); left: max(14px, env(safe-area-inset-left)); right: auto; }
  #hud .bars > div { grid-template-columns: 26px calc(100vw - 150px) auto; }
}
