/* Main stylesheet for the prefecture learning app */

/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap');

/* Global styles */
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: #fff;
    overflow: hidden;
}

/* Center the SVG map */
svg.svg_content {
    display: block;
    margin: 0 auto;
    margin-bottom: 120px;
    /* offset for history container */
    max-width: 90vw;
    max-height: 80vh;
    /* slightly reduce max-height to leave room for history */
    cursor: pointer;
}

/* Prefecture hover effect */
.prefecture:hover {
    fill: #ffcc00;
    transition: fill 0.3s ease;
}

/* Modal overlay */
#quiz-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
}

#quiz-modal.active {
    opacity: 1;
    visibility: visible;
}

#quiz-content {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    color: #fff;
    text-align: center;
}

#quiz-content h2 {
    margin-top: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

#quiz-content input[type="text"] {
    width: 80%;
    padding: 0.5rem;
    margin: 1rem 0;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
}

#quiz-content button {
    background: #ffcc00;
    color: #000;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

#quiz-content button:hover {
    background: #e6b800;
}

/* Toast (question) */
/* Stats Container (Right top) */
#stats-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1002;
    align-items: flex-end;
}

#stats-container>div {
    background: rgba(0, 0, 0, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    transition: transform 0.2s ease;
}

#question-toast {
    color: #fff;
    display: none;
    font-size: 2rem !important;
}

#score-board {
    color: #ffcc00;
}

/* Feedback overlay */
.feedback {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12rem;
    color: #ffcc00;
    opacity: 0;
    pointer-events: none;
    /* Prevents blocking clicks when invisible */
    transition: opacity 0.3s ease;
    z-index: 1003;
}

.feedback.active {
    opacity: 1;
}

/* ヒントコントロール群 (左上) */
#hint-controls {
    position: fixed;
    top: 1rem;
    left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1002;
}

#hint-btn,
#desc-btn,
#capital-btn {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: 2px solid #ccc;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

#hint-btn.active,
#desc-btn.active,
#capital-btn.active {
    background: #ffcc00;
    color: #000;
    border-color: #ffcc00;
}

/* カスタムツールチップ */
.custom-tooltip {
    position: fixed;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 2005;
    display: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    white-space: pre-wrap;
    /* 改行を有効にする */
    border: 2px solid #ccc;
}

/* 連続正解カウンター */
#streak-counter {
    color: #00ff00;
}

/* くす玉コンテナ */
#kusudama-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#kusudama-container.active {
    display: flex;
}

/* くす玉本体 */
.kusudama {
    position: relative;
    width: 200px;
    height: 200px;
    margin-top: -100px;
}

/* くす玉の半分ずつ */
.kusudama-half {
    position: absolute;
    width: 100px;
    height: 200px;
    background: radial-gradient(circle at 100% 50%, #ffdf00, #b8860b);
    border-radius: 100px 0 0 100px;
    transform-origin: center right;
    transition: transform 0.5s ease-in-out;
}

.kusudama-half.right {
    left: 100px;
    border-radius: 0 100px 100px 0;
    transform-origin: center left;
    background: radial-gradient(circle at 0% 50%, #ffdf00, #b8860b);
}

/* 割れるアニメーション */
#kusudama-container.active .kusudama-half.left {
    transform: rotate(30deg);
}

#kusudama-container.active .kusudama-half.right {
    transform: rotate(-30deg);
}

/* 垂れ幕 */
.banner {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    background: #fffff0;
    color: #ff0000;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 20px 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    height: 0;
    overflow: hidden;
    transition: height 1s ease 0.3s;
}

#kusudama-container.active .banner {
    height: 300px;
}

/* 紙吹雪のベース */
.confetti {
    position: absolute;
    top: 100px;
    left: 50%;
    width: 10px;
    height: 10px;
    background: transparent;
}

/* 解答履歴コンテナ */
#history-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 10px 20px;
    box-sizing: border-box;
    z-index: 1001;
    border-top: 2px solid #ccc;
    max-height: 15vw;
    min-height: 100px;
    display: flex;
    flex-direction: column;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 1.2rem;
}

#reset-history-btn {
    background: #ff4444;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: background 0.2s;
}

#reset-history-btn:hover {
    background: #e60000;
}

#history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow-y: auto;
    padding-bottom: 5px;
}

.history-item {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 1.1rem;
    font-weight: bold;
    white-space: nowrap;
}

.history-item.correct {
    background: #e0ffe0;
    color: #008800;
    border: 1px solid #00aa00;
}

.history-item.incorrect {
    background: #ffe0e0;
    color: #dd0000;
    border: 1px solid #ff0000;
}

/* スマホ向けレスポンシブ対応 */
@media (max-width: 768px) {

    /* ヒント関連ボタン */
    #hint-controls {
        top: 0.5rem;
        left: 0.5rem;
        flex-direction: row;
        /* 横並びに変更してスペースを節約 */
        gap: 0.5rem;
    }

    #hint-btn,
    #desc-btn,
    #capital-btn {
        font-size: 1rem;
        padding: 0.3rem 0.6rem;
    }

    /* ステータス関連（問題・スコア・連続正解） */
    #stats-container {
        top: 3.5rem;
        /* ボタンの下に配置 */
        right: 0.2rem;
        left: 0.2rem;
        flex-direction: row;
        justify-content: center;
        /* 画面中央に寄せる */
        flex-wrap: nowrap;
        /* 強制的に1行にする */
        gap: 0.2rem;
        /* 隙間を詰める */
    }

    #stats-container>div {
        font-size: 0.9rem !important;
        /* 1行に収まるように少し小さく */
        padding: 0.3rem 0.4rem;
        white-space: nowrap;
        /* 改行させない */
    }

    /* 地図の調整 */
    svg.svg_content {
        margin-top: 7.5rem;
        /* 上部のUI（ボタンとスコア）に被らないようにしっかり下げる */
        margin-bottom: 90px;
        /* 下部の履歴エリアに被らないように */
        max-height: calc(100vh - 7.5rem - 90px);
        /* 画面内に収まるように計算 */
    }

    /* フィードバック（〇・×） */
    .feedback {
        font-size: 6rem;
    }

    /* カスタムツールチップ */
    .custom-tooltip {
        font-size: 1rem;
        padding: 0.5rem 0.8rem;
    }

    /* 履歴エリアの調整 */
    #history-container {
        padding: 5px 10px;
        min-height: 80px;
    }

    .history-header {
        font-size: 1rem;
    }

    #reset-history-btn {
        font-size: 0.8rem;
        padding: 4px 10px;
    }

    .history-item {
        font-size: 0.9rem;
        padding: 3px 6px;
    }
}

/* 著作権（クレジット）表示 */
.copyright-notice {
    position: fixed;
    bottom: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.7);
    padding: 2px 5px;
    font-size: 10px;
    color: #000 !important;
    border-radius: 3px;
    z-index: 1000;
}

.copyright-notice a {
    color: #000 !important;
    text-decoration: underline;
}