/* 基本スタイル - 万博2025デザインシステム準拠 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: 
        radial-gradient(circle at 20% 30%, rgba(230, 0, 18, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(65, 105, 225, 0.3) 0%, transparent 50%),
        linear-gradient(135deg, 
            #E60012 0%, #C8102E 20%, 
            #4169E1 50%, #0033A0 70%, 
            #E60012 100%
        );
    background-size: 100% 100%, 100% 100%, 300% 300%;
    animation: gradientFlow 20s ease infinite;
    font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    touch-action: pan-y pinch-zoom;
}

@keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#game-container {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 5px;
    overflow: visible;
    touch-action: pan-y;
}

/* スマホ版レイアウト */
.left-panel, .right-panel {
    display: none;
}

.center-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 500px;
    padding-bottom: 30px;
}

.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 15px;
    border-radius: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.mini-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #FF1493;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mini-score {
    font-size: 24px;
    font-weight: bold;
    color: #E60012;
    flex-grow: 1;
    text-align: center;
}

.mini-next {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#mobile-next-canvas {
    width: 40px;
    height: 40px;
}

#mobile-next-canvas {
    display: block;
}

.pause-button-pc {
    display: none;
}

#game-canvas-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: min(400px, 90vw);
    height: min(650px, calc(100vh - 200px));
    max-height: calc(100vh - 200px);
    aspect-ratio: 400 / 650;
}

#game-canvas-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

canvas {
    border: 2px solid #e5e5e5;
    background-color: #fff;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
    border-radius: 14px;
    touch-action: none;
}

/* ランキングタブ（共通スタイル） */
.ranking-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.ranking-tab {
    flex: 1;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(139, 69, 19, 0.3);
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    color: #8B4513;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
}

.ranking-tab:hover {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(139, 69, 19, 0.5);
}

.ranking-tab.active {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-color: #FF8C00;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.ranking-content {
    position: relative;
}

.ranking-list {
    display: none;
}

.ranking-list.active {
    display: block;
}

.ranking-panel {
    background: rgba(255, 235, 200, 0.9);
    padding: 15px;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.8);
    width: 100%;
    max-width: 400px;
    margin: 10px auto;
}

/* PC版：3カラムレイアウト */
@media (min-width: 1024px) {
    #game-container {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 25px;
        padding: 20px;
    }

    .left-panel, .right-panel {
        display: flex;
        flex-direction: column;
        gap: 20px;
        flex-shrink: 0;
    }

    .mobile-header {
        display: none;
    }

    .center-area {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .pause-button-pc {
        display: block;
        padding: 12px 40px;
        font-size: 16px;
        font-weight: bold;
        background: #FF1493;
        color: white;
        border: none;
        border-radius: 50px;
        cursor: pointer;
        box-shadow: 0 5px 15px rgba(255, 20, 147, 0.4);
        transition: all 0.3s;
    }

    .pause-button-pc:hover {
        background: #FF69B4;
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(255, 20, 147, 0.5);
    }

    /* 左パネル */
    .score-panel {
        background: rgba(255, 200, 100, 0.95);
        padding: 25px;
        border-radius: 30px;
        text-align: center;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        border: 4px solid rgba(255, 255, 255, 0.8);
        width: 200px;
    }

    .panel-title {
        font-size: 18px;
        font-weight: bold;
        color: #fff;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
        margin-bottom: 10px;
    }

    .current-score {
        font-size: 52px;
        font-weight: bold;
        color: #FFD700;
        text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
        margin: 10px 0;
    }

    .best-score-label {
        font-size: 13px;
        color: #fff;
        opacity: 0.9;
        margin-top: 10px;
    }

    .best-score-value {
        font-size: 26px;
        font-weight: bold;
        color: #fff;
    }

    .ranking-panel {
        background: rgba(255, 235, 200, 0.95);
        padding: 20px;
        border-radius: 30px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        border: 4px solid rgba(255, 255, 255, 0.8);
        width: 200px;
    }

    .ranking-tabs {
        display: flex;
        gap: 8px;
        margin-bottom: 15px;
    }

    .ranking-tab {
        flex: 1;
        padding: 8px 12px;
        background: rgba(255, 255, 255, 0.5);
        border: 2px solid rgba(139, 69, 19, 0.3);
        border-radius: 15px;
        font-size: 13px;
        font-weight: bold;
        color: #8B4513;
        cursor: pointer;
        transition: all 0.3s;
    }

    .ranking-tab:hover {
        background: rgba(255, 255, 255, 0.7);
        border-color: rgba(139, 69, 19, 0.5);
    }

    .ranking-tab.active {
        background: linear-gradient(135deg, #FFD700, #FFA500);
        border-color: #FF8C00;
        color: white;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    }

    .ranking-content {
        position: relative;
    }

    .ranking-list {
        display: none;
    }

    .ranking-list.active {
        display: block;
    }

    .ranking-title {
        text-align: center;
        font-size: 15px;
        font-weight: bold;
        color: #8B4513;
        margin-bottom: 15px;
        line-height: 1.5;
    }

    .ranking-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px;
        margin: 5px 0;
        border-radius: 15px;
        background: rgba(255, 255, 255, 0.6);
    }

    .rank-now {
        background: rgba(255, 215, 0, 0.4);
        border: 2px solid #FFD700;
    }

    .rank-icon {
        font-size: 22px;
    }

    .rank-label {
        font-weight: bold;
        color: #E60012;
        font-size: 14px;
    }

    .rank-score {
        font-weight: bold;
        color: #666;
        font-size: 14px;
    }

    .rank-score.current {
        color: #E60012;
    }

    /* 右パネル */
    .next-panel {
        background: rgba(255, 200, 150, 0.95);
        padding: 20px;
        border-radius: 30px;
        text-align: center;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        border: 4px solid rgba(255, 255, 255, 0.8);
        width: 180px;
    }

    .next-title {
        font-size: 18px;
        font-weight: bold;
        color: #fff;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
        margin-bottom: 10px;
    }

    .next-preview-large {
        width: 140px;
        height: 140px;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }
    
    #next-canvas {
        display: block;
    }

    .evolution-panel {
        background: rgba(200, 255, 200, 0.95);
        padding: 15px;
        border-radius: 30px;
        text-align: center;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        border: 4px solid rgba(255, 255, 255, 0.8);
        width: 180px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .evolution-title {
        font-size: 16px;
        font-weight: bold;
        color: #2E8B57;
        margin-bottom: 10px;
    }

    #evolution-ring-canvas {
        display: block;
        margin: 0 auto;
    }
}

/* 一時停止ポップアップ */
.pause-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.pause-popup.active {
    display: flex;
}

.pause-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 240, 255, 0.95));
    padding: 40px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    border: 4px solid rgba(255, 105, 180, 0.6);
}

.pause-title {
    font-size: 28px;
    font-weight: bold;
    color: #E60012;
    margin-bottom: 30px;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pause-btn {
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
}

.continue-btn {
    background: linear-gradient(135deg, #4169E1, #00CED1);
    color: white;
}

.restart-btn {
    background: linear-gradient(135deg, #FF6B35, #FFA500);
    color: white;
}

.share-btn {
    background: linear-gradient(135deg, #9370DB, #FF69B4);
    color: white;
}

.pause-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* ゲームオーバー */
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, rgba(230, 0, 18, 0.95), rgba(65, 105, 225, 0.95));
    display: none;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 10px 80px 10px;
}

.game-over-title {
    font-size: 36px;
    font-weight: bold;
    color: white;
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.5);
    margin-bottom: 15px;
}

.score-details {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    text-align: center;
}

.score-details .current-score,
.score-details .best-score-display {
    font-size: 18px;
    font-weight: bold;
    color: #E60012;
    margin: 5px 0;
}

.game-over-buttons {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.retry-button, .share-button {
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 150px;
    z-index: 101;
}

.retry-button {
    background: linear-gradient(135deg, #00CED1, #4169E1);
    color: white;
}

.share-button {
    background: linear-gradient(135deg, #FF69B4, #9370DB);
    color: white;
}

.retry-button:hover, .share-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.new-record {
    font-size: 24px;
    font-weight: bold;
    color: #FFD700;
    animation: recordPulse 1s ease infinite;
    margin: 15px 0;
}

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

/* ゲームオーバー画面のランキング */
.gameover-ranking {
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 15px;
    border-radius: 15px;
    margin: 30px auto;
    max-width: 350px;
    width: 90%;
}

.gameover-ranking-list {
    display: none !important;
}

.gameover-ranking-list.active {
    display: flex !important;
}

.gameover-ranking-title {
    font-size: 14px;
    font-weight: bold;
    color: #8B4513;
    text-align: center;
    margin-bottom: 8px;
}

.gameover-ranking-list {
    flex-direction: column;
    gap: 6px;
}

.gameover-ranking-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(255, 215, 0, 0.2);
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.4);
}

.gameover-ranking-item .rank-icon {
    font-size: 18px;
}

.gameover-ranking-item .rank-score {
    font-size: 14px;
    font-weight: bold;
    color: #E60012;
}

/* ========================================
   広告スタイル
======================================== */

/* AdSense が潰れないよう最低高さと display を明示 */
ins.adsbygoogle {
    display: block !important;
    width: 100% !important;
    min-height: 120px;
}

/* サイドバー広告 */
.ad-sidebar {
    margin-top: 20px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* ゲームオーバー広告 */
.ad-gameover {
    margin: 20px auto;
    padding: 10px;
    max-width: 400px;
    min-height: 140px;
    overflow-y: visible;
    max-height: none;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* リスタート広告オーバーレイ */
.ad-restart-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.ad-restart-overlay.active {
    display: flex;
}

.ad-restart-content {
    background: white;
    border-radius: 30px;
    padding: 30px;
    max-width: 90%;
    max-height: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    text-align: center;
}

.ad-countdown {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
    animation: pulse 1s infinite;
}

.ad-countdown-number {
    color: #FF1493;
    font-size: 24px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.ad-restart-box {
    min-width: 300px;
    min-height: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: scroll;
    max-height: none;
}

/* モバイル表示時は広告を調整 */
@media (max-width: 1023px) {
    .ad-sidebar {
        display: none;
    }
    
    .ad-gameover {
        max-width: 90%;
    }
    
    .ad-restart-content {
        padding: 20px;
    }
    
    .ad-restart-box {
        min-width: 250px;
        min-height: 200px;
    }
}




/* やり直し確認モーダル */
.restart-confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.restart-confirm-modal.active {
    display: flex;
}

.restart-confirm-content {
    background: #2a2a2a;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    text-align: center;
    color: white;
}

.restart-confirm-content h2 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #ffffff;
}

.restart-confirm-content p {
    font-size: 16px;
    margin-bottom: 25px;
    line-height: 1.5;
}

.restart-confirm-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.restart-cancel-btn,
.restart-ok-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.restart-cancel-btn {
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.restart-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.restart-ok-btn {
    background: #a594f9;
    color: white;
}

.restart-ok-btn:hover {
    background: #9484e9;
    transform: translateY(-2px);
}

/* 一時停止ボタンを右パネルに配置 */
@media (min-width: 1024px) {
    .pause-button-pc {
        width: 100%;
        margin: 15px 0;
        padding: 12px 20px;
    }
}

/* 左パネルの高さ調整 */
@media (min-width: 1024px) {
    .score-panel {
        padding: 15px;
        min-height: auto;
    }
    
    .ranking-panel {
        padding: 20px;
        flex-shrink: 0;
    }
    
    .ranking-panel::-webkit-scrollbar {
        width: 6px;
    }
    
    .ranking-panel::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 10px;
    }
    
    .ranking-panel::-webkit-scrollbar-thumb {
        background: rgba(255, 200, 100, 0.5);
        border-radius: 10px;
    }
    
    .ad-sidebar {
        max-height: 250px;
        overflow: hidden;
        flex-shrink: 0;
    }
    
    .left-panel {
        max-height: calc(100vh - 40px);
        overflow: visible;
    }
}

/* 一時停止広告 */
.ad-pause {
    margin: 20px auto;
    padding: 10px;
    min-height: 140px;
    max-width: 400px;
    overflow-y: visible;
    max-height: none;
}

/* PC下部広告 */
.ad-pc-bottom {
    display: none;
}

@media (min-width: 1024px) {
    .ad-pc-bottom {
        display: block;
        width: 100%;
        max-width: 728px;
        margin: 20px auto;
        padding: 10px;
        text-align: center;
        min-height: 140px;
        overflow-y: visible;
        max-height: none;
    }
}

/* 広告×ボタン */
.ad-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
    z-index: 10001;
}

.ad-close-btn:hover {
    background: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ad-restart-content {
    position: relative;
}

/* モバイル/タブレット用のマージン調整 */
@media (max-width: 1023px) {
    body {
        padding: 20px 10px;
    }
    
    #game-container {
        padding: 20px 0;
    }
    
    .center-area {
        margin: 20px 0;
    }
    
    .mobile-header {
        margin-bottom: 15px;
    }
}

/* PC画面の中央揃え */
@media (min-width: 1024px) {
    body {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding: 20px;
    }
    
    #game-container {
        max-width: 1200px;
        margin: 0 auto;
    }
}
