﻿:root {
            --primary: #4f8ef7; --success: #28a745; --danger: #e63946; --warning: #ffc107;
            --draw: #8e44ad; --avoid: #fd7e14; --dark: #1e2230; --gray: #6c757d;
            --student-bg: #ffffff; --adult-bg: #e9ecef;
            --bg-waiting: #e8f5e9; --bg-playing: #ffebee; --bg-resting: #f8f9fa;
            --final-gold: #f5a623; --card-radius: 18px;
        }
        * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
            margin: 0; padding: 0; background-color: #eef1f7; color: var(--dark);
            padding-bottom: 120px; font-size: 18px;
        }
        .container { padding: 15px; max-width: 850px; margin: 0 auto; }
        .card { background: white; border-radius: var(--card-radius); padding: 20px; margin-bottom: 15px; box-shadow: 0 2px 16px rgba(0,0,0,0.08); }
        .view-section { display: none; }
        .view-section.active { display: block; }

        /* ページタイトル */
        .page-title { text-align:center; font-size: 22px; font-weight: 900; margin: 12px 0 16px; letter-spacing: 0.5px; }

        /* ボタン系 */
        .btn { display: inline-block; padding: 16px; border-radius: 14px; border: none; font-size: 19px; font-weight: bold; text-align: center; cursor: pointer; width: 100%; margin-bottom: 10px; transition: 0.15s; text-decoration: none; user-select: none; }
        .btn:active { opacity: 0.7; transform: scale(0.96); }
        .btn-primary { background: var(--primary); color: white; }
        .btn-success { background: var(--success); color: white; }
        .btn-danger { background: var(--danger); color: white; }
        .btn-dark { background: var(--dark); color: white; }
        .btn-draw { background: var(--draw); color: white; }
        .btn-outline { background: transparent; border: 2px solid var(--gray); color: var(--gray); }

        /* 案内案カード */
        .proposal-group { background: var(--dark); padding: 18px; border-radius: 20px; margin-bottom: 22px; border: 3px solid var(--primary); }
        .match-card { background: white; color: var(--dark); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 3px 8px rgba(0,0,0,0.15); }
        .match-card.is-final { background: linear-gradient(135deg, #fff8e1, #fff3cd); border: 3px solid var(--final-gold); animation: pulse-gold 1.5s infinite; }
        @keyframes pulse-gold { 0%,100%{box-shadow:0 0 0 0 rgba(245,166,35,0.4)} 50%{box-shadow:0 0 0 8px rgba(245,166,35,0)} }
        .match-info { flex: 1; font-size: 22px; font-weight: 900; line-height: 1.3; }
        .match-wins-sub { font-size: 13px; color: var(--success); font-weight: bold; }
        .vs-label { color: var(--danger); font-size: 16px; margin: 0 8px; }
        .table-badge { background: var(--primary); color: white; border-radius: 10px; min-width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; margin-right: 12px; font-size: 15px; font-weight: bold; flex-shrink: 0; padding: 0 8px; }
        .final-badge { background: var(--final-gold); color: #333; border-radius: 8px; padding: 4px 10px; font-size: 12px; font-weight: 900; display: inline-block; margin-bottom: 6px; letter-spacing: 1px; }

        /* 回避ラベル */
        .avoid-label { font-size: 11px; font-weight: bold; padding: 3px 8px; border-radius: 4px; display: inline-block; color: white; margin-top: 4px; background: var(--avoid); }

        /* カウントダウンバナー */
        .countdown-banner { background: linear-gradient(135deg, #1e2230, #2c3e50); color: white; border-radius: 16px; padding: 16px 20px; margin-bottom: 18px; text-align: center; border: 2px solid var(--final-gold); }
        .countdown-number { font-size: 48px; font-weight: 900; color: var(--final-gold); line-height: 1; }
        .countdown-label { font-size: 13px; color: #aaa; margin-top: 4px; }

        /* リスト */
        .list-header { margin: 24px 0 10px 10px; font-size: 18px; color: var(--gray); font-weight: bold; }
        .p-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid #eee; }
        .p-item:last-child { border-bottom: none; }
        .p-item.is-adult { background-color: var(--adult-bg); }
        .p-item.selected { background-color: #fff3cd !important; outline: 3px solid var(--warning); z-index: 10; border-radius: 10px; }
        .p-warn-text { font-size: 11px; font-weight: bold; color: var(--danger); display: block; }
        .family-label { color: var(--primary); font-weight: bold; margin-left: 8px; font-size: 0.85em; }

        /* タグボタン */
        .tag-selector { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 22px; }
        .tag-opt { height: 52px; display: flex; align-items: center; justify-content: center; border: 1px solid #ddd; border-radius: 10px; background: white; font-weight: bold; font-size: 20px; cursor: pointer; }
        .tag-opt.active { border-color: var(--primary); background: var(--primary); color: white; box-shadow: 0 0 10px rgba(79,142,247,0.4); }

        .bottom-nav { position: fixed; bottom: 0; width: 100%; background: white; display: flex; justify-content: space-around; padding: 10px 0; box-shadow: 0 -4px 20px rgba(0,0,0,0.1); z-index: 100; border-top-left-radius: 20px; border-top-right-radius: 20px; }
        .nav-item { text-align: center; font-size: 13px; color: var(--gray); text-decoration: none; flex: 1; }
        .nav-item i { display: block; font-size: 26px; margin-bottom: 4px; font-style: normal; }
        .nav-item.active { color: var(--primary); font-weight: bold; }

        .overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: white; z-index: 2000; display: none; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 20px; }
        .rank-table { width: 100%; border-collapse: collapse; }
        .rank-table th { background: #f4f6fb; font-size: 14px; color: #888; padding: 10px 5px; }
        .rank-table td { padding: 12px 5px; border-bottom: 1px solid #eee; text-align: center; font-size: 16px; }
        .rank-table tr:first-child td { color: var(--final-gold); font-weight: 900; font-size: 18px; }
        .row-adult-rank { background-color: #f2f2f2; color: #999; }
        .row-rank-1 td { background: linear-gradient(90deg, #fffbe6, #fff); }
        .points-badge { background: var(--primary); color: white; border-radius: 20px; padding: 2px 10px; font-size: 14px; font-weight: bold; }

        .status-btn { padding: 10px 14px; font-size: 13px; border-radius: 10px; border: 1px solid #ccc; font-weight: bold; cursor: pointer; background: #f8f9fa; text-align: center; }
        .rest-toggle { background: #eee; color: #888; border: 1px solid #ddd; padding: 10px; font-size: 14px; border-radius: 8px; font-weight: bold; cursor: pointer; margin-top: 5px; width: 100%; display: block; }
        .rest-toggle.active { background: var(--warning) !important; color: black !important; border-color: orange !important; }

        /* 決勝オーバーレイ */
        .final-overlay { background: linear-gradient(160deg, #1e2230, #2c3e50); color: white; }
        .final-overlay .call-name { font-size: 52px; font-weight: 900; line-height: 1.1; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
        .final-overlay .call-vs { font-size: 40px; color: var(--final-gold); font-weight: 900; margin: 10px 0; }
        .final-title-text { font-size: 20px; font-weight: bold; color: var(--final-gold); letter-spacing: 2px; margin-bottom: 20px; }
        /* リーグバッジ */

        /* Refined tournament skin */
        :root {
            --primary: #0b766d;
            --success: #16885c;
            --danger: #c8463f;
            --warning: #d9b45c;
            --draw: #6d5b92;
            --avoid: #c76b3c;
            --dark: #152126;
            --gray: #66716f;
            --student-bg: #fffdf7;
            --adult-bg: #edf2ef;
            --bg-waiting: #e8f4ee;
            --bg-playing: #fbebe8;
            --bg-resting: #f3f6f4;
            --final-gold: #d9b45c;
            --card-radius: 8px;
            --surface: #fffdf7;
            --surface-muted: #f4f7f4;
            --line-soft: #dbe6e1;
            --table-green: #08674f;
            --table-green-dark: #064f40;
            --table-line: #a9d2c6;
        }

        body {
            background: linear-gradient(180deg, #eef6f3 0%, #e6efeb 48%, #dce7e2 100%);
            color: var(--dark);
            letter-spacing: 0;
        }

        .container {
            padding: 14px;
            max-width: 900px;
        }

        .card {
            background: var(--surface);
            border: 1px solid rgba(8, 103, 79, 0.12);
            border-radius: var(--card-radius);
            box-shadow: 0 10px 28px rgba(21, 33, 38, 0.07);
        }

        .page-title {
            text-align: left;
            font-size: 21px;
            letter-spacing: 0;
            color: var(--dark);
        }

        .list-header {
            color: #37514b;
            font-size: 15px;
            letter-spacing: 0;
            margin-left: 4px;
        }

        .btn {
            border-radius: 8px;
            font-weight: 800;
            letter-spacing: 0;
            box-shadow: 0 6px 14px rgba(21, 33, 38, 0.08);
        }

        .btn-primary,
        .btn-success,
        .btn-dark,
        .btn-danger,
        .btn-draw {
            border: 1px solid rgba(255,255,255,0.2);
        }

        .btn-primary { background: var(--primary); }
        .btn-success { background: var(--success); }
        .btn-dark { background: var(--dark); }
        .btn-outline {
            background: rgba(255,255,255,0.72);
            border: 1px solid var(--line-soft);
            color: #52615d;
            box-shadow: none;
        }

        input,
        select,
        textarea {
            background: #ffffff;
            border-color: var(--line-soft) !important;
            border-radius: 8px !important;
            color: var(--dark);
        }

        input:focus,
        select:focus,
        textarea:focus {
            outline: 3px solid rgba(11, 118, 109, 0.16);
            border-color: var(--primary) !important;
        }

        .tag-opt,
        .status-btn,
        .rest-toggle {
            border-radius: 8px;
        }

        .tag-opt.active {
            background: var(--primary);
            border-color: var(--primary);
            box-shadow: 0 8px 18px rgba(11, 118, 109, 0.22);
        }

        .proposal-group {
            background: var(--dark);
            border: 1px solid rgba(217, 180, 92, 0.45);
            border-radius: 8px;
            box-shadow: 0 12px 26px rgba(21, 33, 38, 0.16);
        }

        .match-card {
            border-radius: 8px;
            border: 1px solid rgba(255,255,255,0.16);
            box-shadow: 0 6px 16px rgba(0,0,0,0.14);
        }

        .table-badge {
            background: #0d8a7a;
            border-radius: 6px;
        }

        .countdown-banner {
            background: #122a2b;
            border: 1px solid rgba(217, 180, 92, 0.56);
            border-radius: 8px;
            box-shadow: 0 10px 24px rgba(21, 33, 38, 0.16);
        }

        .bottom-nav {
            background: rgba(255, 253, 247, 0.96);
            border-top: 1px solid rgba(8, 103, 79, 0.16);
            border-top-left-radius: 0;
            border-top-right-radius: 0;
            box-shadow: 0 -6px 20px rgba(21, 33, 38, 0.08);
            backdrop-filter: blur(12px);
        }

        .nav-item.active {
            color: var(--primary);
        }

        .rank-card {
            border: 0;
            background: var(--table-green);
            box-shadow: 0 12px 30px rgba(8, 103, 79, 0.20);
        }

        .rank-table {
            border-collapse: collapse;
            background: var(--table-green);
            color: #f6fffb;
            min-width: 560px;
        }

        .rank-table th {
            background: var(--table-green-dark);
            color: #f6fffb;
            border: 1px solid var(--table-line);
            padding: 10px 8px;
            font-size: 13px;
            font-weight: 800;
            white-space: nowrap;
        }

        .rank-table th:first-child {
            color: #f3d86a;
        }

        .rank-table td {
            background: var(--table-green);
            color: #f6fffb;
            border: 1px solid var(--table-line);
            padding: 10px 8px;
            font-size: 15px;
        }

        .rank-table td:nth-child(2) {
            text-align: left;
            font-weight: 800;
        }

        .rank-table tr:first-child td,
        .rank-table .row-rank-1 td {
            background: var(--table-green);
            color: #f6fffb;
            font-weight: 900;
            font-size: 16px;
        }

        .rank-table a,
        .rank-table b[onclick] {
            color: #f6fffb !important;
            text-decoration-color: rgba(246, 255, 251, 0.72) !important;
        }

        .rank-table .row-adult-rank td {
            background: #3f665d;
            color: #d5e3df;
        }

        .points-badge {
            background: #e6f1ec;
            color: var(--table-green-dark);
            border-radius: 999px;
            padding: 3px 10px;
        }

        #home-stats {
            background: #f8faf7;
            border-left: 5px solid var(--primary);
        }

        .p-item {
            border-bottom-color: var(--line-soft);
        }

        .p-item.selected {
            background-color: #f4e7ba !important;
            outline: 2px solid var(--warning);
        }

        @media (max-width: 520px) {
            body { font-size: 16px; }
            .container { padding: 12px; }
            .card { padding: 16px; }
            .btn { font-size: 16px; padding: 13px; }
            .match-info { font-size: 19px; }
            .rank-table th,
            .rank-table td {
                padding: 9px 6px;
                font-size: 14px;
            }
            .nav-item { font-size: 12px; }
            .nav-item i { font-size: 22px; }
        }

/* iPhone/PWA comfort tweaks */
html { min-height: 100%; }
body {
    min-height: 100%;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
}
button, .btn, .nav-item, input, select, textarea {
    touch-action: manipulation;
}
input, select, textarea {
    font-size: 16px;
}
.bottom-nav {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
@media (max-width: 560px) {
    body { font-size: 17px; padding-bottom: 132px; }
    .container { padding: 12px; }
    .card { padding: 16px; }
    .btn { min-height: 54px; font-size: 18px; }
    .match-info { font-size: 19px; }
    .tag-selector { grid-template-columns: repeat(3, 1fr); }
    .tag-opt { height: 56px; }
    .rank-table td, .rank-table th { font-size: 14px; }
}

