/* ═══════════════════════════════════════════════════
   Maze Runner — layout.css
   Full-viewport 3D canvas + HUD overlay
════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #05050c;
  --surface:     #0e0e1c;
  --surface2:    #161628;
  --accent:      #4488ff;
  --accent2:     #00ff88;
  --danger:      #ff2244;
  --gold:        #ffbb00;
  --text:        #dde4ff;
  --text-dim:    #7788aa;
  --border:      #1e2040;
  --font-head:   'Orbitron', monospace;
  --font-body:   'Inter', sans-serif;
  --hud-h:       52px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

.maze-auth-nav {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 140;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Canvas fills entire viewport ── */
#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ── Minimap ── */
#minimap {
  position: fixed;
  top: calc(var(--hud-h) + 8px);
  right: 12px;
  z-index: 20;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #040408;
  image-rendering: pixelated;
  opacity: 0.88;
  pointer-events: none;
}

/* ── HUD bar ── */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--hud-h);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: linear-gradient(to bottom, rgba(5,5,12,0.95), rgba(5,5,12,0.0));
  pointer-events: none;
  gap: 12px;
}

#hud-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 160px;
  pointer-events: none;
}

#hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: var(--font-head);
  pointer-events: none;
}

#hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  pointer-events: all;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bar-label {
  font-family: var(--font-head);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-dim);
  width: 18px;
}

.bar {
  width: 100px;
  height: 7px;
  background: #111122;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22dd44, #88ff66);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.bar-val {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-head);
}

.hud-lives {
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--danger);
  font-family: var(--font-head);
}

#hudFloor {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--accent);
}

#hudTime {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

#hudScore {
  font-size: 11px;
  font-family: var(--font-head);
  color: var(--gold);
  letter-spacing: 1px;
}

.hud-back-link {
  font-size: 10px;
  font-family: var(--font-head);
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 1px;
  transition: color 0.2s;
}
.hud-back-link:hover { color: var(--text); }

/* ── Flash message ── */
#flash {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  font-family: var(--font-head);
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 900;
  letter-spacing: 3px;
  text-shadow: 0 0 16px currentColor;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* ── Screens overlay ── */
#screens {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.game-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5,5,12,0.88);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.game-screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ── Mobile D-pad controller ── */
#dpad {
  display: none;
  position: fixed;
  bottom: 30px;
  left: 30px;
  z-index: 80;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#dpad-ring {
  position: relative;
  width: 138px;
  height: 138px;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(30,35,60,0.92) 0%, rgba(14,16,30,0.96) 100%);
  border: 2px solid rgba(68, 136, 255, 0.35);
  box-shadow: 0 0 18px rgba(68,136,255,0.12), inset 0 0 12px rgba(0,0,0,0.5);
}

/* Cross dividers */
#dpad-ring::before,
#dpad-ring::after {
  content: '';
  position: absolute;
  background: rgba(68, 136, 255, 0.10);
  border-radius: 2px;
}
#dpad-ring::before { width: 2px; height: 100%; left: 50%; top: 0; transform: translateX(-50%); }
#dpad-ring::after  { width: 100%; height: 2px; top: 50%; left: 0; transform: translateY(-50%); }

/* Directional arrows */
.dpad-arrow {
  position: absolute;
  color: rgba(100, 150, 255, 0.45);
  font-size: 13px;
  pointer-events: none;
}
.dpad-u { top: 8px;  left: 50%; transform: translateX(-50%); }
.dpad-d { bottom: 8px; left: 50%; transform: translateX(-50%); }
.dpad-l { left: 9px; top: 50%; transform: translateY(-50%); }
.dpad-r { right: 9px; top: 50%; transform: translateY(-50%); }

/* Sliding nub */
#dpad-nub {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 38% 35%, rgba(100,160,255,0.55), rgba(40,80,180,0.80));
  border: 2px solid rgba(100, 160, 255, 0.6);
  box-shadow: 0 2px 10px rgba(0,0,0,0.5), 0 0 8px rgba(68,136,255,0.3);
  pointer-events: none;
  transition: box-shadow 0.1s;
}

/* ── Mobile jump button ── */
#btn-jump {
  display: none;
  position: fixed;
  bottom: 50px;
  right: 36px;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, rgba(80,200,120,0.45), rgba(20,100,60,0.82));
  border: 2px solid rgba(0, 255, 136, 0.5);
  box-shadow: 0 0 14px rgba(0,255,136,0.15), inset 0 0 8px rgba(0,0,0,0.4);
  color: rgba(180,255,220,0.9);
  font-size: 11px;
  font-family: var(--font-head);
  letter-spacing: 1px;
  font-weight: 700;
  cursor: pointer;
  z-index: 80;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: box-shadow 0.1s, background 0.1s;
}
#btn-jump:active {
  background: radial-gradient(circle at 38% 35%, rgba(80,255,150,0.6), rgba(20,140,80,0.9));
  box-shadow: 0 0 22px rgba(0,255,136,0.35);
}

#btn-mobile-pause {
  display: none;
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 42px;
  border-radius: 8px;
  background: rgba(10, 10, 22, 0.72);
  border: 1px solid rgba(68, 136, 255, 0.45);
  color: #99bbff;
  font-size: 13px;
  font-family: var(--font-head);
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 80;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
#btn-mobile-pause:active { background: rgba(68, 136, 255, 0.24); }

@media (pointer: coarse) {
  #dpad     { display: block; }
  #btn-jump { display: flex; align-items: center; justify-content: center; }
  .desktop-only { display: none !important; }

  /* Auth nav — tiny strip at the very top, above everything */
  .maze-auth-nav {
    top: 0;
    right: 8px;
    font-size: 9px;
    gap: 6px;
    height: 20px;
    align-items: center;
    z-index: 200;
  }

  /* Screens start below the auth nav strip so login info is never covered */
  #screens {
    top: 20px;
  }

  /* Push HUD below auth nav */
  #hud {
    top: 20px;
  }

  /* Pause — top-right, below the HUD score */
  #btn-mobile-pause {
    display: block;
    top: calc(20px + var(--hud-h) + 6px);
    right: 8px;
    left: auto;
    transform: none;
  }

  /* Minimap — below the pause button */
  #minimap {
    top: calc(20px + var(--hud-h) + 56px);
    right: 8px;
  }
}

/* ── Arcade sidebar (desktop) ── */
#arcade-sidebar {
  display: none;
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
}

.sidebar-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  gap: 6px;
  background: var(--surface2);
  border-left: 2px solid var(--border);
  border-radius: 6px 0 0 6px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 9px;
  font-family: var(--font-head);
  letter-spacing: 1px;
  transition: background 0.2s, color 0.2s;
}
.sidebar-link:hover {
  background: var(--surface);
  color: var(--accent);
}
.sidebar-icon { font-size: 18px; }

@media (min-width: 900px) {
  #arcade-sidebar { display: block; }
}
