﻿:root {
    --primary-color: #4CAF50;
    --danger-color: #f44336;
    --bg-color: #f0f4f8;
    --text-color: #333;
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    text-align: center;
    user-select: none; /* ゲーム中の誤選択防止 */
}

/* ヘッダー */
header {
    background: #fff;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    height: 50px;
}

header button {
    padding: 5px 10px;
    cursor: pointer;
}

#title-text {
    font-weight: bold;
    font-size: 1.2rem;
}

#game-timer {
    font-family: monospace;
    font-size: 1.2rem;
    font-weight: bold;
}

/* メインコンテンツ */
main {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    display: block !important; /* flexを解除 */
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
}

.screen.active {
    display: flex;
}

/* タイトル画面 */
.main-title {
    font-size: 2.5rem;
    margin: 40px 0 20px;
    color: #2c3e50;
}

.difficulty-selection {
    display: flex;
    flex-direction: row;      /* 横に並べる */
    justify-content: center;  /* 中央寄せ */
    align-items: stretch;    /* 高さを揃える */
    gap: 15px;               /* ボタン同士の間隔 */
    width: 100%;
    max-width: 800px;        /* 画面が広すぎるときに広がりすぎないように */
    margin: 30px auto;
}

.diff-btn {
    flex: 1;                 /* 3つのボタンを均等な幅にする */
    display: flex;
    flex-direction: column;  /* ボタン内の文字（難易度名と詳細）は縦並び */
    align-items: center;
    justify-content: center;
    padding: 20px 10px;      /* 上下の余白を増やし、左右を抑える */
    min-width: 180px;        /* ボタンが細くなりすぎないように */
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 12px;
    border: none;
    transition: transform 0.2s, background-color 0.2s;
}
.diff-btn:hover {
    transform: scale(1.05);
}

.diff-btn:active {
    transform: scale(0.98);
}

.diff-detail {
    display: block;
    font-size: 0.75rem;      /* 横並びなので少しだけ小さく調整 */
    font-weight: normal;
    margin-top: 8px;
    opacity: 0.9;
    line-height: 1.2;
}

/* モバイル対応：画面が非常に狭い場合（スマホなど）は縦に戻す */
@media (max-width: 600px) {
    .difficulty-selection {
        flex-direction: column;
        align-items: center;
    }
    .diff-btn {
        width: 100%;
        max-width: 300px;
    }
}

.btn-easy { background-color: #4CAF50; color: white; }
.btn-normal { background-color: #FF9800; color: white; }
.btn-hard { background-color: #f44336; color: white; }

.audio-notice {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 20px 0;
    color: #666;
    font-size: 0.9rem;
}

.footer-buttons {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

.small-btn {
    padding: 8px 12px;
    background: #e0e0e0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

/* クイズ画面全体 */
#quiz-screen {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    position: relative;
}

#quiz-screen.active {
    display: flex;
}

/* クイズ画面 */
.timer-container {
    width: 100% !important;
    height: 24px !important;
    background-color: #e0e0e0 !important;
    border-radius: 12px; /* 両端を丸く */
    margin: 20px 0;
    overflow: hidden; /* これで中のバーの左端も丸く切り取られます */
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

#remaining-time-bar {
    width: 100%;
    height: 100%;
    background-color: #4CAF50;
    /* transitionを linear（等速）かつ 0.1s に設定してJSの更新と同期 */
    transition: width 0.1s linear, background-color 0.3s;
    border-radius: 12px; /* 内側も丸めることで左側の欠けを防止 */
}

#life-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    font-size: 1.5rem;
    min-height: 2rem; /* ライフが0になっても高さが消えないように */
}

.heart {
    color: #ff4d4d; /* 鮮やかな赤 */
    font-size: 1.8rem;
    margin: 0 2px;
    /* 絵文字のベースフォントを指定 */
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    display: inline-block;
}

#question-text {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 20px 0 40px;
    min-height: 3rem;
}

/* 入力ラッパー */
#input-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

#answer-input {
    font-size: 2rem;
    padding: 10px;
    width: 200px;
    text-align: right; /* 数字は右寄せが見やすい */
    border: 3px solid #ccc;
    border-radius: 8px;
}

#answer-input:focus {
    border-color: #2196F3;
    outline: none;
}

#prefix-label, #unit-label {
    font-size: 1.2rem;
    font-weight: bold;
    color: #555;
    min-width: 2em; /* レイアウト崩れ防止 */
}
#prefix-label { text-align: right; }
#unit-label { text-align: left; }

.circle-mark {
    display: inline-block;
    width: 160px;
    height: 160px;
    border: 24px solid #4CAF50; /* さらに少し太くしました */
    border-radius: 50%;
}

/* 解説エリア */
#explanation-area {
    width: 100%;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); /* 影を柔らかくする */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s;
    
    /* 他の要素に干渉されないように独立させる */
    position: relative;
    z-index: 2000; 
    border: none !important; /* JSからの border 介入を完全に遮断 */
    text-align: center;
}

.label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
    font-weight: bold;
}

.label, #exp-label {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 5px;
    font-weight: bold;
    display: block; /* 中央寄せを確実にするため */
}

hr {
    border: 0;
    border-top: 1px solid #eee;
    margin: 10px 0;
}

#exp-text {
    font-size: 1rem;
    line-height: 1.5;
    color: #333;
    /* 本文が長くなった際も中央寄せを維持 */
    display: inline-block;
    text-align: center;
}

#exp-answer-text {
    font-size: 1.6rem;
    font-weight: bold;
    color: #f44336;
    margin-bottom: 20px; /* 解説ラベルとの間隔 */
}

#explanation-area.show {
    visibility: visible;
    opacity: 1;
}

#exp-label {
    border-top: 1px solid #eee;
    padding-top: 15px;
    margin-top: 10px;
}

/* 正誤フィードバック */
#feedback-overlay {
    position: absolute;
    top: 100px; 
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    pointer-events: none;
    width: 100%;
    text-align: center;
}

.time-up-text {
    color: #f44336;
    font-size: 5rem;
    font-weight: bold;
    /* 影が解説欄にまで伸びないように、影の設定をシンプルにする */
    text-shadow: 2px 2px 0px rgba(0,0,0,0.2); 
    display: block;
}

/* 結果画面 */
#result-screen h2 {
    font-size: 2.5rem;
    color: #f44336;
}

#result-title {
    font-size: 2.5rem;
    color: #f44336;
    margin-top: 20px;
}

.result-stats {
    font-size: 1.2rem;
    margin: 30px 0;
    line-height: 1.8;
    text-align: left;
    display: inline-block;
}

.share-btn {
    background-color: #000; /* X色 */
    color: white;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 10px;
    width: 100%;
}

.result-buttons .btn-normal {
    margin-top: 10px;
    width: 100%;
}
