/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a0000 0%, #4a0000 100%);
    color: white;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.game-container {
    max-width: 480px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* ===== 畫面管理 ===== */
.screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.screen.hidden {
    display: none;
}

/* ===== 開始畫面 ===== */
#menu-screen h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.instruction {
    font-size: 1.2em;
    margin-bottom: 30px;
    text-align: center;
    color: #ffcc00;
}

.rules {
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 30px;
    max-width: 400px;
}

.rules h3 {
    margin-bottom: 15px;
    color: #ff6666;
}

.rules ul {
    list-style: none;
    text-align: left;
}

.rules li {
    margin: 10px 0;
    padding-left: 10px;
}

/* ===== 按鈕樣式 ===== */
.big-button {
    padding: 15px 50px;
    font-size: 1.5em;
    font-weight: bold;
    background: linear-gradient(145deg, #ff3333, #cc0000);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(255, 0, 0, 0.4);
    transition: all 0.3s ease;
    margin: 10px;
}

.big-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 0, 0, 0.6);
}

.big-button:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(255, 0, 0, 0.4);
}

.small-button {
    padding: 10px 30px;
    font-size: 1em;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
}

.small-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

/* ===== 遊戲畫面 ===== */
#game-screen {
    padding: 0;
    justify-content: flex-start;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 480px;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.7);
    border-bottom: 2px solid rgba(255, 0, 0, 0.5);
}

.info-left, .info-center, .info-right {
    flex: 1;
}

.info-left {
    text-align: left;
}

.info-center {
    text-align: center;
}

.info-right {
    text-align: right;
}

.time-display {
    font-size: 1.5em;
    font-weight: bold;
    color: #ffcc00;
}

.score-display {
    font-size: 1.8em;
    font-weight: bold;
    color: #ff3333;
}

.combo-display {
    font-size: 1em;
    color: #00ff00;
    opacity: 0;
    transition: opacity 0.3s;
}

.combo-display.active {
    opacity: 1;
}

.icon-button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 1.5em;
    padding: 5px 15px;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.3s;
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== Canvas 區域 ===== */
.canvas-container {
    position: relative;
    width: 360px;
    height: 640px;
    margin: 20px auto;
    background: #000;
    border: 3px solid rgba(255, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.lane-indicators {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    pointer-events: none;
}

.lane-label {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.5);
    font-weight: bold;
}

/* ===== 飄字效果 ===== */
.floating-text {
    position: absolute;
    font-size: 1.5em;
    font-weight: bold;
    pointer-events: none;
    animation: float-up 1s ease-out forwards;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes float-up {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-50px) scale(1.5);
        opacity: 0;
    }
}

/* ===== 射擊按鈕 ===== */
.shot-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    width: 100%;
    max-width: 480px;
}

.shot-button {
    flex: 1;
    max-width: 120px;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #cc0000, #990000);
    border: 3px solid #ff0000;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.1s ease;
    box-shadow: 0 5px 15px rgba(255, 0, 0, 0.5);
}

.shot-button:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(255, 0, 0, 0.7);
}

.shot-button:active {
    transform: scale(0.95);
}

.shot-button.hit {
    background: linear-gradient(145deg, #00ff00, #00cc00);
    border-color: #00ff00;
    animation: hit-flash 0.2s;
}

.shot-button.miss {
    background: linear-gradient(145deg, #666, #333);
    border-color: #999;
    animation: miss-shake 0.2s;
}

@keyframes hit-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes miss-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.button-label {
    font-size: 0.8em;
    color: #ffcc00;
    margin-bottom: 5px;
}

.button-shot {
    font-size: 1.5em;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

/* ===== 結束畫面 ===== */
#gameover-screen {
    background: rgba(0, 0, 0, 0.8);
}

#gameover-screen h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #ff3333;
}

.final-stats {
    margin-bottom: 30px;
    background: rgba(0, 0, 0, 0.5);
    padding: 20px 40px;
    border-radius: 15px;
}

.final-stats p {
    font-size: 1.5em;
    margin: 15px 0;
}

.final-score {
    color: #ffcc00;
}

.final-combo {
    color: #00ff00;
}

.input-group {
    margin: 20px 0;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.input-group input {
    padding: 10px 20px;
    font-size: 1.2em;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-align: center;
    width: 250px;
}

.input-group input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* ===== 排行榜畫面 ===== */
#leaderboard-screen h2 {
    font-size: 2em;
    margin-bottom: 20px;
}

.leaderboard-switch {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px;
    border-radius: 25px;
}

.switch-btn {
    padding: 10px 30px;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
}

.switch-btn.active {
    background: linear-gradient(145deg, #ff3333, #cc0000);
    color: white;
}

.leaderboard-list {
    width: 100%;
    max-width: 400px;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.leaderboard-list ol {
    list-style: none;
    counter-reset: item;
}

.leaderboard-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 10px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border-left: 4px solid #ff3333;
}

.leaderboard-list .rank {
    font-weight: bold;
    color: #ffcc00;
    min-width: 50px;
}

.leaderboard-list .name {
    flex: 1;
    font-weight: bold;
}

.leaderboard-list .score {
    color: #00ff00;
    font-weight: bold;
    min-width: 120px;
    text-align: right;
}

.leaderboard-list .date {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9em;
    min-width: 100px;
    text-align: right;
}

/* ===== 響應式設計 ===== */
@media screen and (max-width: 480px) {
    .game-container {
        max-width: 100vw;
    }

    .canvas-container {
        width: 100vw;
        height: auto;
        aspect-ratio: 9/16;
        margin: 10px 0;
    }

    #game-canvas {
        width: 100%;
        height: auto;
    }

    .game-header {
        padding: 10px;
        font-size: 0.9em;
    }

    .shot-buttons {
        padding: 10px;
        gap: 5px;
    }

    .shot-button {
        max-width: 100px;
        height: 70px;
    }

    .rules {
        font-size: 0.9em;
    }

    .leaderboard-list {
        max-height: 50vh;
    }

    .leaderboard-list li {
        flex-wrap: wrap;
        font-size: 0.9em;
    }

    .leaderboard-list .score,
    .leaderboard-list .date {
        min-width: auto;
    }
}

/* ===== 滾動條樣式 ===== */
.leaderboard-list::-webkit-scrollbar {
    width: 8px;
}

.leaderboard-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(255, 51, 51, 0.5);
    border-radius: 10px;
}

.leaderboard-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 51, 51, 0.8);
}
