/* ---
Color Palette (Yorozul Brand Colors)
Primary: #16a085 (Dark Mint), #1abc9c (Bright Mint), #e8f8f5 (Light Mint)
Neutral: #2c3e50 (Dark Blue), #34495e (Slate Blue), #333 (Dark Gray), #555 (Mid Gray), #7f8c8d (Light Gray), #ddd (Border Gray), #f8f9fa (Off White), #fff (White)
Semantic: #e74c3c (Red), #3498db (Blue), #95a5a6 (Ash Gray)
--- */

/* General Body and Container */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
    color: #333;
    display: flex;
    flex-direction: column; 
    align-items: center; 
    min-height: 100vh;
    margin: 0;
    padding: 0; 
}

/* Page Header Style */
.site-header {
    width: 100%;
    background-color: #ffffff;
    color: #333333; 
    padding-top: 15px;
    padding-bottom: 15px; 
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); 
    position: sticky;
    top: 0;
    z-index: 100; 
}
.header-content {
    width: 95%;
    max-width: 900px; 
    margin: 0 auto;
}
.site-header h1 {
    margin: 0;
    font-size: 1.8em;
    color: #1abc9c; 
}
.site-header .subtitle {
    color: #7f8c8d; /* ライトグレー */
    margin: 0;
    font-size: 1em;
}


/* Main Container Style */
.container {
    background-color: #fff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 95%;
    max-width: 900px; 
    margin: 0 auto 20px auto; 
}


/* Page Footer Style */
.page-footer {
    width: 100%;
    background-color: #34495e; /* スレートブルー */
    color: #ddd;
    padding: 40px 0 20px 0; /* パディング調整 */
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
    margin-top: auto; 
}

.footer-content {
    max-width: 900px; 
    width: 95%;
    margin: 0 auto; 
    padding: 0 10px;
}

/* Footer Link Section Layout */
.footer-links-row {
    display: flex;
    flex-wrap: wrap;
    gap: 40px; /* 横並び時の間隔 */
    margin-bottom: 30px;
}

.footer-section {
    flex: 0 1 auto; /* コンテンツ幅に合わせる */
    min-width: 150px;
}

.footer-section .section-title {
    font-size: 1.1em;
    font-weight: bold;
    color: #1abc9c; 
    margin-bottom: 15px;
    margin-top: 0;
}
.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.footer-section li {
    margin-bottom: 8px;
}
.footer-section li a {
    color: #ccc;
    text-decoration: none;
    font-size: 0.95em;
    transition: color 0.3s;
}
.footer-section li a:hover {
    color: #fff;
    text-decoration: underline;
}

/* Disclaimer Text (Old style - used if needed, but mainly for usage notice now) */
.disclaimer-text {
    font-size: 0.75em;
    color: #95a5a6; 
    margin: 5px 0 0 0;
    line-height: 1.6; 
}

.copyright {
    text-align: center;
    font-size: 0.8em;
    color: #95a5a6;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #556c80;
}


/* --- Breadcrumbs (パンくずリスト) --- */
.breadcrumbs {
    font-size: 0.95em; 
    color: #7f8c8d; 
    margin-bottom: 25px; /* 下のマージンを少し広げる */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee; /* 区切り線を追加してカード上部であることを強調 */
}
.breadcrumbs a {
    color: #7f8c8d; 
    text-decoration: none;
    font-weight: normal;
}
.breadcrumbs a:hover {
    text-decoration: underline;
    color: #555; 
}
.breadcrumbs span.separator {
    color: #7f8c8d;
    font-size: 0.9em;
}
.breadcrumbs .current-page {
    color: #7f8c8d;
    font-weight: normal;
}


/* --- Usage Notice (ご利用上の注意) --- */
.usage-notice {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}
.usage-notice h3 {
    font-size: 1.1em;
    color: #34495e;
    margin-bottom: 10px;
    padding-left: 0;
    border-left: none; /* デフォルトのボーダーを消す */
}
.usage-notice ul {
    list-style-type: disc;
    padding-left: 20px;
    color: #555;
    font-size: 0.9em;
}
.usage-notice li {
    margin-bottom: 5px;
    line-height: 1.5;
}


/* --- (以降、既存スタイル) --- */

h2 { 
    font-size: 1.5em; 
    color: #34495e; 
    border-left: 5px solid #16a085; 
    padding-left: 10px; 
    margin: 20px 0 15px; 
}
h3.teams-title {
    font-size: 1.2em;
    color: #34495e;
    margin-top: 25px;
    margin-bottom: 10px;
    padding-left: 5px;
    border-left: 3px solid #1abc9c;
}
.notice { font-size: 0.9em; color: #7f8c8d; margin-top: 5px; margin-bottom: 10px; }
.hidden { display: none !important; }

/* Controls (設定エリア) */
.controls-wrapper { 
    background-color: #f8f9fa; 
    padding: 20px; 
    border-radius: 8px; 
    margin-bottom: 30px; 
}
.control-group {
    margin-bottom: 20px;
}
.control-group label {
    font-weight: bold;
    color: #555;
    display: block;
    margin-bottom: 5px;
}
.control-group input[type="text"],
.control-group input[type="number"] {
    padding: 10px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 100%;
    box-sizing: border-box;
}
.control-group input[type="number"] {
    max-width: 150px;
}
.control-group input:disabled,
input:disabled {
    background-color: #f4f4f4;
    color: #95a5a6;
    cursor: not-allowed;
}


/* Radio Buttons */
.radio-group label {
    font-weight: normal;
    display: block;
    margin: 5px 0;
}
.radio-group input[type="radio"] {
    margin-right: 8px;
}

/* Points Group (勝ち点) */
.points-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.points-group div {
    display: flex;
    flex-direction: column;
}
.points-group label {
    font-size: 0.9em;
    font-weight: normal;
    color: #555;
}
.points-group input[type="number"] {
    max-width: 80px;
    padding: 8px;
}

/* Priority List (順位優先) */
.priority-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    max-width: 300px;
}
.priority-list li {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    background-color: #fff;
    cursor: move; 
    user-select: none;
}
.priority-list li:last-child {
    border-bottom: none;
}
.priority-list li.dragging {
    opacity: 0.5;
    background: #e8f8f5;
}


/* Team Inputs (チーム名入力) */
#team-inputs-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}
.team-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.team-input-group label { /* チーム番号 */
    font-weight: bold;
    color: #7f8c8d;
    min-width: 20px;
}
.team-input-group input[type="text"] {
    flex-grow: 1;
}

/* Buttons */
.button-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 25px;
}
.main-btn, .sub-btn, .card-link-btn {
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s;
    text-align: center;
    box-sizing: border-box;
}
.main-btn { 
    background-color: #1abc9c; 
    color: #fff; 
    flex-grow: 1;
}
.main-btn:hover { background-color: #16a085; }

.sub-btn { 
    background-color: #7f8c8d; 
    color: #fff; 
}
.sub-btn:hover { background-color: #555; }

.main-btn:disabled, .sub-btn:disabled {
    background-color: #95a5a6 !important;
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}


.print-btn {
    background-color: #3498db;
    margin-bottom: 10px;
}
.print-btn:hover {
    background-color: #2980b9;
}

/* Result Area */
.result-container {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 2px solid #16a085;
}
.initial-message {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 30px;
    background-color: #f8f9fa;
    border-radius: 8px;
}
.bracket-wrapper, .league-wrapper {
    overflow-x: visible; 
    padding: 10px;
    background-color: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 8px;
}


/* Index Page: Card Layout */
.card-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}
.selection-card {
    display: block;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-left: 5px solid #1abc9c;
    border-radius: 8px;
    padding: 20px;
    text-decoration: none;
    color: #333;
    transition: box-shadow 0.3s, transform 0.3s;
}
.selection-card:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}
.selection-card h3 {
    color: #16a085;
    margin-top: 0;
}
.selection-card p {
    color: #555;
    font-size: 0.95em;
}
.card-link-btn {
    display: inline-block;
    background-color: #34495e;
    color: #fff;
    padding: 8px 15px;
    font-size: 0.9em;
    margin-top: 10px;
}
.selection-card:hover .card-link-btn {
    background-color: #2c3e50;
}


/* --- Tournament Bracket Styles --- */
.bracket-main-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
}
.bracket-tournament {
    display: flex;
    gap: 10px; /* ラウンド間の隙間 */
}

.bracket-group-title {
    font-size: 1.3em;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 2px solid #eee;
}
.bracket-winners-container,
.bracket-losers-container {
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
}
.bracket-winners-container {
    background-color: #fff;
    border: 1px solid #1abc9c;
}
.bracket-losers-container {
    background-color: #f8f9fa;
    border: 1px solid #95a5a6;
}


.bracket-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around; /* マッチを均等配置 */
    flex-shrink: 0;
    width: 200px; /* マッチボックスの幅 */
}
.round-title {
    text-align: center;
    color: #34495e;
    font-size: 1em;
    font-weight: bold;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #1abc9c;
}
.bracket-match {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 10px; /* マッチ間の最小マージン */
    position: relative; /* 線の描画基準 */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.bracket-team {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.3s;
}
.bracket-team:last-child {
    border-bottom: none;
}
.bracket-team.winner {
    background-color: #e8f8f5; /* Light Mint */
}
.bracket-team.winner .team-name {
    font-weight: bold;
    color: #16a085;
}
.bracket-team.loser {
    background-color: #fdfdfd;
}
.bracket-team.loser .team-name {
    color: #95a5a6;
    text-decoration: line-through;
}

.team-name {
    font-size: 0.95em;
    color: #333;
}
.team-score {
    width: 40px;
    padding: 4px;
    font-size: 1em;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 3px;
    -moz-appearance: textfield; /* スピナー非表示 (Firefox) */
}
.team-score::-webkit-outer-spin-button,
.team-score::-webkit-inner-spin-button {
    -webkit-appearance: none; /* スピナー非表示 (Chrome, Safari) */
    margin: 0;
}
.set-winner-btn {
    font-size: 0.8em;
    padding: 5px;
    width: 100%;
    margin-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}
.bracket-grand-final .bracket-match[data-match-id="grand-final"] .set-winner-btn,
.bracket-grand-final .bracket-match[data-match-id="grand-final-reset"] .set-winner-btn {
    background-color: #e74c3c; /* Red */
}
.bracket-grand-final .bracket-match[data-match-id="grand-final"] .set-winner-btn:hover,
.bracket-grand-final .bracket-match[data-match-id="grand-final-reset"] .set-winner-btn:hover {
    background-color: #c0392b;
}


/* --- 接続線 (簡易版) --- */
.bracket-round:not(:first-child) .bracket-match {
    margin-left: 20px; /* 線のためのスペース */
}
.bracket-round:not(:first-child) .bracket-match::before {
    content: '';
    position: absolute;
    left: -20px; /* マッチボックスの外側へ */
    top: 50%;
    width: 20px;
    height: 2px;
    background-color: #95a5a6;
}

/* 3位決定戦 / グランドファイナル */
.bracket-bronze-match,
.bracket-grand-final {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px dashed #16a085;
}
.bracket-bronze-match .bracket-match,
.bracket-grand-final .bracket-match {
    width: 250px; /* 決勝は少し幅広に */
}

/* --- League Table Styles --- */
.league-wrapper-inner {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 1. 星取表 (Matrix) */
.league-matrix-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 600px; /* 横スクロールを促す最小幅 */
    font-size: 0.9em;
}
.league-matrix-table th,
.league-matrix-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
    min-width: 100px;
}
.league-matrix-table th {
    background-color: #f8f9fa;
    color: #34495e;
    font-weight: bold;
}
.league-matrix-table tbody th { /* 縦列のチーム名 */
    text-align: left;
    background-color: #f8f9fa;
}

.match-self {
    background-color: #f4f4f4;
    color: #95a5a6;
}
.match-mirror {
    background-color: #fdfdfd;
    color: #7f8c8d;
    font-size: 0.9em;
}
.score-input-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.score-input-wrapper input {
    width: 40px;
    padding: 5px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 3px;
    -moz-appearance: textfield;
}
.score-input-wrapper input::-webkit-outer-spin-button,
.score-input-wrapper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 2. 順位表 (Standings) */
.standings-title {
    font-size: 1.3em;
    color: #34495e;
    border-bottom: 2px solid #1abc9c;
    padding-bottom: 5px;
    margin-bottom: 15px;
}
.league-standings-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.95em;
}
.league-standings-table th,
.league-standings-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
}
.league-standings-table th {
    background-color: #34495e;
    color: #fff;
    font-weight: bold;
}
.league-standings-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}
.league-standings-table td:nth-child(2) { /* チーム名 */
    text-align: left;
    font-weight: bold;
}
.league-standings-table td:last-child { /* 勝ち点 */
    font-weight: bold;
    color: #16a085;
}

/* --- Mobile Restriction Styles (新規追加) --- */
.mobile-restriction-message {
    display: none; /* デフォルト非表示 (PC) */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    background-color: #f8f9fa;
    border: 1px solid #e74c3c; /* Red border */
    border-radius: 8px;
    margin-top: 30px;
}

.mobile-restriction-message h3 {
    color: #e74c3c; /* Red */
    font-size: 1.4em;
    margin-bottom: 15px;
}

.mobile-restriction-message p {
    color: #555;
    margin-bottom: 20px;
}

.mobile-restriction-message .pc-icon {
    font-size: 3em;
    margin-bottom: 10px;
    color: #34495e;
}


/* Responsive */
@media (min-width: 600px) {
    /* トップページのカードを2カラムに */
    .card-layout {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .container { padding: 15px; }
    .footer-content { width: 100%; padding: 0 15px; } 
    .button-row { flex-direction: column; }
    .print-btn { float: none; width: 100%; margin-bottom: 15px; }
    
    /* Footerの横並びを解除 */
    .footer-links-row { gap: 20px; }
    
    /* チーム入力欄を1カラムに */
    #team-inputs-container {
        grid-template-columns: 1fr;
    }

    .league-matrix-table {
        font-size: 0.8em; /* モバイルでは文字を小さく */
    }
    .league-matrix-table th,
    .league-matrix-table td {
        padding: 5px;
        min-width: 70px;
    }
    .score-input-wrapper input {
        width: 30px;
    }
    .league-standings-table {
        font-size: 0.85em;
    }
    .league-standings-table th,
    .league-standings-table td {
        padding: 6px;
    }

    /* ▼▼▼ モバイル制限の適用 (新規追加) ▼▼▼ */
    /* ツール固有のクラスを持つ要素を非表示にする */
    .pc-only-tool {
        display: none !important;
    }

    /* 警告メッセージを表示 */
    .mobile-restriction-message {
        display: flex !important;
    }
}

/* Print Styles (印刷用) */
@media print {
    .site-header, 
    .page-footer {
        display: none !important;
    }

    body {
        background-color: #fff;
        padding: 0;
    }
    .container {
        width: 100%;
        max-width: 100%;
        padding: 0;
        box-shadow: none;
        margin: 0; 
    }
    /* 印刷時に不要な要素を非表示 */
    header, 
    nav.breadcrumbs,
    .usage-notice,
    .controls-wrapper, 
    .result-container > h2,
    .print-btn,
    footer, 
    .initial-message,
    .mobile-restriction-message { /* 印刷時も警告は消す */
        display: none !important;
    }
    
    /* 印刷時はツールを表示させる (制限解除) */
    .pc-only-tool {
        display: block !important;
    }

    .result-container {
        border-top: none;
        margin-top: 0;
    }
    .bracket-wrapper, .league-wrapper {
        overflow: visible; /* 印刷時はスクロールバー不要 */
        padding: 0;
        border: none;
    }
    .bracket-winners-container,
    .bracket-losers-container {
        overflow-x: visible;
    }

    #bracket-container, #league-table-container {
        width: 100%;
    }
    
    /* 印刷時のトーナメント表スタイル調整 */
    .bracket-group-title {
        color: #000;
        border-bottom: 2px solid #000;
    }
    .bracket-winners-container,
    .bracket-losers-container {
        border: 1px solid #000;
        padding: 10px;
        page-break-inside: avoid;
    }
    .bracket-tournament {
        gap: 5px; /* 印刷時のスペース削減 */
    }
    .bracket-round {
        width: 180px; /* 幅を少し詰める */
    }
    .bracket-match {
        box-shadow: none;
        border: 1px solid #555;
        page-break-inside: avoid; /* マッチの途中で改ページされないように */
    }
    .bracket-team {
        padding: 6px 8px;
    }
    .team-score {
        display: inline-block;
        border: none;
        padding: 4px;
        background: transparent;
        color: #333;
        font-weight: bold;
    }
    input[disabled].team-score {
        background: transparent;
        color: #333;
    }
    .team-score::placeholder {
        color: transparent;
    }
    .set-winner-btn {
        display: none;
    }
    .bracket-round:not(:first-child) .bracket-match::before {
        background-color: #555;
    }
    .round-title {
        color: #000;
        border-bottom: 1px solid #000;
    }
    .bracket-team.winner {
        background-color: #eee !important;
        font-weight: bold;
    }
    .bracket-team.loser .team-name {
        color: #777;
        text-decoration: none;
    }
    
    
    /* 印刷時のリーグ表スタイル調整 */
    .league-wrapper-inner {
        gap: 20px;
        page-break-inside: avoid;
    }
    .league-matrix-table,
    .league-standings-table {
        font-size: 0.8em; /* 印刷用に縮小 */
        border: 1px solid #000;
    }
    .league-matrix-table th,
    .league-matrix-table td,
    .league-standings-table th,
    .league-standings-table td {
        border: 1px solid #333;
        padding: 5px;
    }
    .league-matrix-table th,
    .league-standings-table th {
        background-color: #eee !important;
        color: #000 !important;
    }
    .score-input-wrapper {
        display: block;
        padding: 5px 0;
    }
    .score-input-wrapper input {
        display: none; /* 入力欄は非表示 */
    }
    
    .score-input-wrapper::after {
        content: attr(data-score-a) ' - ' attr(data-score-b);
        color: #000;
    }

    .match-mirror {
        color: #333;
    }
    .standings-title {
        color: #000;
        border-bottom: 2px solid #000;
    }
}