/* hg-hud / chips */
hg-hud { display: flex; align-items: center; gap: var(--s-2); min-height: var(--hud-h); }
hg-chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow-1); font-weight: 600; font-size: .95rem; }
hg-chip .chip-ic { display: inline-flex; color: var(--ink-2); } hg-chip .icon { width: 18px; height: 18px; }
hg-chip[tone="bad"] { color: var(--bad); } hg-chip[tone="ok"] { color: var(--ok); }
hg-timer[urgent] { color: var(--bad); animation: pulse .8s infinite; border-radius: var(--r-pill); }

/* hg-sheet */
hg-sheet { position: fixed; inset: 0; z-index: 50; display: block; }
.sheet-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / .45); backdrop-filter: blur(3px); animation: fade var(--t-base); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow: auto; background: var(--surface); color: var(--ink);
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: var(--s-2) var(--gutter) max(var(--s-5), env(safe-area-inset-bottom)); box-shadow: var(--shadow-3);
  animation: sheet-up var(--t-slow) var(--ease-out);
}
hg-sheet[closing] .sheet-panel { animation: sheet-down var(--t-base) var(--ease-in) forwards; } hg-sheet[closing] .sheet-backdrop { opacity: 0; transition: opacity var(--t-base); }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-down { to { transform: translateY(100%); } }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }
.sheet-title { font-size: 1.4rem; }
.sheet-body { display: flex; flex-direction: column; gap: var(--s-3); }
@media (min-width: 640px) {
  .sheet-panel { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(520px, 92vw); border-radius: var(--r-lg); animation: sheet-in var(--t-base) var(--ease-out); }
  .sheet-handle { display: none; }
  hg-sheet[closing] .sheet-panel { animation: sheet-out var(--t-base) var(--ease-in) forwards; }
  @keyframes sheet-in { from { opacity: 0; transform: translate(-50%, -48%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%); } }
  @keyframes sheet-out { to { opacity: 0; transform: translate(-50%, -48%) scale(.97); } }
}

/* toast */
.toast-host { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r-md); font-weight: 600; box-shadow: var(--shadow-2); animation: rise-fade var(--t-base) var(--ease-out); max-width: 92vw; text-align: center; }
.toast[leaving] { opacity: 0; transition: opacity var(--t-base); }
.toast[data-type="bad"] { background: var(--bad); color: #fff; } .toast[data-type="ok"] { background: var(--ok); color: #fff; }

/* score reveal */
hg-score-reveal { display: block; text-align: center; }
.score-total { font-family: var(--font-display); font-size: clamp(3rem, 14vw, 5rem); line-height: 1; font-weight: 700; }
.score-rows { list-style: none; padding: 0; margin: var(--s-4) 0 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.score-rows li { display: flex; justify-content: space-between; padding: 8px 12px; background: var(--surface-2); border-radius: var(--r-sm); opacity: 0; }
hg-score-reveal[done] .score-rows li { animation: rise-fade var(--t-base) var(--ease-out) forwards; animation-delay: calc(var(--i) * 70ms); }

/* confetti */
hg-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; } hg-confetti canvas { display: block; }

/* leaderboard */
hg-leaderboard { display: flex; flex-direction: column; gap: var(--s-4); }
.lb-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.lb-tab { flex: 0 0 auto; height: 40px; padding: 0 16px; border-radius: var(--r-pill); background: var(--surface-2); font-weight: 600; }
.lb-tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.lb-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.lb-stats div { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.lb-stats b { font-size: 1.15rem; } .lb-stats span { font-size: .72rem; color: var(--ink-2); }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; padding: 10px 12px; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-1); animation: rise-fade var(--t-base) both; animation-delay: calc(var(--i) * 40ms); }
.lb-row[data-me="true"] { outline: 2px solid var(--accent); }
.lb-rank { font-weight: 700; text-align: center; } .lb-desc { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .lb-time { color: var(--ink-2); font-size: .85rem; } .lb-score { font-size: 1.05rem; }
.lb-empty { color: var(--ink-2); text-align: center; padding: var(--s-6) 0; }

/* settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 44px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r-pill); padding: 3px; }
.seg [role="radio"] { height: 34px; padding: 0 14px; border-radius: var(--r-pill); font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.seg [aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
input[role="switch"] { appearance: none; width: 48px; height: 28px; border-radius: 14px; background: var(--line); position: relative; cursor: pointer; transition: background var(--t-base); margin: 0; }
input[role="switch"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform var(--t-base) var(--ease-out); box-shadow: var(--shadow-1); }
input[role="switch"]:checked { background: var(--accent); } input[role="switch"]:checked::after { transform: translateX(20px); }
.set-input { width: 150px; height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 2px solid var(--line); background: var(--surface-2); }
.set-danger { color: var(--bad); margin-top: var(--s-3); }

.set-range { width: 150px; accent-color: var(--accent); }
