/* Base styles */
body {
  font-family: 'Vazir', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  background: linear-gradient(to bottom, #d6dbdc, #ffffff);
  min-height: 100vh;
  direction: rtl;
}

img {
    -webkit-user-select: none; 
    -moz-user-select: none;    
    -ms-user-select: none;     
    user-select: none;         
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

/* Stats section */
.stats-container {
  width: 100%;
  max-width: 64rem;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: row;
  gap: 1rem;
}

.stat-box {
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  flex: 1;
  min-width: 120px; /* Ensure minimum width for readability */
  box-sizing: border-box; /* Include padding in width calculation */
}

.stat-box h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}

.stat-box p {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2563eb;
}

/* Kiss area */
.kiss-area {
  position: relative;
  width: 100%;
  max-width: 64rem;
  aspect-ratio: 16/9;
  background-color: #e5e7eb;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.flag-background {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Kiss marks container */
#kiss-marks-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Leaderboard Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.leaderboard-modal {
  background-color: #f3f4f6;
  border-radius: 0.75rem;
  padding: 2rem;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  position: relative;
}

.modal-overlay.active .leaderboard-modal {
  transform: translateY(0);
}

.leaderboard-modal h2 {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: #374151;
  margin-bottom: 1.5rem;
  margin-top: 0;
}

.leaderboard-modal .close-button {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #6b7280;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.leaderboard-modal .close-button:hover {
  background-color: #e5e7eb;
  color: #1f2937;
}

#leaderboard-list {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Custom scrollbar for leaderboard */
#leaderboard-list::-webkit-scrollbar {
  width: 8px;
}

#leaderboard-list::-webkit-scrollbar-track {
  background: #e5e7eb;
  border-radius: 4px;
}

#leaderboard-list::-webkit-scrollbar-thumb {
  background: #9ca3af;
  border-radius: 4px;
}

#leaderboard-list::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #d1d5db;
  background-color: white;
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  animation: fadeInUp 0.3s ease-out forwards;
  opacity: 0;
  transform: translateY(10px);
}

.leaderboard-item:last-child {
  margin-bottom: 0;
}

.leaderboard-item span:first-child {
  font-weight: 700;
  color: #2563eb;
  min-width: 30px;
}

.leaderboard-item span:nth-child(2) {
  flex: 1;
  text-align: center;
  font-weight: 600;
  color: #374151;
}

.leaderboard-item span:last-child {
  font-weight: 700;
  color: #16a34a;
  min-width: 80px;
  text-align: left;
}

/* Animation for leaderboard items */
@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Add staggered delay for leaderboard items */
.leaderboard-item:nth-child(1) { animation-delay: 0.1s; }
.leaderboard-item:nth-child(2) { animation-delay: 0.2s; }
.leaderboard-item:nth-child(3) { animation-delay: 0.3s; }
.leaderboard-item:nth-child(4) { animation-delay: 0.4s; }
.leaderboard-item:nth-child(5) { animation-delay: 0.5s; }
.leaderboard-item:nth-child(6) { animation-delay: 0.6s; }
.leaderboard-item:nth-child(7) { animation-delay: 0.7s; }
.leaderboard-item:nth-child(8) { animation-delay: 0.8s; }
.leaderboard-item:nth-child(9) { animation-delay: 0.9s; }
.leaderboard-item:nth-child(10) { animation-delay: 1.0s; }

/* Buttons container */
.buttons-container {
  display: flex;
  gap: 1rem;
  width: 100%;
  max-width: 64rem;
  margin-top: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.toggle-button, .contact-button {
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 0.25rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: background-color 0.2s;
  min-width: 180px;
  box-sizing: border-box;
}

.toggle-button:hover, .contact-button:hover {
  background-color: #1d4ed8;
}

.contact-button {
  background-color: #16a34a;
}

.contact-button:hover {
  background-color: #15803d;
}

/* Responsive adjustments for buttons and modal */
@media (max-width: 768px) {
  .buttons-container {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }
  
  .toggle-button, .contact-button {
    min-width: 150px;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
  }
  
  .leaderboard-modal {
    padding: 1.5rem;
    width: 95%;
  }
  
  .leaderboard-modal h2 {
    font-size: 1.25rem;
  }
  
  #leaderboard-list {
    max-height: 50vh;
  }
}

@media (max-width: 480px) {
  .buttons-container {
    gap: 0.5rem;
  }
  
  .toggle-button, .contact-button {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    min-width: 140px;
    font-family: 'Vazir', Tahoma, Geneva, Verdana, sans-serif;
  }
  
  .leaderboard-modal {
    padding: 1rem;
  }
  
  .leaderboard-modal h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
  }
  
  .leaderboard-item {
    padding: 0.5rem 0.75rem;
    flex-direction: row;
    align-items: center;
  }
  
  .leaderboard-item span:first-child {
    font-size: 0.875rem;
  }
  
  .leaderboard-item span:nth-child(2) {
    font-size: 0.875rem;
  }
  
  .leaderboard-item span:last-child {
    font-size: 0.875rem;
  }
}

/* Buttons container */
.buttons-container {
  display: flex;
  gap: 1rem;
  width: 100%;
  max-width: 64rem;
  margin-top: 1rem;
  justify-content: center;
}

.toggle-button, .contact-button {
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 0.25rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: background-color 0.2s;
  flex: 1;
  max-width: 200px;
}

.toggle-button:hover, .contact-button:hover {
  background-color: #1d4ed8;
}

.contact-button {
  background-color: #16a34a;
}

.contact-button:hover {
  background-color: #15803d;
}

/* Responsive adjustments for buttons */
@media (max-width: 768px) {
  .buttons-container {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }
  
  .toggle-button, .contact-button {
    width: 100%;
    max-width: 300px;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
  }
}

@media (max-width: 480px) {
  .buttons-container {
    gap: 0.5rem;
  }
  
  .toggle-button, .contact-button {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
  }
}

/* Instructions */
.instructions {
  margin-top: 1rem;
  text-align: center;
  color: #4b5563;
  padding: 1rem;
}

/* Buttons container */
.buttons-container {
  display: flex;
  gap: 1rem;
  width: 100%;
  max-width: 64rem;
  margin-top: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.toggle-button, .contact-button {
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 0.25rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: background-color 0.2s;
  min-width: 180px;
  box-sizing: border-box;
}

.toggle-button:hover, .contact-button:hover {
  background-color: #1d4ed8;
}

.contact-button {
  background-color: #16a34a;
}

.contact-button:hover {
  background-color: #15803d;
}

/* Responsive adjustments for buttons */
@media (max-width: 768px) {
  .buttons-container {
    gap: 0.75rem;
  }
  
  .toggle-button, .contact-button {
    min-width: 150px;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
  }
}

@media (max-width: 480px) {
  .buttons-container {
    gap: 0.5rem;
  }
  
  .toggle-button, .contact-button {
    min-width: 140px;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
  }
}

/* Animation for kiss effect */
@keyframes kissEffect {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
  10% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 1;
  }
  20% {
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 1;
  }
  30% {
    transform: translate(-50%, -50%) scale(1.05);
    opacity: 1;
  }
  70% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
  }
}

.kiss-animation {
  position: absolute;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: kissEffect 1.5s ease-out forwards;
  font-size: 24px;
  line-height: 1;
  z-index: 10;
}

.kiss-animation img {
  width: 30px;
  height: 30px;
  display: block;
}

/* Animation for the flag when kissed */
@keyframes flagKissed {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.flag.kissed {
  animation: flagKissed 0.3s ease;
}

/* Animation for the container shake effect */
@keyframes flagShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
  20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.flag-shake {
  animation: flagShake 0.4s ease-in-out;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  width: 300px;
}

.toast {
  background-color: #333;
  color: white;
  padding: 16px 24px;
  border-radius: 4px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  animation: toastSlideIn 0.3s ease-out;
  opacity: 0.95;
  min-height: 48px; /* Minimum touch target size */
}

.toast-success {
  border-right: 4px solid #4caf50;
}

.toast-error {
  border-right: 4px solid #f44336;
}

.toast-warning {
  border-right: 4px solid #ff9800;
}

.toast-info {
  border-right: 4px solid #2196f3;
}

.toast-icon {
  margin-right: 12px;
  font-size: 20px;
  min-width: 24px; /* Ensure consistent width */
}

.toast-message {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 18px;
  padding: 8px;
  margin-left: 12px;
  opacity: 0.7;
  min-width: 32px; /* Minimum touch target size */
  min-height: 32px; /* Minimum touch target size */
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  opacity: 1;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 0.95;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 0.95;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast-exiting {
  animation: toastSlideOut 0.3s ease-in forwards;
}

/* Adjust toast position to avoid overlap with buttons */
@media (max-width: 768px) {
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  main {
    padding: 0.5rem;
  }
  
  .kiss-area {
    aspect-ratio: 4/3;
    border-radius: 0.5rem;
  }
  
  .stat-box {
    padding: 0.75rem;
  }
  
  .stat-box h3 {
    font-size: 1rem;
  }
  
  .stat-box p {
    font-size: 1.25rem;
  }
  
  .leaderboard-container {
    padding: 1rem;
    margin-top: 1rem;
  }
  
  .leaderboard-container h2 {
    font-size: 1.25rem;
  }
  
  .instructions {
    font-size: 0.875rem;
    padding: 0.75rem;
  }
  
  .toast-container {
    width: calc(100% - 20px);
    right: 10px;
    left: 10px;
    top: 10px;
  }
  
  .toast {
    padding: 12px 16px;
    font-size: 13px;
    min-height: 44px;
  }
  
  .toast-icon {
    font-size: 16px;
    margin-right: 8px;
    min-width: 20px;
  }
  
  .toast-message {
    font-size: 13px;
  }
  
  .toast-close {
    font-size: 16px;
    margin-left: 8px;
    min-width: 30px;
    min-height: 30px;
    padding: 6px;
  }
}

/* Small devices (landscape phones, 576px and down) */
@media (max-width: 576px) {  
  .stat-box {
    min-width: auto;
  }
}

/* Extra small devices (phones, 480px and down) */
@media (max-width: 480px) {
  main {
    padding: 0.25rem;
  }
  
  .stats-container {
    margin-bottom: 1rem;
  }
  
  .stat-box {
    padding: 0.5rem;
  }
  
  .stat-box h3 {
    font-size: 0.875rem;
  }
  
  .stat-box p {
    font-size: 1.125rem;
  }
  
  .kiss-area {
    aspect-ratio: 3/4;
    border-radius: 0.25rem;
  }
  
  .leaderboard-container {
    padding: 0.75rem;
    margin-top: 0.75rem;
  }
  
  .leaderboard-container h2 {
    font-size: 1.125rem;
  }
  
  #leaderboard-list {
    max-height: 15rem;
  }
  
  .instructions {
    font-size: 0.8125rem;
    padding: 0.5rem;
  }
  
  .toast-container {
    width: calc(100% - 10px);
    right: 5px;
    left: 5px;
    top: 5px;
  }
  
  .toast {
    padding: 10px 12px;
    font-size: 12px;
    min-height: 40px;
  }
  
  .toast-icon {
    font-size: 14px;
    margin-right: 6px;
    min-width: 18px;
  }
  
  .toast-message {
    font-size: 12px;
  }
  
  .toast-close {
    font-size: 14px;
    margin-left: 6px;
    min-width: 28px;
    min-height: 28px;
    padding: 4px;
  }
}/* Medium devices (tablets, 768px and down) */
@media (max-width: 768px) {
  main {
    padding: 0.5rem;
  }
  
  .kiss-area {
    aspect-ratio: 4/3;
    border-radius: 0.5rem;
  }
  
  .stat-box {
    padding: 0.75rem;
    min-width: 100px;
  }
  
  .stat-box h3 {
    font-size: 1rem;
  }
  
  .stat-box p {
    font-size: 1.25rem;
  }
  
  .leaderboard-container {
    padding: 1rem;
    margin-top: 1rem;
  }
  
  .leaderboard-container h2 {
    font-size: 1.25rem;
  }
  
  .instructions {
    font-size: 0.875rem;
    padding: 0.75rem;
  }
  
  .toast-container {
    width: calc(100% - 20px);
    right: 10px;
    left: 10px;
    top: 10px;
  }
  
  .toast {
    padding: 12px 16px;
    font-size: 13px;
  }
  
  .toast-icon {
    font-size: 16px;
    margin-right: 8px;
  }
  
  .toast-message {
    font-size: 13px;
  }
  
  .toast-close {
    font-size: 16px;
    margin-left: 8px;
  }
}

/* Small devices (landscape phones, 576px and down) */
@media (max-width: 576px) {  
  .stat-box {
    min-width: auto;
  }
}
