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

body {
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height: 100vh;
    overflow: hidden;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Кнопка закриття */
.close-button {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    text-decoration: none;
}

.close-button:hover {
    transform: scale(1.15) rotate(90deg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    background: #ff6b6b;
}

.close-button svg {
    width: 30px;
    height: 30px;
    stroke: #333;
    transition: stroke 0.3s ease;
}

.close-button:hover svg {
    stroke: white;
}

.close-button:active {
    transform: scale(1.05) rotate(90deg);
}

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.title {
    text-align: center;
    color: white;
    font-size: 36px;
    margin-bottom: 15px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    animation: float 3s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.instruments-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 15px;
    padding: 10px;
    flex: 1;
    max-height: calc(100vh - 100px);
}

.instrument {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 15px 10px;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.instrument::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8), transparent);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    pointer-events: none;
    opacity: 0;
}

.instrument:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.instrument.playing {
    animation: pulse 0.5s ease-in-out infinite alternate;
    box-shadow:
        0 0 30px rgba(255, 107, 107, 0.6),
        0 0 60px rgba(255, 107, 107, 0.4),
        0 0 90px rgba(255, 107, 107, 0.2),
        0 15px 40px rgba(0, 0, 0, 0.4);
}

.instrument.playing::before {
    width: 300px;
    height: 300px;
    opacity: 1;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.08);
    }
}

/* Унікальні кольори для кожного інструменту */
.instrument[data-instrument="drum"].playing {
    box-shadow:
        0 0 30px rgba(255, 107, 107, 0.8),
        0 0 60px rgba(255, 107, 107, 0.6),
        0 0 90px rgba(255, 107, 107, 0.4);
}

.instrument[data-instrument="guitar"].playing {
    box-shadow:
        0 0 30px rgba(212, 165, 116, 0.8),
        0 0 60px rgba(212, 165, 116, 0.6),
        0 0 90px rgba(212, 165, 116, 0.4);
}

.instrument[data-instrument="piano"].playing {
    box-shadow:
        0 0 30px rgba(100, 100, 255, 0.8),
        0 0 60px rgba(100, 100, 255, 0.6),
        0 0 90px rgba(100, 100, 255, 0.4);
}

.instrument[data-instrument="violin"].playing {
    box-shadow:
        0 0 30px rgba(139, 69, 19, 0.8),
        0 0 60px rgba(139, 69, 19, 0.6),
        0 0 90px rgba(139, 69, 19, 0.4);
}

.instrument[data-instrument="trumpet"].playing {
    box-shadow:
        0 0 30px rgba(255, 215, 0, 0.8),
        0 0 60px rgba(255, 215, 0, 0.6),
        0 0 90px rgba(255, 215, 0, 0.4);
}

.instrument[data-instrument="xylophone"].playing {
    box-shadow:
        0 0 30px rgba(255, 0, 255, 0.8),
        0 0 60px rgba(255, 0, 255, 0.6),
        0 0 90px rgba(255, 0, 255, 0.4);
}

.instrument[data-instrument="tambourine"].playing {
    box-shadow:
        0 0 30px rgba(255, 165, 0, 0.8),
        0 0 60px rgba(255, 165, 0, 0.6),
        0 0 90px rgba(255, 165, 0, 0.4);
}

.instrument[data-instrument="maracas"].playing {
    box-shadow:
        0 0 30px rgba(78, 205, 196, 0.8),
        0 0 60px rgba(78, 205, 196, 0.6),
        0 0 90px rgba(78, 205, 196, 0.4);
}

.instrument[data-instrument="flute"].playing {
    box-shadow:
        0 0 30px rgba(192, 192, 192, 0.8),
        0 0 60px rgba(192, 192, 192, 0.6),
        0 0 90px rgba(192, 192, 192, 0.4);
}

.instrument[data-instrument="saxophone"].playing {
    box-shadow:
        0 0 30px rgba(218, 165, 32, 0.8),
        0 0 60px rgba(218, 165, 32, 0.6),
        0 0 90px rgba(218, 165, 32, 0.4);
}

.instrument[data-instrument="harp"].playing {
    box-shadow:
        0 0 30px rgba(139, 69, 19, 0.8),
        0 0 60px rgba(139, 69, 19, 0.6),
        0 0 90px rgba(139, 69, 19, 0.4);
}

.instrument[data-instrument="bongo"].playing {
    box-shadow:
        0 0 30px rgba(210, 105, 30, 0.8),
        0 0 60px rgba(210, 105, 30, 0.6),
        0 0 90px rgba(210, 105, 30, 0.4);
}

.instrument[data-instrument="triangle"].playing {
    box-shadow:
        0 0 30px rgba(169, 169, 169, 0.8),
        0 0 60px rgba(169, 169, 169, 0.6),
        0 0 90px rgba(169, 169, 169, 0.4);
}

.instrument[data-instrument="bells"].playing {
    box-shadow:
        0 0 30px rgba(255, 215, 0, 0.8),
        0 0 60px rgba(255, 215, 0, 0.6),
        0 0 90px rgba(255, 215, 0, 0.4);
}

.instrument[data-instrument="banjo"].playing {
    box-shadow:
        0 0 30px rgba(245, 222, 179, 0.8),
        0 0 60px rgba(245, 222, 179, 0.6),
        0 0 90px rgba(245, 222, 179, 0.4);
}

.instrument[data-instrument="castanets"].playing {
    box-shadow:
        0 0 30px rgba(139, 69, 19, 0.8),
        0 0 60px rgba(139, 69, 19, 0.6),
        0 0 90px rgba(139, 69, 19, 0.4);
}

.instrument svg {
    width: 70px;
    height: 70px;
    filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.2));
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.instrument.playing svg {
    transform: scale(1.15) rotate(5deg);
    filter: drop-shadow(5px 5px 10px rgba(0, 0, 0, 0.3));
}

.instrument span {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    text-align: center;
    line-height: 1.2;
}

/* Адаптивність */
@media (max-width: 1024px) and (orientation: portrait) {
    .title {
        font-size: 28px;
        margin-bottom: 10px;
    }

    .instruments-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: auto;
        gap: 12px;
    }

    .instrument svg {
        width: 60px;
        height: 60px;
    }

    .instrument span {
        font-size: 12px;
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    .title {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .instruments-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
        gap: 10px;
    }

    .instrument {
        padding: 12px 8px;
    }

    .instrument svg {
        width: 50px;
        height: 50px;
    }

    .instrument span {
        font-size: 11px;
    }
}

/* Мобільні телефони */
@media (max-width: 480px) {
    .title {
        font-size: 20px;
        margin-bottom: 5px;
    }

    .instruments-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
    }

    .instrument {
        padding: 10px 6px;
        gap: 6px;
    }

    .instrument svg {
        width: 45px;
        height: 45px;
    }

    .instrument span {
        font-size: 10px;
    }

    /* Збільшуємо кнопку закриття для маленьких пальчиків */
    .close-button {
        width: 70px;
        height: 70px;
        top: 10px;
        right: 10px;
    }

    .close-button svg {
        width: 35px;
        height: 35px;
    }
}

/* Дуже маленькі телефони */
@media (max-width: 400px) {
    .title {
        font-size: 18px;
    }

    .instruments-grid {
        gap: 6px;
        padding: 6px;
    }

    .instrument {
        padding: 8px 5px;
    }

    .instrument svg {
        width: 40px;
        height: 40px;
    }

    .instrument span {
        font-size: 9px;
    }

    .close-button {
        width: 65px;
        height: 65px;
        top: 5px;
        right: 5px;
    }

    .close-button svg {
        width: 32px;
        height: 32px;
    }
}

/* Landscape orientation для телефонів */
@media (max-width: 896px) and (orientation: landscape) {
    .title {
        font-size: 20px;
        margin-bottom: 5px;
    }

    .instruments-grid {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(4, 1fr);
        gap: 8px;
        padding: 5px;
        max-height: calc(100vh - 80px);
    }

    .instrument {
        padding: 8px 5px;
        gap: 5px;
    }

    .instrument svg {
        width: 40px;
        height: 40px;
    }

    .instrument span {
        font-size: 9px;
    }

    .close-button {
        width: 50px;
        height: 50px;
        top: 5px;
        right: 5px;
    }

    .close-button svg {
        width: 25px;
        height: 25px;
    }
}

/* Touch-specific improvements */
@media (hover: none) and (pointer: coarse) {
    /* Видаляємо hover ефекти на touch пристроях */
    .instrument:hover {
        transform: none;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    }

    .close-button:hover {
        transform: none;
        background: white;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    }

    .close-button:hover svg {
        stroke: #333;
    }

    /* Додаємо active стани для тактильного відгуку */
    .instrument:active {
        transform: scale(0.95);
    }

    .close-button:active {
        transform: scale(0.9) rotate(90deg);
        background: #ff6b6b;
    }

    .close-button:active svg {
        stroke: white;
    }

    /* Мінімальна область для натискання */
    .close-button {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Ефект хвиль при натисканні */
@keyframes ripple {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(4);
        opacity: 0;
    }
}
