:root {
  --ink: #fff;
  --bg: #12072e;
  --gold1: #ffe27a;
  --gold2: #ffb300;
  --gold3: #b36b00;
  --pink: #ff3d9a;
  --cyan: #2fe6ff;
  --violet: #6a35ff;
  --panel: rgba(24, 10, 60, .86);
  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --logo: "Dela Gothic One", "Zen Maru Gothic", "Hiragino Sans", "Yu Gothic", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { word-break: keep-all; line-break: strict; overflow-wrap: break-word; margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); font-weight: 700; touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: #12072e; touch-action: none; }
a { color: #ffe27a; }
button { font-family: inherit; font-weight: 900; cursor: pointer; }
.screen { position: fixed; inset: 0; display: none; pointer-events: none; z-index: 5; }
.screen.show { display: block; }
.screen > * { pointer-events: auto; }

/* ---------- ボタン ---------- */
.btn { border: 0; border-radius: 999px; padding: 12px 26px; font-size: 18px; color: #3a1d00; background: linear-gradient(#fff, #e9e1ff); box-shadow: 0 5px 0 #8f7bd6, 0 8px 14px rgba(0,0,0,.4); min-height: 48px; transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #8f7bd6, 0 4px 8px rgba(0,0,0,.4); }
.btn.primary { background: linear-gradient(#fff2a8, var(--gold2) 55%, #ff8a00); box-shadow: 0 6px 0 var(--gold3), 0 10px 18px rgba(0,0,0,.45); color: #4a2400; }
.btn.primary:active { box-shadow: 0 2px 0 var(--gold3), 0 4px 8px rgba(0,0,0,.4); }
.btn.huge { font-size: 30px; padding: 16px 52px; min-height: 68px; letter-spacing: .08em; animation: pulse 1.3s ease-in-out infinite; }
.btn[disabled] { filter: grayscale(.9) brightness(.7); animation: none; cursor: default; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* ---------- 読み込み ---------- */
#boot { background: radial-gradient(circle at 50% 40%, #3a1a7a, #12072e 70%); z-index: 50; text-align: center; }
#boot .logo-sm { position: absolute; left: 0; right: 0; top: 34%; font-family: var(--logo); font-size: 30px; color: #fff; text-shadow: 0 3px 0 #6a35ff; }
#boot .logo-sm b { color: var(--gold1); font-weight: 400; }
#boot .bar { position: absolute; left: 50%; top: 50%; width: min(70vw, 360px); height: 14px; transform: translateX(-50%); background: rgba(255,255,255,.15); border-radius: 99px; overflow: hidden; }
#boot .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold2), var(--gold1)); border-radius: 99px; transition: width .2s; }
#boot p { position: absolute; left: 0; right: 0; top: 56%; margin: 0; font-size: 16px; opacity: .85; }

/* ---------- 上の表示 ---------- */
#hud { position: fixed; left: 0; right: 0; top: 0; z-index: 20; display: none; padding: calc(8px + var(--safe-t)) 10px 0; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 6px; pointer-events: none; }
body.hud-on #hud { display: grid; }
#hud > * { pointer-events: auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 8px 14px; min-height: 44px; border-radius: 999px; color: #fff; background: rgba(20, 8, 52, .78); box-shadow: 0 0 0 2px rgba(255,255,255,.35) inset, 0 3px 8px rgba(0,0,0,.4); font-size: 15px; }
.chip .ico { width: 22px; height: 22px; }
.chip.back { justify-self: start; font-size: 16px; }
.chip.back .arr { font-size: 24px; line-height: 1; margin-top: -3px; }
body:not(.in-game) #btn-back { visibility: hidden; }
.chip.snd { justify-self: end; }
.pills { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pill { display: flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 999px; background: rgba(20, 8, 52, .82); box-shadow: 0 0 0 2px rgba(255,226,122,.8) inset, 0 3px 8px rgba(0,0,0,.4); white-space: nowrap; }
.pill .ico { width: 24px; height: 24px; }
.pill .lbl { font-size: 12px; opacity: .85; }
.pill b { font-family: var(--logo); font-weight: 400; font-size: 24px; color: var(--gold1); min-width: 2.4ch; text-align: right; }
.pill.best { padding: 2px 12px; box-shadow: 0 0 0 2px rgba(47,230,255,.7) inset; }
.pill.best b { font-size: 16px; color: var(--cyan); }
.pill.bump b { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.35); } }
body.hud-on.in-game .pills { margin-top: 0; }

/* ---------- おとパネル ---------- */
#soundpanel { position: fixed; inset: 0; z-index: 40; background: rgba(8, 2, 28, .55); display: flex; align-items: center; justify-content: center; }
#soundpanel[hidden] { display: none; }
.sp-card { width: min(88vw, 360px); padding: 22px 20px; border-radius: 24px; background: var(--panel); box-shadow: 0 0 0 3px rgba(255,226,122,.7) inset, 0 12px 30px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 14px; }
.sp-card h3 { margin: 0; text-align: center; font-size: 20px; color: var(--gold1); }
.sp-row { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.sp-row span { width: 6.5em; }
.sp-row input { flex: 1; height: 34px; accent-color: var(--gold2); }
.sp-card .btn { font-size: 16px; }

/* ---------- タイトル ---------- */
#title { background: radial-gradient(ellipse at 50% 30%, rgba(18,7,46,0) 30%, rgba(18,7,46,.55) 100%); }
.title-wrap { position: absolute; left: 0; right: 0; top: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; text-align: center; padding: clamp(14px, 11vh, 120px) 16px 0; gap: 10px; }
.title-wrap .btn.huge { margin-top: auto; }
.title-wrap .note { margin-bottom: clamp(70px, 14vh, 120px); }
.logo { display: flex; flex-direction: column; align-items: center; line-height: 1; font-family: var(--logo); transform: rotate(-3deg); filter: drop-shadow(0 8px 0 rgba(0,0,0,.3)); }
.logo .l1 { font-size: clamp(60px, 18vw, 120px); color: var(--gold1); -webkit-text-stroke: 3px #7a3d00; paint-order: stroke fill; text-shadow: 0 5px 0 #ff8a00, 0 10px 0 #b36b00; letter-spacing: .04em; animation: float 2.4s ease-in-out infinite; }
.logo .l2 { font-size: clamp(34px, 11vw, 72px); color: #fff; -webkit-text-stroke: 3px #b3126b; paint-order: stroke fill; text-shadow: 0 4px 0 var(--pink), 0 8px 0 #7a0a48; margin-top: 6px; }
@keyframes float { 50% { transform: translateY(-6px); } }
@keyframes floatc { 50% { transform: translateX(-50%) translateY(-6px); } }
.tag { margin: 8px 0 0; font-size: clamp(16px, 4.4vw, 24px); text-shadow: 0 2px 6px #000; }
.note { margin: 0; font-size: 13px; opacity: .85; text-shadow: 0 1px 4px #000; }
/* 背の低い画面（スマホを横にしたときなど）：題字と「はじめる」を小さくして、筐体の看板と重ならないようにする */
@media (max-height: 500px) {
  .title-wrap { padding-top: 6px; gap: 2px; }
  .logo .l1 { font-size: 38px; -webkit-text-stroke: 2px #7a3d00; text-shadow: 0 3px 0 #ff8a00, 0 6px 0 #b36b00; }
  .logo .l2 { font-size: 22px; -webkit-text-stroke: 2px #b3126b; text-shadow: 0 2px 0 var(--pink), 0 4px 0 #7a0a48; margin-top: 2px; }
  .tag { font-size: 13px; margin-top: 2px; }
  .title-wrap .btn.huge { font-size: 20px; padding: 6px 34px; min-height: 40px; }
  .title-wrap .note { margin-bottom: 30px; font-size: 11px; }
}
/* 背がやや低い横長の画面（高さ 501〜699）：題字を中くらいに縮めて、「まいにち…」と「はじめる」が筐体の看板に重ならないようにする */
@media (min-height: 501px) and (max-height: 699px) and (min-aspect-ratio: 5/4) {
  .title-wrap { padding-top: 10px; gap: 4px; }
  .logo .l1 { font-size: 64px; -webkit-text-stroke: 2px #7a3d00; text-shadow: 0 4px 0 #ff8a00, 0 8px 0 #b36b00; }
  .logo .l2 { font-size: 38px; -webkit-text-stroke: 2px #b3126b; text-shadow: 0 3px 0 var(--pink), 0 6px 0 #7a0a48; margin-top: 3px; }
  .tag { font-size: 16px; margin-top: 3px; }
  .title-wrap .btn.huge { font-size: 24px; padding: 8px 40px; min-height: 48px; }
  .title-wrap .note { margin-bottom: 36px; }
}
.foot { position: absolute; left: 0; right: 0; bottom: calc(10px + var(--safe-b)); margin: 0; text-align: center; font-size: 12px; text-shadow: 0 1px 4px #000; }
.foot a { margin: 0 6px; }

/* ---------- ロビー ---------- */
.lobby-top { position: absolute; left: 0; right: 0; top: calc(112px + var(--safe-t)); display: flex; justify-content: center; }
.next { background: rgba(20, 8, 52, .7); border-radius: 999px; padding: 6px 16px; font-size: 14px; box-shadow: 0 0 0 2px rgba(255,255,255,.25) inset; }
.next b { font-family: var(--logo); font-weight: 400; color: var(--cyan); margin-left: 4px; font-size: 17px; letter-spacing: .04em; }
.lobby-msg { position: absolute; left: 0; right: 0; bottom: calc(168px + var(--safe-b)); margin: 0; text-align: center; font-size: 18px; text-shadow: 0 2px 6px #000, 0 0 12px #000; animation: float 1.8s ease-in-out infinite; pointer-events: none; }
.cards { --cw: clamp(210px, 72vw, 260px); position: absolute; left: 0; right: 0; bottom: calc(16px + var(--safe-b)); display: flex; gap: 12px; padding: 8px calc(50% - var(--cw) / 2) 18px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; touch-action: pan-x; }
.cards::-webkit-scrollbar { display: none; }
.card { flex: 0 0 var(--cw); scroll-snap-align: center; scroll-snap-stop: always; min-width: 0; border: 0; border-radius: 22px; padding: 10px 8px 12px; color: #fff; text-align: center; opacity: .78; transform: scale(.93); box-shadow: 0 0 0 3px rgba(255,255,255,.55) inset, 0 8px 0 rgba(0,0,0,.35), 0 12px 18px rgba(0,0,0,.4); transition: transform .2s, opacity .2s; }
.card.sel { opacity: 1; transform: scale(1); box-shadow: 0 0 0 3px #ffe27a inset, 0 0 0 3px rgba(255,255,255,.55), 0 8px 0 rgba(0,0,0,.35), 0 12px 18px rgba(0,0,0,.4); }
.card:active { transform: translateY(4px) scale(.97); }
.card .nm { display: block; white-space: nowrap; font-size: clamp(18px, 5.6vw, 24px); font-family: var(--logo); font-weight: 400; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.card .ds { display: block; font-size: clamp(12px, 3.2vw, 14px); margin-top: 2px; opacity: .95; }
.card .go { display: inline-block; margin-top: 6px; padding: 4px 18px; border-radius: 99px; background: #fff; color: #3a1d00; font-size: 16px; }
.cards-nav { position: absolute; bottom: calc(62px + var(--safe-b)); width: 38px; height: 64px; padding: 0 0 4px; border: 0; border-radius: 14px; background: rgba(20, 8, 52, .78); color: var(--gold1); font-size: 32px; line-height: 1; box-shadow: 0 0 0 2px rgba(255,255,255,.35) inset; }
.cards-nav:active { transform: translateY(2px); }
.cards-nav.prev { left: 4px; } .cards-nav.next { right: 4px; }

/* ---------- ゲーム共通 ---------- */
#gameui { position: absolute; inset: 0; pointer-events: none; }
#gameui > * { pointer-events: auto; }
.hint { position: absolute; left: 50%; transform: translateX(-50%); padding: 8px 18px; border-radius: 99px; background: rgba(20, 8, 52, .8); box-shadow: 0 0 0 2px rgba(255,226,122,.7) inset; font-size: 16px; text-align: center; max-width: 92vw; pointer-events: none !important; }
.hint.pop { animation: floatc 1.4s ease-in-out infinite; }
#flash { position: fixed; inset: 0; z-index: 30; pointer-events: none; background: #fff; opacity: 0; }
#flash.on { animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: .85; } 100% { opacity: 0; } }
#toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%) translateY(30px); opacity: 0; z-index: 45; padding: 10px 20px; border-radius: 99px; background: rgba(20,8,52,.9); box-shadow: 0 0 0 2px rgba(255,226,122,.8) inset; pointer-events: none; transition: .3s; font-size: 16px; }
#toast.on { opacity: 1; transform: translateX(-50%); }

/* ---------- 0枚 ---------- */
#zero { background: rgba(8, 2, 28, .72); }
.zero-card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(90vw, 420px); padding: 26px 22px 28px; border-radius: 28px; text-align: center; background: var(--panel); box-shadow: 0 0 0 4px rgba(255,226,122,.8) inset, 0 14px 40px rgba(0,0,0,.6); }
.zero-card h2 { margin: 0 0 8px; font-family: var(--logo); font-weight: 400; font-size: 34px; color: var(--gold1); text-shadow: 0 3px 0 #7a3d00; }
.zero-card .big { font-size: 20px; margin: 6px 0 10px; }
.zero-card .big b { font-size: 28px; color: var(--gold1); }
.zero-card .cnt { margin: 10px 0; font-size: 15px; }
.zero-card .cnt b { font-family: var(--logo); font-weight: 400; font-size: 34px; color: var(--cyan); letter-spacing: .05em; }
.zero-card .best { margin: 6px 0 18px; font-size: 16px; }
.zero-card .best b { color: var(--gold1); font-size: 22px; }

/* ================= 競馬 ================= */
.hk-comm { position: absolute; left: 0; right: 0; top: calc(120px + var(--safe-t)); text-align: center; pointer-events: none !important; }
.hk-comm span { display: inline-block; max-width: 92vw; padding: 8px 22px; border-radius: 14px; font-size: clamp(18px, 5vw, 26px); background: linear-gradient(rgba(10,3,40,.86), rgba(40,12,90,.86)); box-shadow: 0 0 0 3px #ffe27a inset, 0 6px 14px rgba(0,0,0,.5); animation: pop .3s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.hk-sheet { overflow-y: auto; position: absolute; left: 0; right: 0; bottom: 0; max-height: 64%; display: flex; flex-direction: column; gap: 8px; padding: 10px 10px calc(10px + var(--safe-b)); border-radius: 22px 22px 0 0; background: var(--panel); box-shadow: 0 -4px 0 rgba(255,226,122,.8), 0 -10px 30px rgba(0,0,0,.5); }
.hk-step { margin: 0; text-align: center; font-size: 15px; color: var(--gold1); }
.hk-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.hk-row { min-width: 0; display: flex; align-items: center; gap: 6px; padding: 5px 8px; border: 0; border-radius: 14px; color: #fff; text-align: left; background: rgba(255,255,255,.1); box-shadow: 0 0 0 2px rgba(255,255,255,.2) inset; min-height: 48px; }
.hk-row { position: relative; }
.hk-row.has { box-shadow: 0 0 0 2px #7dffb0 inset; }
.hk-row.sel { background: rgba(255, 210, 60, .3); box-shadow: 0 0 0 3px var(--gold1) inset, 0 0 14px rgba(255,210,60,.7); }
.hk-no { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; font-weight: 900; box-shadow: 0 0 0 2px #fff inset; }
.hk-nm { flex: 1; min-width: 0; line-height: 1.15; }
.hk-nm b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hk-nm .l2 { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.hk-nm i { font-style: normal; font-size: 11px; color: #ffd24a; letter-spacing: .02em; white-space: nowrap; }
.hk-nm em { font-style: normal; font-size: 11px; white-space: nowrap; }
.hk-nm em strong { font-size: 19px; color: var(--gold1); font-family: var(--logo); font-weight: 400; margin-left: 1px; }
.hk-bets { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.hk-bet { flex: 1 1 0; min-width: 52px; max-width: 90px; border: 0; padding: 8px 4px; border-radius: 14px; font-size: 18px; color: #fff; background: rgba(255,255,255,.12); box-shadow: 0 0 0 2px rgba(255,255,255,.3) inset; min-height: 48px; }
.hk-bet.sel { background: linear-gradient(#fff2a8, var(--gold2)); color: #4a2400; box-shadow: 0 0 0 3px #fff inset, 0 0 12px rgba(255,210,60,.8); }
.hk-bet[disabled] { opacity: .3; }
.hk-sum { margin: 0; text-align: center; font-size: 15px; min-height: 80px; }
.hk-sheet > * { flex-shrink: 0; }
.hk-top { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.hk-top > * { flex-shrink: 0; }
.hk-lf { flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.hk-bt { padding: 0 6px; border-radius: 10px; font-size: 11px; line-height: 16px; font-weight: 900; color: #3a2400; background: #7dffb0; white-space: nowrap; }
.hk-bet.hk-cx { font-size: 14px; max-width: 110px; min-width: 70px; }
.hk-bl { font-size: 14px; line-height: 1.5; margin: 6px 0; text-align: left; display: inline-block; }
.hk-sum b { color: var(--gold1); font-size: 18px; }
.hk-result { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); width: min(92vw, 440px); text-align: center; padding: 18px 16px 20px; border-radius: 26px; background: var(--panel); box-shadow: 0 0 0 4px var(--gold1) inset, 0 14px 40px rgba(0,0,0,.6); animation: pop .35s ease-out; }
.hk-result h2 { margin: 0; font-family: var(--logo); font-weight: 400; font-size: clamp(24px, 7.5vw, 34px); color: var(--gold1); text-shadow: 0 3px 0 #7a3d00; }
.hk-result.lose h2 { color: #9fd0ff; text-shadow: 0 3px 0 #1b3a66; }
.hk-result p { margin: 6px 0; font-size: 18px; }
.hk-result .rk { text-align: left; font-size: 14px; margin: 8px auto; display: inline-block; line-height: 1.5; }
.hk-result .hk-bl, .hk-result .rk { display: block; width: fit-content; max-width: 100%; margin: 8px auto; }
.hk-result .btns { display: flex; gap: 10px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.hk-result .btns .btn { font-size: 17px; padding: 10px 20px; }
.hk-won { position: absolute; left: 0; right: 0; top: calc(192px + var(--safe-t)); text-align: center; pointer-events: none !important; }
.hk-won .t { font-family: var(--logo); font-size: clamp(30px, 9vw, 52px); color: var(--gold1); -webkit-text-stroke: 2px #7a3d00; paint-order: stroke fill; text-shadow: 0 4px 0 #ff8a00; animation: pop .4s ease-out; }
.hk-won .n { font-family: var(--logo); font-size: clamp(34px, 10vw, 64px); color: #fff; text-shadow: 0 4px 0 #6a35ff, 0 0 20px rgba(255,226,122,.9); }
.hk-skip { position: absolute; right: 12px; bottom: calc(14px + var(--safe-b)); font-size: 15px; padding: 8px 18px; min-height: 40px; }

@media (min-width: 900px) and (min-height: 560px) {
  .hk-sheet { left: auto; right: 16px; bottom: 16px; width: 420px; max-height: none; border-radius: 22px; box-shadow: 0 0 0 3px rgba(255,226,122,.8) inset, 0 10px 30px rgba(0,0,0,.5); }
  .hk-list { grid-template-columns: 1fr; }
  .hk-result { top: 40%; }
}

/* ================= メダル落とし ================= */
.pu-hint { bottom: calc(26px + var(--safe-b)); }
.pu-count { position: absolute; right: 12px; bottom: calc(14px + var(--safe-b)); padding: 6px 14px; border-radius: 99px; background: rgba(20,8,52,.78); font-size: 14px; box-shadow: 0 0 0 2px rgba(255,226,122,.7) inset; pointer-events: none !important; }
.pu-plus { position: fixed; z-index: 25; font-family: var(--logo); font-size: 26px; color: var(--gold1); text-shadow: 0 2px 0 #7a3d00, 0 0 10px #000; pointer-events: none; animation: rise 1s ease-out forwards; }
@keyframes rise { to { transform: translateY(-60px); opacity: 0; } }
.pu-roul { position: absolute; left: 50%; top: calc(124px + var(--safe-t)); transform: translateX(-50%); width: min(46vw, 190px); text-align: center; pointer-events: none !important; }
.pu-roul canvas { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 10px rgba(0,0,0,.6)); }
.pu-roul .msg { margin-top: 2px; font-size: 18px; text-shadow: 0 2px 6px #000; }
.pu-big { position: fixed; left: 0; right: 0; top: 36%; z-index: 26; text-align: center; font-family: var(--logo); font-size: clamp(44px, 14vw, 110px); color: var(--gold1); -webkit-text-stroke: 4px #7a3d00; paint-order: stroke fill; text-shadow: 0 6px 0 #ff3d9a, 0 12px 0 #7a0a48; pointer-events: none; animation: bigpop 2.4s ease-out forwards; }
@keyframes bigpop { 0% { transform: scale(.2) rotate(-12deg); opacity: 0; } 15% { transform: scale(1.15) rotate(-3deg); opacity: 1; } 25% { transform: scale(1) rotate(-3deg); } 85% { opacity: 1; } 100% { transform: scale(1.05) rotate(-3deg); opacity: 0; } }
.confetti { position: fixed; top: -20px; width: 10px; height: 16px; z-index: 24; pointer-events: none; animation: conf 3s linear forwards; }
@keyframes conf { to { transform: translateY(110vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) { .btn.huge, .logo .l1, .lobby-msg { animation: none; } }

/* 競馬：レース中の順位（TV 中継のように） */
.hk-rank { position: absolute; left: 8px; top: calc(190px + var(--safe-t)); display: flex; flex-direction: column; gap: 4px; pointer-events: none !important; }
.hk-rank .rk { position: relative; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; font-weight: 900; box-shadow: 0 0 0 3px #fff inset, 0 2px 6px rgba(0,0,0,.5); text-shadow: 0 1px 3px #000; transition: transform .2s; }
.hk-rank .rk small { position: absolute; left: -2px; top: -6px; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; background: #1a0b3d; color: var(--gold1); font-size: 11px; text-align: center; box-shadow: 0 0 0 1px var(--gold1); }
.hk-rank .rk.me { transform: scale(1.18); box-shadow: 0 0 0 3px var(--gold1) inset, 0 0 0 4px #000, 0 0 14px rgba(255,226,122,.9); }
/* 高さの低い画面：順位の丸の列は上にずらして、6位まで画面に入れる */
@media (max-height: 480px) { .hk-rank { top: calc(60px + var(--safe-t)); gap: 3px; } .hk-rank .rk { width: 30px; height: 30px; font-size: 16px; } }

/* ---------- 直し（折り返し・空の枠・タイトルの演出） ---------- */
.gameui-in { display: contents; }
.pu-count:empty { display: none; }
.chip, .btn, .card .go, .pill, .hk-bet, .hk-won .t, .hk-won .n { white-space: nowrap; }
#title.leaving .tag, #title.leaving .note, #title.leaving .foot, #title.leaving .btn { opacity: 0; transition: opacity .5s; pointer-events: none; }
#title.leaving .logo { animation: logoGo 2.6s ease-in-out forwards; }
@keyframes logoGo { 0% { transform: rotate(-3deg) scale(1); } 25% { transform: rotate(0deg) scale(1.18); filter: drop-shadow(0 0 28px rgba(255,226,122,.95)); } 60% { transform: rotate(0deg) scale(1.12); filter: drop-shadow(0 0 40px rgba(255,61,154,.9)); } 100% { transform: rotate(-3deg) scale(.6) translateY(-80px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #title.leaving .logo { animation: none; opacity: .6; } }

/* せまい画面（幅 430px 以下）では上の表示を小さくして、はみ出さないようにする */
@media (max-width: 430px) {
  #hud { grid-template-columns: auto 1fr auto; gap: 4px; padding-left: 6px; padding-right: 6px; }
  .pills { justify-self: center; }
  .chip { padding: 6px 9px; font-size: 13px; min-height: 40px; }
  .chip.back { font-size: 14px; }
  .pill { padding: 4px 10px; gap: 4px; }
  .pill b { font-size: 20px; }
  .pill .lbl { font-size: 11px; }
  .pill.best { padding: 2px 8px; }
  .pill.best b { font-size: 15px; }
  .hk-nm .l2 { flex-wrap: wrap; row-gap: 0; }
  .hk-nm em { margin-left: auto; }
@media (max-width: 380px) {
  .chip.snd span { display: none; }
}
}
/* よこ長の画面のロビー：コインの表示を左に寄せて、まん中の 3D の看板に重ならないようにする */
@media (min-aspect-ratio: 5/4) {
  body.hud-on:not(.in-game) #hud { grid-template-columns: auto 1fr auto; }
  body.hud-on:not(.in-game) #btn-back { display: none; }
  body.hud-on:not(.in-game) .pills { grid-column: 1; grid-row: 1; justify-self: start; align-items: flex-start; }
  body.hud-on:not(.in-game) .chip.snd { grid-column: 3; grid-row: 1; }
  .lobby-top { justify-content: flex-start; padding-left: 10px; top: calc(92px + var(--safe-t)); }
}

/* 負けた結果の画面：下まで続く背景（夕ぐれ色のグラデーションと、ひかるコインのもよう） */
.hk-lose-bg { position: absolute; inset: 0; pointer-events: none !important; background: radial-gradient(circle at 50% 78%, rgba(255,210,90,.18) 0 2px, transparent 3px) 0 0 / 46px 46px, linear-gradient(rgba(18,7,46,.15) 0%, rgba(40,14,96,.72) 48%, #1a0b3d 100%); }

/* 小さな画面：ひとことの表示を細く折り返さず、結果のカードが上の表示に重ならないようにする */
.hint { width: max-content; }
#toast { width: max-content; max-width: 92vw; text-align: center; }
@media (max-width: 380px) and (max-height: 700px) { .hk-result { top: 52%; } }

/* けいば：高さの低い横長の画面（844x390 ほか）。出走表を右がわにまとめ、馬の一覧が見えるようにする */
@media (max-height: 500px) and (min-aspect-ratio: 5/4) {
  .hk-sheet { left: auto; right: 8px; bottom: 3px; width: min(440px, 56vw); max-height: calc(100% - 92px); gap: 3px; padding: 3px 10px; border-radius: 16px; box-shadow: 0 0 0 3px rgba(255,226,122,.8) inset, 0 10px 30px rgba(0,0,0,.5); }
  .hk-top { flex: 0 0 auto; min-height: 0; overflow: visible; gap: 3px; }
  .hk-step { font-size: 14px; line-height: 16px; }
  .hk-list { gap: 4px; }
  .hk-row { padding: 2px 6px; }
  .hk-lf { gap: 0; }
  .hk-no { width: 24px; height: 24px; font-size: 14px; }
  .hk-bt { line-height: 14px; }
  .hk-nm b { font-size: 14px; }
  .hk-nm em strong { font-size: 16px; }
  .hk-bet { min-height: 32px; padding: 2px; font-size: 16px; }
  .hk-bet.hk-cx { font-size: 14px; }
  .hk-sum { min-height: 0; font-size: 14px; line-height: 1.2; }
  #hk-go { min-height: 36px; padding: 3px 24px; font-size: 18px; }
}
