* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    overflow: hidden;
    background: linear-gradient(180deg, #87CEEB 0%, #E0F0FF 60%, #B8E0FF 100%);
    font-family: 'Segoe UI', sans-serif;
    user-select: none;
}
/* ========== スタート画面 ========== */
#startScreen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #87CEEB 0%, #d4f0ff 100%);
    z-index: 100;
}
#startScreen h1 {
    font-size: clamp(2rem, 6vw, 4rem);
    color: #fff;
    text-shadow: 0 2px 12px rgba(80, 160, 220, 0.5);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}
#startScreen p.sub {
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: #d0eeff;
    margin-bottom: 2.5rem;
}
.settings-box {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 20px;
    padding: 1.8rem 2.5rem;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 24px rgba(100, 180, 240, 0.2);
    margin-bottom: 2.5rem;
    min-width: 340px;
}
.settings-box h2 {
    font-size: 1.1rem;
    color: #5599cc;
    margin-bottom: 1.2rem;
    text-align: center;
}
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}
.setting-row label {
    font-size: 1rem;
    color: #4488bb;
    white-space: nowrap;
}
.setting-row input[type="range"] {
    flex: 1;
    accent-color: #66aadd;
    cursor: pointer;
}
.setting-row .val {
    min-width: 4em;
    text-align: right;
    font-size: 1rem;
    color: #3377aa;
    font-weight: bold;
}
/* ========== 背景色ボタン ========== */
.bg-btns {
    display: flex;
    gap: 0.5rem;
}
.bg-btn {
    padding: 0.35rem 0.9rem;
    font-size: 0.95rem;
    border: 2px solid #aaccee;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.7);
    color: #4488bb;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s, border-color 0.15s;
    font-weight: bold;
}
.bg-btn:hover {
    background: rgba(200, 230, 255, 0.9);
}
.bg-btn.active {
    background: #66aadd;
    color: #fff;
    border-color: #4488bb;
}
.start-btn {
    padding: 1rem 3rem;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #aadeff, #66bbff);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(100, 180, 255, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
    letter-spacing: 0.1em;
}
.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 28px rgba(100, 180, 255, 0.6);
}
/* ========== ゲーム中 UI ========== */
#gameUI {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    pointer-events: none;
}
#topBar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 2rem;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 12px rgba(100, 180, 220, 0.15);
}
#timerDisplay {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    font-weight: bold;
    color: #3377aa;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.3rem 1.2rem;
    border-radius: 30px;
    min-width: 80px;
    text-align: center;
    box-shadow: 0 1px 8px rgba(100, 180, 220, 0.2);
}
#timerDisplay.warning {
    color: #e05555;
    animation: pulse 0.8s infinite;
}
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}
#scoreDisplay {
    font-size: clamp(1rem, 3vw, 1.6rem);
    color: #3377aa;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.3rem 1.2rem;
    border-radius: 30px;
    box-shadow: 0 1px 8px rgba(100, 180, 220, 0.2);
}
#scoreDisplay span {
    font-weight: bold;
    font-size: 1.2em;
    color: #1a5f9a;
}
#audioCtrl {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.3rem 0.9rem;
    border-radius: 30px;
    box-shadow: 0 1px 8px rgba(100, 180, 220, 0.2);
    pointer-events: auto;
}
#muteBtn {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
#volumeSlider {
    width: 80px;
    accent-color: #66aadd;
    cursor: pointer;
}
/* ========== Canvas ========== */
#gameCanvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 5;
}
#trailCanvas {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 85;
    pointer-events: none;
}
/* ========== 終了パネル ========== */
#endScreen {
    display: none;
    position: fixed;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 90;
}
.end-panel {
    position: relative;
    z-index: 95;
    background: rgba(255, 255, 255, 0.82);
    border-radius: 28px;
    padding: 2.5rem 3.5rem;
    text-align: center;
    box-shadow: 0 8px 40px rgba(100, 180, 255, 0.3);
    backdrop-filter: blur(4px);
    animation: popIn 0.5s cubic-bezier(.36, 2, .6, 1) forwards;
}
.end-panel h2 {
    font-size: clamp(3rem, 10vw, 6rem);
    color: #3399cc;
    text-shadow: 0 2px 16px rgba(100, 200, 255, 0.4);
    margin-bottom: 0.5rem;
}
#endScore {
    font-size: clamp(1.4rem, 4vw, 2.4rem);
    color: #1a5f9a;
    margin-bottom: 0.5rem;
}
#endScore span {
    font-size: 1.4em;
    font-weight: bold;
    color: #e07020;
}
#endMessage {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    color: #5599cc;
    margin-bottom: 1.2rem;
}
.trail-note {
    font-size: 0.95rem;
    color: #88aacc;
    margin-bottom: 1.8rem;
}
.close-btn {
    padding: 0.7rem 2.2rem;
    font-size: 1.2rem;
    border: 2px solid #aaccee;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.8);
    color: #5599cc;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    pointer-events: auto;
}
.close-btn:hover {
    transform: scale(1.05);
    background: rgba(200, 230, 255, 0.9);
}
/* ========== 右下「もう一度」 ========== */
#retryBtn {
    display: none;
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 96;
    padding: 1rem 2.5rem;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #aadeff, #66bbff);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(100, 180, 255, 0.5);
    transition: transform 0.15s, box-shadow 0.15s;
    font-weight: bold;
    letter-spacing: 0.05em;
    pointer-events: auto;
}
#retryBtn:hover {
    transform: scale(1.07);
    box-shadow: 0 6px 28px rgba(100, 180, 255, 0.6);
}
@keyframes popIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}
.pop-particle {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 30;
}