/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Space Grotesk", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
}

#app {
  width: 100vw;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  position: relative;
}

/* Screen management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.5s ease-in-out;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
  box-sizing: border-box;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* Start Screen */
#start-screen {
  text-align: center;
  padding: 1rem;
  justify-content: space-between;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.logo-container {
  margin-bottom: 1rem;
  animation: fadeInUp 1s ease-out;
  flex-shrink: 0;
}

.game-title {
  font-family: "Orbitron", monospace;
  font-size: clamp(2.5rem, 8vw, 6rem);
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
  margin-bottom: 1rem;
  line-height: 0.9;
}

.detective {
  background: linear-gradient(45deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
  background-size: 400% 400%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 3s ease-in-out infinite;
}

.subtitle {
  font-size: clamp(1rem, 3vw, 1.5rem);
  color: rgba(255, 255, 255, 0.8);
  font-weight: 300;
}

.game-rules {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
  max-width: 600px;
  animation: fadeInUp 1s ease-out 0.3s both;
  flex-shrink: 0;
}

.rule-item {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.3s ease;
}

.rule-item:hover {
  transform: translateY(-5px);
}

.rule-icon {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 0.5rem;
}

.rule-item span:last-child {
  color: white;
  font-weight: 400;
  text-align: center;
  font-size: clamp(0.8rem, 2vw, 1rem);
}

/* Buttons */
.cta-button {
  background: linear-gradient(45deg, #ff6b6b, #feca57);
  border: none;
  border-radius: 50px;
  padding: clamp(0.8rem, 2vw, 1rem) clamp(2rem, 5vw, 3rem);
  font-size: clamp(1rem, 3vw, 1.5rem);
  font-weight: 700;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 10px 30px rgba(255, 107, 107, 0.3);
  animation: fadeInUp 1s ease-out 0.6s both;
  font-family: "Orbitron", monospace;
}

.cta-button:hover,
.cta-button:active {
  transform: translateY(-3px);
  box-shadow: 0 15px 40px rgba(255, 107, 107, 0.4);
}

.cta-button.secondary {
  background: linear-gradient(45deg, #48dbfb, #0abde3);
  box-shadow: 0 10px 30px rgba(72, 219, 251, 0.3);
}

.cta-button.secondary:hover,
.cta-button.secondary:active {
  box-shadow: 0 15px 40px rgba(72, 219, 251, 0.4);
}

/* Start Actions */
.start-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  margin-top: 0;
  flex-shrink: 0;
}

.leaderboard-link {
  background: linear-gradient(45deg, #a55eea, #26de81);
  border: none;
  border-radius: 50px;
  padding: clamp(0.6rem, 1.5vw, 0.75rem) clamp(1.5rem, 4vw, 2rem);
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  font-weight: 600;
  color: white;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 10px 30px rgba(165, 94, 234, 0.3);
  display: inline-block;
}

.leaderboard-link:hover,
.leaderboard-link:active {
  transform: translateY(-3px);
  box-shadow: 0 15px 40px rgba(165, 94, 234, 0.4);
  text-decoration: none;
  color: white;
}

/* Game Screen */
#game-screen {
  padding: 0.5rem;
  justify-content: space-between;
  overflow: hidden;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin-bottom: 0.5rem;
  padding: 0 0.5rem;
  flex-wrap: nowrap;
  gap: 0.5rem;
  flex-shrink: 0;
}

.score-container,
.lives-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.label {
  color: rgba(255, 255, 255, 0.7);
  font-size: clamp(0.8rem, 2vw, 1rem);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.value {
  color: white;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  font-family: "Orbitron", monospace;
}

.timer-container {
  position: relative;
}

.timer-circle {
  width: clamp(80px, 12vw, 120px);
  height: clamp(80px, 12vw, 120px);
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    var(--primary-color) 0%,
    var(--primary-color) calc(var(--progress, 100) * 3.6deg),
    rgba(255, 255, 255, 0.2) calc(var(--progress, 100) * 3.6deg),
    rgba(255, 255, 255, 0.2) 360deg
  );
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.1s linear;
}

.timer-circle::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.timer-value {
  position: relative;
  z-index: 1;
  font-size: clamp(1.2rem, 3vw, 2rem);
  font-weight: 700;
  color: white;
  font-family: "Orbitron", monospace;
}

.lives-display {
  display: flex;
  gap: 0.5rem;
}

.heart {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  transition: all 0.3s ease;
}

.heart.lost {
  opacity: 0.3;
  filter: grayscale(100%);
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 800px;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b, #feca57);
  border-radius: 10px;
  transition: width 0.5s ease;
  width: 10%;
}

.question-counter {
  color: white;
  font-weight: 600;
  font-size: clamp(0.9rem, 2.5vw, 1.2rem);
  min-width: 80px;
  text-align: center;
}

.game-question {
  text-align: center;
  width: 100%;
  max-width: 1000px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.question-title {
  color: white;
  font-size: clamp(1.2rem, 4vw, 2rem);
  margin-bottom: 0.5rem;
  font-weight: 600;
  flex-shrink: 0;
}

.images-container {
  display: flex;
  gap: clamp(1rem, 3vw, 2rem);
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
  min-height: 0;
}

.image-option {
  position: relative;
  width: min(45vh, 45vw, 450px);
  height: min(45vh, 45vw, 450px);
  max-width: 450px;
  max-height: 450px;
  min-width: 200px;
  min-height: 200px;
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
  border: 4px solid rgba(255, 255, 255, 0.2);
  touch-action: manipulation;
  flex-shrink: 1;
}

.image-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    rgba(255, 107, 107, 0.2),
    rgba(254, 202, 87, 0.2)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tap-indicator {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  padding: 0.8rem 2rem;
  border-radius: 30px;
  font-weight: 700;
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: pulse 2s infinite;
}

/* Feedback states */
.image-option.correct {
  border-color: #00d4aa;
  box-shadow: 0 0 30px rgba(0, 212, 170, 0.5);
  animation: correctPulse 0.6s ease;
}

.image-option.incorrect {
  border-color: #ff6b6b;
  box-shadow: 0 0 30px rgba(255, 107, 107, 0.5);
  animation: incorrectShake 0.6s ease;
}

/* Game Over Screen */
#game-over-screen {
  text-align: center;
  padding: 2rem;
}

.game-over-content {
  max-width: 500px;
}

.game-over-title {
  font-family: "Orbitron", monospace;
  font-size: clamp(2rem, 5vw, 3rem);
  color: white;
  margin-bottom: 2rem;
  font-weight: 700;
}

.final-score-container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.final-score-label {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.2rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.final-score-value {
  font-family: "Orbitron", monospace;
  font-size: clamp(2.5rem, 6vw, 4rem);
  color: #feca57;
  font-weight: 900;
  text-shadow: 0 0 20px rgba(254, 202, 87, 0.5);
}

.name-input-container {
  margin-bottom: 2rem;
}

#player-name {
  width: 100%;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: white;
  font-size: 1.2rem;
  text-align: center;
  margin-bottom: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

#player-name::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

#player-name:focus {
  outline: none;
  border-color: #feca57;
  box-shadow: 0 0 20px rgba(254, 202, 87, 0.3);
}

.submit-button {
  background: linear-gradient(45deg, #00d4aa, #01a3a4);
  border: none;
  border-radius: 15px;
  padding: 1rem 2rem;
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  width: 100%;
}

.submit-button:hover,
.submit-button:active {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 212, 170, 0.3);
}

/* Scoreboard Screen */
#scoreboard-screen {
  padding: 2rem;
  text-align: center;
}

.scoreboard-content {
  max-width: 600px;
  width: 100%;
}

.scoreboard-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  margin-top: 2rem;
}

.scoreboard-title {
  font-family: "Orbitron", monospace;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  color: white;
  margin-bottom: 2rem;
  font-weight: 700;
}

.scoreboard-list {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-height: 400px;
  overflow-y: auto;
}

.score-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border-left: 4px solid #feca57;
}

.score-entry:first-child {
  border-left-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
}

.score-entry:nth-child(2) {
  border-left-color: #feca57;
  background: rgba(254, 202, 87, 0.1);
}

.score-entry:nth-child(3) {
  border-left-color: #48dbfb;
  background: rgba(72, 219, 251, 0.1);
}

.player-name {
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
}

.player-score {
  color: #feca57;
  font-weight: 700;
  font-family: "Orbitron", monospace;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.feedback-content {
  color: white;
}

.feedback-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.feedback-message {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.points-earned {
  font-family: "Orbitron", monospace;
  font-size: 2rem;
  color: #feca57;
  font-weight: 700;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes gradientShift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes correctPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes incorrectShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

/* Responsive Design */
@media (max-width: 1024px) {
  .images-container {
    gap: 1.5rem;
  }

  .image-option {
    width: min(40vh, 40vw, 350px);
    height: min(40vh, 40vw, 350px);
  }

  .game-header {
    padding: 0 0.5rem;
  }
}

/* Image Overlay Feedback */
.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  backdrop-filter: blur(5px);
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.3s ease;
  z-index: 10;
  pointer-events: none;
}

.image-overlay.show {
  opacity: 1;
  transform: scale(1);
}

.image-overlay.correct {
  background: rgba(76, 175, 80, 0.9);
}

.image-overlay.incorrect {
  background: rgba(244, 67, 54, 0.9);
}

.overlay-content {
  text-align: center;
  color: white;
}

.overlay-icon {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.overlay-text {
  font-size: 1.5rem;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  font-family: "Orbitron", monospace;
}

@media (max-width: 768px) {
  .images-container {
    flex-direction: column;
    gap: 1rem;
  }

  .image-option {
    width: min(35vh, 35vw, 280px);
    height: min(35vh, 35vw, 280px);
  }

  .game-rules {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .game-header {
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
  }

  .score-container,
  .lives-container {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }

  .lives-display {
    flex-direction: row;
    gap: 0.2rem;
  }

  .name-input-container {
    flex-direction: column;
    align-items: stretch;
  }

  #player-name,
  .submit-button {
    max-width: none;
  }

  .start-actions,
  .scoreboard-actions {
    gap: 0.8rem;
  }
}

@media (max-width: 480px) {
  .screen {
    padding: 0.5rem;
  }

  .image-option {
    width: min(30vh, 30vw, 200px);
    height: min(30vh, 30vw, 200px);
    border-radius: 15px;
  }

  .overlay-icon {
    font-size: 3rem;
  }

  .overlay-text {
    font-size: 1.2rem;
  }

  .rule-item {
    padding: 1rem;
  }

  .modal-content {
    padding: 1.5rem;
    margin: 1rem;
  }

  .feedback-title {
    font-size: 1.5rem;
  }

  .feedback-message {
    font-size: 1rem;
  }

  .game-header {
    padding: 0 0.25rem;
    margin-bottom: 0.5rem;
  }

  .progress-container {
    margin-bottom: 0.5rem;
  }

  .images-container {
    gap: 0.8rem;
  }
}

/* Touch device optimizations */
.touch-device .image-option {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.touch-device .cta-button,
.touch-device .leaderboard-link {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Prevent text selection on touch devices */
.touch-device * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Enhanced touch feedback */
.image-option:active {
  transform: scale(0.95);
}

.cta-button:active,
.leaderboard-link:active {
  transform: scale(0.95);
}

/* Prevent overscroll and bounce effects */
html,
body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* Prevent pull-to-refresh */
body {
  overscroll-behavior-y: none;
}

/* Loading states */
.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* Timer animation */
.timer-circle.warning {
  animation: timerWarning 1s infinite;
}

@keyframes timerWarning {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}
