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

html, body {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background-color: #000;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

#gameContainer {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}

#gameCanvas {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: calc(100vh * 9 / 16);
    max-width: calc(100dvh * 9 / 16);
    max-height: calc(100vw * 16 / 9);
    aspect-ratio: 9 / 16;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 3% 0;
    container-type: inline-size;
}

#title {
    width: 40%;
    max-width: 40cqw;
    height: auto;
    margin-bottom: 1%;
}

#stageInfo {
    display: block;
    color: #aaa;
    font-size: 2.5cqw;
    margin-bottom: 1%;
}

#targetArea {
    width: 90%;
    padding: 3% 0;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-bottom: 3%;
}

#targetLeft, #targetRight {
    color: #4fc3f7;
    font-size: 6cqw;
    font-weight: bold;
}

.targetSeparator {
    color: #fff;
    font-size: 4cqw;
    margin: 0 2%;
}

#canvas {
    width: 80%;
    aspect-ratio: 1 / 1;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    touch-action: none;
}

#resultArea {
    width: 90%;
    padding: 2% 0;
    text-align: center;
    margin-top: 3%;
}

#instruction {
    color: #aaa;
    font-size: 3.5cqw;
}

#resultLeft, #resultRight {
    color: #fff;
    font-size: 8cqw;
    font-weight: bold;
}

.resultSeparator {
    color: #888;
    font-size: 4cqw;
    margin: 0 2%;
}

#message {
    min-height: 5cqw;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4cqw;
    font-weight: bold;
    margin: 2% 0;
}

#message.success {
    color: #4caf50;
}

#message.fail {
    color: #f44336;
}

#buttonArea {
    width: 80%;
    display: flex;
    gap: 5%;
    justify-content: center;
    margin-top: auto;
    padding-bottom: 8%;
}

#retryButton, #nextButton {
    padding: 3% 8%;
    font-size: 3.5cqw;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.1s;
}

#retryButton {
    background: #607d8b;
    color: #fff;
}

#nextButton {
    background: #4caf50;
    color: #fff;
}

#retryButton:active, #nextButton:active {
    transform: scale(0.95);
    opacity: 0.8;
}

@supports not (container-type: inline-size) {
    #title {
        width: calc(min(100vw, 56.25vh) * 0.4);
    }
    #stageInfo {
        font-size: calc(min(100vw, 56.25vh) * 0.025);
    }
    #targetLeft, #targetRight {
        font-size: calc(min(100vw, 56.25vh) * 0.06);
    }
    .targetSeparator {
        font-size: calc(min(100vw, 56.25vh) * 0.04);
    }
    #instruction {
        font-size: calc(min(100vw, 56.25vh) * 0.035);
    }
    #resultLeft, #resultRight {
        font-size: calc(min(100vw, 56.25vh) * 0.08);
    }
    .resultSeparator {
        font-size: calc(min(100vw, 56.25vh) * 0.04);
    }
    #message {
        font-size: calc(min(100vw, 56.25vh) * 0.04);
    }
    #retryButton, #nextButton {
        font-size: calc(min(100vw, 56.25vh) * 0.035);
    }
}
