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

body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    font-family: 'Yu Gothic', 'Meiryo', sans-serif;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    margin: 0 auto;
    position: relative;
}

.hidden {
    display: none !important;
}

/* ===== タイトル画面 ===== */
#title-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 20px;
    overflow-y: auto;
}

.game-title {
    font-size: 4rem;
    color: #4ade80;
    text-shadow:
        0 0 10px #4ade80,
        0 0 20px #4ade80,
        0 0 40px #22c55e,
        3px 3px 0 #166534;
    margin-bottom: 30px;
    animation: titlePulse 2s ease-in-out infinite;
}

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

.title-tsuru {
    display: flex;
    gap: 60px;
    margin-bottom: 30px;
}

.tsuru-example {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.tsuru-example img {
    width: 120px;
    height: auto;
}

.tsuru-left {
    animation: floatFlipped 3s ease-in-out infinite;
}

.tsuru-right {
    animation: float 3s ease-in-out infinite;
    animation-delay: 1.5s;
}

.color-mode .tsuru-right {
    filter: hue-rotate(180deg) saturate(1.5);
}

.direction-label {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fbbf24;
    text-shadow: 0 0 10px #fbbf24;
}

.color-mode .direction-label.label-left {
    color: #4ade80;
    text-shadow: 0 0 10px #4ade80;
}

.color-mode .direction-label.label-right {
    color: #f472b6;
    text-shadow: 0 0 10px #f472b6;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes floatFlipped {
    0%, 100% { transform: scaleX(-1) translateY(0); }
    50% { transform: scaleX(-1) translateY(-20px); }
}

.instruction {
    color: #e2e8f0;
    font-size: 1.2rem;
    line-height: 2;
    margin-bottom: 40px;
}

#start-btn, #retry-btn {
    padding: 15px 50px;
    font-size: 1.5rem;
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 100%);
    border: none;
    border-radius: 50px;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(74, 222, 128, 0.4);
    transition: all 0.3s ease;
}

#start-btn:hover, #retry-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.6);
}

/* ===== ゲーム画面 ===== */
#game-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#header {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 1.3rem;
    font-weight: bold;
}

#score-value {
    color: #fbbf24;
}

#combo-value {
    color: #f472b6;
}

#play-area {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* ドロップゾーン */
.drop-zone {
    width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 3px dashed rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.drop-zone.highlight {
    background: rgba(74, 222, 128, 0.2);
    border-color: #4ade80;
}

.drop-zone.wrong {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.zone-label {
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.3);
    font-weight: bold;
    writing-mode: vertical-rl;
}

.color-mode #left-zone .zone-label {
    color: rgba(74, 222, 128, 0.5);
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.color-mode #right-zone .zone-label {
    color: rgba(244, 114, 182, 0.5);
    text-shadow: 0 0 10px rgba(244, 114, 182, 0.3);
}

#left-zone {
    border-left: none;
    border-radius: 0 20px 20px 0;
}

#right-zone {
    border-right: none;
    border-radius: 20px 0 0 20px;
}

/* 中央エリア */
#center-area {
    flex: 1;
    position: relative;
}

/* 危険ライン */
#danger-line {
    position: absolute;
    bottom: 200px;
    left: 0;
    right: 0;
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        #ef4444,
        #ef4444 20px,
        #fbbf24 20px,
        #fbbf24 40px
    );
    z-index: 100;
    box-shadow: 0 0 10px #ef4444;
    animation: dangerPulse 1s ease-in-out infinite;
}

@keyframes dangerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 積もったつるエリア */
#pile-area {
    position: absolute;
    bottom: 0;
    left: 150px;
    right: 150px;
    top: 0;
    pointer-events: none;
}

.piled-tsuru {
    position: absolute;
    width: 60px;
    opacity: 0.7;
    filter: grayscale(50%);
}

/* つる（落下・ドラッグ用） */
.tsuru {
    position: absolute;
    width: 80px;
    cursor: grab;
    transition: transform 0.1s ease;
    z-index: 10;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.3));
}

.tsuru:hover {
    transform: scale(1.1);
}

.tsuru.dragging {
    cursor: grabbing;
    z-index: 1000;
    transform: scale(1.2);
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

.tsuru.facing-right {
    /* 元画像（右向き） */
}

.tsuru.facing-right.color-mode {
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.3)) hue-rotate(180deg) saturate(1.5);
}

.tsuru.facing-left {
    transform: scaleX(-1);
}

.tsuru.facing-left.dragging {
    transform: scaleX(-1) scale(1.2);
}

/* 正解・不正解エフェクト */
.tsuru.correct {
    animation: correctAnim 0.5s ease forwards;
}

@keyframes correctAnim {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); }
    100% { transform: scale(0); opacity: 0; }
}

.tsuru.wrong {
    animation: wrongAnim 0.5s ease forwards;
}

@keyframes wrongAnim {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-20px) rotate(-10deg); }
    40%, 80% { transform: translateX(20px) rotate(10deg); }
}

/* スコアポップアップ */
.score-popup {
    position: absolute;
    font-size: 1.5rem;
    font-weight: bold;
    color: #4ade80;
    text-shadow: 0 0 10px #4ade80;
    pointer-events: none;
    animation: popupAnim 1s ease forwards;
    z-index: 1000;
}

.score-popup.minus {
    color: #ef4444;
    text-shadow: 0 0 10px #ef4444;
}

@keyframes popupAnim {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-50px); opacity: 0; }
}

/* タイムボーナス */
.time-bonus-popup {
    position: absolute;
    font-size: 1.8rem;
    font-weight: bold;
    color: #60a5fa;
    text-shadow: 0 0 10px #60a5fa, 0 0 20px #3b82f6;
    pointer-events: none;
    animation: timeBonusAnim 1.5s ease forwards;
    z-index: 1000;
}

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

/* ===== ゲームオーバー画面 ===== */
#gameover-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    text-align: center;
    z-index: 2000;
}

#gameover-screen h2 {
    font-size: 3rem;
    color: #ef4444;
    text-shadow: 0 0 20px #ef4444;
    margin-bottom: 30px;
}

#gameover-screen h2.timeup {
    color: #4ade80;
    text-shadow: 0 0 20px #4ade80;
}

#gameover-screen p {
    font-size: 1.5rem;
    margin-bottom: 15px;
}

#final-score, #max-combo {
    color: #fbbf24;
    font-weight: bold;
}

#retry-btn {
    margin-top: 30px;
}

/* ===== サウンドトグル ===== */
.sound-toggles {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.sound-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sound-label {
    color: #e2e8f0;
    font-size: 1rem;
    font-weight: bold;
    min-width: 35px;
}

.sound-btn {
    padding: 6px 14px;
    font-size: 0.9rem;
    border: 2px solid #4ade80;
    border-radius: 15px;
    background: transparent;
    color: #4ade80;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sound-btn.active {
    background: #4ade80;
    color: #1a1a2e;
}

.sound-btn:hover {
    background: rgba(74, 222, 128, 0.3);
}

.game-sound-toggles {
    display: flex;
    gap: 5px;
}

.sound-icon {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s, opacity 0.2s;
}

.sound-icon:hover {
    transform: scale(1.2);
}

.sound-icon.muted {
    opacity: 0.4;
}

/* ===== モード選択 ===== */
.mode-select {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.mode-btn {
    padding: 10px 20px;
    font-size: 1rem;
    border: 2px solid #fbbf24;
    border-radius: 20px;
    background: transparent;
    color: #fbbf24;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: #fbbf24;
    color: #1a1a2e;
}

.mode-btn:hover {
    background: rgba(251, 191, 36, 0.3);
}

/* ===== タイマー ===== */
#timer {
    color: #60a5fa;
}

#timer-value {
    color: #fbbf24;
    font-weight: bold;
}

/* ===== コンボゲージ ===== */
#combo-gauge-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 5px 20px;
    background: rgba(0, 0, 0, 0.2);
}

#combo-gauge {
    width: 200px;
    height: 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#combo-gauge-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #60a5fa 0%, #4ade80 50%, #fbbf24 100%);
    border-radius: 6px;
    transition: width 0.2s ease;
}

#combo-gauge-fill.full {
    animation: gaugePulse 0.3s ease;
}

@keyframes gaugePulse {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.3); }
}

#combo-gauge-label {
    color: #60a5fa;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* ===== ランキングタブ ===== */
.ranking-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.ranking-tab {
    padding: 8px 16px;
    font-size: 0.9rem;
    border: 2px solid #60a5fa;
    border-radius: 15px;
    background: transparent;
    color: #60a5fa;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ranking-tab.active {
    background: #60a5fa;
    color: #1a1a2e;
}

.ranking-tab:hover {
    background: rgba(96, 165, 250, 0.3);
}

/* ===== サブボタン ===== */
.sub-btn {
    padding: 10px 30px;
    font-size: 1.1rem;
    background: transparent;
    border: 2px solid #60a5fa;
    border-radius: 30px;
    color: #60a5fa;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.sub-btn:hover {
    background: rgba(96, 165, 250, 0.2);
}

/* ===== スコア登録 ===== */
.score-submit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
}

#player-name {
    padding: 12px 20px;
    font-size: 1.1rem;
    border: 2px solid #60a5fa;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 250px;
    text-align: center;
}

#player-name::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#player-name:focus {
    outline: none;
    border-color: #4ade80;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

#submit-score-btn {
    padding: 10px 30px;
    font-size: 1rem;
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
    border: none;
    border-radius: 25px;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

#submit-score-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(96, 165, 250, 0.4);
}

#submit-score-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
}

.rank-result {
    font-size: 1.3rem;
    color: #fbbf24;
    margin: 10px 0;
}

.gameover-buttons {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

/* ===== ランキング画面 ===== */
#ranking-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.95);
    color: #fff;
    z-index: 3000;
    padding: 20px;
    padding-bottom: 80px;
    overflow: hidden;
}

#ranking-screen h2 {
    font-size: 2rem;
    color: #fbbf24;
    text-shadow: 0 0 10px #fbbf24;
    margin-bottom: 20px;
}

.ranking-list {
    flex: 1;
    width: 100%;
    max-width: 500px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 10px;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.2s;
}

.ranking-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.ranking-item:last-child {
    border-bottom: none;
}

.rank-number {
    width: 50px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #60a5fa;
}

.rank-number.gold {
    color: #fbbf24;
    text-shadow: 0 0 5px #fbbf24;
}

.rank-number.silver {
    color: #cbd5e1;
    text-shadow: 0 0 5px #cbd5e1;
}

.rank-number.bronze {
    color: #f97316;
    text-shadow: 0 0 5px #f97316;
}

.rank-name {
    flex: 1;
    font-size: 1.1rem;
    color: #e2e8f0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-score {
    font-size: 1.1rem;
    font-weight: bold;
    color: #4ade80;
    margin-left: 10px;
}

.rank-combo {
    font-size: 0.9rem;
    color: #f472b6;
    margin-left: 10px;
    white-space: nowrap;
}

#ranking-close-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 40px;
    font-size: 1.1rem;
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 100%);
    border: none;
    border-radius: 30px;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    z-index: 10;
}

#ranking-close-btn:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 222, 128, 0.4);
}

.loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

/* ===== フッター ===== */
#credits {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    padding: 6px 15px;
    text-align: center;
    z-index: 5000;
}

#credits p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.7rem;
    margin: 1px 0;
}

#credits a {
    color: #60a5fa;
    text-decoration: none;
}

#credits a:hover {
    text-decoration: underline;
}

/* ===== タイムアップ演出 ===== */
.glow-effect {
    animation: glowAnim 0.5s ease-in-out infinite alternate !important;
    filter: drop-shadow(0 0 10px #fbbf24) drop-shadow(0 0 20px #fbbf24) brightness(1.3) !important;
}

@keyframes glowAnim {
    0% {
        filter: drop-shadow(0 0 10px #fbbf24) drop-shadow(0 0 20px #fbbf24) brightness(1.3);
    }
    100% {
        filter: drop-shadow(0 0 20px #4ade80) drop-shadow(0 0 40px #4ade80) brightness(1.5);
    }
}

.sparkle-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8rem;
    z-index: 1500;
    animation: sparkleAnim 1.5s ease-out forwards;
    pointer-events: none;
}

@keyframes sparkleAnim {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(2) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(3) rotate(360deg);
        opacity: 0;
    }
}

/* ===== ゲームオーバー演出 ===== */
.shake-effect {
    animation: shakeAnim 0.1s ease-in-out infinite;
}

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

.danger-flash {
    animation: dangerFlash 0.2s ease-in-out infinite;
}

@keyframes dangerFlash {
    0%, 100% {
        box-shadow: 0 0 10px #ef4444;
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 30px #ef4444, 0 0 50px #ef4444;
        opacity: 0.8;
    }
}

.explosion-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10rem;
    z-index: 1500;
    animation: explosionAnim 1.5s ease-out forwards;
    pointer-events: none;
}

@keyframes explosionAnim {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    30% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

.explode-tsuru {
    animation: explodeTsuru 1s ease-out forwards !important;
    animation-delay: var(--explode-delay, 0s);
}

@keyframes explodeTsuru {
    0% {
        transform: translateX(0) translateY(0) rotate(0);
        opacity: 0.8;
    }
    100% {
        transform: translateX(var(--explode-x, 0)) translateY(var(--explode-y, -100px)) rotate(var(--explode-rotate, 360deg));
        opacity: 0;
    }
}

/* レスポンシブ対応 */
@media (max-width: 600px) {
    /* タイトル画面をコンパクトに */
    #title-screen {
        justify-content: flex-start;
        padding: 15px 15px 30px;
        max-height: 100vh;
        overflow-y: auto;
    }

    .game-title {
        font-size: 2.5rem;
        margin-bottom: 15px;
    }

    .title-tsuru {
        gap: 30px;
        margin-bottom: 15px;
    }

    .title-tsuru img {
        width: 70px;
    }

    .direction-label {
        font-size: 1.2rem;
    }

    .instruction {
        font-size: 0.95rem;
        line-height: 1.6;
        margin-bottom: 20px;
    }

    .sound-toggles {
        gap: 15px;
        margin-bottom: 15px;
    }

    .sound-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .mode-select {
        margin-bottom: 15px;
    }

    #start-btn {
        padding: 12px 40px;
        font-size: 1.3rem;
    }

    #ranking-btn {
        margin-top: 10px;
        padding: 8px 25px;
        font-size: 1rem;
    }

    /* ゲーム画面 */
    .drop-zone {
        width: 60px;
    }

    .zone-label {
        font-size: 1.5rem;
    }

    #pile-area {
        left: 60px;
        right: 60px;
        bottom: 10px;
    }

    .piled-tsuru {
        width: 35px !important;
    }

    #header {
        font-size: 1rem;
        padding: 10px 15px;
    }

    #combo-gauge-container {
        padding: 3px 10px;
    }

    #combo-gauge {
        width: 120px;
        height: 10px;
    }

    #combo-gauge-label {
        font-size: 0.7rem;
    }

    #danger-line {
        bottom: 100px;
    }

    .gameover-buttons {
        flex-direction: column;
    }

    #player-name {
        width: 200px;
    }

    .ranking-item {
        padding: 8px 10px;
    }

    .rank-combo {
        display: none;
    }

    .explosion-effect {
        font-size: 6rem;
    }

    /* ランキング画面 */
    #ranking-screen {
        padding: 15px;
        padding-bottom: 70px;
    }

    #ranking-screen h2 {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }

    #ranking-close-btn {
        bottom: 15px;
        padding: 10px 30px;
        font-size: 1rem;
    }
}

@media (max-width: 400px) {
    .game-title {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }

    .title-tsuru {
        gap: 20px;
        margin-bottom: 10px;
    }

    .title-tsuru img {
        width: 55px;
    }

    .direction-label {
        font-size: 1rem;
    }

    .instruction {
        font-size: 0.85rem;
        margin-bottom: 15px;
    }

    .drop-zone {
        width: 50px;
    }

    .zone-label {
        font-size: 1.2rem;
    }

    #pile-area {
        left: 50px;
        right: 50px;
        bottom: 10px;
    }

    .piled-tsuru {
        width: 30px !important;
    }

    #danger-line {
        bottom: 80px;
    }

    .mode-select {
        gap: 5px;
    }

    .mode-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .ranking-tabs {
        gap: 5px;
    }

    .ranking-tab {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    #credits p {
        font-size: 0.6rem;
    }
}
