
/* --- Design Tokens --- */
:root {
    /* Core Colors - Modern & Sophisticated Palette */
    --c-bg: #f8fafc; /* 少し冷たいグレー寄りの白 */
    --c-surface: #ffffff;
    --c-text-primary: #1e293b; /* 深いネイビーグレー */
    --c-text-secondary: #475569;
    --c-border: #e2e8f0;
    --c-accent: #2563eb; /* リンクや強調色 */

    /* Category Colors - Deep & Stylish Tones */
    /* Batting: Deep Cerulean Blue */
    --cat-bat: #026AA7; 
    --bg-bat:  #E3F2FD;
    /* Pitching: Muted Crimson */
    --cat-pit: #C2185B;
    --bg-pit:  #FCE4EC;
    /* Fielding: Warm Terracotta/Amber */
    --cat-fld: #D84315;
    --bg-fld:  #FBE9E7;
    /* Overall: Sophisticated Teal */
    --cat-tot: #00796B;
    --bg-tot:  #E0F2F1;
    /* Standard: Modern Indigo Purple */
    --cat-std: #3F51B5;
    --bg-std:  #E8EAF6;

    /* Typography */
    --font-sans: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

    /* Spacing & Layout */
    --header-height: 180px;
    
    /* Border Radius - Sharpened */
    --radius-sm: 2px;   /* 小さなボタン、タグなど */
    --radius: 4px;      /* カード、入力フィールドなど標準的な要素 */
    --radius-lg: 8px;   /* モーダル、大きなコンテナ */
    --radius-xl: 12px;  /* 非常に大きな要素 */
    --radius-full: 9999px; /* 丸いアイコンボタンは維持 */

    /* Shadows - Slightly sharper */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-card: 0 2px 6px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
    --shadow-modal: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 5px 15px -8px rgba(0, 0, 0, 0.08);
}

/* Dark Mode Colors - adjusted for the new palette */
body.dark-mode {
    --c-bg: #0f172a; /* 深いダークネイビー */
    --c-surface: #1e293b;
    --c-text-primary: #f1f5f9;
    --c-text-secondary: #94a3b8;
    --c-border: #334155;
    --c-accent: #60a5fa;

    /* Category Colors - Slightly desaturated and lighter for dark background */
    --cat-bat: #3399ff;
    --bg-bat:  rgba(2, 106, 167, 0.15);
    --cat-pit: #ff4081;
    --bg-pit:  rgba(194, 24, 91, 0.15);
    --cat-fld: #ff6e40;
    --bg-fld:  rgba(216, 67, 21, 0.15);
    --cat-tot: #26a69a;
    --bg-tot:  rgba(0, 121, 107, 0.15);
    --cat-std: #7986cb;
    --bg-std:  rgba(63, 81, 181, 0.15);

    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

body {
    background-color: var(--c-bg);
    color: var(--c-text-primary);
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    overflow-y: scroll;
    transition: background-color 0.3s, color 0.3s;
}

/* --- Header --- */
header {
    background: var(--c-surface);
    padding: 4rem 2rem;
    text-align: center;
    position: relative;
    border-bottom: 1px solid var(--c-border);
    background-image: radial-gradient(var(--c-border) 1px, transparent 1px);
    background-size: 20px 20px;
    transition: background-color 0.3s;
}

.brand {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: -0.05em;
    margin: 0;
    color: var(--c-text-primary);
    background: linear-gradient(135deg, var(--c-text-primary) 0%, var(--c-text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand span { color: var(--cat-bat); -webkit-text-fill-color: var(--cat-bat); }

.subtitle {
    color: var(--c-text-secondary);
    margin-top: 1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: 0.85rem;
}

/* --- Sticky Controls --- */
.controls-area {
    position: sticky;
    top: 0;
    background: var(--c-surface);
    opacity: 0.98;
    backdrop-filter: blur(12px);
    z-index: 100;
    border-bottom: 1px solid var(--c-border);
    padding: 1rem 0;
    transition: background-color 0.3s, border-color 0.3s;
}

.search-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 auto 25px;
    /* 丸みを帯びた影を削除し、フラットなボーダーでシャープに */
    box-shadow: none; 
    border-radius: var(--radius);
}

.search-input {
    width: 100%;
    padding: 16px 20px 16px 50px;
    font-size: 1.05rem;
    /* ボーダーを明示的に追加 */
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text-primary);
    transition: all 0.2s ease;
    /* 影を削除 */
    box-shadow: none; 
}
.search-input:focus {
    outline: none;
    border-color: var(--c-accent);
    /* フォーカス時の影もシャープに */
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15); 
}
/* 検索アイコンの修正 */
.search-icon {
    position: absolute;
    left: 25px; top: 50%; 
    transform: translateY(-50%);
    color: var(--c-text-secondary);
    pointer-events: none;
    width: 20px; /* 明示的にサイズを指定 */
    height: 20px; /* 明示的にサイズを指定 */
    display: flex;
    align-items: center;
    justify-content: center;
}
.search-icon svg { stroke-width: 2.5; width: 20px; height: 20px; } /* SVG自体のサイズも保証 */

.theme-toggle {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    color: var(--c-text-primary);
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.theme-toggle:hover {
    border-color: var(--c-text-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.theme-toggle svg { width: 24px; height: 24px; stroke-width: 2.5; }

.filter-scroll {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 0 20px;
    overflow-x: auto;
    padding-bottom: 5px;
}
.filter-scroll::-webkit-scrollbar { height: 0; }

.filter-chip {
    background: var(--c-surface);
    border: 1:px solid var(--c-border);
    color: var(--c-text-secondary);
    padding: 8px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex; align-items: center; gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.filter-chip:hover {
    background: var(--c-bg); color: var(--c-text-primary); transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}
.filter-chip.active {
    background: var(--c-text-primary); color: var(--c-surface);
    border-color: var(--c-text-primary); box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    transform: none;
}

/* --- Grid --- */
.grid-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.metric-card {
    background: var(--c-surface);
    border-radius: 6px;
    border: 1px solid var(--c-border);
    padding: 32px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex; flex-direction: column;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-card);
}
.metric-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
    border-color: var(--cat-bat);
}

.cat-bat:hover { border-color: var(--cat-bat); }
.cat-pit:hover { border-color: var(--cat-pit); }
.cat-fld:hover { border-color: var(--cat-fld); }
.cat-tot:hover { border-color: var(--cat-tot); }
.cat-std:hover { border-color: var(--cat-std); }

.card-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
}
.card-tag {
    font-size: 0.7rem; font-weight: 800; padding: 6px 12px; border-radius: 8px;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.cat-bat .card-tag { background: var(--bg-bat); color: var(--cat-bat); }
.cat-pit .card-tag { background: var(--bg-pit); color: var(--cat-pit); }
.cat-fld .card-tag { background: var(--bg-fld); color: var(--cat-fld); }
.cat-tot .card-tag { background: var(--bg-tot); color: var(--cat-tot); }
.cat-std .card-tag { background: var(--bg-std); color: var(--cat-std); }

/* 絵文字をSVGアイコンに置き換え */
.calc-icon {
    opacity: 0.3; transition: 0.2s;
}
.calc-icon svg { width: 20px; height: 20px; stroke-width: 2.5; }
.metric-card:hover .calc-icon { opacity: 1; transform: scale(1.1); }
.calc-icon.ai svg { color: var(--ai-color); opacity: 0.8; }

.metric-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0;
    line-height: 1;
    color: var(--c-text-primary);
    letter-spacing: -0.03em;
}
.metric-full {
    font-size: 0.85rem;
    color: var(--c-text-secondary);
    font-weight: 600;
    margin: 6px 0 20px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.metric-desc {
    font-size: 0.95rem;
    color: var(--c-text-secondary);
    margin: 0;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Footer --- */
.footer-area {
    max-width: 1200px;
    margin: 20px auto 60px;
    padding: 0 2rem;
}
.footer-details {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s;
}
.footer-details[open] {
    box-shadow: var(--shadow-card);
    border-color: var(--cat-bat);
}
.footer-summary {
    padding: 20px 24px;
    cursor: pointer;
    font-weight: 700;
    color: var(--c-text-secondary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--c-bg);
    transition: background 0.2s, color 0.2s;
    font-size: 0.9rem;
}
.footer-summary:hover {
    color: var(--c-text-primary);
    background: var(--c-surface);
}
.footer-summary::-webkit-details-marker { display: none; }
.footer-summary::after {
    content: '+'; margin-left: auto; font-size: 1.2rem; font-weight: 400; transition: transform 0.3s;
}
.footer-details[open] .footer-summary::after { transform: rotate(45deg); }

/* Icon in Footer */
.footer-icon svg { width: 20px; height: 20px; stroke-width: 2.5; }

.footer-content {
    padding: 30px 40px;
    border-top: 1px solid var(--c-border);
    font-size: 0.9rem;
    color: var(--c-text-secondary);
    line-height: 1.8;
    animation: fadeIn 0.3s ease;
}
.footer-content h3 {
    font-size: 1rem; color: var(--c-text-primary); margin: 30px 0 12px 0;
    display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 0.05em;
}
.footer-content h3:first-child { margin-top: 0; }
.footer-content h3::before {
    content: ''; display: inline-block; width: 4px; height: 1.2em; background: var(--cat-bat); border-radius: 2px;
}
.footer-content ul {
    margin: 0; padding: 0; list-style: none;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px;
}
.footer-content li { margin: 0; }
.footer-content a {
    color: var(--c-text-primary); text-decoration: none; transition: all 0.2s;
    display: flex; align-items: center; gap: 6px; padding: 8px 12px;
    background: var(--c-bg); border-radius: 8px; border: 1px solid transparent;
    font-weight: 600; font-size: 0.85rem;
}
.footer-content a:hover {
    border-color: var(--cat-bat); color: var(--cat-bat); background: var(--c-surface); transform: translateX(4px);
}
.footer-content p { margin-top: 0; margin-bottom: 16px; }

.logic-box {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}
.logic-title {
    font-weight: 700; color: var(--c-text-primary); margin-bottom: 8px; font-size: 0.95rem;
    display: flex; align-items: center; justify-content: space-between;
}
.logic-cat { font-size: 0.7rem; background: var(--c-text-secondary); color: white; padding: 2px 6px; border-radius: 4px; }
.logic-cat.bat { background: var(--cat-bat); }
.logic-cat.pit { background: var(--cat-pit); }
.logic-formula {
    font-family: var(--font-mono); font-size: 0.85rem; color: var(--cat-bat); background: rgba(255,255,255,0.5);
    padding: 10px; border-radius: 6px; border: 1px solid var(--c-border); margin-bottom: 10px;
}
.logic-desc { font-size: 0.85rem; color: var(--c-text-secondary); line-height: 1.6; }

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}
.modal-overlay.show { opacity: 1; }

.modal-panel {
    background: var(--c-surface);
    width: 95%;
    max-width: 850px;
    max-height: 92vh;
    border-radius: 8px;
    padding: 0;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-float);
    transform: scale(0.95) translateY(20px); 
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--c-border);
}
.modal-overlay.show .modal-panel { transform: scale(1) translateY(0); }

.modal-header {
    padding: 32px 40px;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    position: relative;
}
.modal-body {
    padding: 40px;
    overflow-y: auto;
    color: var(--c-text-primary);
}

.m-cat {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}
.m-title {
    font-size: 3.5rem;
    font-weight: 900;
    margin: 0;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--c-text-primary);
}
.m-full {
    font-size: 1.1rem;
    color: var(--c-text-secondary);
    margin-top: 5px;
    font-weight: 500;
}

.close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--c-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.close-btn:hover { background: var(--c-bg); color: var(--c-text-primary); transform: rotate(90deg); }

.section-label {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--c-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 3rem 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
}
/* 句点を削除 */
.section-label::before { content:''; color: var(--cat-bat); }
.section-label::after { content:''; flex:1; height:1px; background: var(--c-border); }
.section-label.has-hash::before { content:'#'; }

/* --- Formula Box --- */
.formula-box {
    background: #1e293b; /* Always dark for formula */
    border: 1px solid #334155;
    padding: 30px;
    border-radius: 16px;
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-style: italic;
    color: #e2e8f0;
    overflow-x: auto;
    text-align: center;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}
.formula-var {
    color: #38bdf8;
    font-weight: bold;
    margin: 0 2px;
    font-family: var(--font-sans);
    font-style: normal;
}
.formula-op { color: #94a3b8; margin: 0 5px; }

/* --- Calculator Section --- */
.calc-container {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: 16px;
    padding: 30px;
    margin-top: 10px;
    position: relative; /* For ocr button positioning */
}
.calc-container.ai-mode {
    background: rgba(139, 92, 46, 0.05);
    border-color: var(--ai-color);
}
.calc-container.ai-mode .calc-title span { color: var(--ai-color); }
.calc-container.ai-mode .calc-btn { background: #7c3aed; opacity: 0.9;  }
.calc-container.ai-mode .calc-btn:hover { background: #7c3aed; opacity: 0.9; }
.calc-container.ai-mode .calc-res-value { color: var(--ai-color); }

.calc-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--cat-bat);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.calc-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    margin-top: 20px;
}
.calc-group { display: flex; flex-direction: column; gap: 5px; }
.calc-label { font-size: 0.7rem; font-weight: 700; color: var(--c-text-secondary); text-transform: uppercase; }
.calc-field, .calc-select {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
    font-family: var(--font-mono);
    text-align: right;
    font-size: 1rem;
    background: var(--c-surface);
    color: var(--c-text-primary);
}
.calc-select { text-align: left; font-family: var(--font-sans); cursor: pointer; }
.calc-field:focus, .calc-select:focus { outline: none; border-color: var(--cat-bat); box-shadow: 0 0 0 2px rgba(14,165,233,0.2); }

/* Preset Styles */
.preset-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    align-items: center;
    background: rgba(0,0,0,0.03);
    padding: 12px;
    border-radius: 12px;
    flex-wrap: wrap;
    border: 1px solid var(--c-border);
}
.preset-label { width: 100%; font-size: 0.75rem; font-weight: 700; color: var(--c-text-secondary); margin-bottom: 4px; }
.preset-select {
    flex: 1;
    min-width: 140px;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
    font-family: var(--font-sans);
    font-size: 0.9rem;
}
.preset-input {
    flex: 1;
    min-width: 140px;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
    font-family: var(--font-sans);
    font-size: 0.9rem;
}
.preset-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.8rem;
    color: white;
    transition: 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}
.btn-load { background: var(--c-text-secondary); }
.btn-load:hover { background: var(--c-text-primary); }
.btn-save { background: var(--cat-bat); }
.btn-save:hover { opacity: 0.9; }
.btn-del { background: #ef4444; color: white; }
.btn-del:hover { opacity: 0.9; }
.preset-btn svg { width: 16px; height: 16px; stroke-width: 2.5; }

/* --- Advanced Settings Style --- */
.advanced-details {
    grid-column: 1 / -1;
    margin-top: 10px;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0,0,0,0.02);
}
.advanced-summary {
    padding: 12px 15px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--c-text-secondary);
    background: rgba(255,255,255,0.5);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.advanced-summary::before {
    content: ' '; /* 絵文字削除 */
    font-size: 1rem;
}
.advanced-summary:hover {
    background: var(--c-surface);
    color: var(--cat-bat);
}
.advanced-content {
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    border-top: 1px solid var(--c-border);
}
.advanced-details[open] .advanced-summary {
    border-bottom: 1px solid transparent;
}
.advanced-summary .icon-gear {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
    color: var(--c-text-secondary);
}
.advanced-summary:hover .icon-gear { color: var(--cat-bat); }


.warning-msg {
    grid-column: 1 / -1;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #b45309;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}
.warning-msg::before {
    content: '⚠️';
    font-size: 1.2rem;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.calc-result-area {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--c-border);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px;
}
.calc-res-label { font-size: 0.9rem; color: var(--c-text-secondary); font-weight: 600; }
.calc-res-label span { font-size: 0.7em; background: var(--ai-color); color: white; padding: 2px 6px; border-radius: 4px; margin-left: 5px; vertical-align: middle; }
.calc-res-value { font-size: 2.5rem; font-weight: 900; color: var(--cat-bat); font-family: var(--font-mono); line-height: 1; }
.calc-btn {
    background: var(--cat-bat);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.calc-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.calc-btn svg { width: 18px; height: 18px; stroke-width: 2.5; }

.criteria-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.criteria-table th { text-align: left; color: var(--c-text-secondary); width: 120px; padding: 12px 0; border-bottom: 1px solid var(--c-border); }
.criteria-table td { padding: 12px 0; border-bottom: 1px solid var(--c-border); color: var(--c-text-primary); font-weight: 600; }

.related-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.rel-chip {
    background: var(--c-bg);
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--c-text-secondary);
    cursor: pointer;
    border: 1px solid transparent;
    transition: 0.2s;
}
.rel-chip:hover { background: var(--c-text-primary); color: var(--c-surface); }

.no-result {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    color: var(--c-text-secondary);
}

/* --- Smart Parser Style --- */
.parser-area {
    margin-bottom: 20px;
    background: var(--c-surface);
    border: 1px dashed var(--cat-bat);
    padding: 15px;
    border-radius: 12px;
}
.parser-textarea {
    width: 100%;
    height: 120px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 15px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    box-sizing: border-box;
    resize: vertical;
    background: #f8fafc;
    transition: all 0.2s;
}
.parser-textarea:focus {
    background: #ffffff;
    border-color: var(--cat-bat);
    outline: none;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}
.parser-btn {
    background: var(--c-text-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    width: 100%;
    transition: all 0.3s;
    margin-top: 10px;
}
.parser-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.parser-btn.analyzing { background: var(--cat-bat); cursor: wait; animation: pulse 1.5s infinite; }
.parser-btn svg { width: 18px; height: 18px; stroke-width: 2.5; }

@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.6; } 100% { opacity: 1; } }

/* --- Chart Container --- */
.chart-wrapper {
    max-width: 400px;
    margin: 20px auto;
    position: relative;
}

/* Helper for formula formatting */
.var { color: #38bdf8; font-family: var(--font-sans); font-weight: 600; font-style: normal; margin: 0 2px; }

@media (max-width: 700px) {
    .brand { font-size: 2.5rem; }
    .m-title { font-size: 2.5rem; }
    .grid-container { grid-template-columns: 1fr; padding: 40px 1rem;}
    .modal-panel { width: 100%; height: 100%; border-radius: 0; }
    .search-wrapper { padding: 0 1rem; }
}

/* === New Career Mode Styles (v3.0 Power Pros Style) === */
#career-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #f8fafc; /* 背景色: 非常に薄い青グレー */
    z-index: 2000;
    visibility: hidden; opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto; color: #1e293b;
    display: flex; flex-direction: column;
}
#career-overlay.active { visibility: visible; opacity: 1; transform: translateY(0); }

.career-header {
    padding: 15px 30px;
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid #e2e8f0;
    position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.career-brand { font-size: 1.4rem; font-weight: 900; letter-spacing: -0.02em; color: #0f172a; display: flex; align-items: center; gap: 10px; }
.career-brand span { color: #3b82f6; background: #eff6ff; padding: 2px 8px; border-radius: 6px; font-size: 0.8em; }

.career-content {
    max-width: 1200px; margin: 0 auto; width: 100%; padding: 40px 20px;
    box-sizing: border-box; flex: 1;
}

.career-grid { display: grid; grid-template-columns: 380px 1fr; gap: 30px; align-items: start; }

/* パネルデザイン */
.career-panel { 
    background: #ffffff; 
    border-radius: 24px; 
    padding: 32px; 
    border: 1px solid #e2e8f0; 
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
}

.career-title { 
    font-size: 1.1rem; font-weight: 800; margin-bottom: 24px; 
    color: #1e293b; display: flex; align-items: center;
    letter-spacing: 0.05em; border-bottom: 2px solid #f1f5f9; padding-bottom: 10px;
}
.career-title svg { width: 20px; height: 20px; margin-right: 8px; color: #3b82f6; }

/* フォーム要素 */
.c-form-group { margin-bottom: 24px; }
.c-label { display: block; font-size: 0.85rem; font-weight: 700; color: #64748b; margin-bottom: 8px; }
.c-input, .c-select {
    width: 100%; padding: 12px; border-radius: 12px;
    border: 1px solid #cbd5e1; background: #f8fafc;
    color: #1e293b; font-weight: 600; font-size: 0.95rem;
    transition: 0.2s; box-sizing: border-box;
}
.c-input:focus, .c-select:focus { outline: none; border-color: #3b82f6; background: #fff; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }

/* 能力値スライダー（パワプロ風） */
.c-rank-bar {
    height: 6px; width: 100%; background: #e2e8f0; border-radius: 3px; position: relative; margin-top: 10px; margin-bottom: 25px;
}
.c-rank-fill {
    height: 100%; border-radius: 3px; background: linear-gradient(90deg, #3b82f6, #2563eb);
    width: 50%; transition: width 0.2s;
}
.c-rank-input {
    position: absolute; top: -8px; left: 0; width: 100%; height: 20px; opacity: 0; cursor: pointer;
}
.c-rank-label {
    display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; color: #475569;
}
/* ランク表示の色分け */
.rank-s { color: #eab308; } /* Gold */
.rank-a { color: #f97316; } /* Orange */
.rank-b { color: #ef4444; } /* Red */
.rank-c { color: #f43f5e; } /* Pink/Red */
.rank-d { color: #10b981; } /* Green */
.rank-e { color: #3b82f6; } /* Blue */
.rank-f { color: #64748b; } /* Slate */
.rank-g { color: #94a3b8; } /* Gray */

/* ロール切り替えタブ */
.role-tabs { display: flex; gap: 8px; margin-bottom: 24px; background: #f1f5f9; padding: 5px; border-radius: 12px; }
.role-tab { 
    flex: 1; padding: 10px; text-align: center; cursor: pointer; border-radius: 8px; 
    font-weight: 700; font-size: 0.9rem; color: #94a3b8; transition: all 0.2s; 
}
.role-tab.active { background: #ffffff; color: #3b82f6; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.role-tab:hover:not(.active) { color: #1e293b; }

/* 結果表示エリア */
.c-result-header {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); 
    gap: 15px; margin-bottom: 30px; padding: 20px; background: #f8fafc; border-radius: 16px;
}
.c-big-stat { text-align: center; }
.c-big-val { font-size: 1.8rem; font-weight: 900; color: #0f172a; line-height: 1; font-family: var(--font-mono); }
.c-big-lbl { font-size: 0.7rem; font-weight: 700; color: #64748b; margin-top: 5px; letter-spacing: 0.05em; }

/* 履歴テーブル（横スクロール対応） */
.c-history-wrap {
    background: #ffffff; border-radius: 16px; border: 1px solid #e2e8f0;
    max-height: 500px; overflow: auto; /* 縦横スクロール */
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
}
.c-table { width: 100%; min-width: 800px; border-collapse: collapse; font-size: 0.85rem; white-space: nowrap; }
.c-table th { 
    text-align: center; padding: 12px 8px; background: #f1f5f9; 
    color: #475569; font-weight: 700; position: sticky; top: 0; z-index: 10;
    border-bottom: 1px solid #cbd5e1;
}
.c-table td { text-align: center; padding: 10px 8px; border-bottom: 1px solid #f1f5f9; color: #334155; font-family: var(--font-mono); }
.c-table tr:hover { background: #f8fafc; }

/* WARなど強調 */
.val-outstanding { color: #d97706; font-weight: 800; background: #fffbeb; }
.val-great { color: #ea580c; font-weight: 800; }
.val-good { color: #16a34a; font-weight: 700; }

/* レスポンシブ */
@media (max-width: 900px) {
    .career-grid { grid-template-columns: 1fr; }
    .c-result-header { grid-template-columns: repeat(3, 1fr); }
}

/* --- Settings & Variables (Galaxy) --- */
:root {
    --g-node-size: 85px;
    --g-focus-size: 320px;
    --g-font-size: 0.85rem;
}
@media (max-width: 768px) {
    :root {
        --g-node-size: 65px;
        --g-focus-size: 280px;
        --g-font-size: 0.75rem;
    }
    .g-node {
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(30, 41, 59, 0.98) !important;
        border: 1px solid rgba(255,255,255,0.3) !important;
    }
    .g-node.is-focused {
        box-shadow: 0 0 40px rgba(0,0,0,0.5) !important;
    }
}

/* --- Space Environment --- */
#galaxy-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(ellipse at center, #1e293b 0%, #020617 100%);
    z-index: 9999;
    visibility: hidden; opacity: 0;
    transform: scale(1.1);
    transition: opacity 0.5s, transform 0.5s, visibility 0.5s;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
#galaxy-overlay.active { visibility: visible; opacity: 1; transform: scale(1); }
#galaxy-overlay:active { cursor: grabbing; }

#starfield-canvas {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 0;
}

#galaxy-universe {
    position: absolute; top: 50%; left: 50%; width: 0; height: 0;
    transform-style: preserve-3d;
}
#galaxy-universe.is-interacting { will-change: transform; }

#galaxy-cosmos {
    position: absolute; top: 0; left: 0; width: 0; height: 0;
    transform-style: preserve-3d;
}

.launching #galaxy-cosmos {
    animation: galaxyLaunch 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes galaxyLaunch {
    0% { transform: scale(0) rotate(45deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* --- Nodes --- */
.g-node {
    position: absolute;
    width: var(--g-node-size); height: var(--g-node-size);
    transform: translate(-50%, -50%) scale(0);
    border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; cursor: pointer;
    transition: width 0.4s cubic-bezier(0.19, 1, 0.22, 1), height 0.4s cubic-bezier(0.19, 1, 0.22, 1), transform 0.4s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.3s, filter 0.3s;
    box-shadow: 0 0 15px rgba(0,0,0,0.3), inset 0 0 10px rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.2);
    z-index: 10;
    background: rgba(30, 41, 59, 0.85);
    color: #94a3b8;
    font-weight: 700;
    font-size: var(--g-font-size);
    touch-action: none;
    animation: nodePop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-play-state: paused;
    transform-style: flat; 
}
@keyframes nodePop {
    from { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@media (hover: hover) {
    .g-node:hover {
        z-index: 50;
        border-color: white; color: white;
        box-shadow: 0 0 25px rgba(255,255,255,0.25);
        transform: translate(-50%, -50%) scale(1.15);
    }
}

.g-node.is-dimmed {
    opacity: 0.1 !important;
    transform: translate(-50%, -50%) scale(0.8) !important;
    pointer-events: none;
    filter: grayscale(100%);
}
.g-node.is-related {
    opacity: 1 !important;
    border-color: rgba(255,255,255,0.9);
    z-index: 40;
}
@media (min-width: 769px) { .g-node.is-related { box-shadow: 0 0 20px rgba(255,255,255,0.2); } }

.g-node.is-focused {
    width: var(--g-focus-size); height: var(--g-focus-size);
    z-index: 100;
    background: rgba(15, 23, 42, 0.98) !important;
    border: 2px solid rgba(255,255,255,0.6) !important;
    transform: translate(-50%, -50%) scale(1) !important;
    cursor: default;
    box-shadow: 0 0 60px rgba(0,0,0,0.6) !important;
}

.g-content-normal { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; transition: opacity 0.2s; }
.g-node.is-focused .g-content-normal { display: none; opacity: 0; }

.g-content-focus {
    display: none; opacity: 0; width: 100%; height: 100%;
    flex-direction: column; align-items: center; justify-content: center;
    padding: 25px; box-sizing: border-box;
}
.g-node.is-focused .g-content-focus { display: flex; opacity: 1; animation: fadeIn 0.4s ease 0.1s forwards; }

.gf-icon svg { width: 48px; height: 48px; margin-bottom: 10px; opacity: 1; }
.gf-title { font-size: 1.8rem; font-weight: 900; line-height: 1.1; margin-bottom: 5px; color: white; text-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.gf-full { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.8; margin-bottom: 12px; color: #cbd5e1; }
.gf-desc { font-size: 0.85rem; line-height: 1.5; color: #e2e8f0; margin-bottom: 15px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.gf-btn { 
    padding: 10px 24px; border-radius: 30px; border: 1px solid rgba(255,255,255,0.4); 
    background: rgba(255,255,255,0.15); color: white; cursor: pointer; 
    font-size: 0.9rem; font-weight: bold; pointer-events: auto; z-index: 200; position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.gf-btn:active { transform: scale(0.95); background: rgba(255,255,255,0.3); }

@media (max-width: 768px) { 
    .gf-title { font-size: 1.5rem; } 
    .gf-desc { font-size: 0.8rem; -webkit-line-clamp: 4; } 
    .gf-icon svg { width: 36px; height: 36px; }
}
.g-node .icon-normal svg { width: 28px; height: 28px; margin-bottom: 4px; opacity: 0.8; }

#galaxy-lines { position: absolute; top: -5000px; left: -5000px; width: 10000px; height: 10000px; pointer-events: none; z-index: 1; }
.g-line { stroke: rgba(255,255,255,0.15); stroke-width: 1.5; transition: opacity 0.3s; opacity: 0; shape-rendering: geometricPrecision; }
.active .g-line { animation: lineFadeIn 1s 0.5s forwards; }
@keyframes lineFadeIn { to { opacity: 1; } }
.g-line.is-dimmed { opacity: 0.02 !important; }
.g-line.is-related { stroke: rgba(255,255,255,0.6); stroke-width: 2.0; opacity: 1 !important; }

.g-cat-bat { border-color: rgba(14, 165, 233, 0.4); } .g-cat-bat.is-focused { border-color: #0ea5e9; } .g-cat-bat .icon-normal { color: #0ea5e9; }
.g-cat-pit { border-color: rgba(244, 63, 94, 0.4); } .g-cat-pit.is-focused { border-color: #f43f5e; } .g-cat-pit .icon-normal { color: #f43f5e; }
.g-cat-fld { border-color: rgba(217, 119, 6, 0.4); } .g-cat-fld.is-focused { border-color: #d97706; } .g-cat-fld .icon-normal { color: #d97706; }
.g-cat-tot { border-color: rgba(16, 185, 129, 0.4); } .g-cat-tot.is-focused { border-color: #10b981; } .g-cat-tot .icon-normal { color: #10b981; }

.galaxy-controls {
    position: absolute; 
    bottom: 30px; 
    left: 0; right: 0; margin: 0 auto; 
    width: max-content;
    display: flex; gap: 12px; z-index: 1000;
    padding: 8px 16px; border-radius: 40px;
    background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.15);
    opacity: 0; animation: fadeIn 1s 0.5s forwards;
}
.g-btn {
    background: transparent; border: none; color: rgba(255,255,255,0.8); padding: 0; border-radius: 50%; cursor: pointer;
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
}
.g-btn svg { width: 22px; height: 22px; stroke-width: 2; }
.g-btn.close { color: #f43f5e; }
@media (max-width: 768px) {
    .galaxy-controls {
        top: auto !important; bottom: 30px !important; right: auto !important;
        left: 50% !important; transform: translateX(-50%) !important;
        padding: 8px 16px; border-radius: 30px; width: max-content; max-width: 90%;
    }
}

/* === New Career Mode Styles === */
#career-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #f8fafc;
    z-index: 2000;
    visibility: hidden; opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto; color: #1e293b;
    display: flex; flex-direction: column;
}
#career-overlay.active { visibility: visible; opacity: 1; transform: translateY(0); }

.career-header {
    padding: 15px 30px;
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid #e2e8f0;
    position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.career-brand { font-size: 1.4rem; font-weight: 900; letter-spacing: -0.02em; color: #0f172a; display: flex; align-items: center; gap: 10px; }
.career-brand span { color: #3b82f6; background: #eff6ff; padding: 2px 8px; border-radius: 6px; font-size: 0.8em; }

.career-content {
    max-width: 1200px; margin: 0 auto; width: 100%; padding: 40px 20px;
    box-sizing: border-box; flex: 1;
}

.career-grid { display: grid; grid-template-columns: 380px 1fr; gap: 30px; align-items: start; }
.career-panel { 
    background: #ffffff; border-radius: 24px; padding: 32px; 
    border: 1px solid #e2e8f0; 
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
}
.career-title { 
    font-size: 1.1rem; font-weight: 800; margin-bottom: 24px; 
    color: #1e293b; display: flex; align-items: center;
    letter-spacing: 0.05em; border-bottom: 2px solid #f1f5f9; padding-bottom: 10px;
}
.career-title svg { width: 20px; height: 20px; margin-right: 8px; color: #3b82f6; }

.c-form-group { margin-bottom: 24px; }
.c-label { display: block; font-size: 0.85rem; font-weight: 700; color: #64748b; margin-bottom: 8px; }
.c-input, .c-select {
    width: 100%; padding: 12px; border-radius: 12px;
    border: 1px solid #cbd5e1; background: #f8fafc;
    color: #1e293b; font-weight: 600; font-size: 0.95rem;
    transition: 0.2s; box-sizing: border-box;
}
.c-input:focus, .c-select:focus { outline: none; border-color: #3b82f6; background: #fff; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }

.c-rank-bar {
    height: 6px; width: 100%; background: #e2e8f0; border-radius: 3px; position: relative; margin-top: 10px; margin-bottom: 25px;
}
.c-rank-fill {
    height: 100%; border-radius: 3px; background: linear-gradient(90deg, #3b82f6, #2563eb);
    width: 50%; transition: width 0.2s;
}
.c-rank-input {
    position: absolute; top: -8px; left: 0; width: 100%; height: 20px; opacity: 0; cursor: pointer;
}
.c-rank-label {
    display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 700; color: #475569;
}
.rank-s { color: #eab308; } .rank-a { color: #f97316; } .rank-b { color: #ef4444; }
.rank-c { color: #f43f5e; } .rank-d { color: #10b981; } .rank-e { color: #3b82f6; }
.rank-f { color: #64748b; } .rank-g { color: #94a3b8; }

.role-tabs { display: flex; gap: 8px; margin-bottom: 24px; background: #f1f5f9; padding: 5px; border-radius: 12px; }
.role-tab { 
    flex: 1; padding: 10px; text-align: center; cursor: pointer; border-radius: 8px; 
    font-weight: 700; font-size: 0.9rem; color: #94a3b8; transition: all 0.2s; 
}
.role-tab.active { background: #ffffff; color: #3b82f6; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.role-tab:hover:not(.active) { color: #1e293b; }

.c-result-header {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); 
    gap: 15px; margin-bottom: 30px; padding: 20px; background: #f8fafc; border-radius: 16px;
}
.c-big-stat { text-align: center; }
.c-big-val { font-size: 1.8rem; font-weight: 900; color: #0f172a; line-height: 1; font-family: var(--font-mono); }
.c-big-lbl { font-size: 0.7rem; font-weight: 700; color: #64748b; margin-top: 5px; letter-spacing: 0.05em; }

.c-history-wrap {
    background: #ffffff; border-radius: 16px; border: 1px solid #e2e8f0;
    max-height: 500px; overflow: auto; 
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
}
.c-table { width: 100%; min-width: 800px; border-collapse: collapse; font-size: 0.85rem; white-space: nowrap; }
.c-table th { 
    text-align: center; padding: 12px 8px; background: #f1f5f9; 
    color: #475569; font-weight: 700; position: sticky; top: 0; z-index: 10;
    border-bottom: 1px solid #cbd5e1;
}
.c-table td { text-align: center; padding: 10px 8px; border-bottom: 1px solid #f1f5f9; color: #334155; font-family: var(--font-mono); }
.c-table tr:hover { background: #f8fafc; }

.val-outstanding { color: #d97706; font-weight: 800; background: #fffbeb; }
.val-great { color: #ea580c; font-weight: 800; }
.val-good { color: #16a34a; font-weight: 700; }

@media (max-width: 900px) {
    .career-grid { grid-template-columns: 1fr; }
    .c-result-header { grid-template-columns: repeat(3, 1fr); }
}
/* --- タブナビゲーション --- */
.tab-nav-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    /* padding-top を 0 -> 15px に変更してボタンを下げる */
    padding: 15px 20px 20px;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-bg);
    /* position: sticky; を削除してスクロールで流れるようにする */
    position: relative; 
    z-index: 100;
}

.tab-btn {
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: 30px;
    cursor: pointer;
    color: var(--c-text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--c-text-primary);
}

.tab-btn.active {
    background: var(--c-text-primary);
    color: var(--c-bg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.dark-mode .tab-btn:hover { background: rgba(255,255,255,0.1); }

/* --- 成績表エリア --- */
.stats-wrapper {
    max-width: 1600px;
    margin: 30px auto;
    padding: 0 20px;
}

/* コントロールパネル */
.stats-controls {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-card);
}

.control-group {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* 検索ボックス */
.search-box {
    position: relative;
}
.search-icon-small {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    font-size: 0.9rem;
}
.stats-controls input[type="text"] {
    padding: 10px 10px 10px 32px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
    background: var(--c-bg);
    color: var(--c-text-primary);
    width: 240px;
}

.stats-controls select {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
    background: var(--c-bg);
    color: var(--c-text-primary);
    cursor: pointer;
}

/* トグルスイッチ風チェックボックス */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--c-text-primary);
}
.toggle-label input {
    width: 18px;
    height: 18px;
    accent-color: var(--cat-bat);
}

.pa-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--c-text-secondary);
}
.pa-input-group input {
    width: 60px;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--c-border);
    background: var(--c-bg);
    color: var(--c-text-primary);
    text-align: center;
}

/* テーブル */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--c-border);
    background: var(--c-bg);
    box-shadow: var(--shadow-card);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
    font-size: 0.9rem;
}

.leaderboard-table th {
    background: var(--c-card);
    padding: 14px;
    text-align: center;
    font-weight: 700;
    color: var(--c-text-secondary);
    border-bottom: 2px solid var(--c-border);
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
}
.leaderboard-table th:hover {
    background: var(--c-border);
    color: var(--c-text-primary);
}

.leaderboard-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-border);
    text-align: right;
    color: var(--c-text-primary);
    font-variant-numeric: tabular-nums; /* 数字の幅を揃える */
}

/* 固定列 (チーム・名前) */
.leaderboard-table td:nth-child(1),
.leaderboard-table td:nth-child(2) {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--c-bg);
    z-index: 5;
}
.leaderboard-table td:nth-child(2) { left: 70px; border-right: 1px solid var(--c-border); } /* 境界線 */

.leaderboard-table tr:hover td { background: rgba(0,0,0,0.03); }
.dark-mode .leaderboard-table tr:hover td { background: rgba(255,255,255,0.05); }

/* 数値の色分け */
.val-elite { color: #f43f5e; font-weight: 800; } /* ピンク */
.val-great { color: #f97316; font-weight: 700; } /* オレンジ */
.val-good { color: #0ea5e9; font-weight: 700; }  /* 青 */
.val-bad { color: var(--c-text-secondary); opacity: 0.6; }

.stats-footer {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--c-text-secondary);
    text-align: right;
}
/* Tab Icons */
.tab-icon {
    margin-right: 6px;
    vertical-align: text-bottom;
    opacity: 0.8;
}
.tab-btn.active .tab-icon {
    opacity: 1;
}

/* Search Icon in Stats */
.search-icon-small {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--c-text-secondary);
    pointer-events: none;
}

/* Table Sort Icons */
.leaderboard-table th svg {
    display: inline-block;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.6;
}
