:root {
    --bg: #111;
    --card: #1b1b1b;
    --muted: #777;
    --accent: #e50914;
    --white: #fff;
}
* {
    box-sizing: border-box
}
html,
body {
    height: 100%
}
body {
    margin: 0;
    font-family: "Helvetica", "Arial", sans-serif;
    background: var(--bg);
    color: var(--white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: 24px;
}

/* ---------- 上部固定領域 (sticky fixed at top:0) ---------- */
.topbar {
    position: sticky;
    top: 0;
    /* ユーザー指定通り top:0 に固定 */
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.85));
    z-index: 40;
    padding: 10px 12px;
    border-bottom: 1px solid #222;
}

/* 回答履歴（縦に履歴行追加、古い→新しい） */
.history-area {
    margin-bottom: 8px;
}
.history-title {
    font-size: 12px;
    opacity: .7;
    margin-bottom: 6px;
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow: auto;
    padding-right: 6px;
    padding-left: 2px;
}
.history-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.history-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.history-thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    object-fit: cover;
    border: 4px solid transparent;
    background: #222;
}

/* 項番（左端に小さい番号） */
.history-index {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    color: #bbb;
    font-size: 12px;
    font-weight: 700;
}

/* Hit/Blow バッジ群（右側） - 縦並び */
.history-judge {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    /* 縦並び */
    align-items: flex-end;
    /* 右寄せ */
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
}
.badge-hit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    color: #e50914;
    background: rgba(229, 9, 20, 0.08);
    border: 1px solid rgba(229, 9, 20, 0.18);
}
.badge-blow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    color: #b8860b;
    background: rgba(255, 215, 0, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.12);
}
.small-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* 選択中エリア */
.selected-title {
    font-size: 14px;
    opacity: .85;
    margin: 8px 0 6px
}
.selected-area {
    display: flex;
    gap: 8px;
    padding: 6px 2px 12px;
    align-items: center;
}
.select-slot {
    width: 22%;
    aspect-ratio: 1/1;
    background: #1c1c1c;
    border: 2px dashed #444;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease;
}
.select-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover
}
.select-slot .tag {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6)
}

/* 回答ボタン */
.answer-wrap {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    margin-bottom: 6px;
    padding-bottom: 6px
}
.answer-btn {
    width: 92%;
    max-width: 420px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #333;
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.08);
    font-weight: 700;
    font-size: 17px;
    opacity: .45;
}
.answer-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    opacity: 1;
}

/* ---------- メイン（スクロール対象） ---------- */
.main {
    padding: 12px;
    padding-top: 6px;
}

/* ニュースカード */
.pick-area {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 12px;
    padding-bottom: 80px;
}
.card {
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform .18s ease, box-shadow .18s ease, border-color .12s ease;
    border: 4px solid transparent;
    padding: 4px;
}
.card:active {
    transform: scale(.995)
}
.card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 6px
}
.card-body {
    padding: 10px
}
.card-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 6px
}
.card-meta {
    font-size: 12px;
    opacity: .65
}

/* 選択時のアニメーション（カードが持ち上がる）*/
.card.selected {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(229, 9, 20, 0.22);
}

/* color classes */
.color1 {
    border-color: #e50914
}
.color2 {
    border-color: #1e90ff
}
.color3 {
    border-color: #32cd32
}
.color4 {
    border-color: #ffa500
}
.color5 {
    border-color: #8a2be2
}
.color6 {
    border-color: #ff1493
}

/* tag dot on cards */
.card .tag {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6)
}

/* small screens tweaks */
@media (max-width:420px) {
    .select-slot {
        width: 23%
    }
    .history-thumb {
        width: 56px;
        height: 56px;
    }
    .card img {
        height: 150px
    }
}

/* result modal (full-screen dark) */
.modal-bg {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    z-index: 200;
    overflow-y: auto;
    /* ← これを追加 */
}

.modal-panel {
    background: #111;
    padding: 18px;
    border-radius: 12px;
    width: 92%;
    max-width: 420px;
    border: 3px solid var(--accent);
    box-shadow: 0 8px 30px rgba(229, 9, 20, 0.18);
    /* 既存の指定はそのまま残す */
    max-height: 80vh;
    /* 全体高さの最大値を固定 */
    overflow-y: auto;
    /* 内容が長い場合に縦スクロール */
}
.modal-panel h3 {
    margin: 0 0 8px;
    color: var(--accent)
}
.modal-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px
}
.modal-item {
    display: flex;
    gap: 10px;
    align-items: center
}
.modal-item img {
    width: 72px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    border: 3px solid transparent
}
.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: flex-end
}

/* small helper */
.kv {
    font-size: 13px;
    color: #ccc
}

/* hidden helper */
.hidden {
    display: none !important;
}
