* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    max-width: 600px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 30px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: #333;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    justify-content: space-around;
    font-size: 1.2rem;
    font-weight: bold;
    color: #555;
}

.operations-left, .score {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.game-board {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 8px;
    background: #333;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.block {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.1),
        inset 0 2px 4px rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 2px solid #ddd;
}

.block.can-trigger {
    background: linear-gradient(145deg, #a8e6a3, #81c784);
    border-color: #4caf50;
    box-shadow: 
        0 4px 8px rgba(76, 175, 80, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.8);
}

.block.cannot-trigger {
    background: linear-gradient(145deg, #bdbdbd, #9e9e9e);
    border-color: #757575;
    box-shadow: 
        0 4px 8px rgba(158, 158, 158, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.6);
}

.block:hover {
    transform: scale(1.05);
}

.block:hover:not(.can-trigger):not(.cannot-trigger) {
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.15),
        inset 0 2px 4px rgba(255, 255, 255, 0.9);
}

.block.can-trigger:hover {
    box-shadow: 
        0 6px 12px rgba(76, 175, 80, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.9);
}

.block.cannot-trigger:hover {
    box-shadow: 
        0 6px 12px rgba(158, 158, 158, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.7);
}

.block.active {
    background: linear-gradient(145deg, #ff6b6b, #ff5722);
    border-color: #d32f2f;
    animation: glow 0.6s ease;
}

.block.chain-active {
    background: linear-gradient(145deg, #42a5f5, #1976d2);
    border-color: #0d47a1;
    animation: chainReaction 0.4s ease;
}

.arrow {
    position: absolute;
    width: 2px;
    height: 20px;
    background: #d32f2f;
    border-radius: 1px;
    transform-origin: center center;
}

.arrow.up {
    transform: rotate(0deg);
    top: 10px;
    left: 50%;
    margin-left: -1px;
}

.arrow.right {
    transform: rotate(90deg);
    top: 50%;
    left: 30px;
    margin-top: -10px;
}

.arrow.down {
    transform: rotate(180deg);
    top: 30px;
    left: 50%;
    margin-left: -1px;
}

.arrow.left {
    transform: rotate(270deg);
    top: 50%;
    left: 10px;
    margin-top: -10px;
}

@keyframes glow {
    0%, 100% {
        box-shadow: 
            0 4px 8px rgba(0, 0, 0, 0.1),
            inset 0 2px 4px rgba(255, 255, 255, 0.8);
    }
    50% {
        box-shadow: 
            0 0 20px rgba(255, 107, 107, 0.8),
            inset 0 2px 4px rgba(255, 255, 255, 0.9);
    }
}

@keyframes chainReaction {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(45deg, #42a5f5, #2196f3);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(66, 165, 245, 0.4);
}

.btn-secondary {
    background: linear-gradient(45deg, #78909c, #607d8b);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(120, 144, 156, 0.4);
}

.speed-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    color: #555;
}

.speed-selector select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 20px;
    font-size: 1rem;
    background: white;
    outline: none;
    cursor: pointer;
}

.rules {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
    padding: 20px;
    margin-top: 30px;
}

.rules h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.rules ul {
    list-style: none;
    padding: 0;
}

.rules li {
    background: rgba(255, 255, 255, 0.7);
    margin: 8px 0;
    padding: 10px 15px;
    border-radius: 20px;
    border-left: 4px solid #42a5f5;
    color: #555;
}

.rules li::before {
    content: '➤ ';
    color: #42a5f5;
    font-weight: bold;
}

.message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px 40px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    z-index: 1000;
    animation: messageShow 0.5s ease;
}

.message.hidden {
    display: none;
}

.message.success {
    background: linear-gradient(45deg, #4caf50, #45a049);
}

.message.error {
    background: linear-gradient(45deg, #f44336, #d32f2f);
}

@keyframes messageShow {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@media (max-width: 600px) {
    .game-container {
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .block {
        width: 50px;
        height: 50px;
    }
    
    .grid-container {
        padding: 15px;
        gap: 6px;
    }
    
    .controls {
        flex-direction: column;
        gap: 15px;
    }
}