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

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: fixed;       
    width: 100%;
    height: 100%;
    touch-action: none;   
    overscroll-behavior: none;
    font-family: 'Mitr', sans-serif;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse 1000px 700px at 15% 20%, rgba(255, 255, 255, 0.25) 0%, transparent 50%),
        radial-gradient(ellipse 800px 900px at 85% 80%, rgba(168, 224, 245, 0.4) 0%, transparent 55%),
        radial-gradient(ellipse 600px 600px at 60% 40%, rgba(211, 239, 250, 0.3) 0%, transparent 60%),
        linear-gradient(145deg, 
            #A8D8F0 0%,
            #B5E0F3 8%,
            #C3EEFA 15%,
            #D0F0FB 22%,
            #DCF4FC 28%,
            #E5F7FD 35%,
            #E8F8FD 42%,
            #E5F7FD 50%,
            #DCF4FC 58%,
            #D0F0FB 65%,
            #C3EEFA 72%,
            #B5E0F3 80%,
            #A8D8F0 88%,
            #9DD2ED 100%
        );
    background-size: 100% 100%;
    animation: canvas-diagonal-flow 18s ease-in-out infinite;
}

@keyframes canvas-diagonal-flow {
    0% {
        background-position: 0% 0%, 100% 100%, 60% 40%, 0% 0%;
        filter: brightness(1) saturate(1.05) hue-rotate(0deg);
    }
    20% {
        background-position: 5% 10%, 95% 90%, 55% 45%, 0% 3%;
        filter: brightness(1.02) saturate(1.08) hue-rotate(2deg);
    }
    40% {
        background-position: 10% 15%, 90% 85%, 50% 50%, 0% 5%;
        filter: brightness(1.04) saturate(1.1) hue-rotate(3deg);
    }
    60% {
        background-position: 10% 15%, 90% 85%, 50% 50%, 0% 5%;
        filter: brightness(1.04) saturate(1.1) hue-rotate(3deg);
    }
    80% {
        background-position: 5% 10%, 95% 90%, 55% 45%, 0% 3%;
        filter: brightness(1.02) saturate(1.08) hue-rotate(2deg);
    }
    100% {
        background-position: 0% 0%, 100% 100%, 60% 40%, 0% 0%;
        filter: brightness(1) saturate(1.05) hue-rotate(0deg);
    }
}

#uiOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    pointer-events: none;
    z-index: 100;
}

#instructionGroup {
    position: absolute;
    top: 7vh;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 500px;
    text-align: center; 
    padding: 15px 15px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    box-sizing: border-box; 
    pointer-events: auto;
}

#instructionGroup.visible {
    opacity: 1;
    visibility: visible;
}

#instructionText {
    font-size: 1.4em;
    width: 100%;
    margin: 0 auto;
    line-height: 1.4;
    font-weight: 600;
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.8);
    color: #1565c0;
    padding: 10px 15px;
    text-align: center;  
    box-sizing: border-box;
}

#subInstructionText {
    font-size: 1.3em; 
    color: #1976d2;
    margin-top: 3px; 
    margin-left: auto; 
    margin-right: auto;
    line-height: 1.4;
    font-weight: 400;
    text-shadow: 0.5px 0.5px 2px rgba(255, 255, 255, 0.6);
    padding: 5px 12px; 
    text-align: center; 
    width: 100%;  
    box-sizing: border-box;
}

#scoreText {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1em;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    padding: 8px 14px;
    border-radius: 20px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.5s, visibility 0.5s;
    border: 2px solid rgba(66, 165, 245, 0.4);
    box-shadow: 0 2px 10px rgba(66, 165, 245, 0.2);
    font-weight: 600;
    color: #1565c0;
    text-shadow: 0.5px 0.5px 2px rgba(255, 255, 255, 0.8);
    pointer-events: auto;
}

#progressBarContainer {
    width: 70%;
    max-width: 300px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    margin-top: 15px;
    border: 2px solid rgba(66, 165, 245, 0.5);
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(66, 165, 245, 0.3);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#progressBar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #42a5f5 0%, #1e88e5 50%, #1565c0 100%);
    border-radius: 20px;
    transition: width 0.3s ease;
    box-shadow: 0 0 15px rgba(66, 165, 245, 0.8);
}

#countdownText {
    font-size: 4em;
    font-weight: bold;
    color: #1565c0;
    text-shadow: 3px 3px 15px rgba(255, 255, 255, 0.8),
                 0 0 30px rgba(66, 165, 245, 0.8);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 2em;
    z-index: 9999;
    pointer-events: none;
    animation: countdown-pulse 1s ease-in-out infinite;
}

@keyframes countdown-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

button {
    font-size: 1em;
    padding: 15px 30px;
    margin: 10px;
    cursor: pointer;
    font-family: 'Mitr', sans-serif;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

button:not([style]) {
    background: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(10px);
    color: #1565c0 !important;
    border: 3px solid #1565c0 !important;
    border-radius: 25px;
    font-weight: 600;
    box-shadow: 0 6px 15px rgba(66, 165, 245, 0.3);
    transition: all 0.3s ease;
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    pointer-events: auto !important;
    z-index: 1000;
}

button:not([style]):hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translate(-50%, -50%) scale(1.05) translateY(-2px);
    box-shadow: 0 8px 20px rgba(66, 165, 245, 0.4);
}

button:not([style]):active {
    transform: translate(-50%, -50%) scale(0.98);
}

#startScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    color: #1565c0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto;
    cursor: pointer;
    padding: 30px 20px;
    box-sizing: border-box;
}

#startScreen.hidden {
    display: none;
    pointer-events: none;
}

.game-title {
    font-size: 2.1em;
    font-weight: 700;
    color: #1565c0;
    margin-top: 40px;
    letter-spacing: 1px;
    animation: title-glow 2s ease-in-out infinite;
}

@keyframes title-glow {
    0%, 100% { 
        transform: scale(1);
    }
    50% { 
        transform: scale(1.08);
    }
}

.start-instruction {
    position: absolute;
    margin-top: 80px;
    transform: translateX(-50%);
    right: 0.5;
    font-size: 1.4em;
    font-weight: 600;
    padding: 15px 30px;
    color: #78A3D4;
    animation: title-glow 2s ease-in-out infinite;
}

.tap-indicator {
    position: absolute;
    bottom: 35%;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 140px;
    border: 3px solid rgba(241, 241, 241, 0.685);
    border-radius: 80%;
    animation: pulse-tap 2s infinite;
    box-shadow: 0 0 30px rgb(255, 255, 255);
}

@keyframes pulse-tap {
    0% {
        transform: translateX(-50%) scale(0.9);
        opacity: 1;
    }
    50% {
        transform: translateX(-50%) scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: translateX(-50%) scale(0.9);
        opacity: 1;
    }
}

#startScreen:active .start-instruction {
    transform: translateX(-50%) scale(0.95);
    transition: transform 0.1s ease;
}

#startScreen:active .tap-indicator {
    transform: translateX(-50%) scale(0.85);
    transition: transform 0.1s ease;
}

#clickSignal {
    width: 80px;
    height: 80px;
    border: 3px solid rgba(241, 241, 241, 0.685);
    border-radius: 50%;
    position: absolute;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: none;
    animation: pulse-click 1.5s infinite;
    box-shadow: 0 0 30px rgb(255, 255, 255);
    z-index: 200;
}

#clickSignal.hidden {
    display: none !important;
}

@keyframes pulse-click {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.7;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    #instructionText {
        font-size: 1.1em;
    }
    
    #subInstructionText {
        font-size: 0.95em;
    }
    
    .game-title {
        font-size: 1.5em;
    }
}

#stepPopup {
    position: fixed;
    inset: 0;
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 40, 80, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: popup-fadein 0.35s ease;
}

#stepPopup.hidden {
    display: none !important;
}

@keyframes popup-fadein {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}

#stepPopupInner {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 28px;
    padding: 28px 24px 24px;
    width: 88%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(21, 101, 192, 0.25),
                0 4px 20px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    border: 1.5px solid rgba(66, 165, 245, 0.3);
}

#stepPopupBadge {
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(135deg, #42a5f5, #1565c0);
    padding: 5px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.3);
}

#stepPopupTitle {
    font-size: 1.2em;
    font-weight: 700;
    color: #1565c0;
    text-align: center;
    line-height: 1.4;
}

#stepPopupImg {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 16px;
    background: rgba(168, 216, 240, 0.15);
    padding: 8px;
    border: 1px solid rgba(66, 165, 245, 0.2);
}

#stepPopupDesc {
    font-size: 1em;
    color: #1976d2;
    text-align: center;
    line-height: 1.55;
    font-weight: 400;
}

#stepPopupBtn {
    margin-top: 4px;
    padding: 13px 36px !important;
    font-size: 1em !important;
    font-family: 'Mitr', sans-serif;
    font-weight: 600;
    color: #fff !important;
    background: linear-gradient(135deg, #42a5f5, #1565c0) !important;
    border: none !important;
    border-radius: 24px !important;
    box-shadow: 0 4px 16px rgba(21, 101, 192, 0.35) !important;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    position: static !important;
    transform: none !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
}

#stepPopupBtn:active {
    transform: scale(0.96) !important;
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.3) !important;
}