/* Modal Screens - Enhanced Design System */
/* SPACEJAY-148 Phase 3: Modal Redesign - Ornate stone borders & rich textures */
/* Applies to: Pause, Game Over, Controls, Cheat Code, Feedback screens */

/* ═══════════════════════════════════════════════════════════════
   MODAL OVERLAY - Enhanced starfield with nebulae
   ═══════════════════════════════════════════════════════════════ */

.screen.overlay {
  background: 
    radial-gradient(ellipse at 20% 30%, rgba(139, 0, 0, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(75, 0, 130, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(0, 100, 150, 0.15) 0%, transparent 60%),
    linear-gradient(135deg, #05070A 0%, #0a0a0a 50%, #05070A 100%);
  background-size: cover;
  background-position: center;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
}

/* DENSE starfield - matching main menu */
.screen.overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(1px 1px at 10% 20%, white, transparent),
    radial-gradient(1px 1px at 15% 35%, white, transparent),
    radial-gradient(1px 1px at 20% 50%, white, transparent),
    radial-gradient(1px 1px at 25% 65%, white, transparent),
    radial-gradient(1px 1px at 30% 80%, white, transparent),
    radial-gradient(1px 1px at 35% 15%, white, transparent),
    radial-gradient(1px 1px at 40% 30%, white, transparent),
    radial-gradient(1px 1px at 45% 45%, white, transparent),
    radial-gradient(1px 1px at 50% 60%, white, transparent),
    radial-gradient(1px 1px at 55% 75%, white, transparent),
    radial-gradient(1px 1px at 60% 10%, white, transparent),
    radial-gradient(1px 1px at 65% 25%, white, transparent),
    radial-gradient(1px 1px at 70% 40%, white, transparent),
    radial-gradient(1px 1px at 75% 55%, white, transparent),
    radial-gradient(1px 1px at 80% 70%, white, transparent),
    radial-gradient(1px 1px at 85% 85%, white, transparent),
    radial-gradient(1px 1px at 90% 5%, white, transparent),
    radial-gradient(1px 1px at 95% 95%, white, transparent),
    radial-gradient(2px 2px at 12% 42%, rgba(255,255,255,0.8), transparent),
    radial-gradient(2px 2px at 38% 68%, rgba(255,255,255,0.8), transparent),
    radial-gradient(2px 2px at 62% 22%, rgba(255,255,255,0.8), transparent),
    radial-gradient(2px 2px at 88% 78%, rgba(255,255,255,0.8), transparent);
  background-size: 
    200% 200%, 200% 200%, 200% 200%, 200% 200%, 200% 200%,
    200% 200%, 200% 200%, 200% 200%, 200% 200%, 200% 200%,
    200% 200%, 200% 200%, 200% 200%, 200% 200%, 200% 200%,
    200% 200%, 200% 200%, 200% 200%, 250% 250%, 250% 250%,
    250% 250%, 250% 250%;
  animation: stars-drift 180s linear infinite;
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

@keyframes stars-drift {
  from { background-position: 0% 0%; }
  to { background-position: 100% 100%; }
}

/* Ensure modal content is above starfield */
.screen.overlay > * {
  position: relative;
  z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL CONTAINER - Ornate Panel Design
   ═══════════════════════════════════════════════════════════════ */

.modal {
  position: relative;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 90px 80px 70px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: min(500px, 85vw);
  max-width: min(700px, 90vw);
  box-sizing: border-box;
  box-shadow: none;
}

/* Panel frame background */
.modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../../assets/menus/panel-frame2-clean.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: auto;
  z-index: -1;
}

/* Ensure content is above the frame */
.modal > * {
  position: relative;
  z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL TITLE
   ═══════════════════════════════════════════════════════════════ */

.modal h2 {
  font-size: 1.8rem;
  letter-spacing: 4px;
  color: #C0C5CC;
  text-shadow: 
    0 0 30px rgba(0, 212, 255, 0.6),
    0 0 60px rgba(0, 212, 255, 0.3),
    0 4px 0 #1A1C20,
    0 8px 0 #05070A,
    2px 2px 4px rgba(0, 0, 0, 0.9);
  text-align: center;
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL CONTENT
   ═══════════════════════════════════════════════════════════════ */

.modal p {
  color: #8A8F96;
  text-align: center;
  line-height: 1.6;
  background: transparent;
}

/* Stats display in game over modal */
#finish-stats {
  color: #8A8F96;
  font-size: 0.95rem;
  line-height: 2;
  text-align: center;
  letter-spacing: 1px;
  background: transparent;
}

#finish-stats .highlight {
  color: #00D4FF;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.6);
}

/* Rank display */
#finish-rank {
  font-size: 0.85rem;
  color: #8A8F96;
  letter-spacing: 2px;
  text-align: center;
  min-height: 1.2em;
  background: transparent;
}

#finish-rank .highlight { 
  color: #00D4FF; 
  font-weight: bold;
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.6);
}

/* ═══════════════════════════════════════════════════════════════
   MODAL BUTTONS - Unified Button System
   ═══════════════════════════════════════════════════════════════ */

.modal .btn-primary,
.modal .btn-secondary,
.modal .btn-quit {
  position: relative;
  padding: 16px 50px;
  font-size: 0.9rem;
  font-weight: bold;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  min-width: 300px;
  min-height: 70px;
  image-rendering: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #8A8F96;
  text-shadow: 
    0 0 8px rgba(138, 143, 150, 0.4),
    2px 2px 4px rgba(0, 0, 0, 0.8);
}

/* Default state - Neutral button background */
.modal .btn-primary::before,
.modal .btn-secondary::before,
.modal .btn-quit::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../../assets/menus/button-neutral-clean.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: -1;
  width: 100%;
  height: 100%;
  transition: opacity 0.3s ease;
}

/* Cyan button overlay (hidden by default) */
.modal .btn-primary::after,
.modal .btn-secondary::after,
.modal .btn-quit::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('../../assets/menus/button-cyan-clean.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: -1;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Hover state - Show cyan button and change text color */
.modal .btn-primary:hover,
.modal .btn-secondary:hover,
.modal .btn-quit:hover {
  color: #00D4FF;
  text-shadow: 
    0 0 15px rgba(0, 212, 255, 1),
    0 0 30px rgba(0, 212, 255, 0.6),
    2px 2px 4px rgba(0, 0, 0, 0.8);
  transform: translateY(-2px);
}

.modal .btn-primary:hover::after,
.modal .btn-secondary:hover::after,
.modal .btn-quit:hover::after {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL LOGO
   ═══════════════════════════════════════════════════════════════ */

.modal-logo {
  width: clamp(100px, 14vw, 180px);
  opacity: 0.55;
  filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.2));
  margin-top: 10px;
}

/* ═══════════════════════════════════════════════════════════════
   NAME ENTRY (Game Over)
   ═══════════════════════════════════════════════════════════════ */

#name-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
}

#name-entry-label {
  font-size: 0.85rem;
  color: #8A8F96;
  letter-spacing: 1px;
  text-align: center;
}

#player-name {
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #3A3E45;
  border-radius: 4px;
  color: #fff;
  font-size: 1rem;
  letter-spacing: 3px;
  padding: 8px 16px;
  text-align: center;
  width: 220px;
  outline: none;
  text-transform: uppercase;
  transition: border-color 0.2s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

#player-name:focus { 
  border-color: #00D4FF;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.8),
    0 0 15px rgba(0, 212, 255, 0.3);
}

#score-submitted {
  font-size: 0.85rem;
  color: #44cc88;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(68, 204, 136, 0.6);
}

/* ═══════════════════════════════════════════════════════════════
   FEEDBACK SCREEN
   ═══════════════════════════════════════════════════════════════ */

#feedback-text {
  width: 100%;
  max-width: 500px;
  min-height: 120px;
  padding: 12px;
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #3A3E45;
  border-radius: 4px;
  color: #fff;
  resize: vertical;
  font-family: 'Segoe UI', Arial, sans-serif;
  outline: none;
  transition: border-color 0.2s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

#feedback-text:focus {
  border-color: #00D4FF;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.8),
    0 0 15px rgba(0, 212, 255, 0.3);
}

#feedback-char-count {
  color: #5C626B;
  font-size: 0.8rem;
  margin-top: -10px;
  align-self: flex-end;
  margin-right: 10px;
}

#feedback-status {
  color: #44cc88;
  font-size: 0.9rem;
  min-height: 20px;
  margin-bottom: 5px;
  text-align: center;
  text-shadow: 0 0 10px rgba(68, 204, 136, 0.6);
}

#feedback-error {
  color: #ff4444;
  font-size: 0.9rem;
  min-height: 20px;
  margin-bottom: 5px;
  text-align: center;
  text-shadow: 0 0 10px rgba(255, 68, 68, 0.6);
}

/* ═══════════════════════════════════════════════════════════════
   CHEAT CODE SCREEN
   ═══════════════════════════════════════════════════════════════ */

#cheat-input {
  width: 100%;
  max-width: 400px;
  padding: 12px;
  font-size: 1rem;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #3A3E45;
  border-radius: 4px;
  color: #fff;
  text-align: center;
  margin-bottom: 15px;
  outline: none;
  transition: border-color 0.2s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

#cheat-input:focus {
  border-color: #00D4FF;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.8),
    0 0 15px rgba(0, 212, 255, 0.3);
}

#cheat-error {
  color: #ff4444;
  font-size: 0.9rem;
  min-height: 20px;
  margin-bottom: 10px;
  text-shadow: 0 0 10px rgba(255, 68, 68, 0.6);
}

/* ═══════════════════════════════════════════════════════════════
   CONTROLS SCREEN
   ═══════════════════════════════════════════════════════════════ */

#bindings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
  background: transparent;
}

.binding-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: transparent;
}

.binding-label {
  color: #8A8F96;
  font-size: 0.95rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  flex: 1;
}

.binding-key {
  min-width: 80px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #3A3E45;
  border-radius: 4px;
  color: #00D4FF;
  font-family: inherit;
  font-size: 0.95rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  text-align: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

.binding-key:hover {
  border-color: #00D4FF;
  color: #fff;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.8),
    0 0 15px rgba(0, 212, 255, 0.3);
}

.binding-key.listening {
  border-color: #00ff88;
  color: #00ff88;
  animation: pulse-border 0.8s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 #00ff8844; }
  50%       { box-shadow: 0 0 0 6px #00ff8800; }
}

.binding-hint {
  color: #00ff88;
  font-size: 0.85rem;
  letter-spacing: 2px;
  min-height: 1.2em;
  text-align: center;
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.6);
}

/* Preset selector buttons */
#preset-btns {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.preset-btn {
  flex: 1;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #3A3E45;
  border-radius: 4px;
  color: #8A8F96;
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 1px;
  cursor: pointer;
  text-transform: uppercase;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

.preset-btn:hover {
  border-color: #8A8F96;
  color: #fff;
}

.preset-btn.active {
  border-color: #00D4FF;
  color: #00D4FF;
  background: rgba(0, 212, 255, 0.1);
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.8),
    0 0 15px rgba(0, 212, 255, 0.2);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .modal {
    min-width: 85vw;
    padding: 70px 40px 60px 40px;
  }
  
  .modal h2 {
    font-size: 1.4rem;
  }
  
  .modal .btn-primary,
  .modal .btn-secondary,
  .modal .btn-quit {
    min-width: 250px;
  }
}

@media (max-width: 480px) {
  .modal {
    min-width: 90vw;
    padding: 60px 30px 50px 30px;
    gap: 15px;
  }
  
  .modal h2 {
    font-size: 1.2rem;
    letter-spacing: 2px;
  }
  
  .modal .btn-primary,
  .modal .btn-secondary,
  .modal .btn-quit {
    min-width: 200px;
    min-height: 60px;
    font-size: 0.8rem;
  }
  
  #bindings-list {
    max-width: 100%;
  }
  
  .binding-row {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
  
  .binding-key {
    width: 100%;
  }
}

@media (max-height: 700px) {
  .modal {
    padding: 60px 60px 50px 60px;
    gap: 15px;
  }
  
  .modal h2 {
    font-size: 1.4rem;
    margin-bottom: 5px;
  }
  
  .modal .btn-primary,
  .modal .btn-secondary,
  .modal .btn-quit {
    min-height: 60px;
    padding: 12px 40px;
  }
}
