/* Base */
:root { --bg: #050505; --ui-text: #fff; --health: #ff4444; --ammo: #ffff00; }

html,body{
  height:100%; margin:0; background:var(--bg); touch-action:none; -webkit-user-select:none; user-select:none;
  color:var(--ui-text); font-family: "Segoe UI", Arial, sans-serif; overflow:hidden;
}

canvas { display:block; width:100%; height:100vh; max-width:100%; touch-action:none; -webkit-user-select:none; user-select:none; }

/* Top UI (pointer-events none so canvas receives touches by default) */
#topUI{
  position:absolute; top:15px; left:20px; pointer-events:none; z-index:5;
}
#healthUI{ color:var(--health); font-size:28px; filter:drop-shadow(0 0 5px red); }
#ammoUI{
  color:var(--ammo);
  font-size:15px;
  margin-top:6px;
  background: linear-gradient(180deg, rgba(255,255,220,0.06), rgba(0,0,0,0.06));
  padding:6px 10px;
  border-radius:10px;
  display:inline-block;
  box-shadow: 0 4px 18px rgba(255,200,60,0.06), inset 0 -1px 0 rgba(255,255,255,0.02);
  border: 1px solid rgba(255,200,60,0.08);
  font-weight:700;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}
#scoreDisplay{ font-size:20px; font-weight:bold; opacity:0.9; }

/* Top HUD additions */
#timeUI{ color:#99ffcc; font-weight:800; font-size:14px; margin-top:6px; text-shadow:0 1px 0 rgba(0,0,0,0.6); }
#missionUI{ color:#ffd24d; font-weight:800; font-size:13px; margin-top:6px; }
#alertUI{ color:#ff6b6b; font-size:14px; margin-top:6px; font-weight:900; text-shadow:0 1px 0 rgba(0,0,0,0.6); padding:6px 8px; background:rgba(0,0,0,0.35); border-radius:8px; display:inline-block; }

/* Game Over modal */
#gameOverUI{
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
  background:rgba(10,10,15,0.95); padding:30px; border-radius:16px; text-align:center;
  display:none; z-index:60; border:1px solid #444; box-shadow:0 0 40px rgba(0,0,0,1);
  width:86%; max-width:360px; pointer-events: auto;
}
.btn{
  margin-top:18px; padding:12px; font-size:15px; cursor:pointer; border:none; border-radius:10px;
  font-weight:700; width:100%; text-transform:uppercase;
  -webkit-tap-highlight-color: transparent;
}
.btn-restart{ background:#00ffcc; color:#000; }
.btn-secondary{ background:#222; color:#fff; border:1px solid rgba(255,255,255,0.03); }

/* Menu (pre-game) */
#menuUI{
  position: absolute; inset:0; display:flex; align-items:center; justify-content:center;
  background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(0,0,0,0.9));
  z-index:30; padding:20px;
}
.menu-card{
  width:94%; max-width:760px; background:linear-gradient(180deg,#0b0b0d,#0f0f12);
  border-radius:14px; padding:14px; color:#fff; box-shadow:0 10px 60px rgba(0,0,0,0.85);
  border:1px solid rgba(255,255,255,0.04); font-size:15px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  max-height:90vh;
  box-sizing:border-box;
}
.menu-title{ margin:0 0 8px 0; font-size:20px; color:#ffd24d; text-align:center; }
.menu-row{ display:flex; gap:16px; align-items:flex-start; flex:1 1 auto; overflow:auto; min-height:0; }
.menu-col{ flex:1; padding:6px 4px; }
.pay-col{ max-width:220px; text-align:center; }

/* QR image styling inside the payment column */
.pay-col .qr-img{
  display:block;
  margin:8px auto 6px auto;
  width: 180px;
  height: 180px;
  object-fit: contain;
  border-radius:10px;
  background: rgba(255,255,255,0.03);
  padding:8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
}
.paypal-btn{
  display:inline-block; margin-top:8px; padding:10px 12px; background:#003087; color:#fff; border-radius:8px;
  text-decoration:none; font-weight:800; box-shadow: 0 8px 20px rgba(0,48,135,0.18);
}
.menu-actions{ margin-top:12px; display:flex; gap:10px; align-items:center; flex-shrink:0; }
.menu-actions .btn{ flex:1; width:auto; padding:12px; }

/* Tutorial card fallback styles (kept for compatibility) */
#tutorialUI{ display:none; }
.tutorial-card{ display:none; }

/* hint text */
.hint{ font-size:12px; opacity:0.75; margin-top:8px; text-align:center; }

/* Smaller screens adjustments */
@media (max-width:420px){
  #healthUI{ font-size:22px; }
  #ammoUI{ font-size:14px; }
  #scoreDisplay{ font-size:16px; }
  .menu-row{ flex-direction:column; }
  .pay-col{ max-width:100%; text-align:center; }
}

/* Orientation-aware layout: use data-orientation attribute set by JS */
:root[data-orientation="portrait"] {
  --hud-scale: 1.0;
}
:root[data-orientation="landscape"] {
  --hud-scale: 0.92;
}

/* Portrait-specific HUD adjustments */
:root[data-orientation="portrait"] #topUI{
  top: 12px; left: 14px; transform: none;
  display:flex; flex-direction:column; gap:6px;
}
:root[data-orientation="portrait"] #menuUI .menu-card{
  width:92%; max-width:480px; padding:12px;
}
:root[data-orientation="portrait"] .menu-actions{ flex-direction:column; align-items:stretch; }
:root[data-orientation="portrait"] .pay-col{ order:2; margin-top:8px; }

/* Landscape-specific HUD adjustments */
:root[data-orientation="landscape"] #topUI{
  top: 14px; left: 20px; display:flex; flex-direction:row; gap:14px; align-items:center;
}
:root[data-orientation="landscape"] #menuUI .menu-card{
  width:88%; max-width:980px; padding:16px;
}
:root[data-orientation="landscape"] .menu-row{ flex-direction:row; }
:root[data-orientation="landscape"] .pay-col{ max-width:260px; }

/* Scaled UI elements for accessibility and one-handed play */
#topUI > *{ transform-origin: left top; transform: scale(var(--hud-scale)); }

/* Ensure menu action buttons are visible and not pushed off-screen on small viewports */
.menu-actions .btn{ min-height:44px; padding:10px; }

/* Reward timer badge */
#rewardTimer{
  pointer-events:none;
  text-shadow:0 1px 0 rgba(0,0,0,0.6);
}

/* Immersive mode: hide UI, remove cursor and simplify chrome for focused play */
.immersive #menuUI,
.immersive .menu-card,
.immersive #topUI { display:none !important; }

.immersive canvas { cursor: none !important; }

/* In immersive keep the game over modal interactive and on top when it's shown */
.immersive #gameOverUI { pointer-events: auto; z-index: 80; }