/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e1e2e 0%, #2a2a3e 100%);
    color: #cdd6f4;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.page {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Кнопки */
button {
    cursor: pointer;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: inherit;
}

.primary-btn {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(167, 139, 250, 0.4);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(167, 139, 250, 0.6);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-btn {
    background: #313244;
    color: #cdd6f4;
    border: 2px solid #45475a;
}

.secondary-btn:hover {
    background: #45475a;
    border-color: #585b70;
}

/* Инпуты */
input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #45475a;
    background: #313244;
    color: #cdd6f4;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    font-family: inherit;
}

input[type="text"]:focus {
    outline: none;
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.2);
}

input[type="text"]::placeholder {
    color: #6c7086;
}

/* Страница лобби */
.lobby-container {
    background: #313244;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
}

.lobby-container h1 {
    text-align: center;
    margin-bottom: 40px;
    font-size: 36px;
    background: linear-gradient(135deg, #a78bfa 0%, #f38ba8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lobby-section {
    margin-bottom: 30px;
}

.lobby-section h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #a78bfa;
}

.lobby-section input {
    margin-bottom: 15px;
}

.lobby-divider {
    text-align: center;
    margin: 30px 0;
    position: relative;
}

.lobby-divider::before,
.lobby-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 2px;
    background: #45475a;
}

.lobby-divider::before {
    left: 0;
}

.lobby-divider::after {
    right: 0;
}

.lobby-divider span {
    background: #313244;
    padding: 0 15px;
    color: #6c7086;
    font-weight: 600;
}

/* Страница комнаты */
.room-container {
    background: #313244;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
}

.room-header {
    text-align: center;
    margin-bottom: 30px;
}

.room-header h1 {
    font-size: 32px;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #a78bfa 0%, #f38ba8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.room-id {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: #1e1e2e;
    border-radius: 8px;
    border: 2px solid #45475a;
}

.room-id strong {
    font-size: 24px;
    letter-spacing: 3px;
    color: #a78bfa;
}

.room-content h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #a78bfa;
}

.players-section {
    margin-bottom: 30px;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #1e1e2e;
    border-radius: 8px;
    border: 2px solid #45475a;
}

.player-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.host-badge {
    font-size: 18px;
}

.kick-btn {
    padding: 6px 12px;
    font-size: 14px;
    background: #f38ba8;
    color: white;
    border-radius: 6px;
}

.kick-btn:hover {
    background: #f27397;
}

.room-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Страница игры */
.game-container {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 20px;
    width: 100%;
    max-width: 1800px;
    padding: 20px;
    min-height: 100vh; /* ВАЖНО для мобильки */
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.game-info-card {
    background: #313244;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.game-info-card h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #a78bfa;
    border-bottom: 2px solid #45475a;
    padding-bottom: 8px;
}

.room-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.room-info strong {
    font-size: 20px;
    color: #a78bfa;
    letter-spacing: 2px;
}

/* Игроки в игре */
.players-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #1e1e2e;
    border-radius: 8px;
    border: 2px solid #45475a;
    position: relative;
    transition: all 0.3s ease;
}

.player-card.active {
    border-color: #a78bfa;
    box-shadow: 0 0 20px rgba(167, 139, 250, 0.3);
}

.player-card.you {
    background: rgba(167, 139, 250, 0.1);
}

.player-color {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-badge {
    font-size: 10px;
    padding: 2px 6px;
    background: #a78bfa;
    color: white;
    border-radius: 4px;
}

.player-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-top: 6px;
    font-size: 11px;
    color: #9399b2;
}

.player-turn-indicator {
    position: absolute;
    right: 12px;
    font-size: 20px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

/* Кубики */
.dice-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 15px;
}

.dice {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 15px rgba(167, 139, 250, 0.4);
    transition: all 0.3s ease;
    opacity: 1; /* ВАЖНО: всегда видимы */
    /* УБРАЛИ display: none или opacity: 0 */
}

.dice.used {
    opacity: 0.6; /* Просто затемняем, НЕ скрываем */
    filter: grayscale(0.3);
}

.dice.roll {
    animation: rollDice 0.8s ease-in-out;
}

@keyframes rollDice {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    50% { transform: rotate(180deg); }
    75% { transform: rotate(270deg); }
}

/* Доска */
.game-board-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

.canvas-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    background: #1e1e2e;
}

/* История */
.history-box {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    padding: 8px 12px;
    background: #1e1e2e;
    border-radius: 6px;
    font-size: 13px;
    color: #9399b2;
    border-left: 3px solid #a78bfa;
}

/* Чат */
.chat-messages {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.chat-message {
    padding: 8px 12px;
    background: #1e1e2e;
    border-radius: 6px;
    font-size: 13px;
    word-wrap: break-word;
}

.chat-message strong {
    color: #a78bfa;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
}

.chat-input-wrapper input {
    flex: 1;
}

.chat-input-wrapper button {
    padding: 12px 16px;
}

/* Скроллбары */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1e1e2e;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #585b70;
}

/* Модальное окно победы */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: #313244;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 90%;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 32px;
    background: linear-gradient(135deg, #f9e2af 0%, #f38ba8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.modal-body {
    text-align: center;
    margin-bottom: 30px;
}

.modal-body p {
    font-size: 16px;
    color: #9399b2;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-actions button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

/* Уведомление о компенсационном ходе */
.compensation-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f9e2af 0%, #f38ba8 100%);
    color: #1e1e2e;
    padding: 16px 32px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(249, 226, 175, 0.5);
    font-weight: 600;
    font-size: 16px;
    z-index: 999;
    animation: slideDown 0.3s ease, fadeOut 0.3s ease 2.7s;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Адаптивность */
@media (max-width: 1400px) {
    .game-container {
        grid-template-columns: 260px 1fr 260px;
        gap: 15px;
    }
}

@media (max-width: 1200px) {
    .game-container {
        grid-template-columns: 240px 1fr 240px;
        gap: 10px;
    }
}

@media (max-width: 1024px) {
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
        padding: 10px;
    }
    
    .game-sidebar {
        flex-direction: row !important;
        gap: 10px;
        overflow-x: auto;
        padding: 10px 0;
    }
    
    .game-info-card {
        min-width: 280px;
        flex-shrink: 0;
    }
    
    .canvas-wrapper {
        height: 70vh;
        max-height: 500px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .game-container {
        padding: 5px;
        gap: 5px;
    }
    
    .game-sidebar {
        flex-direction: column !important;
        overflow: visible;
    }
    
    .game-info-card {
        min-width: auto;
        padding: 15px;
    }
    
    .dice {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    #game-canvas {
        max-width: 100%;
        height: auto;
    }
    
    .canvas-wrapper {
        height: 60vh;
    }
    
    .lobby-container,
    .room-container {
        padding: 20px;
        margin: 10px;
    }
    
    .lobby-container h1 {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .dice {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .player-color {
        width: 35px;
        height: 35px;
    }
    
    .game-info-card h3 {
        font-size: 14px;
    }
    
    .modal-actions button {
        padding: 12px;
        font-size: 14px;
    }
    
    .compensation-notification {
        font-size: 13px;
        padding: 12px 20px;
        left: 10px;
        right: 10px;
        transform: none;
        width: calc(100% - 20px);
    }
}

/* Уведомление о наказании */
.punishment-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #f38ba8 0%, #eba0ac 100%);
    color: #1e1e2e;
    padding: 30px 50px;
    border-radius: 15px;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 10px 40px rgba(243, 139, 168, 0.5);
    z-index: 10000;
    animation: punishmentPop 0.5s ease-out;
    text-align: center;
}

@keyframes punishmentPop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Стили для отключенной кнопки */
button:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background: #45475a !important;
}

button:disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Стиль для кнопки старта с счетчиком игроков */
#start-game-btn {
    transition: all 0.3s ease;
}
.sound-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.4);
    padding: 6px 10px;
    border-radius: 8px;
}

.sound-controls button {
    font-size: 18px;
    cursor: pointer;
    background: none;
    border: none;
    color: white;
}

.sound-controls input[type="range"] {
    width: 100px;
}
/* === SOUND CONTROLS FIX FOR MOBILE === */
@media (max-width: 768px) {
    .sound-controls {
        position: fixed;
        bottom: 70px; /* выше нижних элементов */
        right: 10px;
        z-index: 1000;
        background: rgba(0, 0, 0, 0.7);
    }
}
@media (max-width: 768px) {
    .game-sidebar.right .game-info-card:nth-child(2) {
        display: none; /* скрываем чат */
    }
}
/* ===== MOBILE ELEMENTS HIDDEN ON DESKTOP ===== */
.mobile-only,
#mobile-overlay {
    display: none;
}
