/* style.css */
body {
    background: #181818;
    font-family: 'Segoe UI', '微軟正黑體', Arial, sans-serif;
    margin: 0;
    padding: 0;
}
.container {
    max-width: 400px;
    margin: 40px auto;
    background: rgba(30,30,30,0.95);
    border-radius: 16px;
    box-shadow: 0 4px 32px 0 #ff980044, 0 0 0 4px #ff980022;
    padding: 32px 24px 40px 24px;
    text-align: center;
    border: 2px solid #ff9800;
}
.container h1 {
    color: #fff;
    margin-bottom: 18px;
    font-size: 1.5em;
    letter-spacing: 2px;
}
#gameArea {
    position: relative;
    width: 300px;
    height: 300px;
    margin: 24px auto 0 auto;
    background: #222;
    border-radius: 12px;
    border: 3px solid #ff3d00;
    box-shadow: 0 0 32px 0 #ff980088, 0 0 0 8px #ff3d0022;
    overflow: hidden;
}
.square {
    position: absolute;
    width: 54px;
    height: 54px;
    background: radial-gradient(circle at 30% 30%, #ff9800 70%, #ff3d00 100%);
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 0 24px 6px #ff9800, 0 0 0 4px #ff3d00;
    border: 2px solid #fff2;
    animation: popIn 0.25s cubic-bezier(.68,-0.55,.27,1.55);
    transition: box-shadow 0.2s, transform 0.15s;
}
.square:active, .square.clicked {
    animation: clickFlash 0.2s;
    box-shadow: 0 0 32px 12px #ff3d00, 0 0 0 8px #ff9800;
    transform: scale(0.85);
}
@keyframes popIn {
    0% { transform: scale(0.2); opacity: 0; }
    80% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes clickFlash {
    0% { filter: brightness(1.5); }
    100% { filter: brightness(1); }
}
#score, #timer {
    font-size: 1.3em;
    margin: 8px 0;
    color: #ff9800;
    text-shadow: 0 2px 8px #ff3d00aa;
    letter-spacing: 1px;
}
#timer {
    color: #ff3d00;
}
#startBtn {
    padding: 12px 32px;
    font-size: 1.1em;
    background: linear-gradient(90deg, #ff9800 60%, #ff3d00 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 12px;
    box-shadow: 0 2px 12px #ff980088;
    font-weight: bold;
    letter-spacing: 2px;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}
#startBtn:hover {
    background: linear-gradient(90deg, #ff3d00 60%, #ff9800 100%);
    box-shadow: 0 4px 24px #ff3d00aa;
    transform: scale(1.05);
}
#startBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#gameOver {
    font-size: 1.5em;
    color: #fff;
    margin-top: 22px;
    background: linear-gradient(90deg, #ff9800 60%, #ff3d00 100%);
    border-radius: 10px;
    padding: 18px 0 10px 0;
    box-shadow: 0 2px 24px #ff3d0088;
    opacity: 0;
    animation: fadeIn 0.8s forwards;
    animation-play-state: paused;
}
#gameOver.show {
    animation-play-state: running;
}
.hidden {
    display: none;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
#playerName {
    display: block;
    margin: 0 auto 12px auto;
    padding: 10px 16px;
    font-size: 1.1em;
    border: 2px solid #ff9800;
    border-radius: 8px;
    background: #222;
    color: #fff;
    outline: none;
    box-shadow: 0 2px 8px #ff980044;
    transition: border 0.2s, box-shadow 0.2s;
    text-align: center;
}
#playerName:focus {
    border: 2px solid #ff3d00;
    box-shadow: 0 4px 16px #ff3d0044;
}
#playerName:disabled {
    opacity: 0.6;
    background: #181818;
    color: #aaa;
}
#leaderboard {
    margin-top: 28px;
    background: rgba(30,30,30,0.92);
    border-radius: 10px;
    padding: 16px 0 10px 0;
    box-shadow: 0 2px 16px #ff980044;
    border: 2px solid #ff9800;
}
#leaderboard h2 {
    color: #ff9800;
    margin: 0 0 10px 0;
    font-size: 1.2em;
    letter-spacing: 2px;
}
#leaderboardList {
    list-style: decimal inside;
    padding: 0;
    margin: 0;
    color: #fff;
    font-size: 1.1em;
}
#leaderboardList li {
    margin: 4px 0;
    padding: 2px 0;
    color: #fff;
    text-shadow: 0 1px 4px #ff980088;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#leaderboardList li span.name {
    color: #ff9800;
    font-weight: bold;
    margin-right: 8px;
}
#leaderboardList li span.score {
    color: #ff3d00;
    font-weight: bold;
}

/* 歡迎名稱輸入 overlay */
.welcome-overlay {
    position: fixed;
    z-index: 1000;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(24,24,24,0.98);
    display: flex;
    align-items: center;
    justify-content: center;
}
.welcome-box {
    background: #222;
    border-radius: 16px;
    box-shadow: 0 4px 32px #ff980044, 0 0 0 4px #ff980022;
    padding: 40px 32px 32px 32px;
    text-align: center;
    border: 2px solid #ff9800;
}
.welcome-box h1 {
    color: #ff9800;
    margin-bottom: 24px;
    font-size: 1.5em;
    letter-spacing: 2px;
}
.welcome-box input {
    display: block;
    margin: 0 auto 18px auto;
    padding: 12px 18px;
    font-size: 1.1em;
    border: 2px solid #ff9800;
    border-radius: 8px;
    background: #181818;
    color: #fff;
    outline: none;
    box-shadow: 0 2px 8px #ff980044;
    text-align: center;
    width: 220px;
}
.welcome-box input:focus {
    border: 2px solid #ff3d00;
    box-shadow: 0 4px 16px #ff3d0044;
}
.welcome-box button {
    padding: 12px 32px;
    font-size: 1.1em;
    background: linear-gradient(90deg, #ff9800 60%, #ff3d00 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 12px #ff980088;
    font-weight: bold;
    letter-spacing: 2px;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}
.welcome-box button:hover {
    background: linear-gradient(90deg, #ff3d00 60%, #ff9800 100%);
    box-shadow: 0 4px 24px #ff3d00aa;
    transform: scale(1.05);
}

/* 主區塊與排行榜 flex 佈局 */
.container-flex {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 32px;
    max-width: 900px;
    margin: 40px auto;
}

.container {
    flex: 1 1 400px;
    min-width: 340px;
    max-width: 420px;
}

#leaderboard {
    flex: 0 0 260px;
    margin-top: 0;
    background: rgba(30,30,30,0.92);
    border-radius: 10px;
    padding: 24px 24px 18px 24px;
    box-shadow: 0 2px 16px #ff980044;
    border: 2px solid #ff9800;
    min-width: 220px;
}
#leaderboard h2 {
    color: #ff9800;
    margin: 0 0 16px 0;
    font-size: 1.2em;
    letter-spacing: 2px;
    text-align: center;
}
#leaderboardList {
    list-style: decimal inside;
    padding: 0;
    margin: 0;
    color: #fff;
    font-size: 1.1em;
}
#leaderboardList li {
    margin: 8px 0;
    padding: 4px 0;
    color: #fff;
    text-shadow: 0 1px 4px #ff980088;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#leaderboardList li span.name {
    color: #ff9800;
    font-weight: bold;
    margin-right: 8px;
}
#leaderboardList li span.score {
    color: #ff3d00;
    font-weight: bold;
}

/* 手機版排行榜移到下方 */
@media (max-width: 800px) {
    .container-flex {
        flex-direction: column;
        align-items: center;
        gap: 0;
    }
    #leaderboard {
        margin-top: 32px;
        min-width: 0;
        width: 100%;
        max-width: 420px;
    }
} 