* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(180deg, #000000 0%, #4a0e0e 50%, #8b0000 100%);
    min-height: 100vh;
    overflow: hidden;
    color: #fff;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(255, 0, 68, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(138, 43, 226, 0.15) 0%, transparent 50%);
    pointer-events: none;
}

.game-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Game header */
.game-header {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 10;
    max-width: 90%;
}

.game-title {
    font-size: 36px;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 40px rgba(220, 20, 60, 0.6),
        2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
    animation: glow-title 2s ease-in-out infinite;
}

@keyframes glow-title {
    0%, 100% { text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 40px rgba(220, 20, 60, 0.6), 2px 2px 4px rgba(0, 0, 0, 0.8); }
    50% { text-shadow: 0 0 30px rgba(255, 215, 0, 1), 0 0 60px rgba(220, 20, 60, 0.8), 2px 2px 4px rgba(0, 0, 0, 0.8); }
}

.game-subtitle {
    font-size: 18px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    font-style: italic;
}

/* Model background */
.model-background {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    margin-top: -30px;
}

.model-frame {
    width: 400px;
    height: 550px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 
        0 0 60px rgba(220, 20, 60, 0.4),
        0 20px 60px rgba(0, 0, 0, 0.6);
    border: 3px solid rgba(255, 215, 0, 0.3);
    position: relative;
}

.model-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    transition: opacity 1s ease;
}

.model-image.visible {
    opacity: 1;
}

.model-image.hot {
    opacity: 1;
}

/* Dice container */
.dice-container {
    position: absolute;
    top: 50%;
    right: 8%;
    transform: translateY(-50%);
    z-index: 5;
    perspective: 1000px;
}

.dice {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-20deg) rotateY(-20deg);
    transition: transform 1s ease-out;
}

.dice.rolling {
    animation: roll 1s ease-out;
}

@keyframes roll {
    0% { transform: rotateX(-20deg) rotateY(-20deg); }
    100% { transform: rotateX(720deg) rotateY(720deg); }
}

.face {
    position: absolute;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #dc143c 0%, #8b0000 100%);
    border: 2px solid #ffd700;
    border-radius: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
    align-items: center;
    padding: 10px;
    box-shadow: 
        0 0 20px rgba(220, 20, 60, 0.5),
        inset 0 0 10px rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
}

.dot {
    width: 16px;
    height: 16px;
    background: radial-gradient(circle, #fff, #ffd700);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
}

/* Face positioning - translateZ должен быть ровно половина размера грани */
.front  { transform: rotateY(0deg) translateZ(50px); }
.back   { transform: rotateY(180deg) translateZ(50px); }
.right  { transform: rotateY(90deg) translateZ(50px); }
.left   { transform: rotateY(-90deg) translateZ(50px); }
.top    { transform: rotateX(90deg) translateZ(50px); }
.bottom { transform: rotateX(-90deg) translateZ(-50px); }

/* Dot patterns */
.front {
    display: grid;
    place-items: center;
}

.back {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 15px;
}
.back .dot:nth-child(1) { justify-self: start; align-self: start; }
.back .dot:nth-child(2) { justify-self: end; align-self: end; }

.right {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    padding: 15px;
}
.right .dot:nth-child(1) { justify-self: start; align-self: start; }
.right .dot:nth-child(2) { justify-self: center; align-self: center; }
.right .dot:nth-child(3) { justify-self: end; align-self: end; }

.left {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    padding: 15px;
}

.top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    padding: 15px;
    position: relative;
}
.top .dot:nth-child(1) { justify-self: start; align-self: start; }
.top .dot:nth-child(2) { justify-self: end; align-self: start; }
.top .dot:nth-child(3) { 
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.top .dot:nth-child(4) { justify-self: start; align-self: end; }
.top .dot:nth-child(5) { justify-self: end; align-self: end; }

.bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    padding: 12px;
}
.bottom .dot:nth-child(1) { justify-self: start; align-self: start; }
.bottom .dot:nth-child(2) { justify-self: end; align-self: start; }
.bottom .dot:nth-child(3) { justify-self: start; align-self: center; }
.bottom .dot:nth-child(4) { justify-self: end; align-self: center; }
.bottom .dot:nth-child(5) { justify-self: start; align-self: end; }
.bottom .dot:nth-child(6) { justify-self: end; align-self: end; }

/* Dice faces positioning */
.face {
    transform-origin: center center;
}

/* Roll button */
.roll-button {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700 0%, #ff8c00 100%);
    border: 4px solid #dc143c;
    cursor: pointer;
    font-size: 28px;
    font-weight: 900;
    color: #8b0000;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    box-shadow: 
        0 0 40px rgba(255, 215, 0, 0.6),
        0 10px 30px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 40px rgba(255, 215, 0, 0.6), 0 10px 30px rgba(0, 0, 0, 0.5); }
    50% { box-shadow: 0 0 60px rgba(255, 215, 0, 0.9), 0 10px 30px rgba(0, 0, 0, 0.5); }
}

.roll-button:hover {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 0 60px rgba(255, 215, 0, 0.9), 0 15px 40px rgba(0, 0, 0, 0.6);
}

.roll-button:active {
    transform: translateX(-50%) scale(0.95);
    background: linear-gradient(135deg, #ff8c00 0%, #ffd700 100%);
}

.roll-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
}

/* Roll counter */
.roll-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 5;
}

.counter-dice {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    transition: all 0.3s ease;
    display: grid;
    place-items: center;
    position: relative;
}

.counter-dice.active {
    background: linear-gradient(135deg, rgba(220, 20, 60, 0.9) 0%, rgba(139, 0, 0, 0.9) 100%);
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

.counter-dice .mini-dots {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
}

.counter-dice.active .mini-dots {
    display: grid;
    place-items: center;
}

.mini-dot {
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, #fff 0%, #ffd700 100%);
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(255, 215, 0, 0.8);
    display: none;
}

/* Mini dice patterns */
.counter-dice[data-value="1"] .mini-dots {
    display: grid;
    place-items: center;
}
.counter-dice[data-value="1"] .mini-dots .mini-dot:nth-child(1) { display: block; }

.counter-dice[data-value="2"] .mini-dots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 8px;
}
.counter-dice[data-value="2"] .mini-dots .mini-dot:nth-child(1) { display: block; justify-self: start; align-self: start; }
.counter-dice[data-value="2"] .mini-dots .mini-dot:nth-child(2) { display: block; justify-self: end; align-self: end; }

.counter-dice[data-value="3"] .mini-dots {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    padding: 8px;
}
.counter-dice[data-value="3"] .mini-dots .mini-dot:nth-child(1) { display: block; justify-self: start; align-self: start; }
.counter-dice[data-value="3"] .mini-dots .mini-dot:nth-child(2) { display: block; justify-self: center; align-self: center; }
.counter-dice[data-value="3"] .mini-dots .mini-dot:nth-child(3) { display: block; justify-self: end; align-self: end; }

.counter-dice[data-value="4"] .mini-dots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    padding: 8px;
}
.counter-dice[data-value="4"] .mini-dots .mini-dot:nth-child(1) { display: block; justify-self: start; align-self: start; }
.counter-dice[data-value="4"] .mini-dots .mini-dot:nth-child(2) { display: block; justify-self: end; align-self: start; }
.counter-dice[data-value="4"] .mini-dots .mini-dot:nth-child(3) { display: block; justify-self: start; align-self: end; }
.counter-dice[data-value="4"] .mini-dots .mini-dot:nth-child(4) { display: block; justify-self: end; align-self: end; }

.counter-dice[data-value="5"] .mini-dots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    padding: 8px;
    position: relative;
}
.counter-dice[data-value="5"] .mini-dots .mini-dot:nth-child(1) { display: block; justify-self: start; align-self: start; }
.counter-dice[data-value="5"] .mini-dots .mini-dot:nth-child(2) { display: block; justify-self: end; align-self: start; }
.counter-dice[data-value="5"] .mini-dots .mini-dot:nth-child(3) { 
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.counter-dice[data-value="5"] .mini-dots .mini-dot:nth-child(4) { display: block; justify-self: start; align-self: end; }
.counter-dice[data-value="5"] .mini-dots .mini-dot:nth-child(5) { display: block; justify-self: end; align-self: end; }

.counter-dice[data-value="6"] .mini-dots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    padding: 6px;
}
.counter-dice[data-value="6"] .mini-dots .mini-dot:nth-child(1) { display: block; justify-self: start; align-self: start; }
.counter-dice[data-value="6"] .mini-dots .mini-dot:nth-child(2) { display: block; justify-self: end; align-self: start; }
.counter-dice[data-value="6"] .mini-dots .mini-dot:nth-child(3) { display: block; justify-self: start; align-self: center; }
.counter-dice[data-value="6"] .mini-dots .mini-dot:nth-child(4) { display: block; justify-self: end; align-self: center; }
.counter-dice[data-value="6"] .mini-dots .mini-dot:nth-child(5) { display: block; justify-self: start; align-self: end; }
.counter-dice[data-value="6"] .mini-dots .mini-dot:nth-child(6) { display: block; justify-self: end; align-self: end; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
    animation: fadeIn 0.5s ease;
}

.modal-overlay.show {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, #1a0a0a 0%, #4a0e0e 100%);
    padding: 50px 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 550px;
    width: 90%;
    border: 3px solid rgba(220, 20, 60, 0.6);
    box-shadow: 0 20px 60px rgba(220, 20, 60, 0.5);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-icon {
    font-size: 72px;
    margin-bottom: 25px;
    animation: spin 3s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.modal-content h2 {
    font-size: 32px;
    font-weight: 700;
    color: #ffd700;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.modal-content p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 17px;
    margin-bottom: 15px;
    line-height: 1.7;
}

.modal-highlight {
    font-size: 18px;
    font-weight: 600;
    color: #ff6b6b;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
}

.modal-button {
    padding: 18px 35px;
    border-radius: 25px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    color: white;
}

.modal-button-confirm {
    background: linear-gradient(135deg, #dc143c 0%, #8b0000 100%);
    box-shadow: 0 8px 20px rgba(220, 20, 60, 0.4);
}

.modal-button-confirm:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(220, 20, 60, 0.6);
}

.modal-button-leave {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.modal-button-leave:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Responsive */
@media (max-width: 768px) {
    .game-title {
        font-size: 28px;
    }
    
    .game-subtitle {
        font-size: 16px;
    }
    
    .model-frame {
        width: 320px;
        height: 450px;
    }
    
    .dice-container {
        right: 5%;
    }
    
    .dice { width: 80px; height: 80px; }
    .face { width: 80px; height: 80px; padding: 8px; }
    .dot { width: 12px; height: 12px; }
    
    /* Обновляем translateZ для нового размера (половина от 80px = 40px) */
    .front  { transform: rotateY(0deg) translateZ(40px); }
    .back   { transform: rotateY(180deg) translateZ(40px); }
    .right  { transform: rotateY(90deg) translateZ(40px); }
    .left   { transform: rotateY(-90deg) translateZ(40px); }
    .top    { transform: rotateX(90deg) translateZ(40px); }
    .bottom { transform: rotateX(-90deg) translateZ(-40px); }
    
    .roll-button { width: 150px; height: 150px; font-size: 24px; }
}

@media (max-width: 480px) {
    .game-header {
        top: 20px;
    }
    
    .game-title {
        font-size: 24px;
    }
    
    .game-subtitle {
        font-size: 14px;
    }
    
    .model-frame {
        width: 280px;
        height: 400px;
    }
    
    .dice-container {
        top: 22%;
        right: 50%;
        transform: translate(50%, -50%);
    }
    
    .dice { width: 70px; height: 70px; }
    .face { width: 70px; height: 70px; padding: 6px; border-radius: 8px; }
    .dot { width: 10px; height: 10px; }
    
    /* Обновляем translateZ для нового размера (половина от 70px = 35px) */
    .front  { transform: rotateY(0deg) translateZ(35px); }
    .back   { transform: rotateY(180deg) translateZ(35px); }
    .right  { transform: rotateY(90deg) translateZ(35px); }
    .left   { transform: rotateY(-90deg) translateZ(35px); }
    .top    { transform: rotateX(90deg) translateZ(35px); }
    .bottom { transform: rotateX(-90deg) translateZ(-35px); }
    
    .roll-button { width: 130px; height: 130px; font-size: 20px; bottom: 100px; }
    .counter-dice { width: 35px; height: 35px; }
    .mini-dot { width: 6px; height: 6px; }
}
