/* --- style_v5.css (Final Mobile Fix) --- */

/* 1. リセット & ベース設定 */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    width: 100%;
    overflow-x: hidden; /* 画面全体での横スクロールを禁止 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    margin: 0;
    padding: 0 0 40px 0;
    width: 100%;
    overflow-x: hidden; /* Bodyでも禁止 */
    -webkit-font-smoothing: antialiased;
}

:root {
    --primary: #0071e3; --like: #34c759; --dislike: #ff3b30; --comment: #ff9500;
    --sc-color: #ffcc00; --mem-color: #30b0c7; --gift-color: #af52de;
    --bg-page: #f2f2f7; --bg-card: #ffffff; --text-main: #1d1d1f; --text-sub: #86868b;
    --text-light: #d2d2d7;
    --radius-l: 18px;
    --shadow-card: 0 2px 10px rgba(0,0,0,0.04);
}

/* === ヘッダー === */
.header-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 0 5px 0;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    margin-bottom: 15px;
    position: sticky;
    top: 0;
    z-index: 999;
    backdrop-filter: blur(20px);
    width: 100%;
    text-align: center;
}
.header-title h1 { font-size: 1.1rem; margin: 0; font-weight: 800; }
.header-title .meta { font-size: 0.7rem; color: var(--text-sub); margin-top: 2px; }

/* === ナビゲーション (横スクロール) === */
.scroll-nav {
    display: flex;
    overflow-x: auto;
    padding: 5px 12px 10px 12px;
    gap: 6px;
    width: 100%;
    justify-content: flex-start; /* 左詰め */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.scroll-nav::-webkit-scrollbar { display: none; }
.scroll-nav::after { content: ""; flex: 0 0 10px; display: block; }

.pill {
    flex: 0 0 auto;
    padding: 6px 12px;
    background: rgba(0,0,0,0.05);
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-sub);
    text-decoration: none;
    display: flex; align-items: center; gap: 4px;
    white-space: nowrap;
}
.pill.active { background: var(--text-main); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.pill.group-holo.active { background: linear-gradient(135deg, #0071e3, #4facfe); }
.pill.group-devis.active { background: linear-gradient(135deg, #1c1c1e, #2c2c2e); color: #64d2ff; }
.pill.group-all.active { background: linear-gradient(135deg, #e6c17b, #d4af37); color: #fff; }
.pill.sort-sc.active { background: var(--sc-color); }
.pill.sort-mem.active { background: var(--mem-color); }
.pill.sort-gift.active { background: var(--gift-color); }

/* === カード (ここが重要: 幅固定ではなく余白で制御) === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-card);
    /* 左右に10pxの余白を強制的に確保 */
    margin: 0 10px 12px 10px;
    width: auto;
    overflow: hidden;
    position: relative;
}

.card-main {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    width: 100%;
}

/* ランク */
.rank-box { width: 28px; text-align: center; margin-right: 8px; flex-shrink: 0; }
.rank-num { font-size: 1.2rem; font-weight: 900; font-style: italic; line-height: 1; }
.rank-1 { color: #ffd60a; } .rank-2 { color: #98989d; } .rank-3 { color: #bf5af2; } .rank-other { color: var(--text-light); font-size: 0.9rem; }

/* プロフィール (文字はみ出し防止の要) */
.profile { 
    flex: 1; 
    min-width: 0; /* これがないとFlexbox内で文字省略が効かない */
    margin-right: 5px;
}
.name {
    font-size: 0.9rem; font-weight: 700; color: var(--text-main);
    display: block; margin-bottom: 2px; text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sub-info { font-size: 0.65rem; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; padding: 2px 4px; border-radius: 4px; font-size: 0.5rem; font-weight: 700; margin-left: 4px; vertical-align: middle; }
.b-devis { background: #f2f2f2; color: #000; border: 1px solid #ddd; }

/* メイン数値 */
.main-metric { text-align: right; min-width: 70px; flex-shrink: 0; }
.metric-val { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.5px; line-height: 1; }
.metric-label { font-size: 0.6rem; color: var(--text-sub); font-weight: 600; }

/* スタッツグリッド */
.stats-grid {
    display: grid; 
    grid-template-columns: repeat(4, 1fr);
    background: #f9f9fc; 
    border-top: 1px solid rgba(0,0,0,0.03); 
    padding: 8px 0;
    width: 100%;
}
.stat-box {
    text-align: center; position: relative; padding: 0 2px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 0; /* はみ出し防止 */
}
.stat-box:not(:last-child)::after {
    content: ""; position: absolute; right: 0; top: 20%; height: 60%; width: 1px; background: rgba(0,0,0,0.05);
}
.stat-label { font-size: 0.55rem; color: var(--text-light); margin-bottom: 2px; white-space: nowrap; }
.stat-val { font-size: 0.75rem; font-weight: 700; color: var(--text-main); white-space: nowrap; }
.stat-diff { font-size: 0.6rem; font-weight: 600; margin-top: 1px; }

.diff-plus { color: var(--dislike); } .diff-zero { color: #ddd; }
.highlight-bg { background: #fffbe6; }

/* History用 */
.log-date { font-size: 0.9rem; font-weight: 700; color: var(--text-sub); }
.daily-ratio-val { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.progress-bar-bg { background: rgba(0,0,0,0.05); height: 8px; border-radius: 10px; overflow: hidden; width: 100%; }
.progress-bar-fill { height: 100%; border-radius: 10px; transition: width 0.3s; }
.back-link {
    display: inline-block; margin-top: 20px; color: var(--primary);
    text-decoration: none; font-weight: 600; padding: 10px 25px;
    background: #fff; border-radius: 25px; box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}