:root {
  --bg-primary: #060709;
  --bg-card: #0e1117;
  --bg-darker: #040507;
  --color-orange: #ff7700;
  --color-orange-glow: rgba(255, 119, 0, 0.45);
  --color-gold: #fbbf24;
  --color-gold-glow: rgba(251, 191, 36, 0.5);
  --color-green: #10b981;
  --color-red: #ef4444;
  --color-blue: #38bdf8;
  --border-tactical: #1f242f;
  --text-muted: #8b9bb4;
  --text-bright: #f8fafc;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-bright);
  font-family: 'Share Tech Mono', monospace;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 50% 10%, rgba(255, 119, 0, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(56, 189, 248, 0.05) 0%, transparent 40%),
    linear-gradient(rgba(20, 24, 33, 0.7) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 24, 33, 0.7) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 24px 24px, 24px 24px;
}

.screen-container {
  width: 100%;
  max-width: 520px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ISLA MORTAL Server Status Bar */
.server-status-bar {
  width: 100%;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.95), rgba(10, 14, 23, 0.95));
  border: 1px solid #ff7700;
  border-left: 4px solid #ff7700;
  box-shadow: 0 0 15px rgba(255, 119, 0, 0.25);
  border-radius: 4px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.server-info-col {
  display: flex;
  flex-direction: column;
}

.server-badge {
  font-family: 'Orbitron', 'Teko', sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: #ffaa00;
  letter-spacing: 1.5px;
  text-shadow: 0 0 8px rgba(255, 170, 0, 0.6);
}

.server-sub {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.server-stats-col {
  display: flex;
  align-items: center;
  gap: 12px;
}

.server-stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}

.pulse-online-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: pulseDot 1.4s infinite alternate;
}

@keyframes pulseDot {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px #10b981; }
}

.stat-status-text {
  color: #10b981;
  font-weight: bold;
  font-size: 10px;
  letter-spacing: 1px;
}

.stat-highlight {
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-weight: bold;
  font-size: 12px;
}

.stat-slash {
  color: var(--text-muted);
  font-size: 10px;
}

.stat-label-mini {
  font-size: 9px;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

.server-connect-btn {
  background: linear-gradient(135deg, rgba(255, 119, 0, 0.2), rgba(255, 119, 0, 0.4));
  border: 1px solid #ff7700;
  color: #fff;
  padding: 4px 8px;
  border-radius: 3px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.server-connect-btn:hover {
  background: #ff7700;
  color: #000;
  box-shadow: 0 0 10px rgba(255, 119, 0, 0.6);
}

/* BCU Telemetry & ECG Wave */
.bcu-monitor {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.bcu-tag {
  font-size: 9px;
  color: var(--color-orange);
  letter-spacing: 1.5px;
  font-weight: bold;
}

.ecg-wave {
  width: 70px;
  height: 14px;
  overflow: visible;
}

.ecg-path {
  fill: none;
  stroke: #10b981;
  stroke-width: 1.5;
  stroke-dasharray: 120;
  stroke-dashoffset: 120;
  animation: ecgPulse 2s linear infinite;
}

@keyframes ecgPulse {
  0% { stroke-dashoffset: 120; }
  100% { stroke-dashoffset: 0; }
}

/* Broadcast Bar */
.broadcast-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  background: rgba(14, 17, 23, 0.9);
  padding: 4px 10px;
  border: 1px solid var(--border-tactical);
  border-radius: 3px;
}

.rec-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-red);
  font-weight: bold;
  letter-spacing: 1px;
}

.rec-dot {
  width: 8px;
  height: 8px;
  background: var(--color-red);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--color-red);
  animation: blinkRec 1s infinite alternate ease-in-out;
}

@keyframes blinkRec {
  0% { opacity: 0.2; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1.15); }
}

.drone-tag {
  color: var(--color-orange);
  font-size: 10px;
  letter-spacing: 1px;
}

.signal-tag {
  color: var(--text-muted);
  font-size: 10px;
}

.text-green { color: var(--color-green); font-weight: bold; }
.text-blue { color: var(--color-blue); }

/* HUD Header */
.hud-header {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-tactical);
  border-left: 4px solid var(--color-orange);
  padding: 10px 14px;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.hud-tag {
  font-size: 10px;
  color: var(--color-orange);
  letter-spacing: 2px;
  font-weight: bold;
}

.hud-title {
  font-family: 'Teko', sans-serif;
  font-size: 30px;
  letter-spacing: 1px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 12px var(--color-orange-glow);
}

.text-gold {
  color: var(--color-gold);
  font-weight: bold;
  text-shadow: 0 0 6px var(--color-gold-glow);
}

.hud-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(75px, 1fr));
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-tactical);
}

/* Banner de Transición de Nivel */
.level-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(6, 7, 9, 0.95);
  border: 2px solid var(--color-green);
  border-left: 6px solid var(--color-green);
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.4);
  padding: 16px 22px;
  text-align: center;
  border-radius: 6px;
  z-index: 12;
  pointer-events: none;
  animation: bannerSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.level-banner.hidden {
  display: none;
}

.level-banner-tag {
  font-size: 11px;
  color: var(--color-green);
  font-weight: bold;
  letter-spacing: 2px;
  display: block;
}

.level-banner-title {
  font-family: 'Teko', sans-serif;
  font-size: 30px;
  color: #fff;
  letter-spacing: 1px;
  margin: 3px 0;
  text-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.level-banner-sub {
  font-size: 11px;
  color: var(--color-gold);
  letter-spacing: 1px;
}

@keyframes bannerSlideIn {
  from { opacity: 0; transform: translate(-50%, -60%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.stat-value {
  font-size: 16px;
  font-weight: bold;
}

.text-accent {
  color: var(--color-gold);
  text-shadow: 0 0 8px var(--color-gold-glow);
}

.lives-container {
  display: flex;
  gap: 4px;
  font-size: 14px;
}

/* Canvas Wrapper */
.game-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

.canvas-border {
  position: relative;
  background: #030406;
  border: 2px solid var(--color-orange);
  box-shadow: 0 0 30px rgba(255, 119, 0, 0.35), inset 0 0 35px rgba(0, 0, 0, 0.95);
  border-radius: 8px;
  overflow: hidden;
}

/* Reflejo curvado de cristal tipo monitor táctico */
.canvas-border::before {
  content: "";
  position: absolute;
  top: 0;
  left: -20%;
  width: 140%;
  height: 55%;
  background: linear-gradient(175deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 40%, transparent 60%);
  pointer-events: none;
  z-index: 6;
  border-radius: 50% 50% 100% 100% / 20% 20% 80% 80%;
}

/* CRT Scanlines con viñeta en esquinas */
.canvas-border.scanlines::after {
  content: " ";
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 50% 50%, transparent 65%, rgba(0, 0, 0, 0.65) 100%),
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.38) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
  background-size: 100% 100%, 100% 3px, 6px 100%;
  pointer-events: none;
  z-index: 5;
}

/* Overlay de Cámara / Retículo */
.cam-overlay {
  position: absolute;
  inset: 8px;
  pointer-events: none;
  z-index: 4;
}

.cam-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: rgba(255, 119, 0, 0.6);
  border-style: solid;
}

.cam-corner.tl { top: 0; left: 0; border-width: 2px 0 0 2px; }
.cam-corner.tr { top: 0; right: 0; border-width: 2px 2px 0 0; }
.cam-corner.bl { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.cam-corner.br { bottom: 0; right: 0; border-width: 0 2px 2px 0; }

canvas {
  display: block;
  image-rendering: pixelated;
  max-width: 100%;
  height: auto;
}

/* Overlay Card */
.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 9, 0.92);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 10;
}

.game-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.overlay-card {
  background: var(--bg-card);
  border: 1px solid var(--color-orange);
  padding: 22px 20px;
  border-radius: 8px;
  text-align: center;
  max-width: 380px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
}

.overlay-drone-preview {
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
}

.drone-preview-img {
  width: 90px;
  height: 90px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px var(--color-orange-glow));
  animation: floatDrone 2.5s infinite ease-in-out;
}

@keyframes floatDrone {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}

.overlay-title {
  font-family: 'Teko', sans-serif;
  font-size: 34px;
  color: var(--color-orange);
  letter-spacing: 1.5px;
}

.overlay-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 10px 0 16px 0;
  line-height: 1.4;
}

/* Reward Box */
.reward-box {
  background: var(--bg-darker);
  border: 1px dashed var(--color-gold);
  padding: 12px;
  margin-bottom: 16px;
  border-radius: 4px;
}

.reward-box.hidden {
  display: none;
}

.reward-tag {
  font-size: 11px;
  color: var(--color-gold);
  font-weight: bold;
  letter-spacing: 1px;
  display: block;
  margin-bottom: 6px;
}

.code-wrapper {
  display: flex;
  gap: 6px;
}

.code-wrapper input {
  flex: 1;
  background: #111;
  border: 1px solid #333;
  color: var(--color-gold);
  padding: 8px;
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  border-radius: 3px;
}

.reward-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

.reward-hint code {
  color: var(--color-orange);
  background: #1a1a1a;
  padding: 2px 4px;
  border-radius: 2px;
}

/* Buttons */
.hud-btn-main {
  width: 100%;
  background: linear-gradient(180deg, #ff8800 0%, #e05e00 100%);
  color: #000;
  border: none;
  font-family: 'Teko', sans-serif;
  font-size: 26px;
  font-weight: bold;
  letter-spacing: 1.5px;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--color-orange-glow);
  transition: transform 0.1s, filter 0.1s;
}

.hud-btn-main:active {
  transform: scale(0.98);
}

.hud-btn-sm {
  background: #222;
  color: #fff;
  border: 1px solid #444;
  padding: 0 12px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
}

.hud-btn-alt {
  background: transparent;
  border: 1px solid var(--border-tactical);
  color: var(--text-muted);
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
}

.footer-actions {
  display: flex;
  gap: 6px;
}

/* Mobile Virtual D-Pad */
.mobile-controls {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.mobile-actions {
  display: flex;
  align-items: center;
}

.action-btn-jump {
  background: linear-gradient(135deg, #ff7700, #d97706);
  color: #fff;
  border: 2px solid #fbbf24;
  font-family: 'Orbitron', 'Teko', sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 4px 18px rgba(255, 119, 0, 0.45);
}

.action-btn-jump:active {
  transform: scale(0.92);
  background: #fbbf24;
  color: #000;
}

.dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
}

.dpad-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-tactical);
  color: var(--color-orange);
  font-size: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  touch-action: none;
}

.dpad-btn:active {
  background: var(--color-orange);
  color: #000;
}

.dpad-center {
  background: var(--bg-darker);
  border-radius: 8px;
  opacity: 0.3;
}

/* Footer */
.hud-footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--text-muted);
  padding: 4px;
}

@media (min-width: 768px) {
  .mobile-controls {
    display: none;
  }
}
