/* ===== ГЛОБАЛЬНЫЕ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(145deg, #fce4ec 0%, #f8f0f5 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.container {
    max-width: 560px;
    width: 100%;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    padding: 32px 24px;
    border-radius: 40px;
    box-shadow: 0 20px 60px rgba(190, 130, 160, 0.15);
    text-align: center;
}

/* ===== СТРАНИЦА ВХОДА (index) ===== */
h1 {
    font-size: 2.8rem;
    font-weight: 700;
    color: #3e2c3b;
    margin-bottom: 0.3em;
}

.subtitle {
    font-size: 1.25rem;
    color: #5e4a5a;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

label {
    display: block;
    font-weight: 500;
    color: #3e2c3b;
    margin-bottom: 6px;
}

input[type="text"] {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e8dce4;
    border-radius: 16px;
    font-size: 1rem;
    background: white;
    transition: 0.2s;
    min-height: 54px;
}

input:focus {
    outline: none;
    border-color: #c77d9a;
    box-shadow: 0 0 0 4px rgba(199, 125, 154, 0.15);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #c77d9a;
    color: #fff;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 16px 32px;
    border-radius: 60px;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 8px 20px rgba(199, 125, 154, 0.3);
    min-height: 54px;
    text-decoration: none;
}

.btn:hover {
    transform: scale(1.02);
    box-shadow: 0 12px 28px rgba(199, 125, 154, 0.4);
    background: #b86686;
}

.btn-secondary {
    background: #d4b8c8;
    box-shadow: 0 8px 20px rgba(180, 140, 160, 0.2);
}
.btn-secondary:hover {
    background: #c4a4b8;
}

.divider {
    color: #8f7a8a;
    font-size: 0.9rem;
}

.join-row {
    display: flex;
    gap: 10px;
}
.join-row input {
    flex: 1;
    min-height: 54px;
}
.join-row .btn {
    flex: 0 0 auto;
}

.message {
    margin-top: 16px;
    font-weight: 500;
    min-height: 1.5em;
}

.hint {
    margin-top: 20px;
    font-size: 0.9rem;
    color: #8f7a8a;
}

/* ===== СТРАНИЦА ЛОББИ ===== */

/* Блок имён вверху */
#playersNamesBlock {
    display: none;
    text-align: center;
    font-size: 2.2rem;
    font-weight: 600;
    color: #3e2c3b;
    padding: 14px 20px;
    background: rgba(255,255,255,0.5);
    border-radius: 60px;
    backdrop-filter: blur(8px);
    margin-bottom: 20px;
    border: 1px solid rgba(199,125,154,0.2);
    box-shadow: 0 4px 20px rgba(199,125,154,0.08);
}
#playersNamesBlock .heart {
    color: #e57373;
    margin: 0 10px;
}
#playersNamesBlock span:first-child { color: #c77d9a; }
#playersNamesBlock span:last-child { color: #c77d9a; }

/* Код комнаты с копированием */
.room-code-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(255,255,255,0.5);
    padding: 8px 24px;
    border-radius: 60px;
    backdrop-filter: blur(6px);
    border: 1px solid rgba(199,125,154,0.2);
    margin: 0 auto 20px;
    cursor: pointer;
    position: relative;
    transition: 0.2s;
    user-select: none;
    min-height: 54px;
}
.room-code-wrapper:hover {
    background: rgba(255,255,255,0.8);
    border-color: #c77d9a;
}
.room-code-wrapper:active {
    transform: scale(0.96);
}
.room-code {
    font-size: 1.8rem;
    font-weight: 700;
    color: #3e2c3b;
    letter-spacing: 3px;
    font-family: 'Courier New', monospace;
}
.copy-message {
    position: absolute;
    right: -80px;
    background: #4caf50;
    color: white;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    opacity: 0;
    transform: translateX(10px);
    transition: 0.3s;
    pointer-events: none;
    white-space: nowrap;
}
.copy-message.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Карточки игр */
.mode-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin: 20px 0;
}
.mode-card {
    flex: 1 1 200px;
    max-width: 280px;
    background: white;
    padding: 24px 16px;
    border-radius: 28px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.04);
    transition: 0.25s ease;
    text-align: center;
}
.mode-card .icon {
    font-size: 2.8rem;
    margin-bottom: 12px;
}
.mode-card h3 {
    font-size: 1.2rem;
    color: #3e2c3b;
    margin-bottom: 8px;
}
.mode-card p {
    color: #6a5a66;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 16px;
}
.mode-card .btn {
    font-size: 1rem;
    padding: 12px 24px;
    width: 100%;
}

/* ===== СТРАНИЦА ИГРЫ ===== */
.game-screen {
    display: none;
    animation: fadeIn 0.4s ease;
}
.game-screen.active {
    display: block;
}

#gameTitle {
    font-size: 1.8rem;
    margin-bottom: 8px;
    color: #3e2c3b;
}
#gameHint {
    color: #8f7a8a;
    font-size: 0.95rem;
    margin-bottom: 16px;
}

/* ---------- Бинго сетка 3x3 ---------- */
.bingo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 16px 0;
}

.bingo-cell {
    background: white;
    border-radius: 16px;
    padding: 16px 8px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: #3e2c3b;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 2px solid #e8dce4;
    cursor: pointer;
    transition: 0.2s;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
    user-select: none;
}
.bingo-cell.selected {
    background: #c77d9a;
    border-color: #c77d9a;
    color: white;
}
.bingo-cell:active {
    transform: scale(0.95);
}
.bingo-cell:hover {
    border-color: #c77d9a;
}

/* ---------- Список вопросов ---------- */
.game-item {
    background: white;
    padding: 14px 18px;
    border-radius: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.game-item .item-index {
    font-weight: bold;
    color: #c77d9a;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}
.game-item p {
    flex: 1;
    margin: 0 10px 0 0;
    font-size: 0.95rem;
    color: #3e2c3b;
}
.game-item input[type="text"] {
    flex: 2;
    min-width: 120px;
    border: 1px solid #e8dce4;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.95rem;
    background: white;
    min-height: 44px;
}
.game-item input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: #c77d9a;
    flex-shrink: 0;
}

#submitAnswersBtn {
    margin-top: 20px;
    width: 100%;
}

/* ---------- Результаты ---------- */
#resultContent {
    text-align: left;
    margin: 16px 0;
}
.result-item {
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 16px;
    background: #f5f0f3;
    border-left: 6px solid #c77d9a;
}

/* ---------- Результаты бинго (сетка с цветами) ---------- */
.result-bingo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 16px 0;
}
.result-bingo-cell {
    border-radius: 16px;
    padding: 16px 8px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: #3e2c3b;
    border: 2px solid #ddd;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
    background: #f5f5f5;
    transition: 0.2s;
}
.result-bingo-cell.both {
    background: #a5d6a7;
    border-color: #4caf50;
}
.result-bingo-cell.player1 {
    background: #ef9a9a;
    border-color: #e57373;
}
.result-bingo-cell.player2 {
    background: #90caf9;
    border-color: #42a5f5;
}
.result-bingo-cell.none {
    background: #f5f5f5;
    border-color: #ccc;
}

/* Легенда результатов бинго */
.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 16px 0 8px;
    font-size: 0.85rem;
    color: #3e2c3b;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.legend-color {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}
.legend-color.both { background: #a5d6a7; }
.legend-color.player1 { background: #ef9a9a; }
.legend-color.player2 { background: #90caf9; }
.legend-color.none { background: #f5f5f5; }

#playAgainBtn {
    width: 100%;
    margin-top: 16px;
}

/* ===== АНИМАЦИЯ ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== АДАПТАЦИЯ ПОД ТЕЛЕФОН ===== */
@media (max-width: 600px) {
    .container {
        padding: 24px 16px;
        border-radius: 28px;
    }
    h1 { font-size: 2.2rem; }
    .subtitle { font-size: 1rem; }

    .btn {
        font-size: 1.1rem;
        padding: 16px 24px;
        min-height: 54px;
    }
    input[type="text"] {
        font-size: 1rem;
        padding: 16px 18px;
        min-height: 54px;
    }
    .join-row {
        flex-direction: column;
        gap: 10px;
    }
    .join-row input { width: 100%; }
    .join-row .btn { width: 100%; }

    /* Лобби */
    #playersNamesBlock {
        font-size: 1.6rem;
        padding: 12px 16px;
    }
    .room-code-wrapper {
        padding: 8px 18px;
        min-height: 48px;
    }
    .room-code {
        font-size: 1.5rem;
        letter-spacing: 2px;
    }
    .copy-message {
        right: -60px;
        font-size: 0.75rem;
        padding: 2px 10px;
    }
    .mode-card {
        flex: 1 1 100%;
        max-width: 100%;
        padding: 20px 16px;
    }
    .mode-card .btn {
        font-size: 1.1rem;
        padding: 14px;
    }

    /* Игра */
    .bingo-grid {
        gap: 8px;
    }
    .bingo-cell {
        font-size: 0.8rem;
        padding: 12px 6px;
        border-radius: 12px;
    }
    .game-item {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .game-item p {
        margin: 0;
    }
    .game-item input[type="text"] {
        width: 100%;
        min-width: unset;
    }
    .game-item .item-index {
        text-align: left;
        width: auto;
    }
    .result-bingo-grid {
        gap: 6px;
    }
    .result-bingo-cell {
        font-size: 0.7rem;
        padding: 10px 4px;
        border-radius: 10px;
    }
    .legend {
        font-size: 0.75rem;
        gap: 8px;
    }
}

/* ===== СКРЫТЫЕ БЛОКИ (для отладки) ===== */
#statusBlock {
    display: none;
}
/* Стили для режима "Я выбираю..." */
.choose-item {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
}
.choose-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.choose-option {
    flex: 1 1 calc(50% - 8px);
    background: white;
    border: 2px solid #e8dce4;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #3e2c3b;
    cursor: pointer;
    transition: 0.2s;
    text-align: center;
}
.choose-option.selected {
    background: #c77d9a;
    border-color: #c77d9a;
    color: white;
}
.choose-option:active {
    transform: scale(0.96);
}
@media (max-width: 600px) {
    .choose-option {
        flex: 1 1 100%;
    }
}
/* Для админки */
.btn-danger {
    background: #d9534f !important;
    box-shadow: 0 8px 20px rgba(217,83,79,0.3) !important;
}
.btn-danger:hover {
    background: #c9302c !important;
}
#gameTopic, #resultTopic {
    background: rgba(255,255,255,0.5);
    padding: 8px 16px;
    border-radius: 30px;
    display: inline-block;
    margin-bottom: 12px;
    font-weight: 600;
    color: #c77d9a;
}
/* Сетка 5x5 для бинго */
.bingo-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}
.result-bingo-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}
/* Клетка Free Space в игре */
.bingo-cell.free-space {
    background: #f0e8ec;
    border-color: #d4b8c8;
    color: #8f7a8a;
    cursor: default;
    font-size: 0.8rem;
}
.bingo-cell.free-space:hover {
    border-color: #d4b8c8;
}
/* Клетка Free Space в результатах */
.result-bingo-cell.free-space-result {
    background: #f5f5f5;
    border-color: #ccc;
    color: #999;
    font-size: 1.2rem;
}
/* Адаптация для телефона */
@media (max-width: 600px) {
    .bingo-grid-5 .bingo-cell {
        font-size: 0.7rem;
        padding: 8px 4px;
    }
    .result-bingo-grid-5 .result-bingo-cell {
        font-size: 0.7rem;
        padding: 8px 4px;
    }
}
/* ===== БИНГО 5x5 (уменьшенный размер) ===== */
.bingo-grid-5 {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin: 12px 0 20px 0; /* добавил отступ снизу, чтобы кнопка не перекрывалась */
}
.bingo-grid-5 .bingo-cell {
    padding: 10px 4px;
    font-size: 0.8rem;
    border-radius: 12px;
    min-height: 50px; /* фиксируем минимальную высоту для выравнивания */
}
/* Free Space в игре */
.bingo-grid-5 .bingo-cell.free-space {
    font-size: 0.9rem;
}

/* Результаты бинго 5x5 */
.result-bingo-grid-5 {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin: 12px 0 16px 0;
}
.result-bingo-grid-5 .result-bingo-cell {
    padding: 10px 4px;
    font-size: 0.8rem;
    border-radius: 12px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.result-bingo-grid-5 .result-bingo-cell.free-space-result {
    font-size: 1.2rem;
}

/* Адаптация для телефона */
@media (max-width: 600px) {
    .bingo-grid-5 {
        gap: 4px;
        margin: 8px 0 16px 0;
    }
    .bingo-grid-5 .bingo-cell {
        padding: 6px 2px;
        font-size: 0.55rem;
        border-radius: 8px;
        min-height: 40px;
        line-height: 1.2;
        word-break: break-word;
    }
    .bingo-grid-5 .bingo-cell.free-space {
        font-size: 0.7rem;
    }
    .result-bingo-grid-5 {
        gap: 4px;
        margin: 8px 0 12px 0;
    }
    .result-bingo-grid-5 .result-bingo-cell {
        padding: 6px 2px;
        font-size: 0.55rem;
        border-radius: 8px;
        min-height: 40px;
        line-height: 1.2;
    }
    .result-bingo-grid-5 .result-bingo-cell.free-space-result {
        font-size: 0.8rem;
    }
}

/* Дополнительно: чтобы контейнер не выходил за границы */
#gameItemsContainer {
    overflow-x: auto; /* на случай, если всё-таки не влезает */
    -webkit-overflow-scrolling: touch;
}
/* ===== ЭКРАН ВСТУПЛЕНИЯ ===== */
.intro-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}
.intro-screen.active {
    opacity: 1;
    pointer-events: auto;
}
/* скрытый intro не занимает место (управляется через display: none в JS) */
.intro-content {
    text-align: center;
    animation: introPop 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.intro-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}
.intro-title {
    font-size: 2.4rem;
    font-weight: 700;
    color: #3e2c3b;
    margin-bottom: 0.3rem;
}
.intro-topic {
    font-size: 1.2rem;
    color: #c77d9a;
    font-weight: 500;
}

@keyframes introPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
/* Статус выбора в лобби */
#selectionStatus {
    background: rgba(255,255,255,0.4);
    padding: 12px 16px;
    border-radius: 30px;
    margin: 8px 0 16px;
    text-align: left;
    font-size: 0.95rem;
    color: #3e2c3b;
}
#selectionStatus div {
    margin: 4px 0;
}
#countdownDisplay {
    background: rgba(199,125,154,0.1);
    padding: 10px;
    border-radius: 60px;
    margin: 10px 0;
    text-align: center;
    border: 1px solid #c77d9a;
}
#countdownSeconds {
    font-size: 2.5rem;
    color: #c77d9a;
}
/* Подсветка карточки, которую выбрал партнёр */
.mode-card.selected-by-partner {
    border: 3px solid #c77d9a;
    background: #fce8f0;
    box-shadow: 0 0 20px rgba(199,125,154,0.3);
}
.mode-card.selected-by-partner .btn {
    opacity: 0.6;
    pointer-events: none;
}
.mode-card .partner-badge {
    display: none;
    font-weight: 500;
}
.mode-card.selected-by-partner .partner-badge {
    display: block;
}
/* Подсветка карточки, которую выбрал партнёр */
.mode-card.selected-by-partner {
    border: 3px solid #c77d9a;
    background: #fce8f0;
    box-shadow: 0 0 20px rgba(199,125,154,0.3);
}
.mode-card .partner-badge {
    display: none;
    font-weight: 500;
}
.mode-card.selected-by-partner .partner-badge {
    display: block;
}
/* Кнопки остаются активными, даже если карточка подсвечена */
.mode-card.selected-by-partner .btn {
    opacity: 1;
    pointer-events: auto;
}
/* Рейтинг звёздами */
#starRating span {
    display: inline-block;
    transition: 0.2s;
    user-select: none;
}
#starRating span:hover {
    transform: scale(1.15);
}
#ratingText {
    transition: 0.2s;
}
.about-link {
    display: inline-block;
    color: #8f7a8a;
    font-size: 0.95rem;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 30px;
    transition: 0.2s;
    background: rgba(255,255,255,0.3);
}
.about-link:hover {
    background: rgba(255,255,255,0.6);
    color: #c77d9a;
}
.room-code-label {
    font-weight: 500;
    color: #3e2c3b;
    font-size: 1rem;
    margin-right: 4px;
}
