* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #0d0d1a;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #e0e0e0;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  position: fixed;
  top: 0;
  left: 0;
}

.hidden {
  display: none !important;
}

/* Loader */
#loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 1000;
  transition: opacity 0.6s ease;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

#loader.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Intro video */
#intro-video {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 90%;
  object-fit: contain;
}

/* Надпись под видео — видна всегда */
.loader-text {
  margin-top: 20px;
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #666;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* App */
#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

#game-canvas {
  display: block;
  touch-action: none;
}

/* Tooltip */
.tooltip {
  position: fixed;
  padding: 8px 16px;
  background: rgba(20, 20, 40, 0.92);
  border: 1px solid rgba(108, 99, 255, 0.5);
  border-radius: 8px;
  font-size: 14px;
  color: #e0e0e0;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -100%);
  transition: opacity 0.2s ease;
  max-width: 90vw;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.overlay.visible {
  opacity: 1;
}

/* Modal */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  max-height: 80dvh;
  background: #1a1a2e;
  border: 1px solid rgba(108, 99, 255, 0.3);
  border-radius: 16px;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.modal.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 500;
  color: #fff;
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #aaa;
  font-size: 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  line-height: 1;
  flex-shrink: 0;
}

.modal-close:hover {
  background: rgba(255, 80, 80, 0.3);
  color: #ff6666;
}

.modal-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  font-size: 15px;
  line-height: 1.6;
  color: #c0c0d0;
  -webkit-overflow-scrolling: touch;
}

.modal-content h3 {
  color: #fff;
  margin: 16px 0 8px;
  font-size: 16px;
}

.modal-content h3:first-child {
  margin-top: 0;
}

.modal-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.modal-content li {
  padding: 10px 14px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border-left: 3px solid #6c63ff;
}

.modal-content p {
  margin-bottom: 12px;
}

.modal-content p:last-child {
  margin-bottom: 0;
}

.modal-content .tag {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(108, 99, 255, 0.2);
  border-radius: 4px;
  font-size: 12px;
  color: #a78bfa;
  margin-right: 6px;
}

/* Mobile hint */
.mobile-hint {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 500;
  animation: fadeIn 0.4s ease;
}

.mobile-hint-content {
  text-align: center;
  padding: 40px;
  max-width: 90%;
}

.mobile-hint-icon {
  font-size: 64px;
  margin-bottom: 24px;
  animation: pinch 2s ease-in-out infinite;
}

.mobile-hint-text {
  font-size: 18px;
  color: #fff;
  margin-bottom: 16px;
  line-height: 1.4;
}

.mobile-hint-orientation {
  font-size: 14px;
  color: #a78bfa;
  margin-bottom: 24px;
  line-height: 1.4;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pinch {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Mobile */
@media (max-width: 768px) {
  .modal {
    width: 95%;
    max-height: 85vh;
    max-height: 85dvh;
    border-radius: 12px;
  }

  .modal-header {
    padding: 16px 18px;
  }

  .modal-header h2 {
    font-size: 18px;
  }

  .modal-content {
    padding: 18px;
    font-size: 14px;
  }

  .mobile-hint-icon {
    font-size: 48px;
  }

  .mobile-hint-text {
    font-size: 16px;
  }

  .mobile-hint-orientation {
    font-size: 13px;
  }
}

@media (orientation: portrait) and (max-width: 768px) {
  .tooltip {
    font-size: 12px;
    max-width: 200px;
    white-space: normal;
    text-align: center;
  }
}