:root {
    --bg-dark: #333;
    --text-light: #f8f8f8;
    --header-height: 60px;
    --theme-color: #ff9800;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0; padding: 0;
    font-family: sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
}

.page { display: none; width: 100%; min-height: 100svh; position: relative; }

/* PC/ブラウザ表示での縦長固定 */
#PAGE_QUIZ, #PAGE_HOME, #PAGE_CATEGORY, #PAGE_QUESTION_LIST, 
#PAGE_ANALYSIS_TOP, #PAGE_ANALYSIS_SUBJECT, #PAGE_SEAL_BOOK, #PAGE_COLLECTION {
    max-width: 500px;
    margin: 0 auto;
    background-color: var(--bg-dark);
}

.header-bar {
    position: fixed; top: env(safe-area-inset-top); left: 50%;
    transform: translateX(-50%);
    width: 100%; max-width: 500px; height: var(--header-height);
    background-color: #222; display: flex; align-items: center; justify-content: center;
    z-index: 2000; box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.back-btn {
    position: absolute; left: 10px; padding: 8px 15px;
    background: #444; color: white; border: none; border-radius: 8px;
}

.mt-60 { padding-top: calc(var(--header-height) + 10px); }

/* --- HOME Status Panel (Rich Layout) --- */
.home-status-wrapper {
    display: flex; align-items: center; width: 95%; margin: 10px auto; gap: 10px;
}
.pld-icon-home { width: 100px; height: 100px; object-fit: contain; flex-shrink: 0; }
.home-status-panel {
    flex-grow: 1; background: #444; border-radius: 12px; padding: 10px; font-size: 0.9rem;
}
.home-boss-img { width: 100%; max-width: 376px; max-height: 120px; object-fit: contain; background: #000; border-radius: 6px; margin: 5px 0; }

/* --- QUIZ Status Panel (Ultra Compact with Effects) --- */
.status-panel-compact {
    width: 90%; margin: 5px auto; padding: 5px 10px;
    background: rgba(0,0,0,0.3); border-radius: 8px; font-size: 0.85rem;
    transition: background 0.5s ease, border 0.5s ease;
    position: relative; overflow: hidden;
}

/* ボス戦時の演出クラス */
.status-panel-compact.is-boss {
    background: rgba(139, 0, 0, 0.7);
    border: 1px solid #ff4444;
}
.status-panel-compact.is-boss .status-message span {
    color: #ff4444;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255,0,0,0.3);
}

/* パネル揺れアニメーション */
@keyframes panel-shake {
    0% { transform: translate(0, 0); }
    20% { transform: translate(-3px, 0); }
    40% { transform: translate(3px, 0); }
    60% { transform: translate(-3px, 0); }
    80% { transform: translate(3px, 0); }
    100% { transform: translate(0, 0); }
}
.animate-shake { animation: panel-shake 0.3s ease-in-out; }

/* ホワイトアウト（閃光）演出 */
@keyframes white-out {
    0% { background-color: rgba(255, 255, 255, 0); }
    20% { background-color: rgba(255, 255, 255, 0.9); }
    100% { background-color: rgba(255, 255, 255, 0); }
}
.animate-flash::before {
    content: ''; position: absolute; inset: 0; z-index: 10;
    animation: white-out 0.4s ease-out; pointer-events: none;
}

/* Common Status Elements */
.status-row-top { display: flex; justify-content: space-between; margin-bottom: 2px; }
.status-gauge-container { width: 100%; height: 8px; background: #111; border-radius: 4px; overflow: hidden; margin: 3px 0; }
.status-gauge-bar { height: 100%; background: linear-gradient(90deg, #4caf50, #8bc34a); transition: width 0.3s; }
.status-message { display: flex; align-items: center; min-height: 24px; font-size: 0.8rem; }
.enemy-icon { width: 20px; height: 20px; margin-right: 6px; object-fit: contain; }

/* Subject Grid & Buttons */
.subject-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 15px; }
.sub-btn { 
    display: flex; align-items: center; justify-content: center;
    color: #fff; border-radius: 12px; padding: 12px 10px; border: none; 
    font-weight: bold; box-shadow: 0 4px rgba(0,0,0,0.2); touch-action: manipulation; 
    gap: 10px;
}
.sub-btn img { width: 40px; height: 40px; object-fit: contain; }

.btn-kokugo { background-color: #a55a6d; }
.btn-sansu  { background-color: #5a8ca5; }
.btn-rika   { background-color: #5a8a5d; }
.btn-shakai { background-color: #b07d4a; }
.btn-eigo   { background-color: #7d6a91; }

.menu-area { padding-bottom: 20px; }
.menu-btn.long { width: 90%; margin: 10px auto; display: flex; align-items: center; justify-content: center; padding: 15px; background: #f8f8f8; border-radius: 12px; border: none; font-weight: bold; color: #333; }

/* Quiz Styles */
.question-box { padding: 20px; font-size: 1.5rem; font-weight: bold; text-align: center; min-height: 120px; display: flex; align-items: center; justify-content: center; line-height: 1.4; }
.choice-grid { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.choice-btn { width: 100%; padding: 18px; background: #eee; border: none; border-radius: 12px; font-size: 1.1rem; position: relative; touch-action: manipulation; transition: opacity 0.2s; color: #333; }

.is-dimmed { opacity: 0.3 !important; filter: grayscale(1); pointer-events: none; }
.choice-btn.is-correct::after {
    content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 80px; height: 80px; border: 8px solid rgba(255, 0, 0, 0.8); border-radius: 50%; z-index: 100; pointer-events: none;
}

.chart-row { padding: 10px 15px; border-bottom: 1px solid #444; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 3000; display: flex; justify-content: center; align-items: center; }
.modal-content { background: #333; padding: 30px; border-radius: 16px; text-align: center; width: 85%; max-width: 320px; }