/* --- 全体のスタイル --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Yusei Magic', cursive;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    color: #4a3e37;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.2) 2px, transparent 2px),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.3) 1px, transparent 1px),
        radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.2) 1px, transparent 1px);
    background-size: 200px 200px, 150px 150px, 300px 300px;
    pointer-events: none;
    animation: sparkle 10s ease-in-out infinite;
}

@keyframes sparkle {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
    position: relative;
}

h1 {
    color: #ff6b6b;
    text-shadow: 3px 3px 0 #ffffff, 6px 6px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    font-size: 2.5rem;
    text-align: center;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}

#game-container {
    position: relative;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 6px solid #ff9f9f;
    border-radius: 25px;
    box-shadow:
        0 15px 35px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    overflow: hidden;
}

#game-canvas {
    display: block;
    border-radius: 19px;
    background: linear-gradient(180deg, #e3f2fd 0%, #ffffff 100%);
}

#score-container {
    position: absolute;
    top: 15px;
    left: 20px;
    font-size: 22px;
    font-weight: bold;
    color: #ff6b6b;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 15px;
    border-radius: 20px;
    border: 3px solid #ffb3b3;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

#score {
    color: #e91e63;
    text-shadow: 1px 1px 0 #ffffff;
}

.controls-info {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 15px;
    border-radius: 15px;
    font-size: 14px;
    color: #666;
    border: 2px solid #ffb3b3;
    text-align: center;
}

#best-score-container {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 18px;
    font-weight: bold;
    color: #9c27b0;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 15px;
    border-radius: 20px;
    border: 3px solid #ce93d8;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

#best-score {
    color: #7b1fa2;
    text-shadow: 1px 1px 0 #ffffff;
}

/* フルーツの絵文字表示用のオーバーレイ */
.fruit-emoji {
    position: absolute;
    font-size: 24px;
    pointer-events: none;
    z-index: 5;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center center;
}

.particle {
    position: absolute;
    pointer-events: none;
    z-index: 50;
    font-size: 20px;
    animation: particleFloat 1.5s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.5);
    }
}

.combo-display {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: bold;
    color: #ff6b6b;
    text-shadow: 3px 3px 0 #ffffff, 5px 5px 15px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 60;
    animation: comboEffect 1s ease-out forwards;
}

@keyframes comboEffect {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

#game-over-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 19px;
    backdrop-filter: blur(5px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

#game-over-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: linear-gradient(145deg, #ffffff, #f8f8f8);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 4px solid #ff9f9f;
    animation: modalPop 0.3s ease-out;
    transform: scale(0.95);
    transition: transform 0.3s ease-in-out;
}

#game-over-modal.visible .modal-content {
    transform: scale(1);
}

@keyframes modalPop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h2 {
    margin-top: 0;
    color: #ff6b6b;
    font-size: 2rem;
    text-shadow: 2px 2px 0 #ffffff;
    margin-bottom: 20px;
}

.modal-content p {
    font-size: 1.2rem;
    margin-bottom: 25px;
    color: #666;
}

#final-score {
    color: #e91e63;
    font-weight: bold;
    font-size: 1.5rem;
}

#restart-button {
    font-family: 'Yusei Magic', cursive;
    background: linear-gradient(145deg, #81c784, #66bb6a);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 15px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 4px solid #4caf50;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

#restart-button:hover {
    background: linear-gradient(145deg, #66bb6a, #4caf50);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#restart-button:active {
    transform: translateY(1px);
    border-bottom-width: 2px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

@media (max-width: 500px) {
    h1 {
        font-size: 2rem;
    }

    #game-container {
        border-width: 4px;
    }

    .modal-content {
        padding: 30px 20px;
        margin: 20px;
    }
}

/* --- フッター --- */
footer {
    width: 100%;
    text-align: center;
    padding: 15px 0;
    z-index: 1;
    color: #4a3e37;
    font-size: 14px;
    margin-top: 20px;
}

.social-links {
    margin-bottom: 8px;
}

.social-links a {
    color: #ff6b6b;
    text-decoration: none;
    margin: 0 10px;
    font-size: 16px;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: #e91e63;
}

.copyright {
    opacity: 0.8;
}