:root {
  --bg: #f2f7f2;
  --panel: #e3f2e1;
  --accent: #9ccf9c;
  --text: #2e4632;
  --light: #ffffff;
}

html, body {
  height: auto;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: center;
  /* height: 100vh; */
}

.container {
  width: 1000px;
  background: var(--light);
  border-radius: 14px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  border: 1px solid #d6e5d6;
  position: relative;
}


/* кнопка выхода */
.exit-button-container {
  position: absolute;
  top: 20px;
  left: 20px;
}

.exit-button {
  font-family: 'Montserrat', sans-serif;
  background: #f64343;
  color: #333;
  border: none;
  padding: 10px 16px;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}

.exit-button:hover {
  background: #d0d0d0;
}



/* CЧЕТ */
.top-score h2 {
  font-size: 2.6rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
}

.main-score {
  font-weight: 700;
  font-size: 2.6rem;
  color: var(--text);
}

.game-wrapper {
  font-size: 1.6rem;
  color: #9db39c;
  font-weight: 400;
}

.game-count {
  font-weight: 400;
}






/* ИГОРОКИ */
.players {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.player {
  flex: 1;
  background: var(--panel);
  padding: 25px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid #cde8cd;
  transition: transform 0.2s;
}

.player:hover {
  transform: scale(1.01);
}

.player-icon {
  width: 90px;
  height: 90px;
  object-fit: contain;
}


.player h3 {
  margin-bottom: 25px;
  color: var(--text);
  font-size: 1.4rem;
}

.player button {
  display: block;
  font-family: 'Montserrat', sans-serif;
  width: 100%;
  margin: 10px 0;
  padding: 14px;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: bold;
  transition: background 0.2s;
}

.player button:hover {
  background: #84be84;
}

.serve-button {
  background: #fffbe0;
  font-family: 'Montserrat', sans-serif;
  color: #4c6e30;
  font-weight: bold;
  padding: 10px 16px;
  font-size: 1rem;
  border: 2px solid #b8cc91;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 10px;
  transition: background 0.2s, border-color 0.2s;
}

.serve-button:hover {
  background: #f6f9e5;
  border-color: #a1be79;
}


.serve-indicator {
  position: absolute;
  width: 32px;
  height: 32px;
  background-image: url('images/ball.png');
  background-size: cover;
  display: none;
}

.player-left .serve-indicator {
  top: 10px;
  left: 10px;
}

.player-right .serve-indicator {
  top: 10px;
  right: 10px;
}

.player {
  position: relative;
}







/* НИЖНЕЕ ТАБЛО */
.match-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.match-grid th,
.match-grid td {
  padding: 14px 12px;
  text-align: center;
  border: 1px solid #dceedd;
  transition: background 0.3s;
}

.match-grid thead th {
  background: #e0f4e0;
  color: #446644;
  font-weight: 500;
}

.name-cell {
  background: #e9f9e9;
  font-weight: 600;
  text-align: left;
  padding-left: 20px;
  color: #2e4632;
  width: 120px;
}

.cell {
  background: #f6fcf6;
  color: #2e4632;
  font-weight: 500;
  cursor: pointer;
}

.cell:focus {
  outline: none;
  background: #dff3df;
}


.cell.active {
  background: #cdeed2;
  color: #1e3f1e;
  font-weight: 700;
}





.undo-container {
  display: flex;
  justify-content: center;
  align-content: center;
  align-items: center;
  margin-top: 20px;
  gap: 20px;
  flex-wrap: wrap;
}

.undo-button {
  background: #ff5a5a;
  font-family: 'Montserrat', sans-serif;
  color: white;
  font-weight: bold;
  padding: 14px 24px;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.undo-button:hover {
  background: #e04848;
}


#champion-tb-checkbox + p {
  background: rgba(203, 203, 203, 0.403);
  border: 2px solid #ccaa00;
  border-radius: 10px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: bold;
  color: #5d5d5d;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

#champion-tb-checkbox:checked + p {
  background: linear-gradient(90deg, #ffe271, #ffd24c);
  border: 2px solid #ccaa00;
  border-radius: 10px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: bold;
  color: #5a4100;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.undo-container label p {
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  font-weight: bold;
  padding: 14px 24px;
  border-radius: 10px;
  transition: background 0.2s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  margin: 0;
}

/* Неактивный стиль */
#champion-tb-checkbox + span {
  background: #f0f0f0;
  color: #5d5d5d;
  border: 2px solid #ccaa00;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Активный стиль */
#champion-tb-checkbox:checked + span {
  background: linear-gradient(90deg, #ffe271, #ffd24c);
  color: #5a4100;
  border: 2px solid #ccaa00;
}

.show-time {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Montserrat', sans-serif;
  background: var(--panel);
  padding: 6px 24px;
  border-radius: 10px;
  border: 1px solid #cde8cd;
  cursor: default;
  transition: background 0.2s, transform 0.2s;
}

.show-time:hover {
  background: #d4ead4;
  transform: scale(1.01);
}

.show-time span {
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
  white-space: nowrap;
}

.show-time input {
  font-family: 'Montserrat', sans-serif;
  background: var(--light);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  width: 80px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.show-time input:focus {
  outline: none;
  border-color: #84be84;
  background: #f9fcf9;
}

.show-time input:hover {
  border-color: #84be84;
}









/* Модальное окно отмены розыгрыша*/
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(40, 40, 40, 0.6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal-window {
  background: #ffffff;
  padding: 40px 30px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  text-align: center;
  min-width: 400px;
  max-width: 90%;
  animation: fadeIn 0.3s ease-in-out;
}

.modal-title {
  font-size: 1.4rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 25px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 30px;
}

.modal-actions button {
  padding: 12px 28px;
  border-radius: 10px;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-actions .confirm {
  background: var(--accent);
  color: white;
  font-weight: bold;
}

.modal-actions .confirm:hover {
  background: #7cbc7c;
}

.modal-actions .cancel {
  background: #f1f1f1;
  color: #444;
}

.modal-actions .cancel:hover {
  background: #ddd;
}

/* Анимация плавного появления */
@keyframes fadeIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}



/* Модальное окно редактирования текущего счета */
.edit-score-container {
  display: flex;
  justify-content: center;
  margin-top: 15px;
}

.edit-score-button {
  font-family: 'Montserrat', sans-serif;
  background: #f0c674;
  color: #3b3b1f;
  font-weight: bold;
  padding: 12px 20px;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.edit-score-button:hover {
  background: #e4b95d;
}

.edit-grid {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 20px 0;
}

.edit-grid input {
  width: 80px;
  padding: 10px;
  font-size: 1.2rem;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 8px;
}



button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  /* если нужно, можно поменять фон отдельно: */
  /* background: #ccc; */
}




/* АДАПТАЦИЯ */
@media (max-width: 768px) {
  body {
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .container {
    width: 100vw;
    min-height: 100vh;
    max-width: 100%;
    padding: 20px 15px 40px 15px;
    border: none;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .exit-button-container {
    top: 10px;
    left: 10px;
  }

  .exit-button {
    font-size: 0.9rem;
    padding: 8px 12px;
  }

  .top-score h2 {
    font-size: 1.6rem;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
    gap: 8px;
  }

  .main-score {
    font-size: 1.6rem;
  }

  .game-wrapper {
    font-size: 1rem;
  }

  .game-count {
    font-size: 1rem;
  }

  .players {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 15px;
  }

  .player {
    width: 48%;
    padding: 15px;
    box-sizing: border-box;
  }

  .player-icon {
    width: 50px;
    height: 50px;
  }

  .player h3 {
    font-size: 1rem;
    margin-bottom: 15px;
  }

  .player button,
  .serve-button {
    font-size: 1.05rem;
    padding: 16px 14px;
    min-height: 54px;
    line-height: 1.2;
    border-radius: 10px;
  }

  .match-grid {
    font-size: 0.9rem;
  }

  .match-grid th,
  .match-grid td {
    padding: 10px;
  }

  .edit-score-button,
  .undo-button {
    font-size: 0.9rem;
    padding: 10px 16px;
  }

  .modal-window {
    min-width: auto;
    width: 90%;
    padding: 25px 20px;
  }

  .modal-title {
    font-size: 1.2rem;
    margin-bottom: 20px;
  }

  .modal-actions {
    flex-direction: column;
    gap: 12px;
  }

  .modal-actions button {
    font-size: 1rem;
    padding: 12px 18px;
  }

  .edit-grid {
    flex-direction: column;
    gap: 15px;
    align-items: center;
  }

  .edit-grid input {
    width: 100px;
    padding: 8px;
    font-size: 1rem;
  }
}
