/* =========================================
   ANTO BOYLE'S GAME 47 - STYLESHEET
   v9.72
   ========================================= */

:root {
  --bg: #050505;
  --panel: #111;
  --text: #0f0;
  --accent: #ff883e;
  --border: #333;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Share Tech Mono", monospace;
  height: 100vh;
  display: flex;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none; /* Prevent text selection dragging */
  -webkit-appearance: none;
  appearance: none;
}

/* --- LAYOUT --- */
#control-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  max-height: 80vh;
  background: rgba(10, 10, 10, 0.95);
  border: 2px solid var(--accent);
  display: none; /* Hidden by default */
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
  z-index: 10000;
  border-radius: 8px;
}

#game-view {
  width: 100vw;
  height: 100vh;
  position: relative;
  background: #000;
  cursor: none !important;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none !important;
}

/* --- UI ELEMENTS --- */
h1 {
  margin: 0 0 10px 0;
  font-size: 1.4rem;
  color: var(--accent);
  border-bottom: 2px solid var(--border);
  padding-bottom: 5px;
}
h2 {
  margin: 15px 0 5px 0;
  font-size: 1rem;
  color: #fff;
  background: #222;
  padding: 2px 5px;
}

.control-group {
  margin-bottom: 10px;
  border-bottom: 1px dashed #222;
  padding-bottom: 5px;
}
.label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 2px;
  color: #888;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  background: #333;
  outline: none;
  -webkit-appearance: none;
  appearance: none; /* Added standard property */
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--text);
  cursor: pointer;
  border-radius: 0;
}

.val-display {
  color: var(--text);
}

/* METRICS */
.metric {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 2px;
}
.metric span:last-child {
  color: #fff;
}

/* --- NEW HUD STYLES --- */
#hud-layer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: none; /* Hidden by default */
  flex-direction: row; /* Horizontal layout: Left Panel ... Right Panel */
  justify-content: space-between; /* Push panels to edges */
  align-items: flex-start; /* Align both to TOP */
  padding: 0; /* Stuck to edges */
  z-index: 20000;
}

.hud-panel {
  background: rgba(0, 0, 0, 0.85);
  padding: 8px;
  border-radius: 4px;
  border: 2px solid rgba(0, 255, 0, 0.4);
  color: #fff;
  font-family: "Share Tech Mono", monospace;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
}

/* v16.04: Compact Square HUD - Top Left (170x120px) */
.hud-left {
  width: 170px;
  height: 120px;
  align-items: flex-start;
  position: fixed;
  top: 5px;
  left: 5px;
  overflow: hidden;
  padding: 6px;
  box-sizing: border-box;
  gap: 2px;
}

/* v16.04: Compact Minimap - Top Right (120x120px) */
.hud-right {
  width: 120px;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: fixed;
  top: 5px;
  right: 5px;
  padding: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  box-sizing: border-box;
  pointer-events: auto;
  gap: 5px;
}

/* v16.04: Stats grid for compact layout */
.hud-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 4px;
  width: 100%;
  margin-top: 1px;
}

/* v16.04: Ultra-compact text sizes for square HUD */
.hud-text-lg {
  font-size: 9.5px;
  font-weight: bold;
  line-height: 1.1;
  margin: 0;
}
.hud-text-md {
  font-size: 8px;
  color: #ddd;
  line-height: 1.1;
  margin: 0;
}
.hud-text-sm {
  font-size: 7px;
  color: #aaa;
  line-height: 1.1;
  margin: 0;
}

/* v15.58: Ultra-compact bars for square HUD */
.hud-bar-container {
  width: 100%;
  height: 8px;
  background: #440000;
  border: 1px solid #660000;
  margin-bottom: 2px;
}
.hud-bar-fill {
  height: 100%;
  background: #ff0000;
  width: 100%;
  transition: width 0.1s;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

/* v16.04: Compact Square minimap canvas (120x120px) */
#minimap-canvas {
  width: 120px !important;
  height: 120px !important;
  border: 1.5px solid #0f0 !important;
  background: rgba(0, 20, 0, 0.9);
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.2);
}

/* v15.58: Compact ammo box styling */
.box-mines {
  background: rgba(40, 40, 0, 0.3);
  padding: 3px;
  border-radius: 2px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  margin: 1px 0;
}

.bar-mines-container {
  background: #332200 !important;
  border-color: #554400 !important;
  height: 6px !important;
  margin-bottom: 1px !important;
}

.bar-mines-fill {
  background: linear-gradient(90deg, #ffaa00, #ffdd00) !important;
}

.text-gold {
  color: #ffd700;
  font-size: 10px !important;
}

/* Hide old Overlay Metrics if we have new HUD? */
.metric {
  display: none !important;
}
/* LOG */
#sys-log {
  height: 120px;
  background: #000;
  border: 1px solid #222;
  color: #666;
  font-size: 0.7rem;
  overflow-y: auto;
  padding: 5px;
  margin-top: auto;
}
.log-entry {
  margin-bottom: 2px;
  border-bottom: 1px solid #111;
}
.log-entry.warn {
  color: #f80;
}

/* OVERLAY */
#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
#overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.msg-box {
  text-align: center;
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid var(--accent);
  padding: 40px;
  transform: scale(0.9);
  transition: transform 0.3s;
}
#overlay.active .msg-box {
  transform: scale(1);
}

button {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 10px 30px;
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  margin-top: 20px;
}
button:hover {
  background: #fff;
}

/* CRT SCANLINE EFFECT */
/* CRT SCANLINE EFFECT REMOVED (User Request v10.55) */
#game-view::after {
  display: none;
}

#drag-handle {
  width: 5px;
  background: #222;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.2s;
  z-index: 20;
}
#drag-handle:hover,
#drag-handle.active {
  background: var(--accent);
}

/* REDESIGNED DEBUG CONSOLE (v12.41) */
#debug-console {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  background: rgba(5, 10, 5, 0.95);
  border-left: 2px solid #0f0;
  color: #0f0;
  font-family: "Share Tech Mono", monospace;
  z-index: 99999;
  padding: 0;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.8);
  transform: translateX(0);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#debug-console.hidden {
  transform: translateX(330px);
}

.debug-header {
  background: #0f0;
  color: #000;
  padding: 8px 12px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.debug-actions button {
  background: #000;
  color: #0f0;
  border: 1px solid #000;
  margin: 0;
  padding: 2px 8px;
  font-size: 10px;
  cursor: pointer;
}

.debug-content {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
}

.debug-section {
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(0, 255, 0, 0.2);
  padding-bottom: 10px;
}

.debug-section h3 {
  font-size: 12px;
  color: #fff;
  margin: 0 0 10px 0;
  background: rgba(0, 255, 0, 0.1);
  padding: 4px;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 6px;
}

.debug-row input[type="checkbox"] {
  accent-color: #0f0;
  cursor: pointer;
}

#debug-logs {
  max-height: 200px;
  overflow-y: auto;
  font-size: 9px;
  background: #000;
  padding: 5px;
  border: 1px solid #111;
}

.log-line {
  border-bottom: 1px solid #111;
  padding: 2px 0;
}

.log-err {
  color: #f00;
}
.log-warn {
  color: #ff0;
}

/* Helper Classes */
.btn-small {
  width: auto;
  padding: 2px 10px;
  font-size: 0.8rem;
}
.magenta-text {
  color: #f0f;
}
.checkbox-auto {
  width: auto;
  height: auto;
}
.stat-row {
  font-size: 0.8rem;
  color: #fff;
  margin-bottom: 2px;
}
.sub-label {
  font-size: 0.6rem;
  color: #666;
  width: 100%;
  text-align: right;
}

/* --- REFACTORED INLINE STYLES --- */

#start-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #111 0%, #000 100%);
  z-index: 20;
  display: flex;
  flex-direction: row;
  justify-content: space-evenly;
  align-items: stretch;
  color: #0f0;
  font-family: "Share Tech Mono", monospace;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto !important;
  overflow-x: hidden;
  scroll-behavior: smooth;
  gap: 20px;
}

/* Custom scrollbar for mouse wheel scrolling */
#start-screen::-webkit-scrollbar {
  width: 8px;
}
#start-screen::-webkit-scrollbar-track {
  background: rgba(0, 10, 0, 0.5);
}
#start-screen::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 0, 0.4);
  border-radius: 4px;
}

/* Default columns layout for desktop */
.start-col-left {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  border-right: 1.5px solid rgba(0, 255, 0, 0.15);
  max-width: 35%;
  background: rgba(0, 5, 0, 0.2);
  border-radius: 8px;
  max-height: 100%;
  overflow-y: auto;
}

.start-col-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
  text-align: center;
  max-height: 100%;
  overflow-y: auto;
}

.start-col-right {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  border-left: 1.5px solid rgba(0, 255, 0, 0.15);
  max-width: 35%;
  background: rgba(255, 136, 62, 0.02);
  border-radius: 8px;
  max-height: 100%;
  overflow-y: auto;
}

/* Start screen typography and panels */
.start-title {
  font-size: 2.4rem;
  color: #0f0;
  text-shadow: 0 0 15px rgba(0, 255, 0, 0.6);
  margin: 0 0 5px 0;
  border-bottom: none;
  padding-bottom: 0;
  text-align: center;
  font-weight: 900;
  letter-spacing: 2px;
}

.start-version {
  font-size: 0.95rem;
  color: #555 !important;
  margin: 0 0 20px 0;
  text-align: center;
}

.start-panel-header {
  font-size: 1.1rem;
  color: var(--accent);
  border-bottom: 2px solid rgba(255, 136, 62, 0.3);
  padding-bottom: 6px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: bold;
}

.start-panel-body {
  font-size: 0.85rem;
  line-height: 1.4;
  color: #bbb;
}

/* Controls Grid */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 10px;
}

@media (min-width: 1025px) {
  .controls-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.control-box {
  background: rgba(0, 15, 0, 0.45);
  border: 1.5px solid rgba(0, 255, 0, 0.15);
  padding: 10px;
  border-radius: 6px;
  box-shadow: inset 0 0 8px rgba(0, 255, 0, 0.05);
}

.control-box h4 {
  margin: 0 0 6px 0;
  font-size: 0.8rem;
  color: #fff;
  border-bottom: 1px solid rgba(0, 255, 0, 0.1);
  padding-bottom: 3px;
  font-weight: bold;
  letter-spacing: 1px;
}

.control-box ul {
  margin: 0;
  padding-left: 15px;
  font-size: 0.75rem;
  color: #aaa;
}

.control-box li {
  margin-bottom: 4px;
}

/* Weapon Legend styling */
.weapon-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weapon-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background: rgba(255, 136, 62, 0.04);
  border: 1px solid rgba(255, 136, 62, 0.12);
  border-radius: 5px;
  font-size: 0.8rem;
  transition: background 0.2s ease;
}

.weapon-item:hover {
  background: rgba(255, 136, 62, 0.08);
}

.weapon-item span:first-child {
  font-size: 1.2rem;
}

.weapon-item span:last-child {
  color: #ddd;
}

.quote-text {
  font-style: italic;
  font-size: 0.8rem;
  color: #555;
  text-align: center;
  margin-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 12px;
  line-height: 1.4;
}

/* Button & Action styling */
.start-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 20px 0;
  z-index: 10;
}

.start-btn-primary {
  background: var(--accent) !important;
  color: #000 !important;
  border: 2px solid var(--accent) !important;
  padding: 12px 35px !important;
  font-size: 1.25rem !important;
  font-weight: bold !important;
  cursor: pointer !important;
  border-radius: 4px !important;
  box-shadow: 0 0 15px rgba(255, 136, 62, 0.4) !important;
  transition: all 0.2s ease !important;
  text-transform: uppercase !important;
  letter-spacing: 1px !important;
  margin: 0 !important;
}

.start-btn-primary:hover:not(:disabled) {
  background: #fff !important;
  border-color: #fff !important;
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.8) !important;
}

.start-btn-primary:disabled {
  background: #222 !important;
  color: #555 !important;
  border-color: #333 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
}

.start-btn-pwa {
  background: #00ff00 !important;
  color: #000 !important;
  border: 2px solid #00ff00 !important;
  padding: 8px 20px !important;
  font-size: 0.9rem !important;
  margin-top: 10px !important;
  font-weight: bold !important;
  cursor: pointer !important;
  border-radius: 4px !important;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.3) !important;
}

.start-btn-secondary {
  background: transparent !important;
  color: #0f0 !important;
  border: 1px solid rgba(0, 255, 0, 0.3) !important;
  padding: 6px 15px !important;
  font-size: 0.85rem !important;
  margin-top: 15px !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.start-btn-secondary:hover {
  background: rgba(0, 255, 0, 0.1) !important;
  border-color: #0f0 !important;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.3) !important;
}

/* HUD Text Colors */
.text-health {
  color: #ff4444;
}
.text-regen {
  width: 100%;
  text-align: right;
  color: #0f0;
}
.text-weapon {
  margin-top: 10px;
}
.text-gold {
  color: #ffff00;
}
.text-enemies {
  margin-top: 10px;
  color: #aaa;
}
.text-score {
  color: #aaa;
}
.text-time {
  margin-top: 10px;
}
.text-dmg-dealt {
  color: #ffaaaa;
}
.text-dmg-taken {
  color: #aaffaa;
}

.box-mines {
  width: 100%;
  display: none;
}
.bar-mines-container {
  height: 8px;
  background: #222;
  border-color: #444;
}
.bar-mines-fill {
  background: #0ff;
  width: 0%;
}

.canvas-minimap {
  border: 2px solid #0f0;
  background: #001100;
  box-shadow: 0 0 10px #0f0;
  border-radius: 4px;
}

/* --- GAME OVER SCREEN --- */
#game-over-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(40, 0, 0, 0.95); /* Deep Red Overlay */
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 20000;
  color: #fff;
}

#game-over-screen h1 {
  color: #ff0000;
  font-size: 4rem;
  text-shadow: 0 0 20px #ff0000;
  margin-bottom: 20px;
}

.stat-box {
  border: 2px solid #ff4444;
  padding: 30px;
  background: rgba(0, 0, 0, 0.8);
  min-width: 400px;
  box-shadow: 0 0 30px rgba(255, 0, 0, 0.2);
  margin-bottom: 30px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin: 10px 0;
  font-size: 1.5rem;
  border-bottom: 1px solid #444;
  padding-bottom: 5px;
}

.stat-val {
  color: #ff883e;
  font-weight: bold;
}

#btn-restart {
  padding: 15px 50px;
  font-size: 2rem;
  background: #ff0000;
  color: #000;
  border: 2px solid #fff;
  cursor: pointer;
  font-family: inherit;
  font-weight: bold;
  text-transform: uppercase;
  transition: all 0.2s;
}

#btn-restart:hover {
  background: #fff;
  color: #ff0000;
  box-shadow: 0 0 30px #fff;
}

/* --- v15.20: TACTICAL LOADER --- */
#loader-container {
  margin: 20px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  z-index: 100;
}
#loader-clock {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  justify-content: center;
  align-items: center;
}
#loader-clock svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
#loader-bg {
  fill: none;
  stroke: rgba(0, 255, 0, 0.05);
  stroke-width: 4;
}
#loader-progress {
  fill: none;
  stroke: #00ff00;
  stroke-width: 6;
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 12px #00ff00);
}
#loader-text {
  font-family: "Share Tech Mono", monospace;
  font-size: 28px;
  color: #00ff00;
  text-shadow: 0 0 15px #00ff00;
  font-weight: bold;
  z-index: 10;
}
#loader-status {
  font-family: "Share Tech Mono", monospace;
  font-size: 14px;
  color: #00ff00;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: center;
  animation: pulse-op 2s infinite;
  max-width: 400px;
}
@keyframes pulse-op {
  0%,
  100% {
    opacity: 1;
    text-shadow: 0 0 5px #0f0;
  }
  50% {
    opacity: 0.5;
    text-shadow: none;
  }
}

/* ==============================================================
   MOBILE TOUCH CONTROLS & LANDSCAPE ORIENTATION - v16.02
   ============================================================== */

/* Prevent default behaviors on mobile */
html, body {
  touch-action: none;
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* Orientation Warning Screen */
#orientation-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 999999;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #0f0;
  font-family: "Share Tech Mono", monospace;
  text-align: center;
}

#orientation-warning .rotate-icon {
  width: 80px;
  height: 80px;
  border: 4px solid #0f0;
  border-radius: 12px;
  margin-bottom: 20px;
  position: relative;
  animation: rotate-phone 2.5s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(0, 255, 0, 0.4);
}

#orientation-warning .rotate-icon::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0f0;
}

#orientation-warning h2 {
  font-size: 1.8rem;
  margin-bottom: 10px;
  text-shadow: 0 0 10px #0f0;
  background: transparent;
  padding: 0;
}

#orientation-warning p {
  color: #888;
  font-size: 1rem;
  max-width: 320px;
}

#orientation-warning h1 {
  font-size: 2rem;
  margin: 15px 0 5px 0;
  font-weight: bold;
  text-shadow: 0 0 10px #0f0;
}

#orientation-warning .game-desc {
  color: #888;
  font-size: 0.85rem;
  max-width: 320px;
  margin: 0 auto 12px auto;
  line-height: 1.4;
  padding: 0 10px;
}

#orientation-warning .start-version {
  color: var(--accent);
  margin: 0 0 20px 0;
  font-size: 1rem;
  letter-spacing: 2px;
}

#orientation-warning .warning-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-top: 15px;
}

#orientation-warning button {
  font-family: "Share Tech Mono", monospace;
  font-size: 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  padding: 8px 18px;
  transition: all 0.2s ease-in-out;
  pointer-events: auto;
}

#orientation-warning #btn-warning-refresh {
  background: #111;
  color: #0f0;
  border: 1px solid #0f0;
  text-shadow: 0 0 5px #0f0;
  box-shadow: 0 0 8px rgba(0, 255, 0, 0.1);
}

#orientation-warning #btn-warning-refresh:hover {
  background: #0f0;
  color: #000;
  box-shadow: 0 0 12px rgba(0, 255, 0, 0.4);
}

#orientation-warning #btn-warning-install {
  background: #0f0;
  color: #000;
  border: none;
  font-weight: bold;
  box-shadow: 0 0 12px rgba(0, 255, 0, 0.3);
}

#orientation-warning #btn-warning-install:hover {
  background: #fff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

@keyframes rotate-phone {
  0% { transform: rotate(0deg); }
  30%, 70% { transform: rotate(90deg); }
  100% { transform: rotate(90deg); }
}

/* Show warning on mobile portrait viewports */
@media (max-width: 900px) and (orientation: portrait) {
  #orientation-warning {
    display: flex !important;
  }
}

/* Touch Controls Wrapper */
#touch-controls-container {
  display: none; /* Auto-shown in mobile_controls.js if touch device detected */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 25000;
}

/* Virtual Joysticks */
.virtual-joystick-base {
  position: absolute;
  width: 100px;
  height: 100px;
  background: rgba(0, 20, 0, 0.35);
  border: 2px solid rgba(0, 255, 0, 0.4);
  border-radius: 50%;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.2);
  display: none; /* Dynamic display on touch */
}

.virtual-joystick-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  background: rgba(0, 255, 0, 0.85);
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  transition: transform 0.05s ease-out;
}

/* Left & Right active zones for spawning joysticks */
#joystick-zone-left, #joystick-zone-right {
  position: absolute;
  bottom: 0;
  width: 50%;
  height: 80%;
  pointer-events: auto;
}

#joystick-zone-left::before {
  content: none !important;
}

#joystick-zone-left { left: 0; }
#joystick-zone-right { right: 0; }

/* Custom NippleJS Joystick Styles */
#joystick-zone-left .back {
  background: rgba(0, 20, 0, 0.35) !important;
  border: 2px solid rgba(0, 255, 0, 0.6) !important;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.3) !important;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100"><circle cx="50" cy="50" r="46" fill="none" stroke="%2300ff00" stroke-width="1" stroke-dasharray="2,3" opacity="0.4" /><text x="50" y="53" fill="%2300ff00" font-family="sans-serif" font-size="8" font-weight="bold" text-anchor="middle" opacity="0.6">MOVE</text><polygon points="50,10 45,18 55,18" fill="%2300ff00" /><text x="50" y="30" fill="%2300ff00" font-family="sans-serif" font-size="10" font-weight="bold" text-anchor="middle">N</text><polygon points="50,90 45,82 55,82" fill="%2300ff00" /><text x="50" y="74" fill="%2300ff00" font-family="sans-serif" font-size="10" font-weight="bold" text-anchor="middle">S</text><polygon points="10,50 18,45 18,55" fill="%2300ff00" /><text x="30" y="53" fill="%2300ff00" font-family="sans-serif" font-size="10" font-weight="bold" text-anchor="middle">W</text><polygon points="90,50 82,45 82,55" fill="%2300ff00" /><text x="70" y="53" fill="%2300ff00" font-family="sans-serif" font-size="10" font-weight="bold" text-anchor="middle">E</text></svg>') !important;
  background-size: 100% 100% !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

#joystick-zone-left .front {
  background: rgba(0, 255, 0, 0.8) !important;
  border: 1.5px solid #fff !important;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5) !important;
}

#joystick-zone-right .back {
  background: rgba(15, 5, 0, 0.35) !important;
  border: 2px solid rgba(255, 136, 62, 0.6) !important;
  box-shadow: 0 0 15px rgba(255, 136, 62, 0.3) !important;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100"><text x="50" y="54" fill="%23ff883e" font-family="sans-serif" font-size="10" font-weight="bold" text-anchor="middle">AIM</text><polygon points="50,15 45,22 55,22" fill="%23ff883e" /><polygon points="50,85 45,78 55,78" fill="%23ff883e" /><polygon points="15,50 22,45 22,55" fill="%23ff883e" /><polygon points="85,50 78,45 78,55" fill="%23ff883e" /></svg>') !important;
  background-size: 100% 100% !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

#joystick-zone-right .front {
  background: rgba(255, 136, 62, 0.8) !important;
  border: 1.5px solid #fff !important;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5) !important;
}

/* Mobile Action Panel (Bottom Right Corner) */
#mobile-action-panel {
  position: absolute;
  right: 195px;
  bottom: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  pointer-events: auto;
  z-index: 26000;
}

/* Weapon Selection HUD for Mobile */
#mobile-weapon-selector {
  position: absolute;
  right: 15px;
  bottom: 15px;
  width: 170px;
  height: 170px;
  background: transparent;
  border: none;
  box-shadow: none;
  z-index: 26000;
  pointer-events: none;
}

.mobile-weapon-btn {
  position: absolute;
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 255, 0, 0.4);
  background: rgba(0, 15, 0, 0.9);
  color: #0f0;
  font-family: inherit;
  font-size: 18px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
  transition: all 0.15s ease;
  box-shadow: inset 0 0 5px rgba(0, 255, 0, 0.3);
}

#mob-w-1 { right: 115px; bottom: 23px; }
#mob-w-2 { right: 110px; bottom: 52px; }
#mob-w-3 { right: 98px; bottom: 77px; }
#mob-w-4 { right: 77px; bottom: 98px; }
#mob-w-5 { right: 52px; bottom: 110px; }
#mob-w-6 { right: 23px; bottom: 115px; }

.mobile-weapon-btn.active {
  background: #0f0;
  color: #000;
  border-color: #fff;
  box-shadow: 0 0 12px #0f0;
  transform: scale(1.1);
}

/* Large Round Interact & Dash Buttons */
.mobile-action-row {
  display: flex;
  gap: 15px;
}

.mobile-action-btn {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(255, 136, 62, 0.2);
  border: 2px solid #ff883e;
  color: #ff883e;
  font-family: inherit;
  font-weight: bold;
  font-size: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 10px rgba(255, 136, 62, 0.3);
  margin: 0;
  padding: 0;
  transition: all 0.1s ease;
}

.mobile-action-btn:active {
  background: #ff883e;
  color: #000;
  box-shadow: 0 0 18px #ff883e;
  transform: scale(0.95);
}

/* System Overrides for Compact Layout */
@media (max-width: 900px) {
  #control-panel {
    width: 90%;
    max-height: 90vh;
    padding: 10px;
  }
  .hud-left, .hud-right {
    transform: scale(0.8);
  }
  .hud-left {
    top: 5px;
    left: 5px;
    transform-origin: top left;
  }
  .hud-right {
    top: 5px;
    right: 5px;
    transform-origin: top right;
  }
}

/* --- COOKIE & PWA OVERLAYS --- */

/* Cookie Consent Overlay */
#cookie-consent-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999999;
  display: none;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}

#cookie-consent-overlay.active {
  display: flex;
}

/* PWA Install Banner Overlay (Bottom Center) */
#pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 15, 0, 0.95);
  border-top: 2px solid #00ff00;
  box-shadow: 0 -5px 25px rgba(0, 255, 0, 0.2);
  z-index: 24000;
  display: none; /* Auto-shown in mobile_controls.js if browser reports installable */
  padding: 12px 20px;
  pointer-events: auto;
  animation: slide-up-banner 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-install-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.pwa-install-text {
  font-family: "Share Tech Mono", monospace;
  color: #00ff00;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 1.5px;
  text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
}

#btn-pwa-install {
  background: #00ff00;
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 6px 16px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  margin: 0;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.4);
  transition: all 0.15s ease;
}

#btn-pwa-install:hover {
  background: #fff;
  box-shadow: 0 0 15px #fff;
}

#btn-pwa-close {
  background: transparent;
  color: #555;
  border: 1px solid #444;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  margin: 0;
  padding: 0;
  transition: all 0.1s ease;
}

#btn-pwa-close:hover {
  color: #ff0000;
  border-color: #ff0000;
}

@keyframes slide-up-banner {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@media (max-width: 600px) {
  .pwa-install-content {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
  .pwa-install-text {
    font-size: 12px;
  }
  #btn-pwa-install {
    width: 100%;
  }
  #btn-pwa-close {
    position: absolute;
    top: 8px;
    right: 8px;
  }
}

/* Portrait mode stack layout for phone screens */
@media (max-width: 768px) and (orientation: portrait) {
  #start-screen {
    flex-direction: column !important;
    overflow-y: auto !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 15px !important;
    gap: 15px !important;
  }
  .start-col-left, .start-col-center, .start-col-right {
    width: 100% !important;
    max-width: 450px !important;
    border: none !important;
    padding: 10px !important;
    background: rgba(0, 15, 0, 0.25) !important;
    border-radius: 8px !important;
  }
  .start-col-left {
    order: 2 !important;
  }
  .start-col-center {
    order: 1 !important;
    background: transparent !important;
  }
  .start-col-right {
    order: 3 !important;
  }
}

/* Compact start screen styling for landscape/short screens to prevent start button cut-off */
@media (max-height: 520px) and (orientation: landscape) {
  #start-screen {
    padding: 10px !important;
    justify-content: space-evenly !important;
    flex-direction: row !important;
    overflow: hidden !important;
    gap: 10px !important;
  }
  
  .start-col-left, .start-col-right {
    max-width: 32% !important;
    padding: 8px !important;
    justify-content: center !important;
  }
  .start-col-left {
    border-right: 1.5px solid rgba(0, 255, 0, 0.15) !important;
  }
  .start-col-right {
    border-left: 1.5px solid rgba(0, 255, 0, 0.15) !important;
  }
  
  .start-col-center {
    flex: 1 !important;
    padding: 5px !important;
    position: relative !important;
    height: 100% !important;
    justify-content: center !important;
  }

  .start-title {
    font-size: 1.3rem !important;
    margin: 0 !important;
    position: absolute !important;
    top: 5px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    white-space: nowrap !important;
  }

  .start-version {
    font-size: 0.7rem !important;
    margin: 0 !important;
    position: absolute !important;
    top: 28px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }

  /* Center the start button absolutely in the center of the viewport */
  #btn-start {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    padding: 6px 15px !important;
    font-size: 0.9rem !important;
    width: 120px !important;
    height: 34px !important;
    margin: 0 !important;
    z-index: 100 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    letter-spacing: 0.5px !important;
    line-height: 1 !important;
  }
  
  #btn-start-pwa-install {
    position: absolute !important;
    bottom: 32px !important;
    left: 50% !important;
    transform: translate(-50%, 0) !important;
    padding: 4px 10px !important;
    font-size: 0.7rem !important;
    z-index: 101 !important;
    width: 100px !important;
    height: 22px !important;
    margin: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }

  #start-pwa-info {
    position: absolute !important;
    bottom: 58px !important;
    left: 50% !important;
    transform: translate(-50%, 0) !important;
    width: 250px !important;
    font-size: 0.62rem !important;
    color: #666 !important;
    margin: 0 !important;
    text-align: center !important;
  }

  /* Target Reticle Circle: Center the loader container directly around the start button */
  #loader-container {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    width: 145px !important;
    height: 145px !important;
    pointer-events: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
  }

  #loader-clock {
    width: 145px !important;
    height: 145px !important;
    position: relative !important;
  }

  #loader-text {
    position: absolute !important;
    bottom: -15px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    font-size: 10px !important;
    text-shadow: 0 0 5px #0f0 !important;
  }

  #loader-status {
    position: absolute !important;
    top: -15px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    font-size: 7px !important;
    letter-spacing: 1px !important;
    white-space: nowrap !important;
  }

  /* Fullscreen button at the bottom center */
  #btn-fullscreen-home {
    position: absolute !important;
    bottom: 5px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    font-size: 0.65rem !important;
    padding: 4px 10px !important;
    margin: 0 !important;
    white-space: nowrap !important;
  }

  /* Side panels layout adjustments for short screen height */
  .start-panel-header {
    font-size: 0.72rem !important;
    margin-bottom: 5px !important;
    padding-bottom: 2px !important;
    letter-spacing: 1px !important;
  }

  .start-panel-body {
    font-size: 0.68rem !important;
    line-height: 1.2 !important;
  }

  .controls-grid {
    gap: 4px !important;
    margin-top: 4px !important;
  }

  .control-box {
    padding: 5px !important;
    border-radius: 4px !important;
  }

  .control-box h4 {
    font-size: 0.65rem !important;
    margin-bottom: 2px !important;
    padding-bottom: 1px !important;
  }

  .control-box ul {
    padding-left: 8px !important;
  }

  .control-box li {
    margin-bottom: 2px !important;
  }

  .weapon-legend {
    gap: 3px !important;
  }

  .weapon-item {
    padding: 3px 6px !important;
    gap: 6px !important;
    font-size: 0.62rem !important;
    border-radius: 3px !important;
  }

  .weapon-item span:first-child {
    font-size: 0.8rem !important;
  }

  .quote-text {
    display: none !important; /* Hide quote to avoid cluttering vertical height on landscape */
  }
}

/* v16.04: Floating Fullscreen Toggle Button */
#btn-fullscreen-toggle {
  position: fixed;
  top: 45px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 32px;
  background: rgba(10, 10, 10, 0.75);
  backdrop-filter: blur(5px);
  border: 1.5px solid rgba(0, 255, 0, 0.4);
  border-radius: 50%;
  color: #0f0;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 30000;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.2);
  transition: all 0.2s ease;
  padding: 0;
}
#btn-fullscreen-toggle:hover, #btn-fullscreen-toggle:active {
  background: rgba(0, 255, 0, 0.2);
  border-color: #0f0;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
  transform: translateX(-50%) scale(1.1);
}

/* HUD Fullscreen Toggle Button */
#btn-fullscreen-hud {
  width: 120px;
  height: 24px;
  background: rgba(10, 10, 10, 0.85) !important;
  border: 1.5px solid #0f0 !important;
  border-radius: 4px !important;
  color: #0f0 !important;
  font-family: "Share Tech Mono", monospace !important;
  font-size: 9px !important;
  font-weight: bold !important;
  cursor: pointer !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  pointer-events: auto !important;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.2) !important;
  transition: all 0.2s ease !important;
  margin: 5px 0 0 0 !important;
  padding: 0 !important;
  letter-spacing: 1px !important;
  text-transform: uppercase !important;
}
#btn-fullscreen-hud:hover, #btn-fullscreen-hud:active {
  background: rgba(0, 255, 0, 0.2) !important;
  color: #fff !important;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.5) !important;
}


