@charset "utf-8";

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    margin: 0; padding: 0;
}

.main {
    max-width: 1400px;
    width: 95%;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

h1 {
    font-size: 1.8em;
    border-bottom: 2px solid #222;
    padding-bottom: 10px;
    margin-top: 0; margin-bottom: 20px;
    color: #222;
}

h2 {
    font-size: 1.2em;
    margin: 0 0 15px 0;
    color: #222;
    border-left: 5px solid #222;
    padding-left: 10px;
}

a { color: #222; text-decoration: none; transition: color 0.2s; }
a:hover { color: #0033AB; text-decoration: underline; }

/* ====== 検索フォーム ====== */
.search-form-block {
    background: #fdfdfd;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

/* レース名など単一行 */
.form-row {
    margin-bottom: 15px;
}
.form-group-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}
.form-group-inline label {
    font-size: 0.85em;
    font-weight: bold;
    color: #555;
    white-space: nowrap;
}
.form-group-inline input[type="text"] {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.95em;
    width: 260px;
    box-sizing: border-box;
}
.form-group-inline input:focus {
    outline: none;
    border-color: #0033AB;
    box-shadow: 0 0 0 2px rgba(0,51,171,0.1);
}

/* チェックボックスグループ */
.form-group-full {
    margin-bottom: 16px;
}
.group-label {
    display: block;
    font-size: 0.85em;
    font-weight: bold;
    color: #555;
    margin-bottom: 6px;
}

.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 10px 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

/* クラスは6列 */
.checkbox-grid:not(.checkbox-grid-sm):not(.checkbox-grid-year) {
    max-width: 700px;
}

/* 競馬場は横並び */
.checkbox-grid-sm {
    max-width: 600px;
}

/* 年は横並び */
.checkbox-grid-year {
    max-width: 100%;
}

.cb-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.88em;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
}
.cb-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    accent-color: #0033AB;
}

/* その他行 */
.cb-other-row {
    width: 100%;
    margin-top: 4px;
}
.cb-other-input {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.88em;
    width: 180px;
    margin-left: 4px;
}
.cb-other-input:focus {
    outline: none;
    border-color: #0033AB;
}

/* 四半期行 */
.quarter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}
.quarter-label {
    font-size: 0.85em;
    font-weight: bold;
    color: #555;
    white-space: nowrap;
}

/* 範囲入力（距離・頭数・賞金） */
.form-row-ranges {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.form-group-range {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-group-range label {
    font-size: 0.85em;
    font-weight: bold;
    color: #555;
}
.range-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}
.range-inputs input[type="number"] {
    padding: 7px 9px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.9em;
    width: 90px;
    box-sizing: border-box;
}
.range-inputs input:focus {
    outline: none;
    border-color: #0033AB;
    box-shadow: 0 0 0 2px rgba(0,51,171,0.1);
}
.range-inputs span {
    color: #777;
    font-size: 0.9em;
}

/* ボタン */
.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.btn-search {
    background: #0033AB;
    color: white;
    border: none;
    padding: 10px 28px;
    font-size: 1em;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-search:hover { background: #002288; }
.btn-reset {
    background: #fff;
    color: #666;
    border: 1px solid #ccc;
    padding: 9px 20px;
    font-size: 0.95em;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}
.btn-reset:hover { background: #f0f0f0; color: #333; text-decoration: none; }

/* ====== 結果エリア ====== */
.result-block {
    background: #fdfdfd;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}
.result-count {
    font-size: 0.95em;
    color: #555;
    margin-bottom: 15px;
}
.result-count strong { color: #0033AB; font-size: 1.1em; }

/* ====== 結果テーブル ====== */
.result-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #ccc;
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.93em;
}
.result-table thead th {
    background: #f2f2f2;
    padding: 9px 10px;
    text-align: left;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
    font-size: 0.88em;
    color: #444;
    user-select: none;
}
.result-table thead th.sortable:hover { background: #e8e8e8; }
.sort-icon { font-size: 0.8em; color: #0033AB; }

.result-table tbody tr {
    cursor: pointer;
    background: #fff;
    transition: background 0.15s;
}
.result-table tbody tr:hover { background: #f0f8ff; }
.result-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}
.result-table tbody tr:last-child td { border-bottom: none; }

/* 列幅 */
.col-date   { width: 90px; white-space: nowrap; }
.col-place  { width: 60px; white-space: nowrap; }
.col-num    { width: 36px; text-align: center; }
.col-name   { min-width: 130px; }
.col-class  { width: 72px; }
.col-dist   { width: 64px; white-space: nowrap; }
.col-count  { width: 48px; text-align: center; }
.col-winner { min-width: 9em; }
.col-jockey { min-width: 9em; }
.col-prize  { width: 80px; white-space: nowrap; }
.col-action { width: 60px; text-align: center; }

.race-class-badge {
    display: inline-block;
    font-size: 0.78em;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
    font-weight: bold;
}
.race-name-link { font-weight: bold; color: #0033AB; }
.race-name-link:hover { text-decoration: underline; }

.btn-detail {
    display: inline-block;
    padding: 3px 9px;
    background: #4CAF50;
    color: white;
    border-radius: 4px;
    font-size: 0.82em;
    font-weight: bold;
    text-decoration: none;
    white-space: nowrap;
}
.btn-detail:hover { background: #45a049; text-decoration: none; color: white; }

.no-results {
    text-align: center;
    color: #999;
    padding: 40px 0;
    font-size: 1.05em;
}

/* リンク */
.back-link {
    display: inline-block;
    margin-top: 20px;
    color: #666;
    font-size: 0.9em;
}
.back-link:hover { color: #0033AB; }

/* PC/SP 切り替え */
.sp-only { display: none; }
.pc-only { display: table-cell; }

/* ====== レスポンシブ ====== */
@media (max-width: 900px) {
    .col-winner, .col-jockey, .col-prize { display: none; }
}

@media (max-width: 768px) {
    .main { width: 100%; margin: 0; padding: 10px; border-radius: 0; box-shadow: none; }
    h1 { font-size: 1.4em; }
    .sp-only { display: table-cell; }
    .pc-only { display: none; }
    .col-winner, .col-jockey, .col-prize { display: none; }
    .form-group-inline input[type="text"] { width: 100%; }
    .form-row-ranges { flex-direction: column; gap: 12px; }
    .checkbox-grid { gap: 5px 10px; }
}

@media (max-width: 480px) {
    .col-place { display: none; }
    .range-inputs input[type="number"] { width: 76px; }
}
