body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* 垂直方向は上寄せを基本に */
    background-color: #f4f7f6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow: hidden; 
}

main {max-width:400px; padding:1em;}
#main-content{width:100%;}
#main-content ul {text-align:left;}
#main-content p{margin-bottom:.5em!important; font-size:16px;} 
img.emoji {width:2em!important; height: 2em !important;}
#unmemorized-list li strong {color:#f00; font-weight:bold;}
.site-main {
    text-align:center;
}

    /* controls（覚えた/覚えてないボタン）の配置を調整 */
    .controls {
       display:flex;
       justify-content: space-around;
    }

.card-container {
    width: 100%;
    max-width: 400px; 
    height: 250px; 
    position: relative;
    /* bodyがflex-startのため、中央に配置するために上部マージンを追加 */
    margin: 5vh auto 20px; 
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d; /* 子要素を3D空間に配置 */
    transition: transform 0.6s; /* 裏返しのトランジション */
}

/* 裏返った状態 */
.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden; /* 裏面を非表示にする */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background-color: white;
}

/* 表面 */
.front {
    background-color: #e9eef2;
    color: #333;
    font-size: 1em;
    font-weight: bold;
    text-align: center;
}

.front .word{font-size:2em;}



/* 裏面 */
.back {
    transform: rotateY(180deg); /* 裏面を180度回転させて配置 */
    background-color: #d1e7dd;
    color: #155724;
    font-size: 1em;
    text-align: left;
    align-items: flex-start;
}

.back p {
    margin: 5px 0;
}

.controls button {
    padding: 10px 20px;
    margin: 0 10px;
    font-size: 1.1em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #007bff;
    color: white;
    transition: background-color 0.2s;
}
/* --- 新しいスタイル（機能追加分） --- */

.hidden {
    display: none !important;
}

/* 進捗ボタンのスタイル */
.result-button {
    padding: 12px 20px;
    font-size: 1.1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

#memorized-button {
    background-color: #28a745; /* Green */
    color: white;
}

#unmemorized-button {
    background-color: #dc3545; /* Red */
    color: white;
}

#memorized-button:active, #unmemorized-button:active {
    transform: translateY(2px);
    box-shadow: none;
}

/* 進捗情報 (カード表面) */
.progress-info {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 0.8em;
    font-weight: normal;
    color: #555;
}

/* 結果画面のスタイル */
.result-screen {
    /* カードと重ねて中央に配置するため、絶対位置指定に変更 */
    position: absolute; 
    top: -70%;
    left: 50%;
    transform: translateX(-50%); /* 中央寄せ */
    
    width: 100%; /* 親要素(card-container)の幅を使う */
    min-height: 100%; /* 親要素(card-container)の高さを使う */
    
    display: flex;
    flex-direction: column;
    justify-content: center; /* 垂直方向も中央寄せ */
    align-items: center;
    text-align: center;
    
    background-color: white; 
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 5; /* カードより前面に表示 */
}

.score-main {
    font-size: 1.5em;
    margin-top: 10px;
    text-align:center;
}

.count-highlight {
    font-size: 2em;
    color: #007bff;
    font-weight: bold;
}

#swipe-instruction {
    margin: 20px 0;
    padding: 10px;
    background-color: #fff3cd;
    color: #856404;
    border-radius: 5px;
    cursor: pointer;
}

#unmemorized-list-container {
    margin-top: 20px;
    text-align: left;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

#unmemorized-list {
    list-style-type: none;
    padding: 0;
}

#unmemorized-list li {
    padding: 8px 0;
    border-bottom: 1px dashed #ddd;
}

#unmemorized-list li:last-child {
    border-bottom: none;
}

#restart-button {
    margin-top: 20px;
    background-color: #6c757d;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
}

/* --- 3. スマートフォン向けデザイン調整 --- */

/* 全体の幅を制限し、中央寄せを強化 */
body {
    padding: 10px;
}

.card-container {
    max-width: 400px; /* カードの最大幅を維持 */
    height: 250px; /* 縦幅を少し広げて見やすく */
}

/* 画面幅が600px以下の場合に適用 */
@media (max-width: 600px) {
   
/* bodyの垂直方向の中央寄せを強化 */
    body {
        justify-content: center;
    }
    
    /* card-containerの垂直方向中央配置を強化 */
    .card-container {
        margin-top: 0;
    }

    /* 音声ボタンのサイズ調整 */
    .speech-control-button {
        padding: 10px 18px;
        font-size: 2em;
    }

    h1 {
    color: #333;
    margin-bottom: 20px; /* 少しマージンを減らす */
}
    
    /* ボタンコンテナの調整 */
    .controls {
        width: 100%;
        display: flex;
        justify-content: center;
        margin-top: 10px;
    }

    .controls button {
flex-basis: 48%; /* 2列配置を維持 */
    margin: 5px 1%;
    padding: 15px 10px;
    font-size: 1.0em;
    }


    .result-button {
        /* 覚えた/覚えてないボタン */
        font-weight: bold;
    }

    /* カード内のテキスト調整 */
    .front {
        font-size: 1.5em; /* 単語のサイズを調整 */
        padding: 15px;
    }
    
    .back p {
        font-size: 0.9em; /* 裏面テキストを小さく */
    }
    
    /* 結果画面の調整 */
    .count-highlight {
        font-size: 2em;
    }
    
    #swipe-instruction {
        font-size: 0.9em;
    }
}

/* --- モーダル表示のためのCSS --- */
.modal {
    /* 画面全体を覆う */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8); /* 半透明の黒背景 */
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 80%;
    overflow-y: auto; /* コンテンツが長い場合はスクロール可能に */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
}

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

.modal-content h2 {
    margin-top: 0;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
    font-size: 1.5em;
}

#unmemorized-list {
    list-style-type: none;
    padding: 0;
    margin: 15px 0;
}

#unmemorized-list li {
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
}

#unmemorized-list li:last-child {
    border-bottom: none;
}

#close-modal-button {
    margin-top: 20px;
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    font-size: 1.1em;
}

/* --- 結果画面ボタンのレイアウト調整 --- */

.result-controls {
    width: 100%;
    margin-top: 30px;
}


.result-controls button {
    font-size: 1em;
    border-radius: 8px;
    width:100%;
}

#restart-button {
    background-color: #28a745; /* 緑色 */
    color: white;
}

#show-unmemorized-button {
    background-color: #ffc107; /* 黄色 */
    color: #333;
}

.speech-control-button {
    display: block;
    margin: 0 auto; /* 中央寄せ */
    margin-top: 15px; /* カードとボタンの間隔 */
    padding: 8px 15px;
    font-size: 1.0em;
    cursor: pointer;
    background-color: #f8f9fa;
    color: #007bff;
    border: 2px solid #007bff;
    border-radius: 5px;
    transition: background-color 0.2s;
    /* card-containerの外に配置するため、relative/absoluteは不要 */
}

.speech-control-button:hover {
    background-color: #e2f0ff;
}

.hidden { display: none !important; }
.screen { padding: 20px; }

.level-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 300px;
    margin: 30px auto;
}

.level-btn {
    padding: 15px;
    font-size: 18px;
    cursor: pointer;
    background: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 10px;
    transition: 0.3s;
}

.level-btn:hover { background: #e0e0e0; border-color: #bbb; }

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.badge {
    background: #333;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
}

.pos-badge {
    margin-top: 10px;
    color: #666;
    font-style: italic;
}

.meaning-large {
    font-size: 24px;
    font-weight: bold;
    margin: 10px 0;
}

.keywords {
    font-size: 14px;
    color: #555;
    margin-bottom: 10px;
}

.example-box {
    margin-top: 15px;
    padding: 10px;
    background: #f9f9f9;
    border-left: 4px solid #ccc;
    font-size: 14px;
    text-align: left;
}
/* アニメーション用のエフェクト要素 */
.flying-icon {
    position: absolute;
    pointer-events: none; /* クリックを邪魔しない */
    font-size: 2rem;
    z-index: 1000;
    animation: flyUpAndFade 0.6s ease-out forwards;
}

@keyframes flyUpAndFade {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-150px) scale(2.5); /* 上に150px移動しながら2.5倍に拡大 */
        opacity: 0;
    }
}
/* コンボ表示：改行禁止と画面中央配置の徹底 */
.combo-display {
    position: fixed; /* 画面に対して固定 */
    top: 40%;
    left: 50%;
    /* 💡 transformで常に中央揃えを維持 */
    transform: translate(-50%, -50%);
    
    /* 💡 改行を絶対にさせない */
    white-space: nowrap;
    
    /* 💡 画面幅に合わせてサイズを調整 (スマホで2行にならない大きさ) */
    font-size: 12vw; 
    
    font-weight: bold;
    color: #ff9800;
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 0 4px 10px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 1001;
    animation: comboZoomFade 0.6s ease-out forwards;
}

/* PCなどの大きな画面では文字が大きくなりすぎないよう制限 */
@media (min-width: 600px) {
    .combo-display {
        font-size: 5rem;
    }
}

@keyframes comboZoomFade {
    0% {
        /* 中央配置(translate)を維持しながらスケールを変更 */
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.8); /* 拡大率を少し抑えて画面内に収める */
        opacity: 0;
    }
}
/* Perfect演出用のスタイル */
.perfect-message {
    font-size: 4rem;
    font-weight: bold;
    color: #ff5722;
    text-shadow: 0 0 20px rgba(255, 87, 34, 0.5);
    animation: perfectBounce 1s infinite alternate;
    margin-bottom: 20px;
}

@keyframes perfectBounce {
    0% { transform: scale(1); }
    100% { transform: scale(1.2) rotate(5deg); }
}

/* 簡易的な紙吹雪の粒 */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #f00;
    z-index: 1002;
    animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}