:root {
  --turf: #0e3a2a; --turf2: #14483a; --gold: #deb85c; --ink: #1c201e; --sub: #606864; --card: #faf8f2;
  --red: #c81e28; --blue: #1e50aa; --green: #168c50; --amber: #d66c0e; --gray: #8a928e;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--turf) repeating-linear-gradient(0deg, var(--turf) 0 64px, var(--turf2) 64px 128px);
  min-height: 100vh; line-height: 1.6;
}
a { color: inherit; }
main { max-width: 760px; margin: 0 auto; padding: 14px 12px 24px; }
footer { max-width: 760px; margin: 0 auto; padding: 8px 14px calc(30px + env(safe-area-inset-bottom)); color: #b8c8be; font-size: 12px; }
.loading, .empty { color: #dfe9e3; text-align: center; padding: 40px 0; }
h1, h2, h3 { margin: 0; }
.panel { background: var(--card); border-radius: 16px; padding: 14px; margin: 0 0 12px; box-shadow: 0 3px 0 rgba(0, 0, 0, .25); }
.dark { background: #0a2c1e; color: #fff; border: 2px solid var(--gold); }
.muted { color: var(--sub); font-size: 13px; }
.dark .muted { color: #c8d6ce; }
.gold { color: var(--gold); }

/* 日付の切り替え */
.datebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 12px; color: #fff; }
.datebar button, .tabs button, .btn {
  border: 0; border-radius: 18px; background: var(--card); color: var(--ink); font: inherit; font-weight: 700; padding: 8px 14px; cursor: pointer;
}
.datebar button[disabled] { opacity: .35; }
.datebar h1 { font-size: 20px; color: var(--gold); text-align: center; flex: 1; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 10px; scrollbar-width: none; }
.tabs button { white-space: nowrap; background: #1f5a46; color: #e7efe9; }
.tabs button.on { background: var(--gold); color: var(--ink); }

/* 勝負レースの帯 */
.shobu-card { display: block; text-decoration: none; background: linear-gradient(135deg, #fff3d0, #f3d98a); border-radius: 16px; padding: 12px 14px; margin: 0 0 12px; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.shobu-card .tag { display: inline-block; background: var(--ink); color: var(--gold); border-radius: 12px; padding: 1px 10px; font-size: 12px; font-weight: 800; }
.shobu-card h2 { font-size: 17px; margin: 4px 0; }
.nums { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }

/* レースの行 */
.race { display: block; text-decoration: none; background: var(--card); border-radius: 14px; padding: 10px 12px; margin: 0 0 8px; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.race-head { display: flex; align-items: baseline; gap: 8px; }
.race-no { font-weight: 900; font-size: 18px; min-width: 38px; }
.race-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race-time { color: var(--sub); font-size: 13px; }
.race-meta { color: var(--sub); font-size: 12px; margin: 0 0 4px; }
.pill { display: inline-block; font-size: 11px; font-weight: 800; border-radius: 10px; padding: 0 8px; color: #fff; vertical-align: 1px; }
.pill.shobu { background: var(--ink); color: var(--gold); }
.pill.hit { background: var(--green); } .pill.miss { background: var(--gray); } .pill.wait { background: #b8a56a; }
.pill.bribe { background: var(--amber); }
.pickline { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 14px; margin-top: 4px; }
.pickline span { white-space: nowrap; }
.mark { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; font-weight: 900; font-size: 13px; margin-right: 3px; }
.m1 { background: var(--red); } .m2 { background: var(--blue); } .m3 { background: #282828; } .m4 { background: #14786e; }
.stars { color: var(--amber); letter-spacing: 1px; }
.up { opacity: .55; }

/* 枠色の馬番 */
.uma { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 6px; border: 2px solid #3c3c3c; font-weight: 900; font-size: 14px; }
.w1 { background: #fff; color: #1c201e; } .w2 { background: #1e1e1e; color: #fff; } .w3 { background: #e20012; color: #fff; }
.w4 { background: #0068b7; color: #fff; } .w5 { background: #ffe100; color: #1c201e; } .w6 { background: #009b46; color: #fff; }
.w7 { background: #f39800; color: #fff; } .w8 { background: #f08cb4; color: #fff; } .w0 { background: #ccc; color: #1c201e; }

/* 詳細 */
.back { display: inline-block; color: #dfe9e3; text-decoration: none; margin: 0 0 8px; font-size: 14px; }
.race-title h1 { font-size: 22px; } .race-title .sub { color: var(--sub); font-size: 13px; }
.pick { border-top: 1px dashed #d8d4c8; padding: 10px 0; }
.pick:first-of-type { border-top: 0; }
.pick-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick-head .horse { font-weight: 900; font-size: 18px; }
.pick p { margin: 4px 0 0; }
.prose { white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 6px 6px; text-align: left; border-bottom: 1px solid #e6e2d6; white-space: nowrap; }
th { color: var(--sub); font-size: 12px; font-weight: 700; }
td.n, th.n { text-align: right; }
tr.hl td { background: #fff4d6; }

/* 勝負レース・成績 */
.bignum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-top: 8px; }
.bignum b { display: block; font-size: 24px; line-height: 1.2; }
.bignum span { font-size: 12px; color: #c8d6ce; }
.plus { color: #7be0a4; } .minus { color: #ff9a8a; }
.curve { width: 100%; height: 120px; display: block; margin-top: 10px; }
.rate { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rate .box { background: var(--card); border-radius: 14px; padding: 10px; text-align: center; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.rate .box small { display: block; color: var(--sub); font-weight: 700; }
.rate .box b { display: block; font-size: 32px; color: var(--red); line-height: 1.2; }
.rate .box span { color: var(--sub); font-size: 12px; }
.seg { display: flex; gap: 6px; margin: 0 0 10px; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 16px; padding: 6px 12px; font: inherit; font-weight: 700; background: #1f5a46; color: #e7efe9; cursor: pointer; }
.seg button.on { background: var(--gold); color: var(--ink); }
.ticket { background: #def4e6; border: 2px solid var(--ink); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.ticket .big { font-weight: 900; font-size: 20px; }

/* 勝負レースの履歴の行は、レース名を折り返して全部見せる */
.race-head.wrap { align-items: flex-start; flex-wrap: wrap; }
.race-head.wrap .race-name { white-space: normal; flex-basis: 100%; }

/* Instagram: グラデーションの大きなボタン(フッター)と、ヘッダーの小さな丸 */
.ig { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; text-decoration: none; color: #fff; margin: 0 0 16px;
  background: linear-gradient(45deg, #f9a03f 0%, #ee2a7b 45%, #8134af 80%, #515bd4 100%); border-radius: 16px; padding: 12px 16px; box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.ig svg { grid-row: span 2; width: 30px; height: 30px; }
.ig span { font-weight: 800; font-size: 16px; } .ig small { color: rgba(255,255,255,.92); font-size: 12px; }
/* 絞り込み・畳み・もっと見る */
.filter { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; margin: 0 0 10px; }
.filter select { flex: 1; font: inherit; font-weight: 700; padding: 8px 10px; border-radius: 12px; border: 0; background: var(--card); color: var(--ink); }
.more { display: block; width: 100%; border: 0; border-radius: 14px; padding: 12px; margin: 8px 0 12px; font: inherit; font-weight: 800; background: var(--gold); color: var(--ink); cursor: pointer; }
.panel .more { background: #efe9d6; }
details.fold > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h3::after { content: " ▾"; color: var(--sub); }
details.fold:not([open]) > summary h3::after { content: " ▸"; }
button.link { border: 0; background: none; font: inherit; color: var(--blue); text-decoration: underline; padding: 0; cursor: pointer; }

/* 勝負レースの馬券風の券面(幅に合わせて、中の文字も拡大縮小する) */
.shobu-entry { margin: 0 0 18px; }
.shobu-link { display: inline-block; color: #dfe9e3; text-decoration: none; font-size: 13px; margin: 0 0 6px 4px; }
.ticket-wrap { margin: 0 0 4px; }
.ticket { container-type: inline-size; position: relative; transform: rotate(-.7deg); filter: drop-shadow(0 5px 6px rgba(0,0,0,.4)); }
.tk-paper { position: relative; display: grid; grid-template-columns: 31% 14% 55%; aspect-ratio: 1000 / 625; color: #141816; border: .5cqw solid #141816; border-radius: 1.4cqw; overflow: hidden;
  background: repeating-linear-gradient(90deg, #deF4e6 0 .5cqw, #cce8d6 .5cqw .75cqw); }
.tk-paper::before { content: ""; position: absolute; inset: 0; background: url(/umaa.png) 78% 60% / 34% no-repeat; opacity: .13; filter: hue-rotate(80deg) saturate(.5); pointer-events: none; }
.tk-paper::after { content: ""; position: absolute; left: 19.6%; top: 0; bottom: 0; width: 7%; background: rgba(150, 215, 175, .35); pointer-events: none; }
.tk-left, .tk-mid, .tk-right { position: relative; z-index: 1; }
.tk-left { padding: 2.2cqw 0 1.6cqw 2.4cqw; display: flex; flex-direction: column; }
.tk-left small { font-size: 1.9cqw; }
.tk-track { font-size: 7.4cqw; font-weight: 900; line-height: 1.1; white-space: nowrap; } .tk-track span { font-size: 3.4cqw; font-weight: 800; }
.tk-no { display: flex; align-items: center; gap: 1.4cqw; font-size: 4.2cqw; font-weight: 900; margin-top: 1.4cqw; }
.tk-no b { background: #141816; color: #fff; font-size: 5.6cqw; padding: .2cqw 1.8cqw; }
.tk-qr { display: flex; gap: 1.4cqw; margin-top: 2.2cqw; } .tk-qr canvas { width: 11cqw; height: 11cqw; }
.tk-info { margin-top: auto; font-size: 2.4cqw; line-height: 1.35; } .tk-info strong { display: block; font-size: 2.9cqw; }
.tk-mid { border: .35cqw solid #141816; margin: 2.2cqw 0 2.2cqw; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 1cqw 0; font-weight: 900; }
.tk-mid small { font-size: 2.6cqw; } .tk-mid b { font-size: 11.5cqw; line-height: 1.05; } .tk-mid b:first-of-type { font-size: 14cqw; }
.tk-right { padding: 2.2cqw 2.4cqw 1.6cqw 2.2cqw; display: flex; flex-direction: column; }
.tk-head { border: .35cqw solid #141816; display: flex; justify-content: space-between; align-items: center; padding: .6cqw 2.2cqw; }
.tk-head strong { font-size: 4.8cqw; } .tk-head span { font-size: 3.8cqw; }
.tk-nums { display: flex; gap: 1.4cqw; margin-top: 2.6cqw; }
.tk-nums i { flex: 1; aspect-ratio: .82; background: #fff; border: .35cqw solid #141816; display: flex; align-items: center; justify-content: center; font-style: normal; font-weight: 900; font-size: 7cqw; }
.tk-wait { font-style: normal; font-weight: 800; font-size: 4cqw; padding: 3cqw 0; }
.tk-stars { display: flex; gap: 1.4cqw; margin-top: 1cqw; } .tk-stars span { flex: 1; text-align: center; font-size: 4cqw; }
.tk-right dl { margin: auto 0 0; } .tk-right dl div { display: flex; justify-content: space-between; align-items: baseline; font-size: 3.6cqw; font-weight: 800; line-height: 1.55; }
.tk-right dt { font-weight: 800; } .tk-right dd { margin: 0; font-size: 4cqw; }
.stamps { position: absolute; right: 3%; bottom: 8%; width: 58%; height: 36%; z-index: 3; pointer-events: none; }
.stamp { position: absolute; border: .9cqw double currentColor; border-radius: 1.6cqw; font-weight: 900; text-align: center; letter-spacing: .5cqw; opacity: .9; mix-blend-mode: multiply;
  background: rgba(255,255,255,.04); -webkit-mask: radial-gradient(circle at 20% 30%, transparent .6cqw, #000 .7cqw) 0 0/3.2cqw 3.2cqw; mask: radial-gradient(circle at 20% 30%, transparent .6cqw, #000 .7cqw) 0 0/3.2cqw 3.2cqw; }
.stamp.hit { color: #cc1c28; font-size: 11cqw; padding: .4cqw 3cqw; right: 8%; top: -2%; transform: rotate(-13deg); }
.stamp.miss { color: #34467c; font-size: 9.4cqw; padding: .4cqw 3cqw; right: 6%; top: 2%; transform: rotate(8deg); }
.stamp.tori { color: #d66c0e; font-size: 8cqw; padding: .3cqw 2.4cqw; right: 12%; top: 40%; transform: rotate(6deg); }
.tk-horses { list-style: none; margin: 8px 0 0; padding: 8px 10px; background: var(--card); border-radius: 12px; display: grid; gap: 4px; }
.tk-horses li { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.tk-money { color: #dfe9e3 !important; margin: 6px 4px 0; } .tk-money b { font-weight: 900; } .plus2 { color: #7be0a4; } .minus2 { color: #ff9a8a; }

/* 判子: 枠を太く、かすれは細かく(読みやすさ優先) */
.stamp { border-width: 1.1cqw; border-style: solid; -webkit-mask: radial-gradient(circle at 20% 30%, transparent .25cqw, #000 .3cqw) 0 0/2.4cqw 2.4cqw; mask: radial-gradient(circle at 20% 30%, transparent .25cqw, #000 .3cqw) 0 0/2.4cqw 2.4cqw; opacity: .92; }
.stamp::before { content: ""; position: absolute; inset: .5cqw; border: .35cqw solid currentColor; border-radius: 1cqw; opacity: .8; }


/* ヘッダー: ブランドの段(上)と、等間隔のナビの段(下、スクロールしても残る) */
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(14px + env(safe-area-inset-top)) 16px 12px; background: var(--turf); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--gold); min-width: 0; }
.brand img { width: 48px; height: 48px; border-radius: 50%; background: #0a2c1e; flex: none; }
.brand strong { display: block; font-size: 21px; line-height: 1.2; letter-spacing: .02em; white-space: nowrap; }
.brand small { display: block; font-size: 12px; color: #c8d6ce; margin-top: 1px; letter-spacing: .08em; }
.ig-mini { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; color: #fff; border-radius: 50%; flex: none;
  background: linear-gradient(45deg, #f9a03f, #ee2a7b 55%, #8134af); box-shadow: 0 2px 0 rgba(0,0,0,.3); }
.ig-mini svg { width: 24px; height: 24px; }
.main-nav { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 10px 14px 12px; background: rgba(14, 58, 42, .97); border-bottom: 2px solid var(--gold); }
.main-nav a { text-align: center; text-decoration: none; color: #e7efe9; font-weight: 800; font-size: 15px; padding: 10px 4px; border-radius: 22px; background: #1d5543; white-space: nowrap; }
.main-nav a.on { background: var(--gold); color: var(--ink); }

/* 中央(JRA)と地方(NAR)の、さりげない見た目の差: 左の細い帯と、ごくわずかな地色、小さな「中央」「地方」の札 */
.race { border-left: 6px solid transparent; }
.race[data-org="JRA"] { border-left-color: var(--gold); background: #fcf9ef; }
.race[data-org="NAR"] { border-left-color: #7fb8ae; background: #f6faf8; }
.org { display: inline-block; font-size: 11px; font-weight: 800; line-height: 1.5; padding: 0 7px; border-radius: 9px; vertical-align: 1px; margin-right: 2px; }
.org.JRA { color: #7a5a10; background: #f3e3b0; } .org.NAR { color: #1f5f55; background: #d3ebe6; }
.tabs button .dot, .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.JRA { background: var(--gold); } .dot.NAR { background: #7fb8ae; }
tr.grp td { background: #f1ede0; color: var(--sub); font-size: 12px; font-weight: 800; padding: 4px 6px; }
.divider { display: flex; align-items: center; gap: 10px; color: #c8d6ce; font-size: 12px; font-weight: 800; margin: 14px 2px 8px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: rgba(200, 214, 206, .35); }
.pill.next { background: var(--red); }

/* ウマーのアイコン: 丸枠なし・大きめ */
.brand img { width: 72px; height: 72px; border-radius: 0; background: none; object-fit: contain; margin: -6px 0 -6px -4px; }
.brand { gap: 10px; }
header.top { padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: 8px; }

/* レースの見出しの会場名(全会場のとき、どこのレースか分かるように) */
.race-no { min-width: 0; white-space: nowrap; }
.venue { display: inline-block; font-weight: 900; font-size: 14px; padding: 0 8px; margin-right: 2px; border-radius: 8px; vertical-align: 2px; }
.venue.JRA { background: #f3e3b0; color: #6b4d0a; } .venue.NAR { background: #d3ebe6; color: #1b5a50; }

.venue { font-size: 13px; padding: 0 7px; }
