body {
  background: linear-gradient(135deg, #191919, #333);
  color: #fff;
  font-family: 'Arial', sans-serif;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.container {
  width: 90%;
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  background: rgba(34, 34, 34, 0.9);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  text-align: center;
  height: auto;
}

h1 {
  font-size: 2rem; /* Pienennetään otsikon kokoa */
  margin-bottom: 12px; /* Pienennetään marginaalia */
  color: #ff1919;
}

#status {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px; /* Pienennetään marginaalia */
  padding: 6px 12px; /* Pienennetään sisäistä marginaalia */
  background: #222;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

#status p {
  margin: 0;
  font-size: 1rem; /* Pienennetään fonttikokoa */
}

label {
  display: block;
  margin: 10px 0 6px; /* Pienennetään marginaalia */
  font-size: 0.9rem; /* Pienennetään fonttikokoa */
}

input, select, button {
  font-size: 0.9rem; /* Pienennetään fonttikokoa */
  padding: 8px; /* Pienennetään sisäistä marginaalia */
  border: none;
  border-radius: 8px;
  margin-bottom: 12px; /* Pienennetään marginaalia */
  width: 100%;
}

#difficultySelect {
  background: #2a2a2a;
  color: #fff;
  border: 2px solid #ff1919;
  font-weight: bold;
}

#difficultySelect option {
  background: #2a2a2a;
  color: #fff;
  padding: 5px;
}

input, select {
  background: #222;
  color: #fff;
}

button {
  background: #ff1919;
  color: #fff;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
}

button:hover {
  background: #ff7676;
  transform: scale(1.05);
}

img {
  width: auto; /* Asetetaan kiinteä leveys */
  height: 200px; /* Asetetaan kiinteä korkeus */
  object-fit: cover; /* Kuva täyttää alueen ja säilyttää mittasuhteet */
  background: #333;
  border-radius: 8px;
  border: 4px solid #ff1919;
  margin-bottom: 20px; /* Pienennetään marginaalia */
  cursor: pointer; /* Näytä että kuvaa voi klikata */
  transition: transform 0.2s;
}

img:hover {
  transform: scale(1.02);
}

/* Kuvan zoomaus modal */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  cursor: pointer;
}

.modal-image {
  max-width: 90%;
  max-height: 90%;
  border: 4px solid #ff1919;
  border-radius: 8px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px; /* Pienennetään vaihtoehtojen välistä tilaa */
}

button.correct {
  background: #4caf50;
  color: #fff;
}

button.wrong {
  background: #ff1919;
  color: #fff;
}

.results {
  margin-top: 24px; /* Pienennetään marginaalia */
}

/* Tuloksien tyylittely */
.results-summary {
  background: #2a2a2a;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  border: 2px solid #ff1919;
}

.achievements {
  background: #1a4c1a;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  border: 2px solid #4caf50;
}

.achievement {
  color: #4caf50;
  font-weight: bold;
  margin: 5px 0;
  text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.wrong-answers {
  background: #4c1a1a;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  border: 2px solid #ff1919;
}

.mistake {
  background: #3a1515;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  border-left: 4px solid #ff1919;
}

/* Historia modal */
.history-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.history-content {
  background: #222;
  padding: 20px;
  border-radius: 12px;
  max-width: 500px;
  max-height: 80%;
  overflow-y: auto;
  border: 2px solid #ff1919;
}

.stats-summary {
  background: #2a2a2a;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
}

.history-list {
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  background: #333;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  border-left: 4px solid #ff1919;
}

/* Tulostaulukko */
.leaderboard-list {
  max-height: 400px;
  overflow-y: auto;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 40px 1fr 80px 80px 80px;
  gap: 10px;
  padding: 10px;
  background: #333;
  border-radius: 5px;
  margin: 5px 0;
  align-items: center;
  font-size: 0.9rem;
}

.leaderboard-item.top-three {
  background: linear-gradient(45deg, #4a4a4a, #2a2a2a);
  border: 2px solid #ffd700;
}

.leaderboard-item .rank {
  font-weight: bold;
  color: #ff1919;
  text-align: center;
}

.leaderboard-item .name {
  font-weight: bold;
  color: #fff;
}

.leaderboard-item .score {
  text-align: center;
  color: #4caf50;
}

.leaderboard-item .points {
  text-align: center;
  color: #ffd700;
  font-weight: bold;
}

.leaderboard-item .difficulty {
  text-align: center;
  font-size: 0.8rem;
  color: #888;
}

.result-buttons {
  margin-top: 20px;
}

.result-buttons button {
  margin: 5px;
  padding: 10px 15px;
  font-size: 0.9rem;
}

#playerInfo button {
  background: #2a2a2a;
  border: 1px solid #ff1919;
  color: #fff;
  transition: all 0.3s;
}

#playerInfo button:hover {
  background: #ff1919;
  color: #fff;
}

table {
  width: 100%;
  color: #fff;
  background: rgba(34, 34, 34, 0.9);
  border-collapse: collapse;
  margin-top: 12px; /* Pienennetään marginaalia */
  border-radius: 8px;
  overflow: hidden;
}

th, td {
  padding: 6px; /* Pienennetään solujen sisäistä marginaalia */
  border-bottom: 1px solid #444;
}

th {
  background: #ff1919;
  color: #191919;
}

td {
  text-align: center;
}

footer {
  text-align: center;
  padding: 12px;
  background: #191919;
  color: #fff;
  font-size: 0.9rem;
  width: 100%;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
  position: relative; /* Footer pysyy normaalissa dokumenttivirrassa */
  margin-top: auto; /* Siirretään footer sivun alaosaan */
}

footer .logo {
  width: 80px;
  height: auto;
  background-color: #191919;
  margin-top: 8px;
  border: none; /* Poistetaan reunat kuvasta */
}

.add-games {
  text-align: center;
  margin: 20px 0; /* Lisätään tilaa ylä- ja alapuolelle */
}

#addGamesButton {
  font-size: 1rem;
  padding: 10px 20px;
  background: #ff1919;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
}

#addGamesButton:hover {
  background: #575757;
  transform: scale(1.05);
}

#timerDisplay {
  font-size: 1.2rem;
  color: #ff1919;
  margin-top: 10px;
}

/* Mobiiliversio */
@media (max-width: 768px) {
  h1 {
    font-size: 1.8rem; /* Pienennetään otsikon kokoa mobiilissa */
  }

  #status p {
    font-size: 0.9rem; /* Pienennetään fonttikokoa mobiilissa */
  }

  img {
    max-width: 100%; /* Kuva mukautuu mobiilinäytölle */
  }

  .container {
    padding: 16px;
  }

  button {
    font-size: 0.8rem; /* Pienennetään fonttikokoa mobiilissa */
    padding: 6px; /* Pienennetään sisäistä marginaalia mobiilissa */
  }
}

/* Analytics Modal Styles */
.analytics-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.analytics-content {
  background: #2c2c2c;
  border-radius: 12px;
  padding: 20px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  color: white;
}

.analytics-section {
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.difficulty-stat {
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  margin: 5px 0;
  border-radius: 5px;
}

.hardest-models {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.model-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: rgba(255, 25, 25, 0.1);
  border-radius: 5px;
  border-left: 3px solid #ff1919;
}

.model-stat .rank {
  font-weight: bold;
  color: #ff1919;
  min-width: 30px;
}

.model-stat .model-name {
  flex: 1;
  text-align: left;
  margin-left: 10px;
}

.model-stat .wrong-count {
  color: #ff6b6b;
  font-weight: bold;
}

.model-stat .avg-time {
  color: #ffd700;
  font-size: 0.9rem;
}

.analytics-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

/* Share Modal Styles */
.share-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.share-content {
  background: #2c2c2c;
  border-radius: 12px;
  padding: 20px;
  max-width: 500px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  color: white;
}

.share-text textarea {
  width: 100%;
  height: 80px;
  background: #333;
  color: white;
  border: 1px solid #555;
  border-radius: 5px;
  padding: 10px;
  resize: vertical;
  font-family: inherit;
}

.share-url {
  display: flex;
  gap: 10px;
  margin: 15px 0;
}

.share-url input {
  flex: 1;
  background: #333;
  color: white;
  border: 1px solid #555;
  border-radius: 5px;
  padding: 8px;
}

.share-buttons {
  display: flex;
  gap: 10px;
  margin: 15px 0;
  flex-wrap: wrap;
}

.share-btn {
  padding: 8px 12px;
  border-radius: 5px;
  text-decoration: none;
  color: white;
  font-size: 0.9rem;
  transition: transform 0.2s;
}

.share-btn:hover {
  transform: scale(1.05);
}

.share-btn.twitter {
  background: #1da1f2;
}

.share-btn.facebook {
  background: #4267b2;
}

.share-btn.whatsapp {
  background: #25d366;
}

/* Challenge Notification Styles */
.challenge-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #2c2c2c;
  border: 2px solid #ff1919;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  color: white;
  z-index: 1000;
  max-width: 400px;
  text-align: center;
}

.challenge-notification h3 {
  margin-top: 0;
  color: #ff1919;
}

.challenge-notification ul {
  text-align: left;
  margin: 15px 0;
}

.challenge-notification ul li {
  margin: 5px 0;
}

/* Enhanced result buttons styling */
.result-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}

.result-buttons button {
  font-size: 0.85rem;
  padding: 8px 12px;
  white-space: nowrap;
}

/* Mobile responsive adjustments for new features */
@media (max-width: 768px) {
  .analytics-content {
    margin: 10px;
    max-height: 90vh;
    padding: 15px;
  }
  
  .share-content {
    margin: 10px;
    padding: 15px;
  }
  
  .model-stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
  
  .model-stat .model-name {
    margin-left: 0;
  }
  
  .share-buttons {
    flex-direction: column;
  }
  
  .analytics-buttons {
    flex-direction: column;
  }
  
  .result-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .result-buttons button {
    width: 100%;
    max-width: 200px;
  }
}