:root {
    --bg-color: #050505;
    --text-color: #ffffff;
    --primary-color: #ffb7c5;
    /* Pink for Sakura theme */
    --secondary-color: #bc13fe;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Zen Kaku+Gothic+New', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    /* Prevent selection text selection during game */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-body);
    overflow: hidden;
    /* Prevent scroll */
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-image: url('../assets/avatar.jpg');
    /* Use main site bg */
    background-size: cover;
    background-position: center;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    /* Dark overlay */
    z-index: -1;
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* UI Layer */
.header-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.back-link {
    color: #aeaeae;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.back-link:hover {
    color: var(--text-color);
}

.game-title {
    font-family: var(--font-heading);
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-color);
    font-size: 1.5rem;
}

.stats-bar {
    position: absolute;
    top: 20px;
    right: 30px;
    display: flex;
    gap: 30px;
    z-index: 100;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--glass-bg);
    padding: 10px 20px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
}

.label {
    font-size: 0.8rem;
    color: #ccc;
    font-family: var(--font-heading);
}

.value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text-color);
}

#timer.warning {
    color: #ff3333;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Background Visualizer */
#bg-visualizer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 800px;
    height: 100%;
    max-height: 800px;
    z-index: 0;
    pointer-events: none;
    opacity: 0.5;
}

/* Game Area */
.game-area {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

/* Sakura Petal */
.petal {
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    border-radius: 100% 0 100% 0;
    box-shadow: 0 0 10px rgba(255, 183, 197, 0.8);
    cursor: pointer;
    transition: transform 0.1s;
}

.petal:active {
    transform: scale(0.9);
}

.petal.blue {
    background-color: #00bfff;
    box-shadow: 0 0 15px #00bfff;
    z-index: 10;
}

.petal.red {
    background-color: #ff4444;
    box-shadow: 0 0 15px #ff4444;
    z-index: 10;
}

.petal.green {
    background-color: #32cd32;
    box-shadow: 0 0 15px #32cd32;
    z-index: 10;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.glass-panel {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    padding: 40px 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 0 30px rgba(255, 183, 197, 0.2);
}

.modal h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.modal p {
    font-size: 1.1rem;
    margin-bottom: 30px;
    line-height: 1.6;
}

.final-score {
    font-size: 4rem;
    font-weight: 900;
    font-family: var(--font-heading);
    margin-bottom: 30px;
    color: #fff;
    text-shadow: 0 0 20px var(--primary-color);
}

.final-score.small {
    font-size: 2.5rem;
    color: #ffd7e6;
    margin-bottom: 0;
}

.score-container {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 5px !important;
}

/* Buttons */
.btn {
    padding: 15px 20px;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: all 0.3s;
    text-decoration: none;
    text-decoration: none;
    display: inline-block;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

.primary-btn {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 15px rgba(255, 183, 197, 0.5);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(255, 183, 197, 0.8);
}

.secondary-btn {
    background: transparent;
    border: 1px solid #fff;
    color: #fff;
    margin-left: 10px;
}

.secondary-btn:hover {
    background: #fff;
    color: #000;
}

.btn-group {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* Click Spark Effect */
.spark {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    pointer-events: none;
    animation: fadeOut 0.5s forwards;
}

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

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Input Styles */
.save-form {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#user-name {
    padding: 10px 15px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 1.1rem;
    font-family: var(--font-body);
    text-align: center;
    width: 200px;
}

#user-name:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(255, 183, 197, 0.5);
}

.small-btn {
    padding: 8px 20px;
    font-size: 1rem;
    min-width: 120px;
}

#save-status.success {
    color: #00ff00;
}

#save-status.error {
    color: #ff3333;
}

/* Volume Control */
.volume-control {
    position: absolute;
    top: 130px;
    /* Moved to Top Left below Header */
    left: 20px;
    bottom: auto;
    right: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    /* Vertical Layout */
    align-items: center;
    gap: 15px;
    background: var(--glass-bg);
    width: 40px;
    /* Minimal width */
    padding: 20px 0;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
    transition: opacity 0.3s;
}

.volume-control:hover {
    background: rgba(255, 255, 255, 0.2);
}

#volume-slider {
    width: 100px;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    transform: rotate(-90deg);
    /* Make vertical */
    margin: 40px 0;
    /* Space for rotation */
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(255, 183, 197, 0.8);
    transition: transform 0.2s;
}

#volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#volume-icon {
    font-size: 1.2rem;
    color: #fff;
    cursor: pointer;
    width: 20px;
    text-align: center;
    transition: color 0.3s;
}

#volume-icon:hover {
    color: var(--primary-color);
}

.sound-unlock-btn {
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    color: #000;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: pulse 1s infinite;
    font-size: 0.7rem;
    padding-left: 2px;
    /* slight visual center adjust for play icon */
}

.sound-unlock-btn:hover {
    transform: scale(1.1);
}

#volume-icon:hover {
    color: var(--primary-color);
}

#volume-icon:hover {
    color: var(--primary-color);
}

/* Score Popup */
.score-popup {
    position: absolute;
    color: #fff;
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    animation: popupAnim 0.8s forwards;
    z-index: 150;
    text-shadow: 0 0 5px var(--primary-color), 0 0 10px #ff69b4;
    white-space: nowrap;
}

@keyframes popupAnim {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translateY(-20px) scale(1.2);
        opacity: 1;
    }

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



/* Mobile Responsive */
@media (max-width: 768px) {
    .header-bar {
        top: 10px;
        left: 10px;
    }

    .game-title {
        font-size: 1.2rem;
    }

    .stats-bar {
        top: 10px;
        right: 10px;
        gap: 10px;
    }

    .stat-box {
        padding: 5px 10px;
    }

    .value {
        font-size: 1.5rem;
    }

    .volume-control {
        top: 110px;
        left: 10px;
        bottom: auto;
        padding: 15px 0;
        width: 36px;
        gap: 10px;
    }

    #volume-slider {
        width: 80px;
        margin: 30px 0;
    }
}