/* Reset CSS */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Background container that will hold the gradient and pattern */
.background-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
}

/* Tire track pattern background */
.background-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    repeating-linear-gradient(90deg, transparent, transparent 50px, rgba(255,255,255,0.02) 50px, rgba(255,255,255,0.02) 52px);
  pointer-events: none;
}

/* Loading overlay */
#loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 100;
}

.hidden {
  display: none !important;
}

body {
  color: white;
  font-family: Arial, sans-serif;
}

.navbar {
  background-color: #000000;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 2rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
}

.logo {
  color: #FF0000;
  font-size: 1.5rem;
  font-weight: bold;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  color: white;
  text-decoration: none;
}

.return-button {
  background-color: #FF0000;
  color: white;
  padding: 0.5rem 1.5rem;
  border-radius: 9999px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s;
}

.return-button:hover {
  background-color: #cc0000;
}

.model-buttons {
  position: fixed;
  top: 50%;
  left: 80px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.15), rgba(255, 0, 0, 0.05));
  padding: 15px;
  border-radius: 18px;
  backdrop-filter: blur(15px);
  border: 2px solid rgba(255, 0, 0, 0.3);
  box-shadow: 0 8px 32px rgba(255, 0, 0, 0.3);
}

.model-button {
  width: 150px;
  height: 140px;
  padding: 8px;
  font-size: 12px;
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.2), rgba(255, 0, 0, 0.05));
  color: white;
  border: 2px solid rgba(255, 0, 0, 0.4);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(255, 0, 0, 0.2);
}

.model-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 0, 0, 0.15), transparent);
  transition: left 0.5s ease;
}

.model-button:hover::before {
  left: 100%;
}

.model-button:hover {
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.3), rgba(255, 0, 0, 0.1));
  border-color: rgba(255, 0, 0, 0.6);
  transform: translateX(5px);
  box-shadow: 0 8px 24px rgba(255, 0, 0, 0.4);
}

.model-button.active {
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.3), rgba(255, 0, 0, 0.15));
  border-color: #FF0000;
  box-shadow: 0 0 25px rgba(255, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.4);
}

.button-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  position: relative;
}

.button-number {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.8), rgba(200, 0, 0, 0.8));
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.button-image {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 5px;
  border: 2px solid rgba(255, 0, 0, 0.3);
  box-shadow: 0 2px 8px rgba(255, 0, 0, 0.3);
}

.button-name {
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  line-height: 1.2;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  margin-top: 2px;
}

.button-image:not([src]), 
.button-image[src=""] {
  background-color: #333;
  border: 2px dashed #666;
  display: flex;
  align-items: center;
  justify-content: center;
}

.button-image:not([src])::before, 
.button-image[src=""]::before {
  content: "IMG";
  color: #999;
  font-size: 10px;
}

#monteroCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.controls-info {
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  z-index: 10;
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.model-input {
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  z-index: 10;
}

.model-input input {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  border-color: #666;
}

.model-input button {
  background-color: #FF0000;
}

/* Info Panel Styles - FIXED VERSION */
.info-panel {
  position: fixed;
  top: 50%;
  right: 40px;
  transform: translateY(-50%);
  width: 300px;
  min-height: 320px;
  background: linear-gradient(135deg, rgba(255, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.85) 100%);
  border: 2px solid #FF0000;
  border-radius: 12px;
  padding: 20px;
  z-index: 15;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(255, 0, 0, 0.3);
  overflow: hidden;
}

.info-panel-title {
  font-size: 20px;
  font-weight: bold;
  color: #FF0000;
  margin-bottom: 18px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.info-panel-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 40px;
}

.info-label {
  font-size: 11px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.2;
  font-weight: 600;
}

.info-value {
  font-size: 14px;
  color: #fff;
  font-weight: 500;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 15px #FF0000, 0 0 30px rgba(255, 0, 0, 0.5);
  }
  50% {
    box-shadow: 0 0 25px #FF0000, 0 0 50px rgba(255, 0, 0, 0.8);
  }
}

/* ============================================
   MOBILE RESPONSIVE STYLES - FIXED VERSION
   ============================================ */

/* Mobile devices (max-width: 768px) */
@media (max-width: 768px) {
  /* Navbar adjustments */
  .navbar {
    padding: 0.5rem 1rem;
  }

  .logo {
    font-size: 1.2rem;
  }

  .return-button {
    padding: 0.4rem 1rem;
    font-size: 14px;
  }

  /* FIX: Remove transform and reposition for mobile */
  .model-buttons {
    position: fixed !important;
    top: auto !important;
    bottom: 80px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    flex-direction: row !important;
    width: 95% !important;
    max-width: 500px !important;
    padding: 10px !important;
    overflow-x: auto !important;
    gap: 8px !important;
  }

  .model-button {
    width: 100px !important;
    height: 90px !important;
    flex-shrink: 0;
    padding: 6px;
    transform: none !important;
  }

  .model-button:hover {
    transform: scale(0.98) !important;
  }

  .button-number {
    width: 22px;
    height: 22px;
    font-size: 12px;
    top: 5px;
    left: 5px;
  }

  .button-image {
    width: 70px !important;
    height: 50px !important;
  }

  .button-name {
    font-size: 10px;
    margin-top: 0;
  }

  /* FIX: Info panel - IMPROVED SPACING */
  .info-panel {
    position: fixed !important;
    top: 70px !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%) !important;
    width: 92% !important;
    max-width: 420px !important;
    min-height: auto !important;
    padding: 14px 16px !important;
    border-radius: 10px;
  }

  .info-panel-title {
    font-size: 15px;
    margin-bottom: 12px;
    letter-spacing: 1px;
    line-height: 1.3;
  }

  .info-panel-content {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px 10px;
  }

  .info-item {
    gap: 4px;
    min-height: 35px;
  }

  .info-label {
    font-size: 10px;
    line-height: 1.2;
  }

  .info-value {
    font-size: 12px;
    line-height: 1.3;
  }

  /* Controls info */
  .controls-info {
    bottom: 20px;
    padding: 8px 16px;
    font-size: 12px;
  }

  .controls-info h3 {
    font-size: 13px;
    margin-bottom: 4px;
  }

  .controls-info ul li {
    font-size: 11px;
  }
}

/* Small mobile devices (max-width: 480px) */
@media (max-width: 480px) {
  .logo {
    font-size: 1rem;
  }

  .return-button {
    padding: 0.3rem 0.8rem;
    font-size: 12px;
  }

  .info-panel {
    top: 65px !important;
    width: 94% !important;
    padding: 12px 14px !important;
  }

  .info-panel-title {
    font-size: 14px;
    margin-bottom: 10px;
    letter-spacing: 0.8px;
  }

  .info-panel-content {
    gap: 10px 8px;
  }

  .info-label {
    font-size: 9px;
  }

  .info-value {
    font-size: 11px;
    line-height: 1.3;
  }

  .info-item {
    min-height: 32px;
  }

  .model-buttons {
    bottom: 70px !important;
    width: 98% !important;
    padding: 8px !important;
    gap: 6px !important;
  }

  .model-button {
    width: 85px !important;
    height: 80px !important;
    padding: 5px;
  }

  .button-number {
    width: 20px;
    height: 20px;
    font-size: 11px;
    top: 4px;
    left: 4px;
  }

  .button-image {
    width: 60px !important;
    height: 40px !important;
  }

  .button-name {
    font-size: 9px;
  }

  .controls-info {
    bottom: 15px;
    padding: 6px 12px;
    max-width: 90%;
  }

  .controls-info h3 {
    font-size: 12px;
  }

  .controls-info ul li {
    font-size: 10px;
  }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .info-panel {
    top: 55px !important;
    width: 48% !important;
    left: 10px !important;
    transform: none !important;
    padding: 10px 12px !important;
    min-height: auto !important;
  }

  .info-panel-title {
    font-size: 13px;
    margin-bottom: 8px;
  }

  .info-panel-content {
    grid-template-columns: 1fr 1fr;
    gap: 8px 6px;
  }

  .info-label {
    font-size: 9px;
  }

  .info-value {
    font-size: 11px;
    line-height: 1.2;
  }

  .info-item {
    min-height: 30px;
  }

  .model-buttons {
    top: 55px !important;
    bottom: auto !important;
    right: 10px !important;
    left: auto !important;
    transform: none !important;
    width: auto !important;
    flex-direction: column !important;
    max-width: 90px !important;
  }

  .model-button {
    width: 80px !important;
    height: 70px !important;
  }

  .button-image {
    width: 55px !important;
    height: 35px !important;
  }

  .controls-info {
    display: none;
  }
}

/* Scrollbar styling for mobile buttons */
.model-buttons::-webkit-scrollbar {
  height: 4px;
}

.model-buttons::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
}

.model-buttons::-webkit-scrollbar-thumb {
  background: rgba(255, 0, 0, 0.5);
  border-radius: 10px;
}

.model-buttons::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 0, 0, 0.7);
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
  .model-button {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .model-button:active {
    transform: scale(0.95) !important;
  }

  .return-button:active {
    transform: scale(0.95);
  }
}