:root {
  --tesla-red: #e82127;
  --electric-blue: #00d9ff;
  --neon-green: #39ff14;
  --cyber-purple: #9d00ff;
  --bg-dark: #0a0e27;
  --bg-darker: #050714;
  --zone-border: rgba(0, 217, 255, 0.3);
  --zone-hover: rgba(0, 217, 255, 0.8);
  --zone-invalid: rgba(232, 33, 39, 0.6);
  --text-primary: #ffffff;
  --text-secondary: #b0b8c8;
  --text-glow: 0 0 10px rgba(0, 217, 255, 0.8);
  --panel-bg: rgba(10, 16, 48, 0.8);
  --card-bg: rgba(15, 22, 58, 0.85);
  --zone-size: 150px;
  --zone-gap: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  font-family: "Orbitron", Arial, sans-serif;
  color: var(--text-primary);
  background: radial-gradient(circle at center, var(--bg-dark), var(--bg-darker));
  min-height: 100%;
}

body {
  position: relative;
  overflow-x: hidden;
}

#background-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.starfield {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(2px 2px at 30% 20%, #ffffff90 90%, transparent),
    radial-gradient(2px 2px at 70% 10%, #ffffff90 90%, transparent),
    radial-gradient(1px 1px at 50% 50%, #ffffff88 90%, transparent),
    radial-gradient(1px 1px at 10% 80%, #ffffff88 90%, transparent),
    radial-gradient(2px 2px at 85% 65%, #ffffff88 90%, transparent);
  background-size: 320px 320px;
  animation: star-drift 30s linear infinite;
}

.tech-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(0, 217, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 217, 255, 0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  transform: perspective(500px) rotateX(65deg) translateY(150px) scale(1.2);
  transform-origin: center top;
  opacity: 0.5;
}

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.game-title {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: var(--text-glow);
  cursor: pointer;
}

.play-counter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--panel-bg);
  border: 1px solid var(--zone-border);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  text-shadow: var(--text-glow);
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
}

.play-counter:hover {
  border-color: var(--primary-neon);
  box-shadow: 0 0 12px rgba(0, 217, 255, 0.3);
}

.counter-icon {
  font-size: 1.1rem;
  animation: pulse-glow 2s ease-in-out infinite;
}

#play-count {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  letter-spacing: 1px;
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
}

.drone-panel {
  background: var(--panel-bg);
  border: 1px solid var(--zone-border);
  border-radius: 14px;
  padding: 0.75rem;
  min-height: 700px;
  backdrop-filter: blur(4px);
}

.panel-header h2 {
  margin: 0;
  text-transform: uppercase;
}

.panel-subtitle {
  margin: 0.3rem 0 0.8rem;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.drone-selector {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  padding-right: 0.2rem;
}

.drone-card {
  min-height: 160px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.drone-card:hover,
.drone-card:focus-visible {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(0, 217, 255, 0.45);
}

.drone-card.selected {
  border-color: rgba(57, 255, 20, 0.9);
  box-shadow: 0 0 22px rgba(57, 255, 20, 0.45);
}

.drone-card.hero {
  min-height: 190px;
  border-width: 2px;
}

.drone-card.dragging {
  box-shadow: 0 0 30px rgba(57, 255, 20, 0.55);
}

.drone-placeholder-wrap {
  width: 120px;
  height: 120px;
  display: grid;
  place-items: center;
}

.drone-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  position: relative;
  box-shadow: 0 0 20px var(--electric-blue);
  display: grid;
  place-items: center;
}

.drone-placeholder::before,
.drone-placeholder::after {
  content: "";
  position: absolute;
  width: 82%;
  height: 4px;
  background: rgba(255, 255, 255, 0.8);
  transform-origin: center;
  animation: spin-propeller 0.3s linear infinite;
}

.drone-placeholder::after {
  transform: rotate(90deg);
}

.drone-name-overlay {
  font-size: 0.55rem;
  letter-spacing: 1px;
  text-shadow: 0 0 5px #000;
}

.drone-name {
  font-size: 0.75rem;
  margin: 0;
  text-align: center;
}

.drone-badge {
  font-size: 0.62rem;
  color: #ffffff;
  padding: 0.2rem 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
}

.stage-wrapper {
  position: relative;
  background: linear-gradient(145deg, rgba(8, 12, 35, 0.85), rgba(5, 8, 20, 0.92));
  border: 1px solid var(--zone-border);
  border-radius: 14px;
  padding: 1rem;
  min-height: 750px;
}

.stage-border-pulse {
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  pointer-events: none;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(5, var(--zone-size));
  grid-template-rows: repeat(2, var(--zone-size));
  gap: var(--zone-gap);
  justify-content: center;
  margin-bottom: 1rem;
}

.drop-zone {
  width: var(--zone-size);
  height: var(--zone-size);
  border-radius: 16px;
  border: 2px dashed var(--zone-border);
  background: rgba(0, 8, 32, 0.5);
  color: var(--text-secondary);
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.drop-zone.zone-valid-hover {
  border-color: var(--zone-hover);
  transform: scale(1.05);
  animation: pulse-glow 0.8s ease infinite;
}

.drop-zone.zone-invalid {
  border-color: var(--tesla-red);
  background: var(--zone-invalid);
  animation: shake-invalid 0.3s ease;
}

.drop-zone.occupied {
  border-style: solid;
  border-color: rgba(57, 255, 20, 0.65);
}

.zone-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.75rem;
}

.zone-drone-slot {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.placed-drone {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
}

.bottom-controls,
.volume-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.volume-row input {
  min-width: 220px;
}

.tempo-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.tempo-label {
  color: var(--text-secondary);
}

#bpm-quick-value {
  min-width: 88px;
  text-align: center;
  text-shadow: var(--text-glow);
}

.mix-message {
  min-height: 28px;
  margin-bottom: 0.8rem;
  color: var(--neon-green);
  text-shadow: 0 0 10px rgba(57, 255, 20, 0.7);
  font-weight: 700;
  letter-spacing: 1px;
}

.control-btn {
  min-width: 80px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.control-btn:hover,
.control-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 0 14px rgba(0, 217, 255, 0.5);
}

.control-btn.danger {
  background: rgba(232, 33, 39, 0.2);
  border-color: rgba(232, 33, 39, 0.8);
}

.record-btn.recording {
  background: rgba(232, 33, 39, 0.6);
  box-shadow: 0 0 18px rgba(232, 33, 39, 0.85);
}

.hidden-control {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.hidden-control.show {
  display: flex;
}

.visualizer-section {
  border: 1px solid rgba(0, 217, 255, 0.25);
  border-radius: 10px;
  padding: 0.7rem;
}

.visualizer-section h3 {
  margin: 0 0 0.5rem;
}

#audio-visualizer {
  width: 100%;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 8px;
}

.effects-rack {
  margin-top: 1rem;
  border: 1px solid rgba(157, 0, 255, 0.6);
  border-radius: 12px;
  padding: 1rem;
  background: rgba(20, 8, 37, 0.85);
}

.effects-rack.hidden {
  display: none;
}

.effects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.effects-grid label {
  display: grid;
  gap: 0.35rem;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: end;
}

.recording-output {
  margin-top: 0.8rem;
}

.recording-output a {
  color: var(--electric-blue);
}

.mobile-only {
  display: none;
}

.mobile-action-strip {
  display: none;
}

.mobile-selected-drone {
  display: none;
}

.mobile-chip {
  min-width: 46px;
  text-align: center;
  padding: 0.3rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--zone-border);
  background: rgba(255, 255, 255, 0.08);
  text-shadow: var(--text-glow);
}

.high-contrast {
  --bg-dark: #000000;
  --bg-darker: #000000;
  --text-primary: #ffffff;
  --zone-border: rgba(255, 255, 255, 0.65);
  --zone-hover: #ffff00;
}

.click-spark {
  position: fixed;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #00d9ff 30%, #e82127 100%);
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 16px #00d9ff;
  z-index: 2000;
  animation: fade-out 0.5s ease forwards;
}

#rgb-split-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1800;
}

.rgb-layer {
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  opacity: 0.25;
}

.red-layer { background: rgba(255, 0, 0, 0.5); transform: translateX(-20px); }
.green-layer { background: rgba(0, 255, 0, 0.3); }
.blue-layer { background: rgba(0, 90, 255, 0.5); transform: translateX(20px); }

#static-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1850;
  opacity: 0.35;
}

#crt-shutdown {
  position: fixed;
  inset: 0;
  z-index: 1900;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.8);
}

#crt-shutdown .crt-screen {
  width: min(80vw, 900px);
  height: min(60vh, 520px);
  border-radius: 10px;
  border: 2px solid #2e3647;
  background: #0a0e27;
  display: grid;
  place-items: center;
  overflow: hidden;
}

#crt-shutdown .crt-content {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(0,217,255,0.2), rgba(0,0,0,0.9));
  transform-origin: center center;
  transition: transform 0.35s ease, opacity 0.2s ease, background 0.3s ease;
}

#crt-shutdown.shutdown .crt-content {
  transform: scaleY(0.05) scaleX(0.02);
  opacity: 0;
}

#crt-shutdown.reboot .crt-content {
  transform: scale(1);
  opacity: 1;
}

.achievement-popup {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2200;
  background: rgba(6, 11, 30, 0.95);
  border: 1px solid rgba(57, 255, 20, 0.7);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  max-width: 340px;
  box-shadow: 0 0 18px rgba(57, 255, 20, 0.4);
}

.achievement-inner h2,
.achievement-inner p {
  margin: 0.25rem 0;
}

.achievement-title {
  color: #39ff14;
}

.achievement-reward {
  color: #00d9ff;
}
