* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.btn:active {
    transform: translateY(0);
}

.score {
    background: rgba(255,255,255,0.2);
    padding: 10px 20px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    backdrop-filter: blur(10px);
}

.size-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.2);
    padding: 10px 15px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.size-selector label {
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
}

.size-select {
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 15px;
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
}

.size-select:hover {
    background: white;
    transform: translateY(-1px);
}

.size-select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(116, 185, 255, 0.5);
}

.game-board {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
}

.main-area {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.horizontal-sums {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    justify-content: center;
}

.vertical-sums {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}

.sum-cell {
    width: 50px;
    height: 50px;
    background: linear-gradient(45deg, #74b9ff, #0984e3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.grid-container {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.game-grid {
    display: grid;
    gap: 5px;
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    --grid-size: 4;
}

.grid-cell {
    width: var(--cell-size, 60px);
    height: var(--cell-size, 60px);
    border: 2px solid #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell-size, 60px) * 0.25);
    font-weight: bold;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.grid-cell:hover {
    background: #e9ecef;
    border-color: #74b9ff;
}

.grid-cell.filled {
    background: linear-gradient(45deg, #a29bfe, #6c5ce7);
    color: white;
    border-color: #6c5ce7;
}

.grid-cell.correct {
    background: linear-gradient(45deg, #00b894, #00a085);
    border-color: #00b894;
    cursor: grab;
}

.grid-cell.correct:active {
    cursor: grabbing;
}

.grid-cell.incorrect {
    background: linear-gradient(45deg, #d63031, #c0392b);
    border-color: #d63031;
    cursor: grab;
}

.grid-cell.incorrect:active {
    cursor: grabbing;
}

.pieces-container {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    margin-bottom: 20px;
}

.pieces-container h3 {
    color: white;
    margin-bottom: 15px;
    text-align: center;
}

.pieces-area {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

.piece {
    width: var(--cell-size, 60px);
    height: var(--cell-size, 60px);
    background: linear-gradient(45deg, #fdcb6e, #e17055);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell-size, 60px) * 0.25);
    font-weight: bold;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    user-select: none;
}

.piece:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.piece:active {
    cursor: grabbing;
}

.piece.used {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(0.8);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 15px;
    width: 80%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    margin-top: -20px;
    margin-right: -20px;
}

.close:hover {
    color: #000;
}

.modal h2 {
    margin-bottom: 20px;
    color: #333;
}

.modal p {
    margin-bottom: 25px;
    font-size: 1.1rem;
    color: #666;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .game-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .main-area {
        flex-direction: column;
        align-items: center;
    }
    
    .grid-cell, .piece {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .sum-cell {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .size-selector {
        flex-direction: column;
        gap: 5px;
    }
}

/* Адаптивность для больших полей */
@media (max-width: 480px) {
    .grid-cell, .piece {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .sum-cell {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
}

/* Анимации */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.correct {
    animation: pulse 0.5s ease;
}

/* Эффект перетаскивания */
.dragging {
    opacity: 0.7;
    transform: rotate(5deg);
}

.drop-zone {
    background: rgba(116, 185, 255, 0.3) !important;
    border-color: #74b9ff !important;
}

/* Выровнять суммы по центру */
.horizontal-sums.top-sums {
    display: grid;
    grid-template-columns: repeat(var(--grid-size, 4), 1fr);
    gap: 10px;
    margin: 10px 0;
    justify-items: center;
}

.vertical-sums.right-sums {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
    align-items: center;
    height: 100%;
} 