/* ============================================
   どうぶつの村 〜音の絆〜
   メインスタイルシート（全5章対応版）
   ============================================ */

:root {
    --color-bg-dark: #1a2f1a;
    --color-bg-medium: #2d4a2d;
    --color-bg-light: #4a7c4a;
    
    --color-sky-day: #87ceeb;
    --color-sky-sunset: #ff7e5f;
    --color-sky-night: #1a1a3e;
    
    --color-grass: #5fa55f;
    --color-grass-dark: #3d7a3d;
    --color-earth: #8b6b4a;
    
    --color-accent-gold: #ffd700;
    --color-accent-coral: #ff6b6b;
    --color-accent-mint: #98fb98;
    --color-accent-lavender: #e6e6fa;
    
    --color-text-light: #fff8e7;
    --color-text-dark: #2d2d2d;
    
    --color-ui-bg: rgba(255, 248, 231, 0.95);
    --color-ui-border: #8b6b4a;
    
    --font-main: 'Zen Maru Gothic', sans-serif;
    
    --transition-fast: 0.2s ease;
    --transition-medium: 0.4s ease;
    --transition-slow: 0.8s ease;
}

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

body {
    font-family: var(--font-main);
    background: var(--color-bg-dark);
    min-height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* ============================================
   音声コントロール
   ============================================ */
#audio-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
}

.btn-icon-small {
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--color-ui-bg);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn-icon-small:hover {
    transform: scale(1.1);
}

.btn-icon-small.disabled {
    opacity: 0.5;
}

.btn-icon-small.disabled::after {
    content: '🔇';
    position: absolute;
    font-size: 1.2rem;
}

/* ============================================
   共通スクリーンスタイル
   ============================================ */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-medium), visibility var(--transition-medium);
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   ボタンスタイル
   ============================================ */
.btn-primary {
    font-family: var(--font-main);
    font-size: 1.4rem;
    font-weight: 700;
    padding: 1rem 3rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(145deg, var(--color-accent-gold), #e6c200);
    color: var(--color-text-dark);
    cursor: pointer;
    box-shadow: 
        0 4px 15px rgba(255, 215, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 8px 25px rgba(255, 215, 0, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.8rem 2rem;
    border: 3px solid var(--color-text-light);
    border-radius: 30px;
    background: transparent;
    color: var(--color-text-light);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--color-text-light);
    color: var(--color-text-dark);
    transform: scale(1.05);
}

.btn-text {
    font-family: var(--font-main);
    font-size: 1rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.btn-text:hover {
    color: var(--color-text-light);
}

.btn-icon {
    font-size: 1.8rem;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: var(--color-ui-bg);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.btn-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

/* ============================================
   タイトル画面
   ============================================ */
#title-screen {
    background: linear-gradient(180deg, 
        #1a1a3e 0%, 
        #2d2d5e 30%, 
        #4a3f6e 60%, 
        #6b5a7e 100%);
}

.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(1px 1px at 160px 120px, #fff, transparent);
    background-size: 200px 200px;
    animation: twinkle 4s ease-in-out infinite;
}

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

.title-content {
    text-align: center;
    z-index: 10;
    animation: fadeInUp 1s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-title {
    font-size: 4rem;
    font-weight: 900;
    color: var(--color-text-light);
    text-shadow: 
        0 0 20px rgba(255, 215, 0, 0.5),
        0 4px 8px rgba(0,0,0,0.3);
    margin-bottom: 0.5rem;
    letter-spacing: 0.1em;
}

.subtitle {
    font-size: 1.8rem;
    color: var(--color-accent-gold);
    margin-bottom: 2rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.title-decoration {
    margin-bottom: 3rem;
}

.note {
    font-size: 2rem;
    color: var(--color-accent-mint);
    margin: 0 1rem;
    display: inline-block;
    animation: float 2s ease-in-out infinite;
}

.note:nth-child(2) {
    animation-delay: 0.3s;
    color: var(--color-accent-lavender);
}

.note:nth-child(3) {
    animation-delay: 0.6s;
    color: var(--color-accent-coral);
}

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

/* ============================================
   章選択画面
   ============================================ */
#chapter-select-screen {
    background: linear-gradient(180deg, 
        #1a2f3e 0%, 
        #2d4a5e 50%, 
        #4a6a7e 100%);
}

.chapter-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 215, 0, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 80% 70%, rgba(152, 251, 152, 0.1) 0%, transparent 30%);
}

.chapter-select-content {
    z-index: 10;
    text-align: center;
    max-width: 800px;
    padding: 2rem;
}

.chapter-select-title {
    font-size: 2.5rem;
    color: var(--color-text-light);
    margin-bottom: 2rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 2rem;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
}

.chapter-item {
    background: var(--color-ui-bg);
    padding: 1.5rem 2rem;
    border-radius: 15px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 3px solid transparent;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 20px;
}

.chapter-item:hover:not(.locked) {
    transform: translateX(10px);
    border-color: var(--color-accent-gold);
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.3);
}

.chapter-item.locked {
    opacity: 0.6;
    cursor: not-allowed;
}

.chapter-item.locked::after {
    content: '🔒';
    position: absolute;
    right: 20px;
    font-size: 1.5rem;
}

.chapter-number {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--color-accent-gold);
    min-width: 60px;
}

.chapter-info {
    flex: 1;
}

.chapter-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-text-dark);
    margin-bottom: 5px;
}

.chapter-description {
    font-size: 0.95rem;
    color: #666;
}

.chapter-item.completed .chapter-number::after {
    content: '✓';
    font-size: 1rem;
    color: var(--color-accent-mint);
    margin-left: 5px;
}

.chapter-item.secret {
    background: linear-gradient(135deg, rgba(139, 107, 74, 0.1), rgba(74, 58, 126, 0.1));
    border: 3px solid rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.chapter-item.secret:hover:not(.locked) {
    border-color: var(--color-accent-gold);
    box-shadow: 0 5px 30px rgba(255, 215, 0, 0.5);
    transform: translateX(10px) scale(1.02);
}

.chapter-item.secret .chapter-number {
    animation: secretPulse 2s ease-in-out infinite;
}

@keyframes secretPulse {
    0%, 100% { 
        transform: scale(1);
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }
    50% { 
        transform: scale(1.1);
        text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    }
}

/* ============================================
   オープニング画面
   ============================================ */
#opening-screen {
    background: linear-gradient(180deg, #1a1a3e 0%, #2d4a6d 100%);
}

.opening-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 50% 50%, rgba(100, 150, 255, 0.1) 0%, transparent 50%);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.story-box {
    background: var(--color-ui-bg);
    padding: 3rem;
    border-radius: 20px;
    max-width: 600px;
    text-align: center;
    box-shadow: 
        0 10px 40px rgba(0,0,0,0.3),
        inset 0 2px 0 rgba(255,255,255,0.5);
    border: 4px solid var(--color-ui-border);
    z-index: 10;
}

#story-text {
    font-size: 1.3rem;
    line-height: 2;
    color: var(--color-text-dark);
    margin-bottom: 2rem;
    min-height: 120px;
}

.story-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

/* ============================================
   村のマップ画面（3D）
   ============================================ */
#village-screen {
    background: var(--color-sky-day);
    position: relative;
    overflow: hidden;
}

#village-3d-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#village-3d-canvas:active {
    cursor: grabbing;
}

#forest-path-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
}

#forest-path-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

#forest-path-message {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
}

.sky {
    position: absolute;
    width: 100%;
    height: 60%;
    background: linear-gradient(180deg, 
        #4a90c2 0%, 
        #87ceeb 40%, 
        #b0e0e6 100%);
}

.sun {
    position: absolute;
    top: 10%;
    right: 15%;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, 
        #fff 0%, 
        #ffd700 50%, 
        rgba(255, 215, 0, 0) 100%);
    border-radius: 50%;
    box-shadow: 0 0 60px rgba(255, 215, 0, 0.6);
    animation: glow 3s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 60px rgba(255, 215, 0, 0.6); }
    50% { box-shadow: 0 0 80px rgba(255, 215, 0, 0.8); }
}

.clouds {
    position: absolute;
    width: 100%;
    height: 50%;
}

.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50px;
    filter: blur(2px);
}

.cloud::before, .cloud::after {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: 50%;
}

.cloud1 {
    width: 100px;
    height: 40px;
    top: 15%;
    left: 10%;
    animation: cloudMove 20s linear infinite;
}

.cloud1::before {
    width: 50px;
    height: 50px;
    top: -25px;
    left: 15px;
}

.cloud1::after {
    width: 40px;
    height: 40px;
    top: -20px;
    right: 15px;
}

.cloud2 {
    width: 80px;
    height: 30px;
    top: 25%;
    left: 60%;
    animation: cloudMove 25s linear infinite;
}

.cloud2::before {
    width: 40px;
    height: 40px;
    top: -20px;
    left: 10px;
}

.cloud3 {
    width: 120px;
    height: 45px;
    top: 10%;
    left: 35%;
    animation: cloudMove 30s linear infinite;
}

.cloud3::before {
    width: 60px;
    height: 60px;
    top: -30px;
    left: 20px;
}

.cloud3::after {
    width: 50px;
    height: 50px;
    top: -25px;
    right: 20px;
}

@keyframes cloudMove {
    0% { transform: translateX(0); }
    100% { transform: translateX(100vw); }
}

.ground {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 45%;
    background: linear-gradient(180deg, 
        var(--color-grass) 0%, 
        var(--color-grass-dark) 50%,
        var(--color-earth) 100%);
    border-top: 4px solid #4a8c4a;
}

.trees {
    position: absolute;
    bottom: 35%;
    width: 100%;
    height: 200px;
}

.tree {
    position: absolute;
    width: 60px;
    height: 120px;
    background: linear-gradient(180deg, #2d5a2d, #1a3d1a);
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

.tree::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 15px;
    height: 40px;
    background: #5a3d2d;
    border-radius: 3px;
}

.tree1 { left: 5%; }
.tree2 { left: 85%; height: 140px; width: 70px; }
.tree3 { left: 92%; height: 100px; width: 50px; }

.forest-entrance {
    position: absolute;
    right: 0;
    bottom: 20%;
    width: 150px;
    height: 200px;
    cursor: pointer;
    transition: all var(--transition-medium);
    display: none; /* 3D版では非表示 */
}

.dark-forest {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(26, 47, 26, 0.7) 30%, 
        rgba(26, 47, 26, 0.95) 100%);
    clip-path: polygon(0% 100%, 50% 0%, 100% 100%);
}

.forest-label {
    position: absolute;
    bottom: 10px;
    right: 20px;
    color: var(--color-text-light);
    font-size: 0.9rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    opacity: 0.8;
}

.forest-entrance:hover {
    transform: scale(1.05);
}

.forest-entrance:hover .forest-label {
    opacity: 1;
}

/* 3D版の森の入り口 */
.forest-entrance-3d {
    position: absolute;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    background: rgba(26, 47, 26, 0.8);
    border-radius: 15px;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 100;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.forest-entrance-3d:hover {
    background: rgba(26, 47, 26, 0.95);
    transform: scale(1.05);
}

.forest-label-3d {
    color: var(--color-text-light);
    font-size: 1rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#characters-container {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none; /* 3D版では非表示 */
}

.character {
    position: absolute;
    cursor: pointer;
    pointer-events: auto;
    transition: transform var(--transition-fast);
    animation: bobble 2s ease-in-out infinite;
    user-select: none;
}

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

.character[data-dragging="true"] {
    animation: none !important;
    transition: none !important;
    cursor: grabbing !important;
    z-index: 1000;
}

.character:active {
    transform: scale(1.15);
}

.character.befriended {
    filter: drop-shadow(0 0 10px var(--color-accent-gold));
}

.character.escaped {
    opacity: 0.6;
    filter: grayscale(50%);
}

/* うろうろアニメーション（狂った猫たち） */
.character.wobbling {
    animation: wobble 3s ease-in-out infinite, bobble 2s ease-in-out infinite;
}

@keyframes wobble {
    0%, 100% {
        left: var(--wobble-start, 25%);
    }
    25% {
        left: calc(var(--wobble-start, 25%) + 5%);
    }
    50% {
        left: var(--wobble-start, 25%);
    }
    75% {
        left: calc(var(--wobble-start, 25%) - 5%);
    }
}

.character.escaped:hover {
    opacity: 0.9;
    filter: grayscale(0%);
    transform: scale(1.1);
}

.character-sprite {
    font-size: 4rem;
    text-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.character-status {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
}

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

#village-ui {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 100;
}

.chapter-indicator {
    background: linear-gradient(145deg, #4a6a8a, #3a5a7a);
    padding: 8px 20px;
    border-radius: 20px;
    color: var(--color-text-light);
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.friend-counter {
    background: var(--color-ui-bg);
    padding: 10px 25px;
    border-radius: 30px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-text-dark);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 3px solid var(--color-ui-border);
}

.friend-icon {
    margin-right: 5px;
}

.learned-notes {
    display: flex;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.learned-note {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.learned-note.unknown {
    background: #ccc;
    color: #999;
}

.message-box {
    background: var(--color-ui-bg);
    padding: 15px 30px;
    border-radius: 15px;
    font-size: 1.1rem;
    color: var(--color-text-dark);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 3px solid var(--color-ui-border);
    max-width: 80%;
    text-align: center;
}

/* ============================================
   対話画面
   ============================================ */
#dialogue-screen {
    background: linear-gradient(180deg, 
        var(--color-sky-day) 0%, 
        #b0e0e6 100%);
}

.dialogue-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 50%);
}

.character-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
    z-index: 10;
}

.animal-sprite {
    font-size: 6rem;
    animation: bounce 1s ease-in-out infinite;
    text-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

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

/* 対話画面でのうろうろアニメーション */
.animal-sprite.wobbling-dialogue {
    animation: wobbleDialogue 3s ease-in-out infinite !important;
}

@keyframes wobbleDialogue {
    0%, 100% { 
        transform: translateX(0) translateY(0); 
    }
    25% { 
        transform: translateX(40px) translateY(-10px); 
    }
    50% { 
        transform: translateX(0) translateY(-20px); 
    }
    75% { 
        transform: translateX(-40px) translateY(-10px); 
    }
}

/* カエル飛びアニメーション */
.animal-sprite.frog-jump {
    animation: frogJump 1.5s ease-in-out infinite;
}

@keyframes frogJump {
    0%, 100% { transform: translateY(0) translateX(0); }
    25% { transform: translateY(-30px) translateX(10px); }
    50% { transform: translateY(-50px) translateX(20px); }
    75% { transform: translateY(-30px) translateX(10px); }
}

/* ウサギ飛びアニメーション */
.animal-sprite.rabbit-hop {
    animation: rabbitHop 0.8s ease-in-out infinite;
}

@keyframes rabbitHop {
    0%, 100% { transform: translateY(0) scaleY(1); }
    30% { transform: translateY(-40px) scaleY(0.9); }
    50% { transform: translateY(-50px) scaleY(1.1); }
    70% { transform: translateY(-40px) scaleY(0.9); }
}

.note-bubble.high-note {
    border: 3px solid #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.animal-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-dark);
    background: var(--color-ui-bg);
    padding: 8px 25px;
    border-radius: 20px;
    margin-top: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.dialogue-box {
    background: var(--color-ui-bg);
    padding: 20px 40px;
    border-radius: 20px;
    max-width: 500px;
    text-align: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    border: 3px solid var(--color-ui-border);
    z-index: 10;
}

#dialogue-text {
    font-size: 1.2rem;
    color: var(--color-text-dark);
    line-height: 1.8;
}

.music-display {
    background: rgba(255, 255, 255, 0.9);
    padding: 20px 30px;
    border-radius: 20px;
    margin-bottom: 1.5rem;
    min-width: 400px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    z-index: 10;
}

.notes-display {
    display: flex;
    justify-content: center;
    gap: 15px;
    min-height: 60px;
    align-items: center;
    flex-wrap: wrap;
}

.note-bubble {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    animation: popIn 0.3s ease-out;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.note-bubble.hidden-name {
    font-size: 1.5rem;
}

.note-bubble.hidden-name::after {
    content: '?';
}

@keyframes popIn {
    0% { transform: scale(0); }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* 音符の色（白鍵） */
.note-bubble.do { background: linear-gradient(145deg, #ff6b6b, #ee5a5a); }
.note-bubble.re { background: linear-gradient(145deg, #ffa500, #e69500); }
.note-bubble.mi { background: linear-gradient(145deg, #ffd700, #e6c200); }
.note-bubble.fa { background: linear-gradient(145deg, #98fb98, #7de67d); }
.note-bubble.so { background: linear-gradient(145deg, #87ceeb, #6bb8d9); }
.note-bubble.la { background: linear-gradient(145deg, #9370db, #7d5cc5); }
.note-bubble.ti { background: linear-gradient(145deg, #ff69b4, #e65aa0); }

/* 音符の色（黒鍵） */
.note-bubble.do-sharp { background: linear-gradient(145deg, #8b0000, #6b0000); }
.note-bubble.re-sharp { background: linear-gradient(145deg, #8b4500, #6b3500); }
.note-bubble.fa-sharp { background: linear-gradient(145deg, #006400, #004400); }
.note-bubble.so-sharp { background: linear-gradient(145deg, #00008b, #00006b); }
.note-bubble.la-sharp { background: linear-gradient(145deg, #4b0082, #3b0062); }

.vs-divider {
    text-align: center;
    margin: 15px 0;
    color: var(--color-accent-coral);
    font-weight: 700;
    font-size: 1rem;
}

.notes-display.player {
    border: 3px dashed #ccc;
    border-radius: 15px;
    padding: 10px;
    min-height: 70px;
}

/* ============================================
   ピアノキーボード（白鍵+黒鍵）
   ============================================ */
.piano {
    display: flex;
    position: relative;
    margin-bottom: 1.5rem;
    z-index: 10;
    justify-content: center;
}

.piano-key {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.1s;
    user-select: none;
}

.piano-key.white {
    width: 55px;
    height: 120px;
    background: linear-gradient(180deg, #fff 0%, #f0f0f0 100%);
    border: 2px solid #ccc;
    border-radius: 0 0 8px 8px;
    color: var(--color-text-dark);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    font-size: 0.9rem;
    margin: 0 2px;
    z-index: 1;
}

.piano-key.black {
    width: 35px;
    height: 75px;
    background: linear-gradient(180deg, #333 0%, #111 100%);
    border: 2px solid #000;
    border-radius: 0 0 5px 5px;
    color: #ddd;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    font-size: 0.7rem;
    margin: 0 -17px;
    z-index: 2;
    position: relative;
}

.piano-key.white:hover {
    background: linear-gradient(180deg, #fff 0%, #e8e8e8 100%);
}

.piano-key.black:hover {
    background: linear-gradient(180deg, #444 0%, #222 100%);
}

.piano-key.white:active,
.piano-key.white.active {
    background: linear-gradient(180deg, #e0e0e0 0%, #d0d0d0 100%);
    transform: translateY(3px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.piano-key.black:active,
.piano-key.black.active {
    background: linear-gradient(180deg, #222 0%, #000 100%);
    transform: translateY(2px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* 白鍵のアクティブ色 */
.piano-key[data-note="do"].active { background: linear-gradient(180deg, #ff6b6b, #ee5a5a) !important; color: white; }
.piano-key[data-note="re"].active { background: linear-gradient(180deg, #ffa500, #e69500) !important; color: white; }
.piano-key[data-note="mi"].active { background: linear-gradient(180deg, #ffd700, #e6c200) !important; }
.piano-key[data-note="fa"].active { background: linear-gradient(180deg, #98fb98, #7de67d) !important; }
.piano-key[data-note="so"].active { background: linear-gradient(180deg, #87ceeb, #6bb8d9) !important; }
.piano-key[data-note="la"].active { background: linear-gradient(180deg, #9370db, #7d5cc5) !important; color: white; }
.piano-key[data-note="ti"].active { background: linear-gradient(180deg, #ff69b4, #e65aa0) !important; color: white; }

/* 黒鍵のアクティブ色 */
.piano-key[data-note="do#"].active { background: linear-gradient(180deg, #ff3333, #cc0000) !important; }
.piano-key[data-note="re#"].active { background: linear-gradient(180deg, #ff8800, #cc6600) !important; }
.piano-key[data-note="fa#"].active { background: linear-gradient(180deg, #00cc00, #009900) !important; }
.piano-key[data-note="so#"].active { background: linear-gradient(180deg, #3399ff, #0066cc) !important; }
.piano-key[data-note="la#"].active { background: linear-gradient(180deg, #9933ff, #6600cc) !important; }

.dialogue-controls {
    display: flex;
    gap: 20px;
    align-items: center;
    z-index: 10;
}

/* ============================================
   結果画面
   ============================================ */
#result-screen {
    background: rgba(0, 0, 0, 0.7);
}

#result-content {
    background: var(--color-ui-bg);
    padding: 3rem;
    border-radius: 30px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
    border: 4px solid var(--color-ui-border);
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-animal {
    font-size: 5rem;
    margin-bottom: 1rem;
}

#result-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--color-text-dark);
}

#result-title.success {
    color: var(--color-accent-gold);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#result-title.failure {
    color: var(--color-accent-coral);
}

#result-message {
    font-size: 1.1rem;
    color: var(--color-text-dark);
    margin-bottom: 1rem;
    line-height: 1.8;
}

.learned-note-popup {
    padding: 15px;
    margin-bottom: 1rem;
    border-radius: 15px;
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.1));
    border: 2px solid var(--color-accent-gold);
    display: none;
}

.learned-note-popup.show {
    display: block;
    animation: popIn 0.5s ease-out;
}

.learned-note-popup .note-bubble {
    display: inline-flex;
    margin: 0 5px;
}

/* ============================================
   狼との対話画面
   ============================================ */
#wolf-screen {
    background: var(--color-sky-night);
}

.wolf-bg {
    position: absolute;
    width: 100%;
    height: 100%;
}

.dark-sky {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, 
        #0a0a1a 0%, 
        #1a1a3e 50%, 
        #2d2d5e 100%);
}

.moon {
    position: absolute;
    top: 10%;
    right: 20%;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, 
        #fffacd 0%, 
        #f0e68c 50%, 
        rgba(240, 230, 140, 0) 100%);
    border-radius: 50%;
    box-shadow: 0 0 80px rgba(255, 250, 205, 0.5);
}

.dark-trees {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 40%;
    background: 
        linear-gradient(180deg, transparent 0%, #0a0a1a 100%),
        repeating-linear-gradient(90deg, 
            #1a1a2e 0px, 
            #1a1a2e 50px, 
            #0a0a1a 50px, 
            #0a0a1a 100px);
}

.wolf-display {
    z-index: 10;
    margin-bottom: 1rem;
}

.wolf-sprite {
    font-size: 8rem;
    animation: wolfBreath 3s ease-in-out infinite;
    text-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

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

.wolf-sprite.angry {
    animation: wolfAngry 0.5s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(255, 0, 0, 0.5));
}

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

.wolf-sprite.happy {
    animation: wolfHappy 1s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
}

.wolf-sprite.playful {
    animation: wolfHappy 1s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
}

.wolf-sprite.wolf-dancing {
    animation: wolfDance 0.8s ease-in-out infinite;
    filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.8));
}

@keyframes wolfHappy {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.05) rotate(-2deg); }
    75% { transform: scale(1.05) rotate(2deg); }
}

@keyframes wolfDance {
    0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
    25% { transform: translateY(-10px) rotate(-5deg) scale(1.05); }
    50% { transform: translateY(-20px) rotate(0deg) scale(1.1); }
    75% { transform: translateY(-10px) rotate(5deg) scale(1.05); }
}

.wolf-dialogue-box {
    background: rgba(255, 248, 231, 0.95);
    padding: 20px 40px;
    border-radius: 20px;
    max-width: 500px;
    text-align: center;
    margin-bottom: 1rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    border: 3px solid #4a4a6a;
    z-index: 10;
}

#wolf-dialogue-text {
    font-size: 1.2rem;
    color: var(--color-text-dark);
    line-height: 1.8;
}

.wolf-phase-indicator {
    background: rgba(0, 0, 0, 0.5);
    color: var(--color-text-light);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    z-index: 10;
}

.wolf-music {
    background: rgba(255, 255, 255, 0.85);
}

.notes-display.wolf .note-bubble {
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.wolf-controls {
    z-index: 10;
}

/* ============================================
   エンディング画面
   ============================================ */
#ending-screen {
    background: #1a1a3e;
}

.ending-bg {
    position: absolute;
    width: 100%;
    height: 100%;
}

.sunrise-sky {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, 
        #ff7e5f 0%, 
        #feb47b 30%, 
        #ffcc80 60%, 
        #87ceeb 100%);
    animation: sunriseAnimation 3s ease-out forwards;
}

@keyframes sunriseAnimation {
    0% {
        background: linear-gradient(180deg, 
            #1a1a3e 0%, 
            #2d2d5e 50%, 
            #4a3f6e 100%);
    }
    100% {
        background: linear-gradient(180deg, 
            #ff7e5f 0%, 
            #feb47b 30%, 
            #ffcc80 60%, 
            #87ceeb 100%);
    }
}

.ending-sun {
    position: absolute;
    bottom: 30%;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, 
        #fff 0%, 
        #ffd700 30%, 
        rgba(255, 215, 0, 0) 70%);
    border-radius: 50%;
    animation: sunRise 3s ease-out forwards;
}

@keyframes sunRise {
    0% {
        bottom: -100px;
        opacity: 0;
    }
    100% {
        bottom: 30%;
        opacity: 1;
    }
}

.ending-ground {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 30%;
    background: linear-gradient(180deg, 
        var(--color-grass) 0%, 
        var(--color-grass-dark) 100%);
}

.ending-content {
    text-align: center;
    z-index: 10;
    animation: fadeInUp 1s ease-out 2s both;
}

.ending-title {
    font-size: 3.5rem;
    color: white;
    text-shadow: 
        0 0 30px rgba(255, 215, 0, 0.8),
        0 4px 8px rgba(0,0,0,0.3);
    margin-bottom: 1rem;
}

.ending-chapter {
    font-size: 1.5rem;
    color: var(--color-accent-gold);
    margin-bottom: 1rem;
}

.ending-animals {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.ending-animal {
    font-size: 3rem;
    animation: celebrate 1s ease-in-out infinite;
    text-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.ending-animal:nth-child(odd) {
    animation-delay: 0.2s;
}

@keyframes celebrate {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

.ending-text {
    font-size: 1.3rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 2rem;
    line-height: 2;
}

.credits {
    font-size: 1.5rem;
    color: var(--color-accent-gold);
    margin-bottom: 2rem;
}

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

/* ============================================
   レスポンシブ対応
   ============================================ */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1.3rem;
    }
    
    .story-box {
        margin: 20px;
        padding: 2rem;
    }
    
    #story-text {
        font-size: 1.1rem;
    }
    
    .animal-sprite {
        font-size: 4rem;
    }
    
    .piano-key.white {
        width: 40px;
        height: 90px;
        font-size: 0.7rem;
    }
    
    .piano-key.black {
        width: 25px;
        height: 55px;
        font-size: 0.6rem;
        margin: 0 -12px;
    }
    
    .music-display {
        min-width: auto;
        width: 90%;
        padding: 15px;
    }
    
    .note-bubble {
        width: 40px;
        height: 40px;
        font-size: 0.85rem;
    }
    
    .wolf-sprite {
        font-size: 5rem;
    }
    
    .ending-title {
        font-size: 2.5rem;
    }
    
    .character-sprite {
        font-size: 3rem;
    }
    
    .chapter-item {
        padding: 1rem 1.5rem;
    }
    
    .chapter-number {
        font-size: 2rem;
        min-width: 50px;
    }
    
    .chapter-title {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .piano {
        flex-wrap: wrap;
        justify-content: center;
        max-width: 320px;
    }
    
    .piano-key.white {
        width: 35px;
        height: 70px;
        font-size: 0.6rem;
    }
    
    .piano-key.black {
        width: 22px;
        height: 45px;
        font-size: 0.5rem;
        margin: 0 -10px;
    }
    
    .ending-buttons {
        flex-direction: column;
    }
}
