/* ====================================
   小学生向け音階アプリ - スタイル
   ==================================== */

/* ====================================
   基本設定
   ==================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'M PLUS Rounded 1c', 'Hiragino Kaku Gothic ProN', 'メイリオ', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* ====================================
   音声有効化オーバーレイ
   ==================================== */
.audio-enable-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.audio-enable-content {
    background: white;
    padding: 50px 40px;
    border-radius: 25px;
    text-align: center;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
}

.music-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

.audio-enable-content h2 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 25px;
}

.enable-audio-btn {
    padding: 20px 40px;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 auto;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s;
}

.enable-audio-btn:active {
    transform: scale(0.95);
}

/* ====================================
   ヘッダー
   ==================================== */
.header {
    text-align: center;
    margin-bottom: 25px;
    animation: fadeInDown 0.8s ease;
}

.title {
    font-size: 2.5rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.2rem;
    color: white;
    opacity: 0.9;
}

/* ====================================
   ステータスバー
   ==================================== */
.status-bar {
    background: white;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-around;
    gap: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    animation: fadeIn 1s ease;
}

.status-item {
    text-align: center;
    flex: 1;
}

.status-item i {
    font-size: 1.8rem;
    margin-bottom: 8px;
    color: #667eea;
}

.status-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.status-value {
    font-size: 1.8rem;
    font-weight: 900;
    color: #333;
}

.rank-badge {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border-radius: 15px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.rank-badge i {
    color: #ff6b6b;
}

.rank-name {
    font-size: 1rem;
    font-weight: 900;
    color: #333;
}

/* ====================================
   進捗バー
   ==================================== */
.progress-container {
    background: white;
    border-radius: 15px;
    padding: 15px 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
    font-size: 1rem;
}

.progress-bar {
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 10px;
    transition: width 0.5s ease;
    width: 0%;
}

/* ====================================
   モード選択
   ==================================== */
.mode-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    justify-content: center;
    animation: fadeIn 1.2s ease;
}

.mode-btn {
    background: white;
    border: 3px solid transparent;
    border-radius: 15px;
    padding: 15px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    flex: 1;
    min-width: 120px;
    max-width: 180px;
}

.mode-icon {
    font-size: 2rem;
    color: #667eea;
}

.mode-text {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
}

.mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.mode-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: #667eea;
}

.mode-btn.active .mode-icon,
.mode-btn.active .mode-text {
    color: white;
}

/* ====================================
   ゲームエリア
   ==================================== */
.game-area {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: fadeIn 1.4s ease;
}

.game-message {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    padding: 20px;
    margin-bottom: 25px;
    background: #f8f9fa;
    border-radius: 15px;
    border: 3px solid #667eea;
}

/* ====================================
   五線譜
   ==================================== */
.staff-container {
    position: relative;
    height: 150px;
    background: #fefefe;
    border-radius: 15px;
    margin-bottom: 25px;
    padding: 30px 20px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

.staff-lines {
    position: relative;
    height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.staff-line {
    height: 2px;
    background: #333;
    width: 100%;
}

.clef {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 4rem;
    color: #333;
}

.note {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #333;
    border-radius: 50%;
    left: 50%;
    opacity: 0;
    transition: all 0.3s ease;
}

.note.active {
    opacity: 1;
    animation: noteAppear 0.5s ease;
}

/* ====================================
   鍵盤エリア
   ==================================== */
.piano-container {
    margin-bottom: 25px;
}

.piano-keys {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.key-btn {
    width: 100px;
    height: 140px;
    border: 4px solid #333;
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    font-family: 'M PLUS Rounded 1c', sans-serif;
}

.key-emoji {
    font-size: 2.5rem;
}

.key-name {
    font-size: 1.5rem;
    font-weight: 900;
    color: white;
}

.key-letter {
    font-size: 1.1rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
}

/* 虹色の鍵盤（7色） */
.key-btn:nth-child(1) { background: linear-gradient(135deg, #ff6b6b, #ff8787); }  /* 赤 */
.key-btn:nth-child(2) { background: linear-gradient(135deg, #ffa500, #ffbb33); }  /* オレンジ */
.key-btn:nth-child(3) { background: linear-gradient(135deg, #ffd93d, #ffe066); }  /* 黄色 */
.key-btn:nth-child(4) { background: linear-gradient(135deg, #6bcf7f, #8fd99f); }  /* 緑 */
.key-btn:nth-child(5) { background: linear-gradient(135deg, #4d96ff, #6eb5ff); }  /* 青 */
.key-btn:nth-child(6) { background: linear-gradient(135deg, #9b59b6, #b370cf); }  /* 紫 */
.key-btn:nth-child(7) { background: linear-gradient(135deg, #a0522d, #cd853f); }  /* 茶色 */

.key-btn:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.key-btn:active {
    transform: translateY(-4px) scale(1.02);
}

.key-btn.active {
    animation: keyPress 0.3s ease;
}

.key-btn.correct {
    animation: correctFlash 0.6s ease;
}

.key-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ====================================
   コントロールエリア
   ==================================== */
.control-area {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.control-btn {
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    font-family: 'M PLUS Rounded 1c', sans-serif;
}

.start-btn {
    background: linear-gradient(135deg, #6bcf7f, #4ecdc4);
    color: white;
}

.listen-btn {
    background: linear-gradient(135deg, #feca57, #ff6b6b);
    color: white;
}

.next-btn {
    background: linear-gradient(135deg, #4d96ff, #667eea);
    color: white;
}

.control-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.control-btn:active {
    transform: translateY(0);
}

/* ====================================
   メロディ作りエリア
   ==================================== */
.melody-area {
    margin-top: 25px;
}

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

.melody-btn {
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    font-family: 'M PLUS Rounded 1c', sans-serif;
}

.melody-btn:hover {
    transform: translateY(-2px);
}

.melody-display {
    min-height: 60px;
    background: #f8f9fa;
    border: 3px dashed #667eea;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.melody-note {
    padding: 8px 16px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ====================================
   達成メッセージ
   ==================================== */
.achievement {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
    min-height: 50px;
    animation: bounce 0.5s ease;
}

/* ====================================
   メダルセクション
   ==================================== */
.medals-section {
    background: white;
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.medals-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: #333;
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.medals-container {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 100px;
}

.medal {
    font-size: 3rem;
    animation: medalPop 0.6s ease;
    cursor: pointer;
    transition: transform 0.2s;
}

.medal:hover {
    transform: scale(1.2);
}

/* ====================================
   フッター
   ==================================== */
.footer {
    text-align: center;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    padding: 20px;
}

/* ====================================
   パーティクルエフェクト
   ==================================== */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

.particle {
    position: absolute;
    font-size: 2rem;
    animation: float 3s ease-out forwards;
    pointer-events: none;
}

/* ====================================
   アニメーション
   ==================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

@keyframes correctFlash {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    25%, 75% {
        transform: scale(1.2);
        filter: brightness(1.5);
    }
    50% {
        transform: scale(1.1);
        filter: brightness(1.3);
    }
}

@keyframes medalPop {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

@keyframes noteAppear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes float {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-500px) rotate(360deg);
        opacity: 0;
    }
}

/* ====================================
   レスポンシブ対応
   ==================================== */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    .title {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .status-bar {
        flex-wrap: wrap;
        gap: 10px;
    }

    .status-item {
        min-width: 80px;
    }

    .status-value {
        font-size: 1.5rem;
    }

    .mode-btn {
        min-width: 100px;
        padding: 12px 15px;
    }

    .mode-icon {
        font-size: 1.8rem;
    }

    .mode-text {
        font-size: 0.9rem;
    }

    .game-message {
        font-size: 1.3rem;
    }

    .key-btn {
        width: 85px;
        height: 120px;
    }

    .key-emoji {
        font-size: 2rem;
    }

    .key-name {
        font-size: 1.3rem;
    }

    .key-letter {
        font-size: 0.9rem;
    }

    .achievement {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.6rem;
    }

    .piano-keys {
        gap: 8px;
    }

    .key-btn {
        width: 70px;
        height: 100px;
    }

    .key-emoji {
        font-size: 1.8rem;
    }

    .key-name {
        font-size: 1.1rem;
    }

    .key-letter {
        font-size: 0.8rem;
    }
}
