:root {
  --primary: #2c3e50;
  --secondary: #4CAF50;
  --highlight: #FFD700;
  --background: #f9f9f9;
  --border: #ddd;
  --saved-bg: #e8f5e9;
  --tab-active: #3498db;
  --tab-inactive: #bdc3c7;
}

* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 15px;
  background: var(--background);
  color: var(--primary);
  font-size: 16px;
}

.container {
  max-width: 100%;
  margin: 0 auto;
}

/* Блок настройки */
#setup {
  margin-bottom: 25px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.players-input {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.players-input input {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 18px;
  height: 55px;
}

.btn-randomize, .btn-new-game {
  padding: 18px 25px;
  margin-right: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s;
  font-size: 18px;
  font-weight: bold;
  min-height: 60px;
}

.btn-randomize:hover {
  background: #1a252f;
}

.btn-new-game {
  background: #e74c3c;
  width: 100%;
  margin-top: 10px;
}

.btn-new-game:hover {
  background: #c0392b;
}

/* Матчи */
.match {
  margin-bottom: 25px;
  border: 2px solid var(--border);
  padding: 20px;
  border-radius: 12px;
  background: white;
  transition: background 0.3s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.match.saved {
  background: var(--saved-bg);
  border-color: var(--secondary);
}

.match-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--border);
}

.match-header h3 {
  margin: 0;
  font-size: 1.4em;
  color: var(--primary);
}

.rest-info {
  font-weight: bold;
  color: #e74c3c;
  font-size: 1.1em;
}

.teams-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 15px;
  align-items: center;
  text-align: center;
}

.team {
  padding: 15px;
  background: #f8f9fa;
  border-radius: 8px;
}

.team-players {
  font-weight: bold;
  margin-bottom: 15px;
  font-size: 1.2em;
  color: var(--primary);
}

.score-input {
  width: 100%;
  max-width: 120px;
  padding: 15px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1.3em;
  font-weight: bold;
  margin: 0 auto;
  display: block;
}

.vs {
  font-weight: bold;
  color: var(--primary);
  font-size: 1.3em;
  padding: 0 10px;
}

.save-btn {
  padding: 18px 30px;
  background: var(--secondary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2em;
  font-weight: bold;
  margin-top: 15px;
  width: 100%;
  min-height: 60px;
}

.save-btn.saved {
  background: var(--highlight);
  color: var(--primary);
}

/* Табы результатов */
.results-tabs {
  margin-top: 30px;
}

.tab-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 18px 15px;
  background: var(--tab-inactive);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1em;
  font-weight: bold;
  transition: background 0.3s;
  min-height: 60px;
}

.tab-btn.active {
  background: var(--tab-active);
}

.tab-content {
  display: none;
  padding: 20px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tab-content.active {
  display: block;
}

.tab-content h2 {
  margin-top: 0;
  margin-bottom: 20px;
  text-align: center;
  color: var(--primary);
  font-size: 1.4em;
}

/* Таблицы результатов */
.player-result {
  margin: 12px 0;
  padding: 18px;
  border-bottom: 2px dashed var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  border-radius: 8px;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
}

.player-name {
  font-weight: bold;
  min-width: 120px;
  font-size: 1.1em;
}

.player-stats {
  display: flex;
  gap: 20px;
  font-size: 1em;
  color: #666;
  flex-wrap: wrap;
}

.total {
  font-weight: bold;
  color: var(--secondary);
  font-size: 1.2em;
}

.wins {
  color: #e74c3c;
  font-weight: bold;
}

.points-diff {
  color: #9b59b6;
  font-weight: bold;
}

.position {
  background: var(--primary);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: bold;
  min-width: 40px;
  text-align: center;
  font-size: 1.2em;
}

.hidden {
  display: none;
}

.players-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 25px;
}

.players-list div {
  padding: 18px;
  background: #f0f0f0;
  border-radius: 8px;
  text-align: center;
  font-size: 1.2em;
  font-weight: bold;
}

/* Адаптивность для планшетов и десктопов */
@media (min-width: 768px) {
  body {
    padding: 25px;
    font-size: 14px;
  }
  
  .container {
    max-width: 800px;
  }
  
  .players-input {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .players-list {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .btn-new-game {
    width: auto;
    margin-top: 0;
  }
  
  .match-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  
  .save-btn {
    width: auto;
    min-width: 200px;
  }
  
  .tab-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .players-input {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .score-input {
    max-width: 100px;
    padding: 12px;
  }
  
  .save-btn {
    padding: 15px 25px;
    font-size: 1.1em;
  }
}

/* Улучшения для очень маленьких экранов */
@media (max-width: 360px) {
  body {
    padding: 10px;
    font-size: 14px;
  }
  
  .match {
    padding: 15px;
  }
  
  .teams-container {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .vs {
    order: -1;
    padding: 10px 0;
  }
  
  .player-result {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .player-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
  }
  
  .player-stats {
    justify-content: space-between;
    width: 100%;
  }
}