/* Общие стили */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

body {
  font-family: Arial, sans-serif;
  background: white; /* Изменено на белый */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Навигация */
nav {
  width: 100%;
  background: #000000;
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 12px 10px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

nav a {
  color: white;
  text-decoration: none;
  font-size: 1em;
  font-weight: bold;
  padding: 8px 16px;
  border-radius: 6px;
  transition: background 0.3s;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

nav a:hover {
  background: rgba(255, 255, 255, 0.2);
}

nav a.active {
  background: rgba(255, 255, 255, 0.9);
  color: #000000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #4a5cd8 0%, #000000 100%);
}

.container {
  max-width: 1000px;
  width: 100%;
  background: white;
  border-radius: 15px;
  padding: 20px;
  margin: 20px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

h1 { 
  font-size: 2em; 
  color: #222; 
}

.subtitle { 
  font-size: 0.9em; 
  color: #777; 
  margin-bottom: 15px; 
}

.format-selector {
  display: flex; 
  gap: 10px; 
  margin-bottom: 15px; 
  align-items: center;
}

.format-input {
  width: 70px; 
  padding: 6px; 
  font-size: 1em;
  border-radius: 6px; 
  border: 1px solid #aaa; 
  text-align: center;
}

.format-btn {
  padding: 8px 16px; 
  border: 2px solid #555; 
  background: transparent;
  border-radius: 20px; 
  cursor: pointer; 
  font-size: 0.9em;
  text-transform: lowercase;
  min-height: 44px;
  touch-action: manipulation;
}

.format-btn:hover { 
  background: #f2f2f2; 
}

.format-hint { 
  font-size: 0.8em; 
  color: #555; 
}

.search-box {
  width: 100%; 
  max-width: 400px; 
  margin: 10px auto 20px;
  display: flex; 
  align-items: center; 
  border: 1px solid #aaa;
  border-radius: 20px; 
  padding: 6px 12px;
}

.search-box input { 
  flex: 1; 
  border: none; 
  outline: none; 
  font-size: 1em; 
}

.pyramid-container {
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 8px;
  margin-bottom: 25px;
}

.pyramid-row { 
  display: flex; 
  justify-content: center; 
  gap: 8px; 
  flex-wrap: wrap; 
}

.slot {
  display: flex; 
  flex-direction: column; 
  align-items: center;
  min-width: 70px; 
  position: relative;
}

.slot-circle {
  width: 60px; 
  height: 60px; 
  border-radius: 50%;
  background: #ddd; 
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-weight: bold; 
  color: #555; 
  font-size: 0.9em;
}

.contestant-img {
  width: 65px; 
  height: 65px; 
  border-radius: 50%;
  object-fit: cover; 
  border: 4px solid;
  transition: opacity 0.3s ease;
}

.contestant-img.loading {
  opacity: 0.7;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.korea-border { 
  border-color: #002080; 
}

.japan-border { 
  border-color: #a6005a; 
}

.contestant-name {
  font-size: 0.75em; 
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  margin-top: 5px;
}

.remove-btn {
  position: absolute; 
  top: -5px; 
  right: -5px;
  width: 24px; 
  height: 24px; 
  background: #ff4d4d; 
  color: white;
  border-radius: 50%; 
  font-size: 14px; 
  display: flex;
  align-items: center; 
  justify-content: center; 
  cursor: pointer; 
  opacity: 0;
  touch-action: manipulation;
  z-index: 10;
}

.slot:hover .remove-btn { 
  opacity: 1; 
}

.slot-badge {
  position: absolute;
  bottom: 18px;
  background: #000000; 
  color: white;
  font-size: 0.65em;
  width: 20px; 
  height: 20px; 
  border-radius: 50%;
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-weight: bold;
  box-shadow: 
    0 0 8px rgba(122, 31, 208, 0.6),
    0 0 16px rgba(122, 31, 208, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  animation: glow-pulse 2s ease-in-out infinite alternate;
}

.crown {
  position: absolute;
  bottom: 18px;
  width: 26px; 
  height: 26px;
  fill: #000000;
  filter: 
    drop-shadow(0 0 6px rgba(122, 31, 208, 0.9))
    drop-shadow(0 0 12px rgba(122, 31, 208, 0.6))
    drop-shadow(0 0 18px rgba(122, 31, 208, 0.4));
  animation: crown-glow 3s ease-in-out infinite alternate;
}

.crown-text {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7em;
  font-weight: bold;
  color: white;
  text-shadow: 
    0 0 4px rgba(122, 31, 208, 0.8),
    0 0 8px rgba(122, 31, 208, 0.6),
    0 0 2px rgba(0,0,0,0.6);
  pointer-events: none;
  animation: text-glow 3s ease-in-out infinite alternate;
}

.contestants-list {
  max-height: 350px; 
  overflow-y: auto;
  border: 1px solid #ddd; 
  border-radius: 10px;
  padding: 10px; 
  background: #f8f9fa; 
  width: 100%;
}

.contestants-grid {
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
}

.contestant-card {
  display: flex; 
  flex-direction: column; 
  align-items: center;
  padding: 8px; 
  border-radius: 10px; 
  cursor: pointer;
  background: white; 
  border: 1px solid #ddd;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.contestant-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.contestant-card:active {
  transform: translateY(0);
}

.contestant-card.disabled { 
  opacity: 0.4; 
}

.country-tag {
  font-size: 0.65em; 
  padding: 2px 6px; 
  border-radius: 10px; 
  margin-top: 4px;
}

.korea-tag { 
  background: #002080; 
  color: white; 
}

.japan-tag { 
  background: #a6005a; 
  color: white; 
}

.download-btn {
  margin-top: 15px; 
  padding: 12px 24px; 
  border: none;
  background: #333; 
  color: white; 
  border-radius: 25px;
  cursor: pointer; 
  font-size: 1em;
  min-height: 50px;
  touch-action: manipulation;
  font-weight: bold;
}

.watermark { 
  margin-top: 15px; 
  font-size: 0.9em; 
  opacity: 0.4; 
  color: #666;
}

/* Планшеты */
@media (max-width: 768px) {
  .container {
    padding: 15px;
    margin: 15px;
  }
  
  h1 {
    font-size: 1.8em;
  }
  
  .header-img {
    height: 150px;
  }
  
  .contestants-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
  }
  
  .contestant-card {
    padding: 6px;
  }
}

/* Мобильные телефоны */
@media (max-width: 480px) {
  nav {
    gap: 15px;
    padding: 10px 8px;
  }
  
  nav a {
    font-size: 0.9em;
    padding: 8px 12px;
  }
  
  .container {
    padding: 12px;
    margin: 10px;
  }
  
  h1 {
    font-size: 1.6em;
    margin: 10px 0;
  }
  
  .subtitle {
    font-size: 0.8em;
    text-align: center;
  }
  
  .header-img {
    height: 120px;
  }
  
  .format-selector {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
  }
  
  .format-input {
    width: 60px;
    padding: 8px;
    font-size: 16px;
  }
  
  .format-btn {
    padding: 8px 12px;
    font-size: 0.85em;
  }
  
  .search-box {
    max-width: 100%;
    margin: 15px auto 20px;
    padding: 8px 12px;
  }
  
  .search-box input {
    font-size: 16px;
  }
  
  .pyramid-container {
    margin-bottom: 20px;
  }
  
  .contestant-img { 
    width: 50px; 
    height: 50px; 
  }
  
  .slot-circle { 
    width: 50px; 
    height: 50px; 
    font-size: 0.8em; 
  }
  
  .contestant-name { 
    font-size: 0.65em;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .slot { 
    min-width: 55px; 
  }
  
  .slot-badge { 
    width: 18px; 
    height: 18px; 
    font-size: 0.6em; 
    bottom: 14px; 
  }
  
  .crown { 
    width: 22px; 
    height: 22px; 
    bottom: 14px; 
  }
  
  .crown-text { 
    bottom: 16px; 
    font-size: 0.6em; 
  }
  
  .remove-btn {
    width: 18px; 
    height: 18px; 
    font-size: 12px; 
  }
  
  .contestants-list {
    max-height: 280px;
    padding: 8px;
  }
  
  .contestants-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
  }
  
  .contestant-card {
    padding: 6px;
    border-radius: 8px;
  }
  
  .contestant-card .contestant-img {
    width: 45px;
    height: 45px;
  }
  
  .contestant-card .contestant-name {
    font-size: 0.6em;
  }
  
  .country-tag {
    font-size: 0.55em;
    padding: 1px 4px;
  }
  
  .watermark {
    font-size: 0.8em;
    text-align: center;
  }
}

/* Очень маленькие экраны */
@media (max-width: 320px) {
  .contestants-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .contestant-img { 
    width: 45px; 
    height: 45px; 
  }
  
  .slot-circle { 
    width: 45px; 
    height: 45px; 
  }
}

/* Анимации свечения для короны и кружочков */
@keyframes glow-pulse {
  0% { 
    box-shadow: 
      0 0 8px rgba(122, 31, 208, 0.6),
      0 0 16px rgba(122, 31, 208, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  100% { 
    box-shadow: 
      0 0 12px rgba(122, 31, 208, 0.8),
      0 0 24px rgba(122, 31, 208, 0.6),
      inset 0 1px 0 rgba(255, 255, 255, 0.3);
  }
}

@keyframes crown-glow {
  0% {
    filter: 
      drop-shadow(0 0 6px rgba(122, 31, 208, 0.9))
      drop-shadow(0 0 12px rgba(122, 31, 208, 0.6))
      drop-shadow(0 0 18px rgba(122, 31, 208, 0.4));
  }
  100% {
    filter: 
      drop-shadow(0 0 10px rgba(122, 31, 208, 1))
      drop-shadow(0 0 20px rgba(122, 31, 208, 0.8))
      drop-shadow(0 0 30px rgba(122, 31, 208, 0.6));
  }
}

@keyframes text-glow {
  0% {
    text-shadow: 
      0 0 4px rgba(122, 31, 208, 0.8),
      0 0 8px rgba(122, 31, 208, 0.6),
      0 0 2px rgba(0,0,0,0.6);
  }
  100% {
    text-shadow: 
      0 0 8px rgba(122, 31, 208, 1),
      0 0 16px rgba(122, 31, 208, 0.8),
      0 0 2px rgba(0,0,0,0.6);
  }
}