/* ============================================
   GAME MODAL
   ============================================ */

/* Overlay */
.game-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.game-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Modal Container */
.game-modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
}

.game-modal-overlay.active .game-modal {
  transform: scale(1) translateY(0);
}

/* Modal Header */
.game-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  background: linear-gradient(135deg, var(--orange) 0%, #FF9A4D 100%);
  flex-shrink: 0;
}

.game-modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: white;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.game-modal-close {
  background: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--orange);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.game-modal-close:hover {
  background: var(--coral);
  color: white;
  transform: scale(1.1);
}

/* Game Container - iframe wrapper */
.game-modal-container {
  flex: 1;
  position: relative;
  background: #1a1a2e;
  min-height: 0; /* Important for flex child */
}

/* Responsive iframe container - maintains aspect ratio */
.game-modal-iframe-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.game-modal-iframe-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Loading state */
.game-modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
}

.game-modal-loading-spinner {
  font-size: 3rem;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.game-modal-loading-text {
  font-weight: 700;
  font-size: 1.1rem;
}

/* Fullscreen button */
.game-modal-fullscreen {
  position: absolute;
  bottom: 15px;
  right: 15px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--dark-blue);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.game-modal-fullscreen:hover {
  background: white;
  transform: scale(1.1);
}

/* ============================================
   DESKTOP STYLES
   ============================================ */
@media (min-width: 768px) {
  .game-modal-overlay {
    padding: 30px;
  }
  
  .game-modal {
    max-width: 450px;
    max-height: 90vh;
  }
  
  .game-modal-header {
    padding: 18px 25px;
  }
  
  .game-modal-title {
    font-size: 1.4rem;
  }
  
  /* Fixed aspect ratio for desktop - phone-like */
  .game-modal-container {
    aspect-ratio: 9/16;
    max-height: calc(90vh - 70px);
  }
}

/* ============================================
   MOBILE STYLES - Full screen experience
   ============================================ */
@media (max-width: 767px) {
  .game-modal-overlay {
    padding: 0;
  }
  
  .game-modal {
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
  }
  
  .game-modal-header {
    padding: 12px 15px;
  }
  
  .game-modal-title {
    font-size: 1.1rem;
  }
  
  .game-modal-close {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }
  
  .game-modal-container {
    flex: 1;
  }
  
  /* Hide fullscreen button on mobile - already full screen */
  .game-modal-fullscreen {
    display: none;
  }
}

/* ============================================
   LANDSCAPE MOBILE - Optimize for gaming
   ============================================ */
@media (max-width: 900px) and (orientation: landscape) {
  .game-modal {
    flex-direction: row;
    max-height: 100vh;
  }
  
  .game-modal-header {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 15px 10px;
    flex-direction: column-reverse;
    gap: 15px;
  }
  
  .game-modal-title {
    font-size: 1rem;
  }
  
  .game-modal-container {
    flex: 1;
    height: 100%;
  }
}

/* ============================================
   FULLSCREEN MODE
   ============================================ */
.game-modal.fullscreen {
  max-width: 100%;
  max-height: 100%;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

.game-modal.fullscreen .game-modal-header {
  display: none;
}

.game-modal.fullscreen .game-modal-container {
  height: 100%;
  max-height: 100%;
  aspect-ratio: unset;
}

.game-modal.fullscreen .game-modal-fullscreen {
  display: flex;
}

/* Exit fullscreen button in fullscreen mode */
.game-modal.fullscreen .game-modal-exit-fullscreen {
  position: fixed;
  top: 15px;
  right: 15px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 25px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-modal:not(.fullscreen) .game-modal-exit-fullscreen {
  display: none;
}
