* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #0f172a;
    color: #e2e8f0;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

.title {
    text-align: center;
    margin: 20px 0 16px;
    font-size: 30px;
    letter-spacing: 2px;
    color: #00ff99;
    text-shadow: 0 0 20px #00ff9966;
}

.container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 32px;
    padding: 0 20px 40px;
}

.game-box {
    padding: 8px;
    background: #020617;
    border-radius: 14px;
    box-shadow: 0 0 30px rgba(0, 255, 153, 0.15), 0 0 60px rgba(0,0,0,0.6);
    border: 1px solid #1e3a5f;
    flex-shrink: 0;
}

canvas {
    display: block;
    border-radius: 8px;
    background: #000;
    width: 720px;
    height: 720px;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 210px;
    flex-shrink: 0;
}

.card {
    background: #0c1a2e;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #1e3a5f;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.card h2 {
    margin: 0 0 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #64748b;
}

.info p {
    margin: 4px 0;
    font-size: 16px;
    font-weight: bold;
    color: #e2e8f0;
}

.level {
    display: flex;
    flex-direction: column;
}

.level .buttons {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-bottom: 8px;
}

.level .buttons button {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 14px;
    font-weight: bold;
}

.level-desc {
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #94a3b8;
    margin: 4px 0;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.speed-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.speed-control span {
    min-width: 44px;
    text-align: center;
    font-weight: bold;
    font-size: 15px;
    color: #00ff99;
}

.speed-control button {
    width: 46px;
    height: 36px;
    padding: 0;
    font-size: 12px;
    font-weight: bold;
}

button {
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
}

button:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #16a34a, #15803d);
}

button.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 0 10px #f59e0b66;
}

#toggleSound {
    width: 100%;
    font-size: 12px;
    padding: 8px;
}

.gameover {
    text-align: center;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.gameover h2 {
    margin: 0;
    font-size: 20px;
    color: #ef4444;
    text-transform: none;
    letter-spacing: 0;
}

.gameover p {
    margin: 0;
    font-size: 13px;
    color: #94a3b8;
}

.gameover button {
    width: 100%;
    font-size: 14px;
    margin-top: 4px;
}

@media (max-width: 880px) {
    .container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    canvas {
        width: min(96vw, 600px);
        height: min(96vw, 600px);
    }

    .panel {
        width: min(96vw, 600px);
        flex-direction: row;
        flex-wrap: wrap;
    }

    .panel .card {
        flex: 1 1 140px;
    }
}