* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #1a1a1a;
    color: #fff;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    position: fixed; /* iOS Safariのアドレスバー対策としてスクロールを完全に防ぐ */
    top: 0;
    left: 0;
}

/* 汎用非表示クラス */
.hidden {
    display: none !important;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: calc(100vh * 9 / 16); /* 画面の高さに応じて最大幅を動的計算（タブレット対応） */
    max-height: 100vh;
    aspect-ratio: 9 / 16;
    background-color: #ffe4b5; /* フォールバック */
    background-image: linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05)), url('apple-orchard-background.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    margin: 0 auto; /* 中央配置 */
}

@media (min-aspect-ratio: 9/16) {
    #game-container {
        height: 100%;
        width: auto;
    }
}

@media (max-aspect-ratio: 9/16) {
    #game-container {
        width: 100%;
        height: auto;
    }
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.left-ui {
    display: flex;
    flex-direction: row; /* 横並びに変更して被りを軽減 */
    align-items: flex-start; /* 上揃えに戻す */
    gap: 8px;
    pointer-events: auto; /* ボタンをクリック可能にするため */
}

/* ブラウザの余白・オーバースクロール領域も暗色にそろえる。 */
html {
    background-color: #1a1a1a;
}

#score-board {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.3); /* 枠線追加 */
    border-radius: 10px; /* 角丸統一 */
    padding: 6px 10px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    line-height: 1.3;
    display: flex;
    flex-direction: column; /* 2行に戻す */
    justify-content: center; /* 縦方向の中央揃え */
}

#next-box {
    background: rgba(0, 0, 0, 0.5); /* 背景色統一 */
    border: 2px solid rgba(255, 255, 255, 0.3); /* 枠線追加 */
    border-radius: 10px; /* 角丸統一 */
    padding: 4px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    margin-top: -4px;
}



#next-preview {
    margin-top: 4px;
    width: 40px; /* リンゴのサイズを戻す */
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none; /* スマホのスワイプスクロール防止 */
}

/* スタート画面 */
#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: clamp(16px, 4vh, 36px) 12px clamp(44px, 8vh, 64px);
    gap: 20px;
    z-index: 30;
    color: #583722;
    text-align: center;
}

#sound-toggle-btn {
    height: 29px; /* スコアボード(約58px)の半分に設定 */
    padding: 0 8px;
    border-radius: 6px; /* 角丸も少し小さく調整 */
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 14px; /* ネクスト・スコアに合わせて少し大きく */
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s, transform 0.1s;
}

#sound-toggle-btn:active {
    transform: scale(0.9);
}

#sound-toggle-btn.muted {
    background-color: rgba(255, 50, 50, 0.5);
}

#start-screen h1 {
    font-size: 28px;
    margin-bottom: 10px;
    color: #ff9933;
    display: inline-block; /* ブロック自体の幅を中身に合わせる */
    text-align: left; /* 中身のテキストは左揃えにする */
}

#start-screen .title-logo {
    width: 96%;
    margin: 0 0 12px;
    line-height: 0;
    flex-shrink: 0;
    text-align: center;
}
.title-logo img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 32vh;
    max-height: 32dvh;
    object-fit: contain;
}

#start-screen p {
    font-size: 16px;
    margin-bottom: 30px;
    color: #71523c;
}

/* モード選択UI */
.mode-selection {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

.mode-btn {
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background-color: #555;
    border: 3px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Hiragino Maru Gothic ProN', 'M PLUS Rounded 1c', sans-serif;
}

.mode-btn:hover {
    background-color: #666;
}

/* 選択されたモード */
.mode-btn.selected {
    background-color: #ff3366; /* 少し目立つ色 */
    border: 3px solid #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(255, 51, 102, 0.4);
}

#btn-hard-mode.selected {
    background-color: #9900cc; /* HARD用にもう少しダークな色に */
    box-shadow: 0 4px 10px rgba(153, 0, 204, 0.4);
}

#start-button {
    padding: 15px 40px;
    font-size: 22px;
    font-weight: bold;
    color: #fff;
    background-color: #33ccff;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
}

#start-button:active:not(:disabled) {
    transform: scale(0.95);
}

#start-button:hover:not(:disabled) {
    background-color: #00bfff;
}

#start-button:disabled {
    background-color: #888;
    cursor: not-allowed;
    transform: none;
}

.line-share-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    color: #ccc;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    cursor: pointer;
    margin-top: 20px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
    font-family: 'Hiragino Maru Gothic ProN', 'M PLUS Rounded 1c', sans-serif;
}

.line-share-btn:hover {
    background-color: rgba(0, 195, 0, 0.15);
    border-color: #00c300;
    color: #fff;
}

#start-screen.hidden {
    display: none;
}

/* ゲームオーバー画面 */
#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-top: 60px; /* GAME OVERの文字を少し下に移動 */
    z-index: 20;
    color: #fff;
}

#game-over-screen.hidden {
    display: none;
}

#game-over-screen h1 {
    font-size: 36px;
    margin-bottom: 10px;
    color: #ff4d4d;
}

#game-over-screen .best-score {
    font-size: 20px;
    margin-bottom: 5px;
}

#new-best-notice {
    color: #ffd700; /* ゴールド */
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    margin-bottom: 10px;
    animation: newBestPulse 1.5s infinite alternate;
}

@keyframes newBestPulse {
    from { transform: scale(1); opacity: 0.8; }
    to { transform: scale(1.1); opacity: 1; }
}

.final-score, .best-score {
    font-size: 24px;
    margin-bottom: 5px;
}

.harvest-result {
    font-size: 16px;
    margin-bottom: 10px;
    color: #ffebcd; /* 少し柔らかい色味 */
}

#retry-button {
    margin-top: 8px; /* ランキングとの間を詰める */
    padding: 12px 32px;
    font-size: 20px;
    font-weight: bold;
    color: #fff;
    background-color: #ff8c00;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
}

#retry-button:active {
    transform: scale(0.95);
}

#retry-button:hover {
    background-color: #ffa500;
}

/* ランキングUI */
#ranking-container {
    width: 100%;
    margin-top: 8px;
    margin-bottom: 5px; /* 「もう一回」ボタンとの間を詰める */
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

#ranking-loading, #ranking-error {
    font-size: 14px;
    color: #ccc;
}

.highlight-text {
    color: #ffcc00;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 5px;
    animation: flash 1.5s infinite alternate;
}

@keyframes flash {
    0% { opacity: 1; text-shadow: 0 0 10px #ffcc00; }
    100% { opacity: 0.8; text-shadow: 0 0 5px #ffcc00; }
}

#ranking-input-section input {
    width: 80%;
    padding: 10px;
    margin-top: 10px;
    border: 2px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
    text-align: center;
}

#submit-score-button {
    margin-top: 10px;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background-color: #32cd32;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
}

#submit-score-button:disabled {
    background-color: #777;
    cursor: not-allowed;
    transform: none;
}

#submit-score-button:active:not(:disabled) {
    transform: scale(0.95);
}

.ranking-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.ranking-tab {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.ranking-tab:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.ranking-tab.active {
    background-color: #ffdf00;
    color: #333;
    font-weight: bold;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

#ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    display: inline-block;
    width: 100%;
}

#ranking-list li {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 16px;
    font-family: monospace;
}

#ranking-list li:last-child {
    border-bottom: none;
}

#ranking-list li.current-player {
    background: rgba(255, 215, 0, 0.3);
    font-weight: bold;
    border-radius: 5px;
}

/* スコアポップアップアニメーション */
.score-popup {
    position: absolute;
    /* 日本語対応の丸ゴシック系フォントを指定 */
    font-family: 'Hiragino Maru Gothic ProN', 'ヒラギノ丸ゴ ProN W4', 'M PLUS Rounded 1c', 'YuRounded', 'Arial Rounded MT Bold', sans-serif;
    font-weight: 900;
    
    /* 黄金のグラデーション */
    background: linear-gradient(180deg, #ffffff 0%, #ffea00 40%, #ff8c00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    
    /* グラデーションテキスト用の影（text-shadowではなくdrop-shadowを使用） */
    filter: drop-shadow(0px 4px 2px rgba(0,0,0,0.5)) drop-shadow(0px 0px 4px rgba(255,100,0,0.8));
    
    pointer-events: none;
    z-index: 50;
    transform-origin: center center;
    
    /* 跳ねるようなイージング関数 */
    animation: popupAnim 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popupAnim {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(-15deg); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1.5) rotate(5deg); }
    35% { opacity: 1; transform: translate(-50%, calc(-50% - 30px)) scale(1.1) rotate(0deg); }
    70% { opacity: 1; transform: translate(-50%, calc(-50% - 20px)) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, calc(-50% - 80px)) scale(1.5); }
}

/* コンボ用スコア表示のベース */
.score-popup.combo-text {
    /* コンテナ自体は色を持たず、子要素のFlexレイアウトを担当 */
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    filter: drop-shadow(0px 4px 2px rgba(80,40,20,0.8));
    z-index: 60; /* 通常スコアより手前 */
    animation: comboPopupAnim 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

/* 点数部分（上段） */
.score-popup.combo-text .score-val {
    /* 通常のスコアと同じような明るい黄金のグラデーション */
    background: linear-gradient(180deg, #ffffff 0%, #ffea00 40%, #ff8c00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.1em;
}

/* コンボテキスト部分（下段） */
.score-popup.combo-text .combo-val {
    /* 少し控えめでリッチなゴールドに変更 */
    background: linear-gradient(180deg, #ffffff 0%, #ffeaa7 40%, #f39c12 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 0.6em; /* コンボ文字は小さくして邪魔にならないように */
    white-space: nowrap;
}

@keyframes comboPopupAnim {
    /* 回転をなくし、拡縮も少しマイルドにして「うるささ」を軽減 */
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.4); }
    40% { opacity: 1; transform: translate(-50%, calc(-50% - 20px)) scale(1.2); }
    70% { opacity: 1; transform: translate(-50%, calc(-50% - 10px)) scale(1.25); }
    100% { opacity: 0; transform: translate(-50%, calc(-50% - 60px)) scale(1.4); }
}

/* 台風後のゲームオーバー救済演出 */
.chicori-rescue {
    position: absolute;
    z-index: 110;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.chicori-rescue-heading {
    position: absolute;
    z-index: 1;
    top: 31%;
    left: 50%;
    width: 88%;
    max-width: 410px;
    height: auto;
    transform: translateX(-50%);
    transition: opacity .3s;
    user-select: none;
}

.chicori-rescue canvas {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
}

/* 大収穫ポップアップ */
.daisyukaku-popup {
    position: absolute;
    font-family: 'M PLUS Rounded 1c', 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', sans-serif;
    font-size: clamp(50px, 18vw, 90px); /* さらに大きく目立つように調整 */
    font-weight: 800; /* ExtraBold */
    color: #E84A3A;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
    transform-origin: center center;
    
    /* 二重フチと薄い影をtext-shadowで表現 */
    text-shadow: 
        /* 内側の白フチ (#FFFDF8) */
        -2px -2px 0 #FFFDF8,  2px -2px 0 #FFFDF8,
        -2px  2px 0 #FFFDF8,  2px  2px 0 #FFFDF8,
         0px -2px 0 #FFFDF8,  0px  2px 0 #FFFDF8,
        -2px  0px 0 #FFFDF8,  2px  0px 0 #FFFDF8,
        
        /* 外側の赤茶フチ (#9E3B2E) - 白の2px分よりさらに外側に3px分追加 (計5px) */
        -5px -5px 0 #9E3B2E,  5px -5px 0 #9E3B2E,
        -5px  5px 0 #9E3B2E,  5px  5px 0 #9E3B2E,
         0px -5px 0 #9E3B2E,  0px  5px 0 #9E3B2E,
        -5px  0px 0 #9E3B2E,  5px  0px 0 #9E3B2E,
        -4px -5px 0 #9E3B2E,  4px -5px 0 #9E3B2E,
        -5px -4px 0 #9E3B2E,  5px -4px 0 #9E3B2E,
        -4px  5px 0 #9E3B2E,  4px  5px 0 #9E3B2E,
        -5px  4px 0 #9E3B2E,  5px  4px 0 #9E3B2E,
        
        /* 薄いドロップシャドウ（下方向、ぼかし弱め） */
         0px  8px 3px rgba(80, 40, 20, 0.22);
    
    /* アニメーションのカーブを少し柔らかく弾むように設定 */
    animation: daisyukakuAnim 0.9s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.daisyukaku-popup--illustrated {
    width: 90%;
    max-width: 560px;
    font-size: 0;
    text-shadow: none;
    animation: harvestArtworkAnim 1.6s ease-out forwards;
}

.daisyukaku-popup--illustrated img {
    display: block;
    width: 100%;
    height: auto;
}

@keyframes harvestArtworkAnim {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.65); }
    16% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
    28%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -58%) scale(1); }
}

@keyframes daisyukakuAnim {
    0% {
        /* X軸方向は -50% (真ん中) ではなく -46% にして少し右へ光学調整 */
        transform: translate(-46%, -50%) scale(0.6);
        opacity: 0;
    }
    15% {
        transform: translate(-46%, -50%) scale(1.15);
        opacity: 1;
    }
    30% {
        transform: translate(-46%, -50%) scale(1.0);
        opacity: 1;
    }
    80% {
        transform: translate(-46%, -50%) scale(1.0);
        opacity: 1;
    }
    100% {
        transform: translate(-46%, -50%) scale(1.0);
        opacity: 0;
    }
}

/* 横画面（ランドスケープ）対応 */
@media (orientation: landscape) and (max-aspect-ratio: 16/9) {
    /* ゲームコンテナからはみ出すUIの表示を許可 */
    #game-container {
        overflow: visible;
    }
    
    /* 横画面ではUIを左右の余白（黒帯部分）に逃がす */
    .left-ui {
        position: absolute;
        left: -130px;
        top: 20px;
        flex-direction: column; /* 外に逃がした場合は縦並びの方が見やすい */
    }
    
    #next-box {
        position: absolute;
        right: -80px;
        top: 20px;
    }
}

#copyright {
    margin: 0;
    flex: 0 0 auto;
    line-height: 1.5;
    letter-spacing: 0.04em;
    font-size: 13px;
    font-weight: normal;
    color: #725b45;
    text-align: center;
    pointer-events: none;
}

/* ===== 台風イベント用スタイル ===== */
.typhoon-notice {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Hiragino Maru Gothic ProN', 'M PLUS Rounded 1c', sans-serif;
    font-size: clamp(30px, 8vw, 50px);
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 10px rgba(0,0,0,0.8), 0 0 20px rgba(0,200,255,0.8);
    z-index: 100;
    pointer-events: none;
    white-space: nowrap;
    animation: noticeFade 2.5s ease-in-out forwards;
}

@keyframes noticeFade {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    10% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}

.typhoon-notice--illustrated {
    width: 94%;
    max-width: 560px;
    text-shadow: none;
    animation: typhoonArtworkEntrance 2.5s ease-in-out forwards;
}
.typhoon-notice-artwork {
    display: block;
    width: 100%;
    height: auto;
}
@keyframes typhoonArtworkEntrance {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.55) rotate(-8deg); }
    12% { opacity: 1; transform: translate(-50%, -50%) scale(1.04) rotate(3deg); }
    25% { transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
    45% { transform: translate(-50%, -50%) scale(1) rotate(2deg); }
    75% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-1deg); }
    100% { opacity: 0; transform: translate(-38%, -58%) scale(0.96) rotate(6deg); }
}

.typhoon-leaf {
    position: absolute;
    pointer-events: none;
    z-index: 90;
    will-change: transform;
}

/* 葉っぱよりゆっくり横切り、約3秒でもがきながら2回転する。 */
.typhoon-chicori {
    position: absolute;
    left: 0;
    height: auto;
    pointer-events: none;
    z-index: 91;
    will-change: transform;
    animation: chicoriFly 3s linear forwards;
}

@keyframes chicoriFly {
    0% { transform: translate(var(--chicori-start-x), 24px) rotate(var(--chicori-start-angle)); }
    50% { transform: translate(calc((var(--chicori-start-x) + var(--chicori-end-x)) / 2), -36px) rotate(var(--chicori-mid-angle)); }
    100% { transform: translate(var(--chicori-end-x), 40px) rotate(var(--chicori-end-angle)); }
}

@keyframes leafFlyRight {
    0% { transform: translate(-100px, 0) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translate(120vw, var(--dropY)) rotate(var(--rotEnd)); opacity: 0; }
}

@keyframes leafFlyLeft {
    0% { transform: translate(120vw, 0) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translate(-100px, var(--dropY)) rotate(var(--rotEnd)); opacity: 0; }
}

#start-screen .line-share-btn { color: #64452f; border-color: #aa8965; background: rgba(255,255,255,0.35); }

/* ロゴと操作を中央にまとめ、著作権表示は独立したフッターへ。 */
#start-screen .title-content {
    transform: translateY(clamp(8px, 2vh, 16px));
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
#start-screen .title-content > * { flex-shrink: 0; }
#start-screen p { margin-bottom: clamp(18px, 3vh, 28px); font-size: clamp(12px, 3.5vw, 16px); }
#start-screen .mode-selection { margin-bottom: 24px; }
#start-screen .line-share-btn { margin: 16px 0 0; }
@media (max-height: 600px) {
    #start-screen { padding-top: 10px; padding-bottom: 36px; gap: 12px; }
    #start-screen .title-logo { margin-bottom: 4px; }
    .title-logo img { max-height: 27vh; max-height: 27dvh; }
    #start-screen p { margin-bottom: 14px; }
    #start-screen .mode-selection { margin-bottom: 16px; }
    #start-screen .line-share-btn { margin-top: 12px; }
}

/* ===== 2026-10-16 画面の見た目統一・りんごマグネット広告 ===== */
/* 色はロゴの赤・黄・こげ茶に寄せる。ボタンは丸ゴシックのピル型にそろえる。 */
:root {
    --logo-yellow: #f7d84a;
    --logo-yellow-shadow: #c9a52a;
    --logo-ink: #3a1a0e;
}
.pill {
    font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', sans-serif;
    font-weight: 800;
    letter-spacing: .04em;
    border-radius: 999px;
    cursor: pointer;
}

/* りんごマグネット広告（タイトル・ゲームオーバー共通の1行リンク） */
.magnet-ad-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 4px 6px;
    font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: #64452f;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    flex-shrink: 0;
}
.magnet-badge {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    object-fit: contain;
}

/* タイトル画面 */
#start-screen p { font-family: 'M PLUS Rounded 1c', sans-serif; font-weight: 800; color: #5a3320; }
#start-screen .mode-selection { gap: 12px; }
#start-screen .mode-btn {
    padding: 7px 22px;
    font-size: 15px;
    color: #6b3b22;
    background: rgba(255, 255, 255, 0.65);
    border: 2px solid #dcc3a2;
    box-shadow: none;
    transform: none;
}
/* EASY は若葉の緑、HARD はロゴの赤 */
#start-screen .mode-btn.selected {
    color: #fff;
    background: #6cbf3a;
    border-color: #6cbf3a;
    box-shadow: 0 3px 0 #4a8e22;
    transform: none;
}
#start-screen #btn-hard-mode.selected {
    color: #fff;
    background: #ec2235;
    border-color: #ec2235;
    box-shadow: 0 3px 0 #b3121f;
}
#start-screen #start-button {
    padding: 10px 44px;
    font-size: 20px;
    color: #fff;
    background: #1ea7e8;
    border: none;
    box-shadow: 0 3px 0 #1277ad;
}
#start-screen #start-button:disabled { background: #999; box-shadow: 0 3px 0 #777; }
#start-screen #start-button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #1277ad; }
#start-screen .line-share-btn { margin-top: 16px; padding: 8px 20px; font-size: 14px; }
#start-screen .magnet-ad-link {
    margin-top: 12px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(90, 51, 32, 0.18);
}

/* ゲームオーバー画面：暗い幕は残し、文字とアクセントをはっきりさせる */
/* 中身が画面より高いときに上が切れないよう、中央寄せは auto マージンで行いスクロール可能にする */
#game-over-screen {
    justify-content: flex-start;
    overflow-y: auto;
    padding: 24px 20px 20px;
    background: rgba(40, 18, 8, 0.82);
    font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', sans-serif;
}
#game-over-screen h1 {
    font-size: 36px;
    font-weight: 800;
    color: #ff3b4b;
    letter-spacing: .04em;
    margin-top: auto;
    margin-bottom: 6px;
    text-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}
#game-over-screen .final-score { font-size: 26px; font-weight: 800; margin-bottom: 2px; }
.go-sub { display: flex; gap: 16px; font-size: 15px; font-weight: 800; color: #ffe9a8; margin-bottom: 12px; }
.go-sub b { color: var(--logo-yellow); font-weight: 800; }
#game-over-screen #new-best-notice { font-size: 20px; margin: -4px 0 8px; }
#game-over-screen #ranking-container {
    margin: 0 0 14px;
    padding: 10px 12px 6px;
    background: rgba(255, 245, 225, 0.10);
    border: 1px solid rgba(255, 245, 225, 0.22);
    border-radius: 14px;
}
#game-over-screen .ranking-tabs { margin-bottom: 6px; gap: 8px; }
#game-over-screen .ranking-tab {
    padding: 5px 20px;
    font-size: 14px;
    color: #ffe9cc;
    background: rgba(255, 245, 225, 0.16);
    border: none;
    text-decoration: none;
}
/* タイトル画面のモードボタンとそろえる：EASY は若葉の緑、HARD はロゴの赤 */
#game-over-screen #tab-easy.active { background: #6cbf3a; color: #fff; box-shadow: 0 3px 0 #4a8e22; }
#game-over-screen #tab-hard.active { background: #ec2235; color: #fff; box-shadow: 0 3px 0 #b3121f; }
/* grid だと、古い main.js（1行テキスト）のとき 2em 幅の列に全文が入って縦に崩れるため flex にする */
#game-over-screen #ranking-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
    border-bottom: 1px solid rgba(255, 245, 225, 0.16);
}
/* 順位：名前より小さい丸バッジ。1〜3位は金・銀・銅のメダル、1位には王冠 */
#game-over-screen #ranking-list li .rk {
    position: relative;
    flex: 0 0 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #ffe9cc;
    background: rgba(255, 245, 225, 0.14);
    border-radius: 50%;
}
#game-over-screen #ranking-list li:nth-child(1) .rk { color: #5a3a00; background: radial-gradient(circle at 35% 30%, #fff3b0, #f5c518 55%, #c99400); box-shadow: 0 2px 0 #9a7100; }
#game-over-screen #ranking-list li:nth-child(2) .rk { color: #3d4650; background: radial-gradient(circle at 35% 30%, #ffffff, #cfd8e0 55%, #9aa7b2); box-shadow: 0 2px 0 #77838e; }
#game-over-screen #ranking-list li:nth-child(3) .rk { color: #4a2510; background: radial-gradient(circle at 35% 30%, #ffd9b0, #d9894a 55%, #a85e26); box-shadow: 0 2px 0 #7f4519; }
#game-over-screen #ranking-list li:nth-child(1) .rk::before {
    content: "";
    position: absolute;
    top: -11px;
    left: 50%;
    width: 18px;
    height: 12px;
    transform: translateX(-50%);
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 12'%3E%3Cpath d='M1 11 L2 3 L6 7 L9 1 L12 7 L16 3 L17 11 Z' fill='%23f5c518' stroke='%239a7100' stroke-width='1' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
}
#game-over-screen #ranking-list li:nth-child(1) { padding-top: 10px; }
#game-over-screen #ranking-list li .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
/* 点数：全順位で右端にそろえる */
#game-over-screen #ranking-list li .sc { flex: 0 0 auto; min-width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; }
#game-over-screen #ranking-list li.current-player { background: rgba(247, 216, 74, 0.28); border-radius: 6px; }
#game-over-screen .highlight-text { color: var(--logo-yellow); font-size: 18px; }
#game-over-screen #ranking-input-section input { border: 2px solid #dcc3a2; border-radius: 999px; font-family: inherit; padding: 8px 10px; }
#game-over-screen #submit-score-button {
    padding: 8px 24px;
    font-size: 15px;
    color: var(--logo-ink);
    background: var(--logo-yellow);
    box-shadow: 0 3px 0 var(--logo-yellow-shadow);
}
#game-over-screen #retry-button {
    margin: 0 0 10px;
    padding: 9px 40px;
    font-size: 19px;
    color: #fff;
    background: #ff8a1f;
    border: none;
    border-radius: 999px;
    box-shadow: 0 3px 0 #c45f0c;
}
#game-over-screen #retry-button:active { transform: translateY(2px); box-shadow: 0 1px 0 #c45f0c; }
#game-over-screen .line-share-btn {
    margin: 0 0 8px;
    padding: 8px 20px;
    font-size: 14px;
    color: #ffe9cc;
    border-color: rgba(255, 233, 204, 0.5);
}
#game-over-screen .magnet-ad-link { margin-bottom: auto; color: #ffe9cc; background: rgba(255, 245, 225, 0.14); }
