:root {
    --bg-color: #fffde7;
    --main-color: #ff9800;
    --sub-color: #4dd0e1;
    --accent-pink: #ff80ab;
    --back-gray: #b0bec5;
    --text-brown: #5d4037;
    --white: #ffffff;
}

/* --- 基本設定 & Android縮小対策 --- */
html {
    touch-action: manipulation; /* スマホでのダブルタップ拡大を防止 */
    -webkit-text-size-adjust: 100%; /* Androidでの文字サイズ勝手な変更を防止 */
    text-size-adjust: 100%;
}

body {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(#ffe082 20%, transparent 20%);
    background-size: 24px 24px;
    margin: 0; padding: 0;
    color: var(--text-brown);
    overflow-x: hidden; /* 横揺れ防止 */
    width: 100%;
}

#app {
    width: 100%;
    max-width: 500px; /* PCでは広がりすぎないように */
    min-height: 100vh;
    min-height: -webkit-fill-available; /* スマホのアドレスバー対策 */
    background: rgba(255,255,255,0.95);
    margin: 0 auto;
    position: relative;
    box-shadow: 0 0 30px rgba(0,0,0,0.1);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* --- 画面切り替え --- */
.screen { display: none; padding: 20px; width: 100%; box-sizing: border-box; flex-grow: 1; }
.active { display: block; animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- タイトル画面のデザイン --- */
.title-container {
    display: flex; flex-direction: column; align-items: center; margin: 20px 0; gap: 15px;
}
.nyanto-circle {
    width: 120px; height: 120px; background: white;
    border: 6px solid var(--accent-pink); border-radius: 50%;
    overflow: hidden; box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
.nyanto-circle img {
    width: 100%; height: 100%; object-fit: cover;
    transform: scale(1.2) translateY(5px);
}

/* タイトル文字の色帯デコレーション */
.logo-area { text-align: center; }
.main-title {
    display: flex; justify-content: center; gap: 5px; margin: 0; padding: 10px;
    perspective: 500px;
}
.main-title .bounce {
    display: inline-block; font-size: 42px; font-weight: 900; color: white;
    padding: 5px 10px; border-radius: 12px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
    transform: rotate(-3deg); box-shadow: 3px 3px 0 rgba(0,0,0,0.15);
}
.c1 { background-color: #ff5252; } .c2 { background-color: #448aff; }
.c3 { background-color: #ffab40; } .c4 { background-color: #69f0ae; }

.sub-title {
    display: inline-block; font-size: 18px; font-weight: 900; color: white;
    background: linear-gradient(90deg, #ff80ab, #f06292);
    padding: 5px 20px; border-radius: 50px; margin-top: 5px;
    box-shadow: 0 4px 0 #d81b60; animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }


/* --- UIパーツ --- */
.card-panel {
    background: var(--white); padding: 25px 20px; border-radius: 30px;
    text-align: center; border: 5px solid #fce4ec; box-shadow: 0 8px 0 #f8bbd0;
    margin-bottom: 25px; width: 100%; box-sizing: border-box;
}

.kids-input {
    width: 100%; max-width: 100%; padding: 15px;
    border: 3px solid #eee; border-radius: 20px;
    font-size: 18px; text-align: center; box-sizing: border-box;
    margin-bottom: 15px; font-family: inherit; font-weight: bold; background: #f9f9f9;
}

/* ぷにぷにボタン */
.btn-pop {
    width: 100%; padding: 18px; font-size: 20px; font-weight: 900;
    color: white; border-radius: 50px; margin-bottom: 15px;
    border: none; cursor: pointer; position: relative; top: 0;
    transition: 0.1s; display: flex; align-items: center; justify-content: center;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}
.btn-main { background: var(--main-color); box-shadow: 0 6px 0 #ef6c00; }
.btn-sub { background: var(--sub-color); box-shadow: 0 6px 0 #00acc1; }
.btn-pink { background: var(--accent-pink); box-shadow: 0 6px 0 #f06292; }
.btn-back { background: var(--back-gray); box-shadow: 0 6px 0 #78909c; font-size: 16px; padding: 12px; }
.btn-pop:active { top: 6px; box-shadow: none !important; }

/* クイズ用 */
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.choice-btn {
    background: var(--white); border: 4px solid #eee; border-radius: 15px;
    padding: 15px 5px; font-size: 18px; font-weight: 900; color: var(--text-brown);
    box-shadow: 0 5px 0 #ddd; position: relative; width: 100%;
}
.choice-btn:active { top: 5px; box-shadow: none; }

.quiz-card {
    background: white; border-radius: 15px; padding: 10px;
    border: 3px solid #eee; text-align: center; cursor: pointer;
}
.quiz-img { max-width: 100%; height: auto; max-height: 160px; object-fit: contain; display: block; margin: 0 auto; }

.region-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.region-check {
    background: #fff; border: 3px solid #eee; padding: 12px 5px;
    border-radius: 15px; font-size: 16px; font-weight: 800; box-shadow: 0 4px 0 #eee;
}
.region-check.checked {
    background: var(--accent-pink); color: white; border-color: #f06292; box-shadow: 0 4px 0 #d81b60;
}

/* ヘッダー */
.header-bar {
    background: var(--white); padding: 8px 15px; border-radius: 30px;
    display: flex; justify-content: space-between; align-items: center;
    border: 3px solid #eee; margin-bottom: 20px;
}
.pt-badge { background: #ffe082; padding: 5px 12px; border-radius: 50px; font-weight: 900; border: 2px solid #ffca28; }

/* --- ガチャ & 図鑑 --- */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); display: none;
    justify-content: center; align-items: center; z-index: 10000; overflow-y: auto;
}
#gacha-results { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 20px; }

.item-card {
    background: white; padding: 10px; border-radius: 15px; text-align: center;
    width: 85px; border: 4px solid #eee; box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    transform: scale(0); animation: pop-card 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.27) forwards;
}
@keyframes pop-card { to { transform: scale(1); } }
.item-star-tag { font-size: 10px; color: #ff9800; font-weight: 900; }
.item-name-tag { font-size: 10px; font-weight: 900; margin-top: 5px; line-height: 1.2; }
.r5 { background: #fff9c4; animation: rainbow-glow 2s infinite; }
@keyframes rainbow-glow { 0% { box-shadow: 0 0 5px red; } 50% { box-shadow: 0 0 15px yellow; } 100% { box-shadow: 0 0 5px red; } }

.zukan-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.slot { background: #eee; border-radius: 8px; text-align: center; padding: 5px; font-size: 12px; color: #aaa; }
.zukan-item { background: #fff; border: 2px solid #ffcc80; border-radius: 8px; padding: 2px; text-align: center; }
.zukan-star { font-size: 8px; color: #ff9800; display: block; }
.zukan-name { font-size: 9px; font-weight: 900; display: block; white-space: nowrap; overflow: hidden; }

/* --- アニメーション & エフェクト --- */
.correct-flash { animation: flash-green 0.5s ease; }
@keyframes flash-green { 50% { background-color: #c8e6c9; } }

.wrong-shake { animation: shake-red 0.5s ease; }
@keyframes shake-red {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); background-color: #ffcdd2; }
    75% { transform: translateX(8px); }
}

.ready-flash { animation: flash-ready 0.4s ease 2; }
@keyframes flash-ready { 50% { background-color: #ffcc80; transform: scale(1.02); } }

.gacha-shake { animation: gacha-vibrate 0.5s linear infinite; }
@keyframes gacha-vibrate {
    0% { transform: translate(0,0); } 25% { transform: translate(3px, 3px) rotate(1deg); }
    50% { transform: translate(0, -3px) rotate(-1deg); } 75% { transform: translate(-3px, 3px) rotate(1deg); }
}

.gacha-flash {
    position: fixed; top:0; left:0; width:100%; height:100%;
    background: white; z-index: 11000; opacity: 0; pointer-events: none;
}
.do-flash { animation: flash-white 0.8s ease-out; }
@keyframes flash-white { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }

.pt-anim {
    position: fixed; font-size: 40px; font-weight: 900; color: #ff9800;
    text-shadow: 2px 2px 0 #fff; z-index: 9999; pointer-events: none;
    animation: move-to-pt 1.2s cubic-bezier(0.5, -0.5, 0.5, 1.5) forwards;
}
@keyframes move-to-pt {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    30% { transform: translate(-50%, -80%) scale(1.2); opacity: 1; }
    100% { transform: translate(120px, -350px) scale(0); opacity: 0; }
}

.cat-particle {
    position: fixed; font-size: 24px; pointer-events: none; z-index: 9999;
    animation: cat-fly 1.5s cubic-bezier(0.12, 0, 0.39, 0) forwards;
}
@keyframes cat-fly {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translate(var(--mx), var(--my)) rotate(var(--mr)) scale(0); opacity: 0; }
}

/* --- にゃんとくんステージ（PCデフォルト設定） --- */
/* PCでは画面中央寄り、右下に全身を表示 */
#nyanto-stage {
    position: fixed; bottom: -10px; left: 50%;
    transform: translateX(calc(-50% + 240px));
    z-index: 4000; pointer-events: none;
    display: flex; flex-direction: column; align-items: flex-end;
}
#nyanto-img {
    width: 220px; transform: translateY(220px);
    transition: 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#nyanto-img.show { transform: translateY(0); }

.speech-bubble {
    background: #fff; border: 4px solid var(--accent-pink); border-radius: 20px;
    padding: 10px 15px; font-weight: 900; box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    opacity: 0; transform: scale(0.5); transition: 0.3s; pointer-events: auto;
    max-width: 200px; margin-bottom: -15px; position: relative; right: 20px;
}
.speech-bubble.show { opacity: 1; transform: scale(1); }


/* --- ★重要：スマホ・Android対応（幅600px以下） --- */
@media screen and (max-width: 600px) {
    /* フォントサイズの強制調整 */
    body { font-size: 16px; }

    /* 猫ステージ：右下に固定 & はみ出し防止 */
    #nyanto-stage {
        left: auto; transform: none;
        right: 0; bottom: 0;
        width: 100%; max-width: 100vw;
        padding-right: 0;
        align-items: flex-end; /* 右寄せ */
    }

    /* 猫画像：スマホでは上半身だけ出す調整 */
    #nyanto-img {
        width: 140px; /* サイズを控えめに */
        margin-right: -10px; /* 右端に寄せる */
        /* ★ここがポイント！体を下に埋めて上半身だけ見せる */
        margin-bottom: -40px; 
        transform: translateY(200px); /* 初期位置（隠れてる） */
    }
    #nyanto-img.show {
        /* 上がってきても、-40px分は埋まったまま＝上半身ひょっこり */
        transform: translateY(0);
    }

    /* 吹き出し：画面からはみ出ないように */
    .speech-bubble {
        right: 10px; margin-bottom: 5px;
        max-width: 85vw; /* 画面幅いっぱいまで許可 */
        font-size: 14px;
    }

    /* 入力欄やボタンを大きく押しやすく */
    .kids-input { font-size: 18px; padding: 12px; }
    .btn-pop { font-size: 18px; padding: 15px; }
    .card-panel { padding: 20px 15px; width: 96%; margin-left: auto; margin-right: auto; }
    
    /* タイトルの調整（折り返さないサイズ） */
    .main-title .bounce { font-size: 32px; padding: 4px 8px; }
    .nyanto-circle { width: 90px; height: 90px; }
}