/* ====================================
   リセット & 基本設定
   ==================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

/* iOS音声有効化通知 */
.ios-audio-notice {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ios-notice-content {
    background: white;
    padding: 40px 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    margin: 20px;
}

.ios-notice-content i {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 20px;
}

.ios-notice-content p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: #333;
}

.enable-audio-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Noto Sans JP', sans-serif;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* ====================================
   ヘッダー
   ==================================== */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    animation: fadeInDown 0.8s ease;
}

.header h1 i {
    margin-right: 15px;
    animation: pulse 2s ease infinite;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 300;
    animation: fadeIn 1s ease;
}

/* ====================================
   ステータスバー
   ==================================== */
.status-bar {
    background: #f8f9fa;
    padding: 20px 30px;
    border-bottom: 2px solid #e9ecef;
}

.score-display {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    color: #495057;
}

.score-item i {
    font-size: 1.3rem;
    color: #667eea;
}

.score-item strong {
    color: #667eea;
    font-size: 1.3rem;
    font-weight: 700;
}

.rank-display {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 8px 15px;
    border-radius: 20px;
    color: white;
}

.rank-display i {
    color: #ffd700;
}

.rank-display span {
    color: white;
}

.rank-display strong {
    color: white;
    font-size: 1.1rem;
}

/* ====================================
   モード選択
   ==================================== */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 30px;
    background: #fff;
    flex-wrap: wrap;
}

.mode-btn {
    flex: 1;
    min-width: 180px;
    max-width: 250px;
    padding: 20px 25px;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
}

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

.mode-btn:hover {
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.mode-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.mode-btn.active i {
    color: white;
}

/* ====================================
   ゲームエリア
   ==================================== */
.game-area {
    padding: 40px 30px;
}

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

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

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

.clef {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-60%);
    font-size: 7.5rem;
    color: #333;
    line-height: 1;
    font-family: serif;
}

.note {
    position: absolute;
    width: 28px;
    height: 28px;
    background: #333;
    border-radius: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-20deg);
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.note::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 35px;
    background: #333;
    right: -1px;
    top: -35px;
}

/* 下第1線（加線）- 下のドの時に表示 */
.note::before {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    background: #333;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease;
}

.note.ledger-line::before {
    width: 40px;
}

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

/* シャープ記号 */
.sharp-sign {
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    font-weight: bold;
    color: #333;
    font-family: serif;
}

/* メッセージエリア */
.message-area {
    margin-bottom: 30px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-message {
    font-size: 1.2rem;
    color: #495057;
    text-align: center;
    padding: 15px 25px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.game-message.success {
    background: #d4edda;
    color: #155724;
    border-left-color: #28a745;
    animation: messageSlide 0.5s ease;
}

.game-message.error {
    background: #f8d7da;
    color: #721c24;
    border-left-color: #dc3545;
    animation: shake 0.5s ease;
}

/* 音階ボタン（ピアノ風レイアウト） */
.piano-keys {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    position: relative;
    height: 180px;
    padding: 0 40px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

/* 白鍵 */
.key-btn.white {
    width: 60px;
    height: 180px;
    border: 2px solid #333;
    background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
    border-radius: 0 0 8px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 15px;
    gap: 5px;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
    margin: 0;
}

/* 黒鍵 */
.key-btn.black {
    width: 36px;
    height: 110px;
    border: 2px solid #000;
    background: linear-gradient(180deg, #2c3e50 0%, #000000 100%);
    color: white;
    border-radius: 0 0 6px 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 10px;
    gap: 3px;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    position: absolute;
    z-index: 2;
    top: 0;
}

/* 黒鍵の位置調整（正確な位置）
   白鍵の幅: 60px, 黒鍵の幅: 36px
   黒鍵は白鍵の境界線上に配置（左端から白鍵幅 - 黒鍵幅/2）
   C(0-60) | C#(42-78) | D(60-120) | D#(102-138) | E(120-180) | F(180-240) | F#(222-258) | G(240-300) | G#(282-318) | A(300-360) | A#(342-378) | B(360-420) | C(420-480)
*/
.key-btn.black[data-note="C#"] { left: calc(40px + 60px - 18px); }   /* padding 40px + C幅 60px - 黒鍵半幅 18px = 82px */
.key-btn.black[data-note="D#"] { left: calc(40px + 120px - 18px); }  /* padding + CD幅 120px - 18px = 142px */
.key-btn.black[data-note="F#"] { left: calc(40px + 240px - 18px); }  /* padding + CDEF幅 240px - 18px = 262px */
.key-btn.black[data-note="G#"] { left: calc(40px + 300px - 18px); }  /* padding + CDEFG幅 300px - 18px = 322px */
.key-btn.black[data-note="A#"] { left: calc(40px + 360px - 18px); }  /* padding + CDEFGA幅 360px - 18px = 382px */

.key-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(102, 126, 234, 0.4);
}

.key-btn.white:hover {
    background: linear-gradient(180deg, #f0f8ff 0%, #e6f2ff 100%);
}

.key-btn.black:hover {
    background: linear-gradient(180deg, #34495e 0%, #1a1a1a 100%);
}

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

.key-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    animation: keyPress 0.3s ease;
}

.key-btn.correct {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-color: #28a745;
    animation: correctAnim 0.5s ease;
}

.key-btn.incorrect {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border-color: #dc3545;
    animation: shake 0.5s ease;
}

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

.note-name {
    font-size: 1.1rem;
    font-weight: 700;
}

.note-letter {
    font-size: 0.8rem;
    opacity: 0.7;
}

.key-btn.black .note-name {
    font-size: 0.9rem;
}

.key-btn.black .note-letter {
    font-size: 0.7rem;
}

/* ゲームコントロール */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.control-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    font-family: 'Noto Sans JP', sans-serif;
}

.control-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.control-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.control-btn.secondary {
    background: #6c757d;
    color: white;
}

.control-btn.secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* シーケンス表示 */
.sequence-display {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
    border: 2px solid #e9ecef;
}

.sequence-title {
    font-weight: 600;
    margin-bottom: 15px;
    color: #495057;
}

.sequence-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sequence-item {
    background: white;
    padding: 10px 20px;
    border-radius: 8px;
    border: 2px solid #667eea;
    color: #667eea;
    font-weight: 600;
    animation: fadeIn 0.3s ease;
}

/* ====================================
   レベルアップ通知 & スコアポップアップ
   ==================================== */
.level-up-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 60px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    opacity: 0;
    transition: all 0.5s ease;
}

.level-up-notification.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    animation: levelUpBounce 0.6s ease;
}

.level-up-content {
    text-align: center;
}

.level-up-content i {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: starSpin 1s ease;
}

.level-up-text {
    font-size: 2rem;
    font-weight: 700;
}

.score-popup {
    position: fixed;
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    z-index: 999;
    pointer-events: none;
    opacity: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.score-popup.show {
    animation: scoreFloat 1s ease;
}

/* ====================================
   説明セクション
   ==================================== */
.instructions {
    background: #f8f9fa;
    padding: 40px 30px;
    border-top: 2px solid #e9ecef;
}

.instructions h3 {
    color: #667eea;
    font-size: 1.5rem;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-instructions {
    display: grid;
    gap: 20px;
}

.instruction-item {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.instruction-item strong {
    display: block;
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.instruction-item strong i {
    margin-right: 8px;
}

.instruction-item p {
    color: #6c757d;
    line-height: 1.6;
}

/* ====================================
   フッター
   ==================================== */
.footer {
    background: #343a40;
    color: white;
    padding: 20px;
    text-align: center;
    font-size: 0.9rem;
}

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

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

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

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

@keyframes correctAnim {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

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

@keyframes noteAppear {
    0% {
        transform: translate(-50%, -50%) rotate(-20deg) scale(0);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) rotate(-20deg) scale(1.2);
    }
    100% {
        transform: translate(-50%, -50%) rotate(-20deg) scale(1);
        opacity: 1;
    }
}

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

@keyframes levelUpBounce {
    0% {
        transform: translate(-50%, -50%) scale(0);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes starSpin {
    0% {
        transform: rotate(0deg) scale(0);
    }
    50% {
        transform: rotate(180deg) scale(1.2);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

@keyframes scoreFloat {
    0% {
        transform: translateY(0) scale(0);
        opacity: 0;
    }
    20% {
        transform: translateY(-20px) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) scale(1);
        opacity: 0;
    }
}

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

    .header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .status-bar {
        padding: 15px 20px;
    }

    .score-display {
        gap: 20px;
    }

    .score-item {
        font-size: 0.9rem;
    }

    .mode-selector {
        padding: 20px 15px;
        gap: 10px;
    }

    .mode-btn {
        min-width: 140px;
        padding: 15px 20px;
        font-size: 0.9rem;
    }

    .mode-btn i {
        font-size: 1.5rem;
    }

    .game-area {
        padding: 30px 20px;
    }

    .staff-container {
        height: 170px;
        padding: 40px 15px 30px 15px;
    }

    .staff-lines {
        height: 90px;
    }

    .clef {
        font-size: 6rem;
        left: 20px;
        top: 50%;
        transform: translateY(-60%);
    }

    .note {
        width: 22px;
        height: 22px;
    }

    .note::after {
        width: 2px;
        height: 28px;
        top: -28px;
    }

    .game-message {
        font-size: 1rem;
        padding: 12px 20px;
    }

    .piano-keys {
        height: 140px;
        padding: 0 20px;
        overflow-x: auto;
    }

    .key-btn.white {
        width: 45px;
        height: 140px;
        padding-bottom: 10px;
    }

    .key-btn.black {
        width: 28px;
        height: 85px;
        padding-bottom: 8px;
    }

    /* 黒鍵の位置調整（タブレット） 白鍵45px, 黒鍵28px */
    .key-btn.black[data-note="C#"] { left: calc(20px + 45px - 14px); }   /* 51px */
    .key-btn.black[data-note="D#"] { left: calc(20px + 90px - 14px); }   /* 96px */
    .key-btn.black[data-note="F#"] { left: calc(20px + 180px - 14px); }  /* 186px */
    .key-btn.black[data-note="G#"] { left: calc(20px + 225px - 14px); }  /* 231px */
    .key-btn.black[data-note="A#"] { left: calc(20px + 270px - 14px); }  /* 276px */

    .note-name {
        font-size: 0.9rem;
    }

    .note-letter {
        font-size: 0.7rem;
    }

    .key-btn.black .note-name {
        font-size: 0.7rem;
    }

    .key-btn.black .note-letter {
        font-size: 0.6rem;
    }

    .control-btn {
        padding: 12px 25px;
        font-size: 0.9rem;
    }

    .instructions {
        padding: 30px 20px;
    }

    .instructions h3 {
        font-size: 1.2rem;
    }

    .instruction-item strong {
        font-size: 1rem;
    }

    .instruction-item p {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .piano-keys {
        height: 120px;
        padding: 0 15px;
    }

    .key-btn.white {
        width: 35px;
        height: 120px;
        padding-bottom: 8px;
    }

    .key-btn.black {
        width: 22px;
        height: 70px;
        padding-bottom: 5px;
    }

    /* 黒鍵の位置調整（スマホ） 白鍵35px, 黒鍵22px */
    .key-btn.black[data-note="C#"] { left: calc(15px + 35px - 11px); }   /* 39px */
    .key-btn.black[data-note="D#"] { left: calc(15px + 70px - 11px); }   /* 74px */
    .key-btn.black[data-note="F#"] { left: calc(15px + 140px - 11px); }  /* 144px */
    .key-btn.black[data-note="G#"] { left: calc(15px + 175px - 11px); }  /* 179px */
    .key-btn.black[data-note="A#"] { left: calc(15px + 210px - 11px); }  /* 214px */

    .note-name {
        font-size: 0.75rem;
    }

    .note-letter {
        font-size: 0.6rem;
    }

    .key-btn.black .note-name {
        font-size: 0.6rem;
    }

    .key-btn.black .note-letter {
        font-size: 0.5rem;
    }
}
