*{
    margin:0;
    padding:0;
    box-sizing:border-box;
}

body{
    background:#0f172a;
    color:#fff;
    font-family:"Segoe UI",sans-serif;
    min-height:100vh;
    padding:20px;
}

/* ヘッダー */

.header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:20px;

    background:#1e293b;
    padding:20px;
    border-radius:16px;

    box-shadow:0 0 20px rgba(0,0,0,.3);
}

.logo-area h1{
    font-size:28px;
    color:#22c55e;
}

.logo-area p{
    margin-top:5px;
    color:#94a3b8;
}

.race-info{
    display:flex;
    gap:20px;
    font-size:14px;
}

/* メイン3カラム */

.dashboard{
    display:grid;
    grid-template-columns:250px 1fr 300px;
    gap:20px;
    margin-bottom:20px;
}

/* 共通カード */

.horse-list,
.horse-detail,
.ranking,
.chart-box{
    background:#1e293b;
    border-radius:16px;
    padding:20px;

    box-shadow:0 0 20px rgba(0,0,0,.25);
}

/* 出走馬一覧 */

.horse-list-title{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    margin-bottom:15px;
}

.horse-list-title h2{
    margin:0;
}

.horse-sort{
    display:flex;
    gap:6px;
}

.sort-tab{
    border:none;
    border-radius:999px;
    padding:6px 9px;
    background:#334155;
    color:#94a3b8;
    font:inherit;
    font-size:12px;
    cursor:pointer;
    transition:.3s;
}

.sort-tab:hover{
    background:#475569;
    color:#fff;
}

.sort-tab.active{
    background:#22c55e;
    color:#07120b;
    font-weight:bold;
}

.horse-list ul{
    list-style:none;
}

.horse-list li{
    padding:12px;
    margin-bottom:8px;

    background:#334155;
    border-radius:10px;

    cursor:pointer;
    transition:.3s;
    display:flex;
    align-items:center;
}

.horse-list li:hover{
    background:#22c55e;
    transform:translateX(5px);
}

.horse-list li.active{
    background:#22c55e;
    color:#000;
    font-weight:bold;
}

/* 馬詳細 */

.detail-card{
    display:grid;
    grid-template-columns:380px 1fr;
    gap:20px;
}

.horse-image{
    width:100%;
    max-width:380px;
}

.horse-image img{
    width:100%;
    height:280px;
    object-fit:cover;
    border-radius:12px;
}

.horse-info{
    flex:1;
}

.horse-info h3{
    font-size:clamp(22px,3vw,30px);
    margin-bottom:15px;
}

.grade{
    font-size:22px;
    color:#22c55e;
    margin-bottom:20px;
}

/* ステータス */

.stat-grid{
    display:grid;
    grid-template-columns:repeat(2,1fr);
    gap:12px;
}

.stat{
    background:#334155;
    padding:15px;
    border-radius:10px;
}

.stat span{
    display:block;
    color:#94a3b8;
    margin-bottom:5px;
}

.stat strong{
    font-size:20px;
}

.winrate{
    margin-top:20px;
    font-size:22px;
    color:#22c55e;
}

/* ランキング */

.ranking ol{
    padding-left:20px;
}

.ranking li{
    margin-bottom:10px;
}

.tips{
    margin-top:25px;
    padding:15px;
    background:#334155;
    border-radius:10px;
}

.tips h3{
    margin-bottom:10px;
    color:#22c55e;
}

/* グラフ */

.bottom-area{
    display:grid;
    grid-template-columns:1fr 1fr 1fr;
    gap:20px;
}

.chart-box{
    min-height:300px;
    overflow:hidden;
}

.chart-box h2{
    margin-bottom:15px;
}

.rating p{
    margin-bottom:15px;
    font-size:18px;
}

/* レスポンシブ */

@media(max-width:1400px){

    .dashboard{
    display:grid;
    grid-template-columns:
        minmax(220px,250px)
        1fr
        minmax(250px,300px);
}

    .bottom-area{
        grid-template-columns:1fr;
    }

    .detail-card{
        flex-direction:column;
    }

    .horse-image{
        width:100%;
    }

}

/* AIスコア */

.ai-score{
    margin:15px 0 25px;
    font-size:18px;
    color:#94a3b8;
}

.ai-score span{
    font-size:clamp(28px,5vw,48px);
    font-weight:bold;
    color:#22c55e;
    margin:0 5px;
}

/* 馬プロフィール */

.horse-profile{
display:grid;
    grid-template-columns:
        repeat(auto-fit,minmax(120px,1fr));
    gap:10px;
    margin-top:20px;
}

.horse-profile div{
    background:#334155;
    padding:12px;
    border-radius:10px;
    font-size:14px;
}

/* 成績 */

.record{
    display:flex;
    gap:20px;
    margin-top:20px;
    margin-bottom:20px;
}

.record div{
    background:#334155;
    padding:12px 18px;
    border-radius:10px;
    font-weight:bold;
}

.record span{
    color:#22c55e;
}

/* 前走成績 */

.last-race{
    margin-top:20px;
}

.last-race h4{
    margin-bottom:10px;
    color:#22c55e;
}

.last-race table{
    width:100%;
    border-collapse:collapse;
}

.last-race th,
.last-race td{
    padding:10px;
    text-align:left;
    border-bottom:1px solid #475569;
}

.last-race th{
    color:#94a3b8;
}

/* AI印 */

.prediction{
    background:#334155;
    padding:15px;
    border-radius:10px;
    margin-bottom:15px;
}

.prediction h3{
    color:#22c55e;
    margin-bottom:10px;
}

.prediction p{
    margin-bottom:8px;
}

/* 展開予想 */

.pace{
    line-height:2;
    font-size:15px;
}

.pace p{
    background:#334155;
    padding:12px;
    border-radius:10px;
    margin-bottom:10px;
}

.chart-box canvas{
    max-width:100%;
    height:250px !important;
}

@media(max-width:768px){

    body{
        padding:10px;
    }

    .header{
        flex-direction:column;
        gap:15px;
        text-align:center;
    }

    .race-info{
        justify-content:center;
    }

    .horse-info h3{
        font-size:24px;
    }

    .record{
        flex-direction:column;
    }

    .horse-profile{
        grid-template-columns:repeat(2,1fr);
    }

}

/* AIスコアバー */

.score-bar{
    width:100%;
    height:14px;

    background:#334155;

    border-radius:999px;

    overflow:hidden;

    margin-top:-10px;
    margin-bottom:20px;
}

.score-fill{
    height:100%;
    border-radius:999px;

    background:linear-gradient(
        90deg,
        #22c55e,
        #4ade80,
        #86efac
    );

    box-shadow:
        0 0 10px rgba(34,197,94,.5);

    transition:.5s;
}

/* 馬番 */

.horse-number{

    display:inline-flex;
    align-items:center;
    justify-content:center;

    width:30px;
    height:30px;

    margin-right:10px;

    border-radius:50%;

    font-size:14px;
    font-weight:bold;

    border:2px solid rgba(255,255,255,.2);

    flex-shrink:0;
}

/* 1枠 白 */

.frame1{
    background:#ffffff;
    color:#000000;
}

/* 2枠 黒 */

.frame2{
    background:#111111;
    color:#ffffff;
}

/* 3枠 赤 */

.frame3{
    background:#ef4444;
    color:#ffffff;
}

/* 4枠 青 */

.frame4{
    background:#3b82f6;
    color:#ffffff;
}

/* 5枠 黄 */

.frame5{
    background:#facc15;
    color:#000000;
}

/* 6枠 緑 */

.frame6{
    background:#22c55e;
    color:#ffffff;
}

/* 7枠 橙 */

.frame7{
    background:#f97316;
    color:#ffffff;
}

/* 8枠 桃 */

.frame8{
    background:#ec4899;
    color:#ffffff;
}

.mini-stats{
    display:grid;
    grid-template-columns:1fr;
    gap:10px;
}

.mini-card{
    background:#334155;
    border-radius:10px;
    padding:12px;
    text-align:center;
}

.mini-card span{
    display:block;
    color:#94a3b8;
    font-size:12px;
    margin-bottom:5px;
}

.mini-card strong{
    color:#22c55e;
    font-size:16px;
}

.detail-bottom{
    display:grid;
    grid-template-columns:220px 1fr;
    gap:20px;
    margin-top:20px;
}

.record{
    display:grid;
    gap:12px;
}

.left-column{
    display:flex;
    flex-direction:column;
    gap:15px;
}

/* =====================
   スマホ表示
===================== */
@media (max-width: 767px) {

  body {
    padding: 12px;
  }

  /* ヘッダー：レース情報を2行にコンパクト化 */
  .header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title title"
      "course race";
    align-items: center;
    gap: 6px 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
    text-align: left;
  }

  .logo-area {
    display: contents;
  }

  .logo-area h1 {
    grid-area: title;
    font-size: 18px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .logo-area p {
    grid-area: course;
    margin: 0;
    font-size: 13px;
  }

  .race-info {
    grid-area: race;
    justify-content: flex-end;
    gap: 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* 3カラムを縦1列にする */
  .dashboard {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 14px;
  }

  .horse-list,
  .horse-detail,
  .ranking,
  .chart-box {
    padding: 16px;
    border-radius: 14px;
  }

  /* 出馬表 */
  .horse-list {
    padding: 12px;
  }

  .horse-list-title {
    margin-bottom: 8px;
  }

  .horse-list-title h2,
  .horse-detail h2,
  .ranking h2,
  .chart-box h2 {
    font-size: 21px;
  }

  .horse-list-title h2 {
    font-size: 20px;
  }

  .horse-list ul {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
  }

  .horse-list li {
    min-width: 0;
    min-height: 38px;
    margin: 0;
    padding: 5px 7px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .horse-list li:hover {
    transform: none;
  }

  .horse-number {
    width: 22px;
    height: 22px;
    margin-right: 5px;
    font-size: 11px;
  }

  .sort-tab {
    padding: 5px 8px;
    font-size: 11px;
  }

  /* 馬詳細 */
  .detail-card {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .horse-image,
  .horse-image img {
    max-width: none;
    width: 100%;
  }

  .horse-image img {
    height: 230px;
  }

  .mini-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .mini-card {
    padding: 10px 5px;
  }

  .mini-card strong {
    font-size: 13px;
  }

  .horse-info h3 {
    font-size: 25px;
    margin-bottom: 10px;
  }

  .grade {
    font-size: 19px;
    margin-bottom: 14px;
  }

  .ai-score {
    margin: 12px 0 20px;
    font-size: 16px;
  }

  .ai-score span {
    font-size: 40px;
  }

  .stat-grid {
    gap: 8px;
  }

  .stat {
    padding: 12px;
  }

  .stat strong {
    font-size: 18px;
  }

  .horse-profile {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 14px;
  }

  .horse-profile div {
    padding: 10px;
    font-size: 13px;
  }

  /* 勝率・前走成績 */
  .detail-bottom {
    grid-template-columns: 1fr;
    gap: 4px;
    margin-top: 16px;
  }

  .record {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 0 0 16px;
  }

  .record div {
    padding: 10px 5px;
    text-align: center;
    font-size: 13px;
  }

  .last-race {
    margin-top: 0;
  }

  .last-race th,
  .last-race td {
    padding: 9px 6px;
    font-size: 13px;
  }

  /* AI予想 */
  .ranking ol {
    columns: 2;
    column-gap: 26px;
    padding-left: 18px;
    font-size: 14px;
  }

  .ranking li {
    margin-bottom: 8px;
  }

  .prediction,
  .tips {
    padding: 13px;
  }

  .tips {
    margin-top: 15px;
  }

  /* 下部3項目 */
  .bottom-area {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .chart-box {
    min-height: 0;
  }

  .chart-box canvas {
    height: 230px !important;
  }
}