/* リセット + iOS Safari 向け操作制御 */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
}

::selection {
    background: transparent;
    color: inherit;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    overscroll-behavior: none;
}

:root {
    --ff-window-top: #2b4cc4;
    --ff-window-bottom: #0a1450;
    --ff-border-light: #e9f0ff;
    --ff-border-dark: #4b6bd8;
    --ff-text: #ffffff;
    --ff-text-shadow: 1px 1px 0 #0a0f30, 2px 2px 0 rgba(0, 0, 0, 0.4);
    --ff-accent: #ffd54a;
    /* 左親指向け：十字キーを大きめ */
    --pad-size: clamp(148px, 42vw, 190px);
    --btn-size: clamp(68px, 18vw, 84px);
    --pad-h: clamp(168px, 26dvh, 220px);
}

body {
    font-family: 'DotGothic16', 'Courier New', monospace;
    background: radial-gradient(circle at 50% 0%, #1b1f4a 0%, #070a22 60%, #03030f 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: stretch;
    color: var(--ff-text);
    padding:
        max(2px, env(safe-area-inset-top))
        max(4px, env(safe-area-inset-right))
        0
        max(4px, env(safe-area-inset-left));
}

/* ===== レイアウト：プレイ画面を最大化 ===== */
.game-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    background: transparent;
}

/* ===== プレイ画面（残り高さを全部使う） ===== */
.game-area {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    border: 3px solid var(--ff-border-light);
    border-radius: 10px 10px 0 0;
    box-shadow:
        0 0 0 2px var(--ff-border-dark),
        inset 0 0 18px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    touch-action: none;
    background: #1a2440;
}

/* コンパクトHUD（ゲーム画面内オーバーレイ＝縦スペースを奪わない） */
.hud {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 130;
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 6px;
    padding: 4px 10px;
    width: auto;
    max-width: calc(100% - 16px);
    background: linear-gradient(180deg, rgba(43, 76, 196, 0.88) 0%, rgba(10, 20, 80, 0.9) 100%);
    border: 2px solid var(--ff-border-light);
    border-radius: 8px;
    box-shadow:
        0 0 0 2px rgba(10, 20, 80, 0.7),
        0 2px 8px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.hud-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
    line-height: 1.1;
    padding: 0 4px;
}

.hud .label {
    font-size: 0.58rem;
    color: var(--ff-accent);
    text-shadow: 1px 1px 0 #0a0f30;
}

.hud .stat {
    font-size: 1rem;
    text-shadow: var(--ff-text-shadow);
    white-space: nowrap;
}

/* 「17秒」を横並びで一体表示 */
.hud .time-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
    flex-direction: row;
}

.hud .time-stat #time {
    font-size: 1rem;
}

.hud .time-unit {
    font-size: 0.78rem;
    margin-left: 1px;
}

.hud-pause {
    pointer-events: auto;
    margin-left: 4px;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    background: rgba(0, 0, 30, 0.35);
    color: #fff;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
    transition: transform 0.07s ease;
}

.hud-pause:active,
.hud-pause.pressed {
    transform: scale(0.9) translateY(1px);
}

#lives.danger,
#time.danger {
    color: #ff6b6b;
}

#lives.danger {
    animation: lifePulse 0.6s infinite;
}

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

/* ===== 風景レイヤー（クロスフェード用二重構造） ===== */
.scenery-stack {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.scenery {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.scenery-layer {
    opacity: 0;
    transition: opacity 0.85s ease-in-out;
    will-change: opacity;
}

.scenery-layer.is-active {
    opacity: 1;
}

.scenery .sky,
.scenery .far,
.scenery .mid,
.scenery .near,
.scenery .prop {
    position: absolute;
    pointer-events: none;
}

.scenery .sky { inset: 0; }
.scenery .far { left: 0; right: 0; bottom: 26%; height: 44%; }
.scenery .mid { left: 0; right: 0; bottom: 10%; height: 34%; }
.scenery .near { left: 0; right: 0; bottom: 0; height: 20%; }

/* --- 風景1: 陽だまりの庭（丘・木・花） --- */
.scenery.stage-1 .sky {
    background: linear-gradient(180deg, #6bb8ff 0%, #b8e4ff 45%, #eaf6c4 100%);
}
.scenery.stage-1 .sky::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 12%;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff7c8 0%, #ffd54a 55%, #f0a020 100%);
    box-shadow: 0 0 28px 10px rgba(255, 220, 100, 0.45);
}
.scenery.stage-1 .sky::after {
    content: '';
    position: absolute;
    top: 14%;
    right: 8%;
    width: 70px;
    height: 28px;
    background:
        radial-gradient(ellipse 40% 70% at 20% 60%, #fff 0%, transparent 70%),
        radial-gradient(ellipse 50% 80% at 55% 50%, #fff 0%, transparent 70%),
        radial-gradient(ellipse 35% 60% at 85% 65%, #fff 0%, transparent 70%);
    opacity: 0.85;
}
.scenery.stage-1 .far {
    background:
        radial-gradient(ellipse 42% 70% at 15% 100%, #6bb86a 0%, transparent 72%),
        radial-gradient(ellipse 50% 80% at 70% 100%, #4e9a48 0%, transparent 72%),
        radial-gradient(ellipse 35% 55% at 45% 100%, #7ec96f 0%, transparent 70%);
}
.scenery.stage-1 .mid {
    background: linear-gradient(180deg, transparent 0%, #8fd18a 35%, #5fad5a 100%);
    clip-path: polygon(0 60%, 14% 42%, 30% 52%, 48% 28%, 66% 48%, 82% 24%, 100% 46%, 100% 100%, 0 100%);
}
.scenery.stage-1 .near {
    background: linear-gradient(180deg, #a8e078 0%, #6fbf4e 50%, #4a8f30 100%);
}
.scenery.stage-1 .prop-a {
    left: 8%;
    bottom: 16%;
    width: 36px;
    height: 70px;
    background:
        linear-gradient(90deg, transparent 40%, #6b4226 40%, #6b4226 60%, transparent 60%),
        radial-gradient(ellipse 90% 55% at 50% 28%, #3d9a3a 0%, #2a7028 70%, transparent 71%);
    background-size: 100% 100%, 100% 70%;
    background-position: bottom, top;
    background-repeat: no-repeat;
}
.scenery.stage-1 .prop-b {
    right: 12%;
    bottom: 14%;
    width: 44px;
    height: 78px;
    background:
        linear-gradient(90deg, transparent 38%, #5a3518 38%, #5a3518 62%, transparent 62%),
        radial-gradient(ellipse 95% 58% at 50% 30%, #4aad48 0%, #2f7a2c 72%, transparent 73%);
    background-size: 100% 100%, 100% 72%;
    background-position: bottom, top;
    background-repeat: no-repeat;
}
.scenery.stage-1 .near::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 18% 35%, #ff8ab8 0 3px, transparent 4px),
        radial-gradient(circle at 38% 55%, #fff 0 2px, transparent 3px),
        radial-gradient(circle at 62% 30%, #ffd54a 0 2.5px, transparent 3.5px),
        radial-gradient(circle at 78% 60%, #ff8ab8 0 3px, transparent 4px),
        radial-gradient(circle at 88% 25%, #fff 0 2px, transparent 3px);
}

/* --- 風景2: 海辺の桟橋 --- */
.scenery.stage-2 .sky {
    background: linear-gradient(180deg, #3a96d8 0%, #9fd4f0 48%, #f5e6b0 100%);
}
.scenery.stage-2 .sky::before {
    content: '';
    position: absolute;
    top: 12%;
    right: 14%;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff8e0, #ffcc66 60%, #f0a020);
    box-shadow: 0 0 24px 8px rgba(255, 200, 80, 0.4);
}
.scenery.stage-2 .far {
    background: linear-gradient(180deg, transparent 30%, #2f7fb8 100%);
}
.scenery.stage-2 .mid {
    background:
        linear-gradient(180deg, #3aa0d0 0%, #2478a8 100%);
}
.scenery.stage-2 .mid::before {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 18%;
    height: 40%;
    background:
        repeating-linear-gradient(
            90deg,
            transparent 0 28px,
            rgba(255, 255, 255, 0.18) 28px 46px
        );
    opacity: 0.7;
}
.scenery.stage-2 .mid::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 22%;
    height: 4px;
    background: repeating-linear-gradient(90deg, #fff7 0 20px, transparent 20px 40px);
}
.scenery.stage-2 .near {
    background: linear-gradient(180deg, #e8d5a3 0%, #c4a86a 45%, #a88848 100%);
}
.scenery.stage-2 .prop-a {
    left: 18%;
    bottom: 18%;
    width: 64%;
    height: 14px;
    background: #8b6914;
    box-shadow: 0 5px 0 #6e5210;
    border-radius: 2px;
}
.scenery.stage-2 .prop-a::before,
.scenery.stage-2 .prop-a::after {
    content: '';
    position: absolute;
    bottom: -18px;
    width: 8px;
    height: 22px;
    background: #6e5210;
}
.scenery.stage-2 .prop-a::before { left: 12%; }
.scenery.stage-2 .prop-a::after { right: 12%; }
.scenery.stage-2 .prop-b {
    right: 10%;
    bottom: 28%;
    width: 28px;
    height: 36px;
    background: #c45a3a;
    clip-path: polygon(50% 0%, 100% 100%, 0 100%);
    opacity: 0.9;
}

/* --- 風景3: 夕暮れの街角 --- */
.scenery.stage-3 .sky {
    background: linear-gradient(180deg, #1a1038 0%, #b04838 42%, #f0a060 100%);
}
.scenery.stage-3 .sky::before {
    content: '';
    position: absolute;
    top: 28%;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffd080 0%, #ff8a40 55%, transparent 70%);
    opacity: 0.9;
}
.scenery.stage-3 .far {
    bottom: 18%;
    height: 52%;
    background:
        linear-gradient(90deg,
            transparent 0%,
            #151022 6%, #151022 16%, transparent 17%,
            #1c1630 28%, #1c1630 40%, transparent 41%,
            #151022 52%, #151022 64%, transparent 65%,
            #1c1630 74%, #1c1630 90%, transparent 91%);
}
.scenery.stage-3 .far::after {
    content: '';
    position: absolute;
    inset: 25% 0 0 0;
    background:
        radial-gradient(circle at 11% 42%, #ffdb6e 0 2px, transparent 3px),
        radial-gradient(circle at 34% 58%, #ffdb6e 0 2px, transparent 3px),
        radial-gradient(circle at 58% 38%, #ffdb6e 0 1.5px, transparent 2.5px),
        radial-gradient(circle at 82% 52%, #ffdb6e 0 2px, transparent 3px);
}
.scenery.stage-3 .mid {
    background: linear-gradient(180deg, #3a2848 0%, #2a1c38 100%);
    clip-path: polygon(0 38%, 100% 52%, 100% 100%, 0 100%);
}
.scenery.stage-3 .near {
    background: linear-gradient(180deg, #4a3a55 0%, #2a2238 100%);
}
.scenery.stage-3 .prop-a {
    left: 22%;
    bottom: 18%;
    width: 18px;
    height: 52px;
    background: #2a2038;
    box-shadow: 28px 8px 0 #221830, 56px 0 0 #2e2440;
}
.scenery.stage-3 .prop-b {
    right: 20%;
    bottom: 20%;
    width: 22px;
    height: 60px;
    background: #1e1830;
    box-shadow: -30px 10px 0 #281e3a;
}

/* --- 風景4: 月夜の路地 --- */
.scenery.stage-4 .sky {
    background: linear-gradient(180deg, #040710 0%, #101838 50%, #1a2448 100%);
}
.scenery.stage-4 .sky::before {
    content: '';
    position: absolute;
    top: 8%;
    right: 14%;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff8e0 0%, #f0e0a0 45%, #d4c878 100%);
    box-shadow: 0 0 32px 10px rgba(255, 245, 180, 0.35);
}
.scenery.stage-4 .sky::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 10% 16%, #fff 0 1px, transparent 2px),
        radial-gradient(circle at 26% 30%, #fff 0 1px, transparent 2px),
        radial-gradient(circle at 48% 10%, #fff 0 1.5px, transparent 2px),
        radial-gradient(circle at 68% 38%, #fff 0 1px, transparent 2px),
        radial-gradient(circle at 86% 20%, #fff 0 1px, transparent 2px),
        radial-gradient(circle at 40% 48%, #fff 0 1px, transparent 2px);
    opacity: 0.75;
}
.scenery.stage-4 .far {
    background: linear-gradient(180deg, transparent 0%, #0c1228 100%);
}
.scenery.stage-4 .mid {
    background:
        linear-gradient(90deg, #1a2238 0 20%, transparent 20% 26%, #162033 26% 52%, transparent 52% 60%, #1c2740 60% 100%);
    clip-path: polygon(0 18%, 100% 32%, 100% 100%, 0 100%);
}
.scenery.stage-4 .near {
    background: linear-gradient(180deg, #141a2c 0%, #080c18 100%);
}
.scenery.stage-4 .prop-a {
    left: 8%;
    bottom: 16%;
    width: 40px;
    height: 90px;
    background: #121828;
    box-shadow: inset -8px 0 0 rgba(255, 220, 120, 0.08);
}
.scenery.stage-4 .prop-a::after {
    content: '';
    position: absolute;
    top: 28%;
    left: 8px;
    width: 10px;
    height: 10px;
    background: #ffd54a;
    box-shadow: 0 0 8px #ffd54a, 16px 22px 0 0 #ffb74a, 0 44px 0 0 #ffe082;
    opacity: 0.85;
}
.scenery.stage-4 .prop-b {
    right: 6%;
    bottom: 14%;
    width: 48px;
    height: 100px;
    background: #101624;
}

/* --- 風景5: 桜の丘 --- */
.scenery.stage-5 .sky {
    background: linear-gradient(180deg, #7eb8e8 0%, #f0c8d8 55%, #ffe8f0 100%);
}
.scenery.stage-5 .far {
    background:
        radial-gradient(ellipse 40% 60% at 22% 80%, #f5a8c8 0%, transparent 70%),
        radial-gradient(ellipse 48% 65% at 72% 85%, #f090b8 0%, transparent 70%);
}
.scenery.stage-5 .mid {
    background: linear-gradient(180deg, #c8e8a8 0%, #9dcf78 100%);
    clip-path: polygon(0 52%, 22% 30%, 48% 46%, 72% 18%, 100% 40%, 100% 100%, 0 100%);
}
.scenery.stage-5 .near {
    background: linear-gradient(180deg, #b8e090 0%, #7cbc58 100%);
}
.scenery.stage-5 .prop-a,
.scenery.stage-5 .prop-b {
    bottom: 16%;
    width: 54px;
    height: 88px;
    background:
        linear-gradient(90deg, transparent 42%, #6b4226 42%, #6b4226 58%, transparent 58%),
        radial-gradient(ellipse 100% 55% at 50% 28%, #ffb0d0 0%, #f090b8 55%, transparent 70%);
    background-size: 100% 100%, 100% 68%;
    background-position: bottom, top;
    background-repeat: no-repeat;
}
.scenery.stage-5 .prop-a { left: 10%; }
.scenery.stage-5 .prop-b { right: 14%; height: 96px; width: 60px; }
.scenery.stage-5 .near::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 15% 40%, #ffb7d5 0 5px, transparent 6px),
        radial-gradient(circle at 40% 20%, #ffc0dc 0 4px, transparent 5px),
        radial-gradient(circle at 65% 50%, #ffb0d0 0 6px, transparent 7px),
        radial-gradient(circle at 85% 25%, #ffc8e0 0 4px, transparent 5px);
    opacity: 0.9;
}

.place-tag {
    position: absolute;
    transition: opacity 0.35s ease, transform 0.45s ease;
    top: 42px;
    left: 8px;
    z-index: 120;
    font-size: 0.68rem;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
    background: rgba(10, 20, 60, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    padding: 2px 8px;
    pointer-events: none;
    letter-spacing: 0.04em;
}

.place-tag.is-swapping {
    opacity: 0;
    transform: translateY(-6px);
}

.game-area.thunder-flash {
    animation: thunderFlash 0.45s ease-out;
}

@keyframes thunderFlash {
    0% { filter: brightness(1); }
    15% { filter: brightness(1.85) saturate(0.7); }
    30% { filter: brightness(0.9); }
    50% { filter: brightness(1.55); }
    100% { filter: brightness(1); }
}

.gameover-cats {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.gameover-panel {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(8, 16, 60, 0.55);
    border: 2px solid rgba(255, 255, 255, 0.28);
    max-width: 92%;
}

.gameover-cat {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: catPopIn 0.55s ease-out both, catFloat 2.4s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.gameover-cat img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.gameover-cat .emoji-cat {
    line-height: 1;
}

@keyframes catPopIn {
    0% { opacity: 0; transform: scale(0.3) translateY(20px); }
    70% { opacity: 1; transform: scale(1.08) translateY(-4px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

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

.basket {
    position: absolute;
    bottom: 12px;
    font-size: clamp(38px, 11vw, 52px);
    z-index: 100;
    transform: translateX(-50%);
    transition: left 0.05s linear;
}

.falling-item {
    position: absolute;
    width: 50px;
    height: 50px;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.falling-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.falling-item.cat { font-size: 45px; }
.falling-item.bomb { font-size: 40px; animation: shake 0.5s infinite; }
.falling-item.speed { font-size: 35px; animation: sparkle 1s infinite; }
.falling-item.dog { font-size: 45px; }
.falling-item.ice { font-size: 40px; animation: iceShine 1s infinite; }
.falling-item.rain { font-size: 40px; animation: rainSway 1s infinite; }
.falling-item.golden_cat img { width: 56px; height: 56px; display: block; }
.falling-item.fish {
    font-size: 42px;
    animation: fishSwim 0.6s ease-in-out infinite alternate;
}

.falling-item.is-doubled {
    filter: invert(1) hue-rotate(180deg) !important;
    animation: none !important;
}

.falling-item.is-bouncing {
    z-index: 60;
}

.shot {
    position: absolute;
    width: 14px;
    height: 14px;
    margin-left: -7px;
    border-radius: 50%;
    z-index: 80;
    pointer-events: none;
    background: radial-gradient(circle at 35% 30%, #fff9c4, #ffeb3b 45%, #ff9800 100%);
    box-shadow: 0 0 10px #ffeb3b, 0 0 18px rgba(255, 193, 7, 0.7);
}

@keyframes fishSwim {
    from { transform: rotate(-8deg) translateX(-2px); }
    to { transform: rotate(8deg) translateX(2px); }
}

/* ===== 雨：右上起点→右・左・真下へ扇状 ===== */
.rain-layer {
    position: absolute;
    inset: 0;
    z-index: 40;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
    overflow: hidden;
}

.rain-effect .rain-layer {
    opacity: 1;
}

.rain-effect .game-area {
    filter: saturate(0.7) brightness(0.82);
}

.rain-effect .basket {
    filter: blur(1.4px);
    opacity: 0.82;
}

.rain-drop {
    position: absolute;
    width: 2px;
    height: 16px;
    background: linear-gradient(180deg, transparent, rgba(210, 230, 255, 0.95));
    border-radius: 1px;
    transform-origin: top center;
    animation-name: rainFall;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    will-change: transform, opacity;
}

@keyframes rainFall {
    0% {
        transform: translate(0, 0) rotate(var(--rain-rot, 25deg));
        opacity: 0;
    }
    6% { opacity: 0.95; }
    100% {
        transform: translate(var(--rain-drift, -20vw), 130vh) rotate(var(--rain-rot, 25deg));
        opacity: 0.1;
    }
}

/* ボーナス */
.bonus-stage .game-area {
    box-shadow: 0 0 28px #4fc3f7, inset 0 0 40px rgba(79, 195, 247, 0.25);
    border-color: #4fc3f7;
    animation: bonusPulse 1.2s ease-in-out infinite;
}

@keyframes bonusPulse {
    0%, 100% { filter: saturate(1.1); }
    50% { filter: saturate(1.35) brightness(1.05); }
}

.bonus-timer {
    position: absolute;
    top: 42px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 210;
    font-size: 0.95rem;
    font-weight: 900;
    color: #fff59d;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    white-space: nowrap;
    background: rgba(10, 20, 80, 0.55);
    padding: 4px 12px;
    border: 2px solid #4fc3f7;
    border-radius: 6px;
}

.speed-boost .game-area {
    box-shadow: 0 0 20px #ffeb3b;
    border-color: #ffeb3b;
}

.slow-motion .game-area {
    box-shadow: 0 0 20px #87ceeb;
    border-color: #4169e1;
}

/* ボタン（オーバーレイ用） */
.btn {
    position: relative;
    font-family: inherit;
    background: linear-gradient(180deg, #2b4cc4 0%, #0a1450 100%);
    color: var(--ff-text);
    border: 2px solid var(--ff-border-light);
    padding: 12px 22px 12px 30px;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.08s ease;
    box-shadow: 0 0 0 2px var(--ff-border-dark), 0 4px 0 #061030, 0 6px 12px rgba(0, 0, 0, 0.4);
    text-shadow: var(--ff-text-shadow);
    touch-action: manipulation;
}

.btn::before {
    content: '▶';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ff-accent);
    opacity: 0;
}

.btn:active,
.btn.pressed {
    transform: translateY(3px) scale(0.96);
    box-shadow: 0 0 0 2px var(--ff-border-dark), 0 1px 0 #061030, inset 0 2px 6px rgba(0, 0, 0, 0.35);
}

.btn:active::before,
.btn:hover::before {
    opacity: 1;
}

.btn-sub {
    opacity: 0.9;
    font-size: 0.9rem;
    padding: 10px 18px 10px 28px;
}

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

.effect {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
    font-size: 28px;
    animation: effectPop 1s ease-out forwards;
}

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

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.2) rotate(180deg); opacity: 0.7; }
}

@keyframes iceShine {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.1); filter: brightness(1.3); }
}

@keyframes rainSway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(3px); }
}

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

@keyframes goldGlow {
    0% { filter: drop-shadow(0 0 6px gold); }
    100% { filter: drop-shadow(0 0 16px gold); }
}

.combo-display {
    position: absolute;
    top: 42px;
    left: 50%;
    transform: translateX(-50%) scale(1);
    z-index: 200;
    font-weight: 900;
    font-size: 1.2rem;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.combo-display.show { opacity: 1; }
.combo-display.pop { animation: comboPop 0.3s ease; }

@keyframes comboPop {
    0% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.3); }
    100% { transform: translateX(-50%) scale(1); }
}

.combo-display .multiplier {
    display: block;
    font-size: 0.8rem;
    color: #ffeaa7;
    text-align: center;
}

.banner {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    z-index: 300;
    font-weight: 900;
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    opacity: 0;
    text-align: center;
    white-space: nowrap;
}

.banner.show { animation: bannerPop 1.2s ease forwards; }

@keyframes bannerPop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 400;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(180deg, rgba(43, 76, 196, 0.93) 0%, rgba(10, 20, 80, 0.95) 100%);
    color: var(--ff-text);
    text-align: center;
    padding: 16px;
    text-shadow: var(--ff-text-shadow);
}

.overlay h2 {
    font-size: 1.4rem;
    letter-spacing: 0.04em;
    color: var(--ff-accent);
}

.overlay p {
    font-size: 0.9rem;
    line-height: 1.6;
    opacity: 0.95;
}

.overlay .hint-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    font-size: 0.74rem;
    padding: 8px 12px;
    border: 2px solid var(--ff-border-light);
    border-radius: 6px;
    background: rgba(0, 0, 20, 0.25);
    max-width: 92%;
}

.overlay .big-emoji {
    font-size: 2.6rem;
    animation: bounce 1.2s infinite;
}

.game-over-overlay .result-line {
    font-size: 1.05rem;
    margin: 2px 0;
}

.countdown {
    position: absolute;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.countdown span { animation: countdownPop 0.9s ease; }

@keyframes countdownPop {
    0% { transform: scale(2.2); opacity: 0; }
    30% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.6); opacity: 0; }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.game-area.sound-effect { animation: flash 0.3s; }
.game-area.dog-catch { animation: dogWarn 0.3s; }

@keyframes flash {
    0%, 100% { filter: none; }
    50% { filter: brightness(1.4) saturate(1.3); }
}

@keyframes dogWarn {
    0%, 100% { filter: none; }
    50% { filter: sepia(0.4) hue-rotate(-20deg) brightness(1.1); }
}

/* ===== ファミコン風パッド（携帯縦長・左親指重視） ===== */
.fc-pad {
    flex: 0 0 var(--pad-h);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
    background: linear-gradient(180deg, #3a3a48 0%, #1e1e28 100%);
    border: 3px solid #6a6a78;
    border-top: none;
    border-radius: 0 0 14px 14px;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.45);
}

.fc-dpad {
    width: var(--pad-size);
    height: var(--pad-size);
    display: grid;
    grid-template-columns: 1.15fr 1fr 1.15fr;
    grid-template-rows: 0.75fr 1.25fr 0.75fr;
    gap: 4px;
    /* 左親指の自然な位置へ寄せる */
    margin-left: 2px;
    margin-bottom: 2px;
}

.fc-btn {
    border: none;
    border-radius: 8px;
    background: #2a2a34;
    color: #c8c8d0;
    font-size: 1.25rem;
    font-family: inherit;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.1),
        0 4px 0 #111118;
    transition: transform 0.07s ease, background 0.07s ease, box-shadow 0.07s ease;
    touch-action: none;
}

.fc-btn:disabled {
    opacity: 0.22;
    box-shadow: none;
}

.fc-btn:not(:disabled):active,
.fc-btn.pressed {
    transform: translateY(3px) scale(0.95);
    background: #454556;
    box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.55);
    color: #fff;
}

.fc-up { grid-column: 2; grid-row: 1; }
.fc-left {
    grid-column: 1;
    grid-row: 2;
    font-size: 1.45rem;
}
.fc-center {
    grid-column: 2;
    grid-row: 2;
    background: #22222c;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
}
.fc-right {
    grid-column: 3;
    grid-row: 2;
    font-size: 1.45rem;
}
.fc-down { grid-column: 2; grid-row: 3; }

.fc-actions {
    display: flex;
    gap: clamp(12px, 4vw, 20px);
    align-items: center;
    padding-right: 2px;
    /* Aを少し下・右へ（右親指） */
    padding-top: 10px;
}

.fc-round {
    width: var(--btn-size);
    height: var(--btn-size);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-family: inherit;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    box-shadow:
        0 6px 0 rgba(0, 0, 0, 0.45),
        inset 0 2px 0 rgba(255, 255, 255, 0.28);
    transition: transform 0.07s ease, box-shadow 0.07s ease;
    touch-action: none;
    line-height: 1.05;
}

.fc-round .fc-letter {
    font-size: 1.4rem;
    font-weight: 700;
}

.fc-round small {
    font-size: 0.52rem;
    letter-spacing: 0.04em;
    opacity: 0.9;
}

.fc-a {
    background: radial-gradient(circle at 35% 30%, #ff8a80, #c62828 70%);
    transform: translateY(6px);
}

.fc-b {
    background: radial-gradient(circle at 35% 30%, #ffd54f, #f9a825 70%);
    color: #3a2800;
    text-shadow: none;
}

.fc-round:active,
.fc-round.pressed {
    transform: translateY(5px) scale(0.93);
    box-shadow:
        0 2px 0 rgba(0, 0, 0, 0.45),
        inset 0 3px 8px rgba(0, 0, 0, 0.4);
}

.fc-a:active,
.fc-a.pressed {
    transform: translateY(9px) scale(0.93);
}

@media (max-width: 380px) {
    :root {
        --pad-size: clamp(140px, 44vw, 170px);
        --btn-size: clamp(64px, 19vw, 78px);
        --pad-h: clamp(160px, 28dvh, 200px);
    }

    .hud .stat,
    .hud .time-stat #time {
        font-size: 0.92rem;
    }

    .overlay .hint-grid {
        font-size: 0.68rem;
        gap: 3px 8px;
    }

    .banner { font-size: 1.2rem; }
}

@media (max-height: 700px) {
    :root {
        --pad-h: clamp(150px, 24dvh, 180px);
        --pad-size: clamp(136px, 38vw, 160px);
    }

    .overlay .hint-grid {
        max-height: 28vh;
        overflow: auto;
    }
}

@media (min-width: 700px) {
    .game-container {
        max-width: 520px;
        max-height: min(900px, 100dvh);
        margin: auto;
        padding: 8px 0;
    }

    .game-area { border-radius: 10px 10px 0 0; }

    :root {
        --pad-size: 176px;
        --btn-size: 86px;
        --pad-h: 200px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rain-drop,
    .falling-item.bomb,
    .falling-item.speed,
    .falling-item.ice,
    .falling-item.rain,
    .falling-item.fish,
    .overlay .big-emoji {
        animation: none !important;
    }
}
