* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1e1e2f, #2a2a3b);
    color: #fff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

body.has-game-active {
    padding-bottom: 60px; /* дополнительное пространство для toast */
}

#app {
    width: 100%;
    max-width: 1200px;
    background: rgba(0,0,0,0.5);
    border-radius: 30px;
    padding: 20px;
    backdrop-filter: blur(5px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px);}
    to { opacity: 1; transform: translateY(0);}
}

h1, h2, h3 {
    text-align: center;
    margin-bottom: 20px;
    font-weight: 600;
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(45deg, #ff6b6b, #feca57);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.menu-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

button {
    background: #ff6b6b;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

@media (hover: hover) {
  button:hover { 
    transform: scale(1.02);
    background: #ff5252;
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
  }
}

.backBtn {
    background: #4a4a6a;
    margin-top: 15px;
    display: inline-block;
}

input, select {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border-radius: 30px;
    border: none;
    background: #2e2e42;
    color: white;
    font-size: 1rem;
    outline: none;
}

input::placeholder {
    color: #aaa;
}

.song-list {
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 15px;
    margin-top: 20px;
}

#songsContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

.song-card {
    background: #3a3a55;
    padding: 12px 18px;
    border-radius: 40px;
    transition: 0.2s;
    font-weight: bold;
}

.song-card button {
  margin: 5px;
  padding: 5px 10px;
  font-size: 0.9rem;
}
.delete-song-btn {
  background-color: #dc3545;
}
.delete-song-btn:hover {
  background-color: #c82333;
}

.players {
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 15px;
    margin-top: 20px;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
}

.playersList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));;
}

.player-card {
    background: #2e2e42;
    padding: 15px 25px;
    margin: 10px;
    border-radius: 20px;
    text-align: center;
    min-width: 150px;
}

.player-name {
    font-size: 1.2rem;
    font-weight: bold;
}

.player-score {
    font-size: 1.5rem;
    color: #feca57;
}

.preview-song {
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 15px;
    margin-top: 10px;
    justify-content: center;
    gap: 20px;
}
.song-volume-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    gap: 15px;
}

.scoreboard {
    background: #2e2e42;
    padding: 10px 20px;
    border-radius: 30px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.score-item {
    font-weight: bold;
}

.current-lyric {
    background: #ff6b6b;
    padding: 15px 25px;
    border-radius: 40px;
    font-size: 1.3rem;
    font-weight: bold;
    text-align: center;
    flex: 1;
    box-shadow: 0 0 15px rgba(255,107,107,0.5);
}

.lyrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin: 30px 0;
    max-height: 50vh;
    overflow-y: auto;
    padding: 5px;
}

.lyric-btn {
    background: #3a3a55;
    border: none;
    padding: 15px;
    border-radius: 20px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.1s linear;
    text-align: left;
    word-break: break-word;
}

.lyric-btn:hover {
    background: #4a4a6a;
    transform: scale(1.01);
}

.lyric-btn.active {
    background: #feca57;
    color: #1e1e2f;
    box-shadow: 0 0 15px #feca57;
    font-weight: bold;
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

#gameAudio {
    display: none;
    margin-top: 15px;
    border-radius: 30px;
}

@media (max-width: 700px) {
    .lyrics-grid {
        grid-template-columns: 1fr;
    }
    .menu-buttons {
        flex-direction: column;
    }
    .preview-song-btn {
        max-width: 20%;
    }
    button {
        width: 100%;
    }
}

.options-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin: 20px 0;
    max-height: 60vh;
    padding: 10px;
}

.option-btn {
  background: linear-gradient(135deg, #3a3a55, #2a2a3b);
  border: 2px solid #ff6b6b;
  padding: 20px;
  font-size: 1.2rem;
  font-weight: bold;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
  text-align: center;
  word-break: break-word;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: opacity 0.3s ease-out, transform 0.2s ease;
}
@media (hover: hover) {
  .option-btn:hover { background:#ff5252; }
}
.option-btn.active {
  background: #ff5252;
  transform: scale(1.02);
  box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.option-btn.fade-out {
  opacity: 0.4;
  transform: scale(0.98);
  pointer-events: none;
}

.option-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 12px 24px;
  border-radius: 40px;
  z-index: 1000;
  font-weight: bold;
  animation: fadeOut 2s forwards;
}

.toast.success {
  background: #4caf50;
}

.toast.error {
  background: #f44336;
}

@keyframes fadeOut {
  0% { opacity: 1; transform: translateX(-50%) translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

.preview-line-btn {
  background-color: #4caf50;
  margin-right: 5px;
  padding: 5px 10px;
}
.preview-line-btn:hover {
  background-color: #45a049;
}
.line-editor-row button {
  margin-left: 5px;
}

/* Редактор строк */
.lines-editor-container {
  margin: 15px 0;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #4a4a6a;
  border-radius: 16px;
  padding: 10px;
  background: #1e1e2f;
}

.line-editor-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  background: #2e2e42;
  padding: 8px 12px;
  border-radius: 12px;
  flex-wrap: wrap;
}

.line-editor-row .line-text {
  flex: 3;
  min-width: 200px;
  background: #3a3a55;
  border: none;
  padding: 8px 12px;
  border-radius: 20px;
  color: white;
  font-size: 0.9rem;
}

.line-editor-row .time-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #3a3a55;
  padding: 4px 12px;
  border-radius: 20px;
}

.line-editor-row .time-wrapper label {
  font-size: 0.8rem;
  color: #aaa;
  margin: 0;
}

.line-editor-row .line-time {
  width: 90px;
  background: transparent;
  border: none;
  color: #feca57;
  font-weight: bold;
  padding: 6px 0;
  text-align: center;
  font-size: 0.9rem;
}

.line-editor-row button {
  margin: 0;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.preview-line-btn {
  background-color: #4caf50;
}
.preview-line-btn:hover {
  background-color: #45a049;
}

.remove-line-btn {
  background-color: #dc3545;
}
.remove-line-btn:hover {
  background-color: #c82333;
}

/* Чекбокс синхронизации */
.sync-checkbox-wrapper {
  margin: 15px 0;
  background: #2e2e42;
  padding: 10px 15px;
  border-radius: 40px;
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
}

.sync-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}

.sync-checkbox-label input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Редактор сложности */
.difficulty-rules-header {
  display: grid;
  grid-template-columns: 1fr 1fr 50px;
  gap: 12px;
  margin: 10px 0;
  padding: 0 10px;
  font-weight: bold;
  color: #feca57;
  font-size: 0.9rem;
}

.difficulty-editor-container {
  margin-bottom: 15px;
}

.difficulty-rule-row {
  display: grid;
  grid-template-columns: 1fr 1fr 50px;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  background: #2e2e42;
  padding: 8px 12px;
  border-radius: 12px;
}

.difficulty-rule-row input {
  background: #3a3a55;
  border: none;
  padding: 8px 12px;
  border-radius: 20px;
  color: white;
}

.difficulty-rule-row button {
  background: #dc3545;
  padding: 6px;
  margin: 0;
}

.difficulty-note {
  font-size: 0.8rem;
  color: #aaa;
  margin-top: 8px;
  font-style: italic;
}

.edit-buttons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.edit-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 25px;
}

.edit-section {
  background: rgba(0,0,0,0.3);
  padding: 15px;
  border-radius: 20px;
  margin-bottom: 20px;
}

.edit-section h3 {
  text-align: left;
  margin-bottom: 15px;
  border-left: 4px solid #ff6b6b;
  padding-left: 12px;
}

.info-fields {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.info-fields label {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2e2e42;
  padding: 8px 16px;
  border-radius: 40px;
}

.info-fields input {
  background: #3a3a55;
  border: none;
  padding: 6px 12px;
  border-radius: 20px;
  color: white;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
}
.modal-content {
    background: #2e2e42;
    margin: 10% auto;
    padding: 25px;
    border-radius: 30px;
    width: 80%;
    max-width: 700px;
    color: #fff;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    position: relative;
}
.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #ff6b6b;
}
.close-modal:hover {
    color: #feca57;
}
.modal-content h2 {
    margin-top: 0;
    color: #feca57;
}
.modal-content ol {
    margin-left: 20px;
    line-height: 1.6;
}
.modal-content a {
    color: #ff6b6b;
    text-decoration: none;
}
.modal-content a:hover {
    text-decoration: underline;
}
.modal-content p {
    margin: 8px 0;
    line-height: 1.5;
}
.modal-content .substep {
    margin-left: 24px;
}

@media (max-width: 700px) {
  .options-container {
      grid-template-columns: 1fr;
      gap: 12px;
      max-height: 50vh;
  }
  .option-btn {
      padding: 14px;
      font-size: auto;
  }
  .modal-content {
      width: 90%;
      margin: 20% auto;
      padding: 15px;
  }
  .modal-content ol {
      font-size: 0.9rem;
  }
}

/* Анимации слайдов */
.slide-out-left {
    animation: slideOutLeft 0.5s forwards;
}
.slide-in-left {
    animation: slideInLeft 0.5s forwards;
}
.slide-in-right {
    animation: slideInRight 0.5s forwards;
}
.slide-out-right {
    animation: slideOutRight 0.5s forwards;
}
@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-100%); opacity: 0; display: none; }
}
@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; display: block; }
}
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; display: none; }
}

/* Панель победителя */
.winner-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: none;
    overflow-y: auto;
    padding: 20px;
}
.winner-content {
    background: linear-gradient(135deg, #2e2e42, #1e1e2f);
    max-width: 500px;
    margin: 10% auto;
    border-radius: 40px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    border: 2px solid #feca57;
}
.winner-name {
    font-size: 2rem;
    font-weight: bold;
    color: #feca57;
    margin: 20px 0;
    text-shadow: 0 0 10px #ff6b6b;
}
.score-table {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
    background: #2e2e42;
    border-radius: 20px;
    overflow: hidden;
}
.score-table th, .score-table td {
    padding: 12px;
    border-bottom: 1px solid #4a4a6a;
}
.score-table th {
    background: #ff6b6b;
    color: white;
}
.winner-row {
    background: #feca57;
    color: #1e1e2f;
    font-weight: bold;
}
.close-winner-btn {
    background: #ff6b6b;
    border: none;
    padding: 12px 30px;
    border-radius: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    margin-top: 20px;
}
.close-winner-btn:hover {
    background: #feca57;
    color: #1e1e2f;
}

#bgCanvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* Анимации появления кнопок */
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fly-in {
    from { opacity: 0; transform: translateY(-120px) rotate(-10deg); }
    to { opacity: 1; transform: translateY(0) rotate(0); }
}
@keyframes bounce-in {
    0% { opacity: 0; transform: translateY(-150px) scale(0.6); }
    60% { opacity: 1; transform: translateY(20px) scale(1.05); }
    80% { transform: translateY(-8px) scale(0.98); }
    100% { transform: translateY(0) scale(1); }
}
@keyframes pop-in {
    0% { opacity: 0; transform: scale(0.3); }
    70% { opacity: 1; transform: scale(1.1); }
    100% { transform: scale(1); }
}

.option-btn.animate-fade { animation: fade-in var(--entrance-duration) ease-out; }
.option-btn.animate-fly-in { animation: fly-in var(--entrance-duration) cubic-bezier(0.34, 1.56, 0.64, 1); }
.option-btn.animate-bounce { animation: bounce-in var(--entrance-duration) ease-out; }
.option-btn.animate-pop { animation: pop-in var(--entrance-duration) ease-out; }

/* Стили для секции настроек анимации */
.animation-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.animation-settings label {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #2e2e42;
    padding: 10px 16px;
    border-radius: 20px;
}
.animation-settings select,
.animation-settings input {
    background: #3a3a55;
    border: none;
    padding: 6px 12px;
    border-radius: 16px;
    color: white;
    flex: 1;
}