/* components.css — reusable pieces: header, panels, form controls, buttons,
   balls, sheets, toasts, the shot clock. */
/* ── header ── */
.top { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.top h1 { flex: 1; margin: 0; font-size: 20px; font-weight: 900; letter-spacing: -.2px; text-wrap: balance; }
.top h1 small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.iconbtn { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--glass-2); border: 1px solid var(--line); flex-shrink: 0; transition: transform .15s var(--ease), background .2s; }
.iconbtn:active { transform: scale(.92); }
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn.on { background: var(--brass); color: var(--rail); border-color: transparent; }

/* ── generic panels / controls ── */
.panel { background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 14px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.lbl { font-size: 13px; font-weight: 700; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 8px; }
.txt { width: 100%; border-radius: 14px; border: 1px solid var(--line); background: rgba(244,239,227,.07); padding: 12px 14px; font-weight: 600; font-size: 16px; min-width: 0; }
.txt::placeholder { color: rgba(244,239,227,.35); }
.prow { display: flex; gap: 8px; align-items: center; }
.prow .dot { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-weight: 900; font-size: 13px; color: var(--rail); }
.prow .hcp { width: 76px; flex-shrink: 0; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 14px; border-radius: 999px; background: var(--glass-2); border: 1px solid var(--line); font-weight: 700; font-size: 14px; transition: background .2s, color .2s, transform .15s; }
.chip:active { transform: scale(.95); }
.chip.on { background: var(--ivory); color: var(--rail); border-color: transparent; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button { width: 44px; height: 44px; border-radius: 50%; background: var(--glass-2); border: 1px solid var(--line); font-size: 22px; font-weight: 700; }
.stepper button:disabled { opacity: .3; }
.stepper b { font-size: 26px; font-weight: 900; min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; text-align: start; width: 100%; }
.switch span { font-weight: 600; font-size: 15px; }
.switch small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.switch i { width: 50px; height: 30px; border-radius: 99px; background: rgba(244,239,227,.18); position: relative; flex-shrink: 0; transition: background .25s; }
.switch i::after { content: ""; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .25s var(--spring); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.switch.on i { background: var(--good); }
.switch.on i::after { transform: translateX(-20px); }
.rules { font-size: 13px; color: var(--muted); line-height: 1.9; margin: 0; padding-inline-start: 18px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 15px 16px; border-radius: 18px; font-weight: 900; font-size: 17px;
  background: var(--ivory); color: var(--rail); transition: transform .15s var(--ease), opacity .2s; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .35; }
.btn.brass { background: linear-gradient(135deg, #e8c779, var(--brass) 60%, #b98f3c); }
.btn.ghost { background: var(--glass-2); color: var(--ivory); border: 1px solid var(--line); box-shadow: none; font-weight: 700; font-size: 15px; padding: 13px; }
.btn.bad { background: var(--bad); color: #fff; }
.btn svg { width: 20px; height: 20px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* ── balls ── */
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 10px; justify-items: center; }
.pad.pool { grid-template-columns: repeat(5, 1fr); gap: 10px 8px; }
.ball { --c: #c8202a; position: relative; width: 100%; max-width: 74px; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, rgba(255,255,255,.55), transparent 22%), radial-gradient(circle at 60% 65%, var(--c), color-mix(in srgb, var(--c) 55%, #000) 95%);
  box-shadow: 0 8px 16px rgba(0,0,0,.4), inset -6px -8px 14px rgba(0,0,0,.35);
  display: grid; place-items: center; transition: transform .18s var(--spring), opacity .3s, filter .3s; }
.ball:active { transform: scale(.88); }
.ball span { width: 46%; aspect-ratio: 1; border-radius: 50%; background: #fbf8f0; color: #151515; display: grid; place-items: center; font-weight: 900; font-size: clamp(13px, 4.2vw, 19px); font-family: system-ui, sans-serif; box-shadow: inset 0 -2px 3px rgba(0,0,0,.15); }
.ball.stripe { background:
  radial-gradient(circle at 34% 30%, rgba(255,255,255,.55), transparent 22%),
  linear-gradient(180deg, #f4efe3 0 24%, transparent 24% 76%, #f4efe3 76%),
  radial-gradient(circle at 60% 65%, var(--c), color-mix(in srgb, var(--c) 55%, #000) 95%); }
.ball:disabled { opacity: .22; filter: grayscale(.7); }
.ball.next { animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 0%, 100% { box-shadow: 0 8px 16px rgba(0,0,0,.4), inset -6px -8px 14px rgba(0,0,0,.35), 0 0 0 0 rgba(217,178,95,.0); } 50% { box-shadow: 0 8px 16px rgba(0,0,0,.4), inset -6px -8px 14px rgba(0,0,0,.35), 0 0 0 6px rgba(217,178,95,.45); } }
.ball.gone { opacity: .18; filter: grayscale(1); transform: scale(.82); }
.ball.free { outline: 3px dashed var(--chalk); outline-offset: 4px; }
.ball .who { position: absolute; bottom: -4px; inset-inline-end: -4px; min-width: 20px; height: 20px; border-radius: 99px; font-size: 11px; font-weight: 900; display: grid; place-items: center; background: var(--brass); color: var(--rail); padding: 0 5px; }
.ghostball { width: 100%; max-width: 74px; aspect-ratio: 1; border-radius: 50%; border: 2px dashed rgba(244,239,227,.3); display: grid; place-items: center; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); line-height: 1.3; transition: transform .15s; }
.ghostball:active { transform: scale(.9); }
.ghostball:disabled { opacity: .3; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin: 0; min-height: 1.5em; }
.flyball { position: fixed; z-index: 56; border-radius: 50%; pointer-events: none; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .wide { grid-column: 1 / -1; }
.act { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 14px 8px; border-radius: 16px; font-weight: 700; font-size: 15px; background: var(--glass-2); border: 1px solid var(--line); transition: transform .15s var(--ease); }
.act:active { transform: scale(.96); }
.act:disabled { opacity: .3; }
.act svg { width: 19px; height: 19px; }
.act.main { background: var(--ivory); color: var(--rail); border-color: transparent; font-weight: 900; }
.act.foul { background: rgba(255,107,91,.18); border-color: rgba(255,107,91,.45); color: #ffb3aa; }

/* ── shot clock ── */
.clock { position: relative; width: 46px; height: 46px; flex-shrink: 0; }
.clock svg { width: 46px; height: 46px; transform: rotate(-90deg); }
.clock circle { fill: none; stroke-width: 4; }
.clock .tr { stroke: rgba(244,239,227,.15); }
.clock .vl { stroke: var(--good); stroke-linecap: round; transition: stroke-dashoffset .25s linear, stroke .3s; }
.clock b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; font-weight: 900; font-variant-numeric: tabular-nums; }
.clock.low .vl { stroke: var(--bad); }
.clock.low b { color: var(--bad); animation: pulse .5s ease-in-out infinite alternate; }
.clock.out { animation: shake .4s; }
@keyframes pulse { to { transform: scale(1.15); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ── sheets ── */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; background: rgba(2, 12, 8, .6); animation: fade .25s; }
.sheet .body { width: 100%; max-width: 540px; max-height: 88dvh; overflow-y: auto; border-radius: 28px 28px 0 0; background: linear-gradient(180deg, #154b37, #0c3324);
  border-top: 1px solid rgba(244,239,227,.15); padding: 10px max(18px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px; animation: up .38s var(--ease); }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: rgba(244,239,227,.25); margin: 0 auto 4px; }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 900; }
.sheet p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }


/* ── small helpers ── */
.ball.mini { width: 46px; height: 46px; max-width: none; flex-shrink: 0; box-shadow: 0 4px 10px rgba(0,0,0,.35), inset -4px -5px 9px rgba(0,0,0,.35); }
.ball.mini span { font-size: 13px; }
.hitem .ball.mini { width: 38px; height: 38px; }
.hint.start { text-align: start; }
.center { text-align: center; }
.meta .bad, .meta .bad b { color: var(--bad); }

/* ── toast & flash ── */
.toast { position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 70; max-width: calc(100% - 40px);
  background: var(--ivory); color: var(--rail); padding: 11px 18px; border-radius: 14px; font-weight: 700; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: toast 2.2s var(--ease) forwards; text-align: center; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 20px); } 12%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, 10px); } }
.flash { position: fixed; inset: 0; z-index: 50; pointer-events: none; animation: flash .5s ease-out forwards; }
@keyframes flash { from { opacity: .5; } to { opacity: 0; } }


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
