/* GRIDBREAK — neon wireframe corridor, tuned for portrait mobile Chrome. */

:root {
  --green: #39ff6a;
  --green-dim: #0f6b2c;
  --cyan: #00e5ff;
  --red: #ff2b4d;
  --amber: #ffcc33;
  --bg: #000;
  --ink: #d9ffe4;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ---------- camera layer ---------- */

#cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror: moving your right hand moves the right shield */
  filter: grayscale(0.55) contrast(1.25) brightness(0.42) saturate(0.6);
  opacity: 0;
  transition: opacity 700ms ease;
}
#stage.cam-live #cam { opacity: 0.5; }

/* Darkens the feed toward the horizon so the corridor reads as depth, not video. */
#camveil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% 40%, rgba(57,255,106,0.10) 0%, rgba(0,0,0,0.55) 45%, rgba(0,0,0,0.9) 100%),
    linear-gradient(to bottom, #000 0%, rgba(0,0,0,0.35) 28%, rgba(0,0,0,0.15) 60%, rgba(0,0,0,0.7) 100%);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- HUD ---------- */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: calc(12px + var(--safe-t)) 14px calc(12px + var(--safe-b));
  display: flex;
  flex-direction: column;
}
#hud.hidden { display: none; }

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.health { display: flex; gap: 5px; align-items: center; }
.health i {
  display: block;
  width: 26px;
  height: 9px;
  border: 1px solid var(--green);
  background: var(--green);
  box-shadow: 0 0 10px rgba(57,255,106,0.8);
  transform: skewX(-22deg);
  transition: background 180ms, box-shadow 180ms, border-color 180ms, opacity 180ms;
}
.health i.spent {
  background: transparent;
  border-color: rgba(57,255,106,0.28);
  box-shadow: none;
  opacity: 0.6;
}
.health.critical i:not(.spent) {
  border-color: var(--red);
  background: var(--red);
  box-shadow: 0 0 14px rgba(255,43,77,0.9);
  animation: pulse 700ms ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.35 } }

.hud-stats { text-align: right; line-height: 1.1; }
.score {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--green);
  text-shadow: 0 0 14px rgba(57,255,106,0.7);
  font-variant-numeric: tabular-nums;
}
.wave { font-size: 11px; letter-spacing: 3px; color: rgba(217,255,228,0.65); margin-top: 3px; }

.buffs { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.buff {
  font-size: 10px;
  letter-spacing: 2px;
  padding: 4px 8px;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  background: rgba(0,229,255,0.08);
  text-shadow: 0 0 8px rgba(0,229,255,0.8);
}

.trackwarn {
  position: absolute;
  left: 14px; right: 14px;
  top: 46%;
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 2px;
  color: var(--amber);
  text-shadow: 0 0 10px rgba(255,204,51,0.6);
  opacity: 0;
  transition: opacity 260ms;
  pointer-events: none;
}
.trackwarn.on { opacity: 1; }

.combo {
  margin-top: auto;
  margin-bottom: 8px;
  text-align: center;
  font-size: 15px;
  letter-spacing: 4px;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(255,204,51,0.7);
  opacity: 0;
  transition: opacity 200ms;
}
.combo.on { opacity: 1; }

.banner {
  position: absolute;
  left: 0; right: 0;
  top: 34%;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--green);
  text-shadow: 0 0 24px rgba(57,255,106,0.9);
  opacity: 0;
  pointer-events: none;
}
.banner.show { animation: bannerIn 1900ms ease forwards; }
@keyframes bannerIn {
  0%   { opacity: 0; transform: scale(0.8); letter-spacing: 22px; }
  18%  { opacity: 1; transform: scale(1);   letter-spacing: 8px; }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.05); }
}

.icon-btn {
  position: absolute;
  right: 12px;
  bottom: calc(12px + var(--safe-b));
  pointer-events: auto;
  width: 44px; height: 44px;
  border: 1px solid rgba(57,255,106,0.35);
  background: rgba(0,0,0,0.45);
  color: var(--green);
  font: inherit;
  font-size: 10px;
  letter-spacing: 1px;
}
.icon-btn.off { color: rgba(217,255,228,0.35); border-color: rgba(217,255,228,0.18); }

/* ---------- screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-t)) 20px calc(20px + var(--safe-b));
  /* Light enough that the corridor keeps running behind the menus. */
  background: radial-gradient(125% 85% at 50% 42%, rgba(0,16,6,0.34) 0%, rgba(0,0,0,0.84) 72%);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  z-index: 10;
}
.screen.hidden { display: none; }

.panel {
  width: 100%;
  max-width: 400px;
  text-align: center;
  border: 1px solid rgba(57,255,106,0.28);
  background: rgba(0,0,0,0.66);
  padding: 26px 20px;
  box-shadow: 0 0 60px rgba(57,255,106,0.10) inset, 0 0 40px rgba(0,0,0,0.9);
}
.panel-slim { border-color: rgba(57,255,106,0.18); }

.title {
  margin: 0 0 6px;
  font-size: clamp(34px, 12vw, 52px);
  font-weight: 800;
  letter-spacing: 4px;
  color: #eafff0;
  text-shadow: 0 0 30px rgba(57,255,106,0.85);
}
.title span { color: var(--green); }
.title.dead { color: #ffd9df; text-shadow: 0 0 30px rgba(255,43,77,0.8); }
.title.dead span { color: var(--red); }

.subtitle {
  margin: 0 0 14px;
  font-size: 15px;
  letter-spacing: 6px;
  color: var(--green);
  font-weight: 600;
}
.subtitle.warn { color: var(--red); }

.tag { margin: 0 0 18px; font-size: 13px; line-height: 1.55; color: rgba(217,255,228,0.75); }

.rules {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  text-align: left;
  font-size: 12.5px;
  line-height: 1.65;
  color: rgba(217,255,228,0.72);
}
.rules li { position: relative; padding-left: 18px; margin-bottom: 6px; }
.rules li::before { content: "▸"; position: absolute; left: 0; color: var(--green); }
.rules b { color: #eafff0; font-weight: 600; }

.btn {
  display: block;
  width: 100%;
  padding: 16px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #001a08;
  background: var(--green);
  border: none;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(57,255,106,0.55);
  transition: transform 120ms, box-shadow 120ms;
}
.btn:active { transform: scale(0.97); box-shadow: 0 0 12px rgba(57,255,106,0.4); }

.linkbtn {
  margin-top: 14px;
  background: none;
  border: none;
  font: inherit;
  font-size: 11.5px;
  letter-spacing: 1px;
  color: rgba(217,255,228,0.5);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.fineprint { margin: 14px 0 0; font-size: 10.5px; line-height: 1.5; color: rgba(217,255,228,0.42); }

/* ---------- calibration ---------- */

.calib-hands { display: flex; gap: 14px; justify-content: center; margin-bottom: 16px; }
.calib-hand {
  flex: 1;
  padding: 14px 6px;
  border: 1px solid rgba(217,255,228,0.18);
  font-size: 10px;
  letter-spacing: 3px;
  color: rgba(217,255,228,0.4);
  transition: all 200ms;
}
.calib-hand span {
  display: block;
  width: 26px; height: 26px;
  margin: 0 auto 8px;
  border-radius: 50%;
  border: 2px solid rgba(217,255,228,0.2);
}
.calib-hand.on {
  border-color: var(--green);
  color: var(--green);
  background: rgba(57,255,106,0.08);
}
.calib-hand.on span {
  border-color: var(--green);
  background: rgba(57,255,106,0.3);
  box-shadow: 0 0 18px rgba(57,255,106,0.8);
}
.calib-msg { margin: 0 0 16px; font-size: 12.5px; line-height: 1.5; color: rgba(217,255,228,0.7); min-height: 38px; }

.calib-ring {
  width: 76px; height: 76px;
  margin: 0 auto;
  border: 2px solid rgba(57,255,106,0.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 20px rgba(57,255,106,0.8);
  opacity: 0;
  transition: opacity 200ms;
}
.calib-ring.on { opacity: 1; }

/* ---------- game over ---------- */

.final { display: flex; justify-content: center; gap: 10px; margin: 4px 0 20px; }
.final-item { flex: 1; }
.final-item span {
  display: block;
  font-size: 30px;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 16px rgba(57,255,106,0.6);
  font-variant-numeric: tabular-nums;
}
.final-item label { display: block; font-size: 9px; letter-spacing: 2px; color: rgba(217,255,228,0.45); margin-top: 4px; }

/* ---------- loading ---------- */

.loading {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(28px + var(--safe-b));
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(217,255,228,0.6);
}
.loading.hidden { display: none; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(57,255,106,0.25);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* Landscape on a phone: shrink the chrome so the play area survives. */
@media (max-height: 460px) {
  .panel { padding: 16px; max-width: 480px; }
  .rules { display: none; }
  .title { font-size: 30px; }
  .btn { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .health.critical i:not(.spent) { animation: none; }
  .banner.show { animation-duration: 1200ms; }
}
