/* Konami Mode Mobile Interface - Design Moderno */
#konami-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(20px) saturate(180%);
  animation: overlay-fade-in 0.4s ease-out;
  /* Safe area: evita sovrapposizioni con notch/dynamic island */
  padding: calc(40px + env(safe-area-inset-top))
           calc(20px + env(safe-area-inset-right))
           calc(40px + env(safe-area-inset-bottom))
           calc(20px + env(safe-area-inset-left));
  box-sizing: border-box;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

@keyframes overlay-fade-in {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(20px) saturate(180%);
  }
}

.konami-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  animation: container-slide-up 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: #000000;
  /* Margini laterali più confortevoli */
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

@keyframes container-slide-up {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.konami-title {
  color: rgba(255, 255, 255, 0.9);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 24px;
  font-weight: 300;
  margin-top: env(safe-area-inset-top);
  margin-bottom: 60px;
  letter-spacing: 3px;
  text-transform: uppercase;
  opacity: 0;
  animation: title-fade-in 0.6s ease-out 0.4s forwards;
}

@keyframes title-fade-in {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.konami-sequence {
  min-height: 56px;
  margin-bottom: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 320px;
  max-width: 85vw;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.konami-sequence .correct {
  display: inline-block;
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, #4CAF50, #2E7D32);
  border-radius: 50%;
  animation: dot-appear 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 2px 4px rgba(76, 175, 80, 0.3),
    0 0 8px rgba(76, 175, 80, 0.2);
}

.konami-sequence .error {
  color: rgba(239, 68, 68, 0.9);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  font-weight: 400;
  animation: error-shake 0.6s ease-in-out;
}

@keyframes dot-appear {
  from {
    transform: scale(0) rotate(180deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes error-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.konami-controls {
  display: grid;
  grid-template-areas: 
    ". up ."
    "left down right"
    ". . ."
    "action1 . action2";
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto auto 40px auto;
  gap: 30px;
  width: 100%;
  max-width: 300px;
  align-items: center;
  justify-items: center;
  opacity: 0;
  animation: controls-fade-in 0.8s ease-out 0.4s forwards;
}

@keyframes controls-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.konami-row {
  display: contents;
}

.konami-btn {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.87);
  font-size: 20px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  backdrop-filter: blur(20px);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.24);
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.konami-btn[data-key="ArrowUp"] { grid-area: up; }
.konami-btn[data-key="ArrowDown"] { grid-area: down; }
.konami-btn[data-key="ArrowLeft"] { grid-area: left; }
.konami-btn[data-key="ArrowRight"] { grid-area: right; }
.konami-btn[data-key="KeyB"] { grid-area: action1; }
.konami-btn[data-key="KeyA"] { grid-area: action2; }

.konami-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.konami-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 1);
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.16),
    0 2px 4px rgba(0, 0, 0, 0.32);
  transform: scale(1.05);
}

.konami-btn:hover::before {
  width: 100%;
  height: 100%;
}

.konami-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 
    0 1px 4px rgba(0, 0, 0, 0.2),
    inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.konami-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right));
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.6);
  font-size: 16px;
  cursor: pointer;
  font-weight: 400;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  opacity: 0;
  animation: close-fade-in 0.6s ease-out 0.6s forwards;
}

@keyframes close-fade-in {
  from {
    opacity: 0;
    transform: scale(0.8) rotate(-90deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.konami-close:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: rgba(239, 68, 68, 0.8);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Mobile responsive adjustments */
@media (max-width: 480px) {
  #konami-overlay {
    padding: 30px 15px;
  }
  
  .konami-title {
    font-size: 20px;
    margin-bottom: 50px;
    letter-spacing: 2px;
  }
  
  .konami-sequence {
    padding: 16px;
    margin-bottom: 60px;
    min-height: 45px;
    width: 280px;
  }
  
  .konami-controls {
    max-width: 280px;
    gap: 24px;
  }
  
  .konami-btn {
    width: 56px;
    height: 56px;
    font-size: 18px;
  }
  
  .konami-close {
    width: 28px;
    height: 28px;
    font-size: 14px;
    top: 20px;
    right: 20px;
  }
}

@media (max-width: 360px) {
  #konami-overlay {
    padding: 20px 10px;
  }
  
  .konami-title {
    font-size: 18px;
    margin-bottom: 40px;
  }
  
  .konami-sequence {
    width: 250px;
    padding: 14px;
    margin-bottom: 50px;
  }
  
  .konami-controls {
    max-width: 250px;
    gap: 20px;
  }
  
  .konami-btn {
    width: 52px;
    height: 52px;
    font-size: 16px;
  }
  
  .konami-sequence .correct {
    width: 10px;
    height: 10px;
  }
  
  .konami-close {
    top: 15px;
    right: 15px;
  }
}