/* ==========================================================
   ブログづくりゲーム — シニアにやさしい大きな文字のデザイン
   ========================================================== */

:root {
    --navy: #1b2a52;
    --navy-2: #33417a;
    --indigo: #4a3b8c;
    --gold: #f5b83d;
    --orange: #e8590c;
    --orange-dark: #c74a08;
    --cream: #faf6ee;
    --card: #ffffff;
    --ink: #26282e;
    --ink-sub: #5a5e6b;
    --line: #d8d4c8;
    --green: #2f9e44;
    --focus: #1971c2;
    --radius: 16px;
    --shadow: 0 4px 14px rgba(27, 42, 82, 0.12);
}

/* --- 基本 --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 18px; scroll-behavior: smooth; }
html[data-fontsize="large"]  { font-size: 21px; }
html[data-fontsize="xlarge"] { font-size: 24px; }

body {
    font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "BIZ UDGothic", "Yu Gothic", sans-serif;
    font-weight: 500;
    background: var(--cream);
    color: var(--ink);
    line-height: 1.9;
}

img { max-width: 100%; }

/* 見やすいフォーカス枠（キーボード操作用） */
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
    outline: 4px solid var(--focus);
    outline-offset: 2px;
}

.hidden { display: none !important; }

/* --- ヘッダー --- */
.hero {
    background:
        radial-gradient(1000px 400px at 85% -10%, rgba(245, 184, 61, 0.25), transparent 60%),
        linear-gradient(135deg, var(--navy) 0%, var(--indigo) 100%);
    color: #fff;
    padding: 2rem 1rem 2.4rem;
}

.hero-inner { max-width: 62rem; margin: 0 auto; }

.hero-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.hero-title {
    font-size: 2.1rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.hero-lead {
    margin-top: 0.8rem;
    font-size: 1.05rem;
    color: #eef0ff;
}

/* 文字サイズ切替 */
.font-switch {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
}

.font-switch-label { font-size: 0.85rem; color: #dfe3ff; margin-right: 0.2rem; }

.font-btn {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.55);
    border-radius: 999px;
    padding: 0.25rem 0.9rem;
    cursor: pointer;
}

.font-btn:hover { background: rgba(255, 255, 255, 0.2); }

.font-btn.active {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy);
}

/* --- 成績ボード --- */
.scoreboard {
    margin-top: 1.4rem;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 0.8rem;
}

.score-item {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
    backdrop-filter: blur(4px);
}

.score-label { display: block; font-size: 0.85rem; color: #cfd6ff; }

.score-value {
    display: block;
    font-size: 1.45rem;
    font-weight: 900;
    color: var(--gold);
    line-height: 1.4;
}

.score-num { font-size: 1.7rem; color: #fff; }
.score-num small { font-size: 0.9rem; font-weight: 700; color: #cfd6ff; margin-left: 0.15rem; }

.score-sub { display: block; font-size: 0.8rem; color: #cfd6ff; margin-top: 0.3rem; }

.level-bar {
    margin-top: 0.5rem;
    height: 0.7rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    overflow: hidden;
}

.level-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--gold), #ffd97a);
    border-radius: 999px;
    transition: width 0.8s ease;
}

/* --- レイアウト --- */
.container { max-width: 62rem; margin: 0 auto; padding: 1.4rem 1rem 3rem; }

.panel {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem 1.4rem;
    margin-top: 1.6rem;
}

.panel-title {
    font-size: 1.45rem;
    font-weight: 900;
    color: var(--navy);
    border-bottom: 3px solid var(--gold);
    padding-bottom: 0.5rem;
    margin-bottom: 1.2rem;
}

.panel-icon { margin-right: 0.3rem; }

/* --- あそびかた --- */
.howto {
    margin-top: 1.6rem;
    background: #fff8e6;
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    padding: 0;
    overflow: hidden;
}

.howto summary {
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--navy);
    padding: 1rem 1.3rem;
    list-style: none;
}

.howto summary::-webkit-details-marker { display: none; }
.howto summary:hover { background: #ffefc4; }

.howto-list { padding: 0.4rem 2.4rem 1rem; }
.howto-list li { margin-bottom: 0.5rem; }

.howto-note {
    padding: 0 1.3rem 1.2rem;
    color: var(--ink-sub);
    font-size: 0.92rem;
}

/* --- ステップ --- */
.step { margin-bottom: 1.7rem; }

.step-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.7rem; }

.step-num {
    flex: none;
    width: 2.3rem;
    height: 2.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--orange);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 900;
    border-radius: 50%;
}

.step-title { font-size: 1.25rem; font-weight: 900; color: var(--navy); }

/* ジャンルボタン */
.genre-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.7rem;
}

.genre-btn {
    font-family: inherit;
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--ink);
    background: #f4f1e8;
    border: 3px solid var(--line);
    border-radius: 14px;
    padding: 0.8rem 0.4rem;
    cursor: pointer;
    text-align: center;
    line-height: 1.5;
    transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.genre-btn .genre-emoji { display: block; font-size: 1.9rem; line-height: 1.3; }

.genre-btn:hover { transform: translateY(-2px); border-color: var(--gold); }

.genre-btn.selected {
    background: #fff3d6;
    border-color: var(--orange);
    box-shadow: 0 0 0 2px rgba(232, 89, 12, 0.25);
}

/* 入力欄 */
.text-input {
    width: 100%;
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--ink);
    background: #fffdf7;
    border: 3px solid var(--line);
    border-radius: 12px;
    padding: 0.8rem 1rem;
}

.text-input:focus { border-color: var(--focus); }

.body-input { resize: vertical; line-height: 1.9; }

.title-suggest { margin-top: 0.7rem; }

.title-candidates { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }

.title-candidate {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    color: var(--navy);
    background: #eef2ff;
    border: 2px solid #b8c4f0;
    border-radius: 999px;
    padding: 0.45rem 1.1rem;
    cursor: pointer;
}

.title-candidate:hover { background: #dde5ff; border-color: var(--indigo); }

.body-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.7rem;
}

.char-count { font-size: 1rem; font-weight: 700; color: var(--ink-sub); }

/* --- ボタン --- */
.btn {
    font-family: inherit;
    font-weight: 900;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    font-size: 1.35rem;
    color: #fff;
    background: linear-gradient(135deg, var(--orange), var(--orange-dark));
    padding: 1rem 2.4rem;
    box-shadow: 0 6px 16px rgba(232, 89, 12, 0.4);
    letter-spacing: 0.05em;
}

.btn-primary:hover { box-shadow: 0 8px 20px rgba(232, 89, 12, 0.5); }

.btn-sub {
    font-size: 1.02rem;
    color: var(--navy);
    background: #fff;
    border: 3px solid var(--navy-2);
    padding: 0.55rem 1.3rem;
}

.btn-sub:hover { background: #eef2ff; }

.btn-cancel {
    font-size: 1rem;
    color: var(--ink-sub);
    background: #eceae2;
    border: 2px solid var(--line);
    padding: 0.6rem 1.2rem;
}

.submit-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

/* --- バッジ --- */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.8rem;
}

.badge {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    border-radius: 14px;
    padding: 0.8rem 1rem;
    border: 2px solid var(--line);
    background: #f4f1e8;
    filter: grayscale(1);
    opacity: 0.55;
}

.badge.earned {
    filter: none;
    opacity: 1;
    background: #fff8e6;
    border-color: var(--gold);
    box-shadow: 0 3px 10px rgba(245, 184, 61, 0.35);
}

.badge-emoji { font-size: 2rem; flex: none; }
.badge-name { font-weight: 900; color: var(--navy); line-height: 1.4; }
.badge-desc { font-size: 0.85rem; color: var(--ink-sub); line-height: 1.5; }

/* --- 記事カード --- */
.empty-msg {
    text-align: center;
    color: var(--ink-sub);
    font-size: 1.1rem;
    padding: 1.5rem 0.5rem;
}

.post-card {
    border: 2px solid var(--line);
    border-left: 8px solid var(--gold);
    border-radius: 14px;
    padding: 1.1rem 1.3rem;
    margin-bottom: 1rem;
    background: #fffdf7;
}

.post-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}

.post-genre {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--navy);
    background: #eef2ff;
    border-radius: 999px;
    padding: 0.15rem 0.8rem;
}

.post-date { font-size: 0.9rem; color: var(--ink-sub); }

.post-title { font-size: 1.3rem; font-weight: 900; color: var(--navy); margin-bottom: 0.4rem; }

.post-body { white-space: pre-wrap; margin-bottom: 0.8rem; }

.post-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; }

.btn-edit {
    font-size: 0.95rem;
    color: var(--navy);
    background: #eef2ff;
    border: 2px solid #b8c4f0;
    padding: 0.4rem 1.1rem;
}

.btn-delete {
    font-size: 0.95rem;
    color: #c92a2a;
    background: #fff0f0;
    border: 2px solid #f1b5b5;
    padding: 0.4rem 1.1rem;
}

/* --- フッター --- */
.footer {
    text-align: center;
    color: var(--ink-sub);
    font-size: 0.9rem;
    padding: 1.5rem 1rem 2.5rem;
}

/* --- トースト --- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    transform: translateX(-50%) translateY(200%);
    background: var(--navy);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 900;
    padding: 1rem 2rem;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    transition: transform 0.35s ease;
    z-index: 50;
    max-width: 92vw;
    text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); }

.toast.levelup { background: linear-gradient(135deg, var(--orange), var(--orange-dark)); }

/* --- 紙吹雪 --- */
.confetti-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 40;
}

.confetti {
    position: absolute;
    top: -3vh;
    width: 0.8rem;
    height: 1.2rem;
    border-radius: 3px;
    animation: confetti-fall linear forwards;
}

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

/* --- スマホ対応 --- */
@media (max-width: 720px) {
    .hero-title { font-size: 1.6rem; }
    .scoreboard { grid-template-columns: 1fr 1fr; }
    .score-item.score-level { grid-column: 1 / -1; }
    .genre-grid { grid-template-columns: repeat(2, 1fr); }
    .btn-primary { width: 100%; }
}
