/* 핀 천둥 — HUD·화면. 글자와 터치 타깃은 전부 DOM(월드만 캔버스).
   터치 타깃 ≥ 44 px · 대비 4.5:1 · 세로 360×640 부터(D37). 폰트는 자체 호스팅(CDN 0 — D30). */
@font-face {
  font-family: 'PinThunder';
  src: url('../assets/fonts/pt-sans.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
:root {
  --bg: #0f1220;
  --panel: #191d2f;
  --panel2: #232840;
  --ink: #f4f6ff;
  --ink-dim: #b9c0d8;
  --accent: #ffc65c;
  --accent2: #59e0d0;
  --danger: #ff6b6b;
  --ok: #6ee7a0;
  --radius: 14px;
  --tap: 44px;
  --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 {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: 'PinThunder', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#input-plate { position: fixed; inset: 0; z-index: 2; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }

/* ── HUD ───────────────────────────────────────────────── */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: calc(8px + var(--safe-t)) 10px calc(10px + var(--safe-b)); }
#hud[hidden] { display: none; }
#hud button, #hud .predict-opts { pointer-events: auto; }

.hud-top { display: flex; gap: 8px; align-items: flex-start; }
.chip { display: flex; align-items: center; gap: 6px; background: rgba(16,19,34,.82); border: 1px solid #39405e; border-radius: 999px; padding: 8px 14px; min-height: var(--tap); font-weight: 700; font-size: 15px; }
.chip .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex: none; }
.icon-btn { min-width: var(--tap); min-height: var(--tap); border-radius: 12px; background: rgba(16,19,34,.82); border: 1px solid #39405e; font-size: 15px; letter-spacing: 2px; }

.sheet { flex: 1; display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; background: rgba(16,19,34,.82); border: 1px solid #39405e; border-radius: 12px; padding: 4px; min-height: var(--tap); }
.sheet::-webkit-scrollbar { display: none; }
.sheet .fr { min-width: 40px; flex: none; text-align: center; border-right: 1px solid #333a55; padding: 0 3px; }
.sheet .fr:last-child { border-right: 0; }
.sheet .fr .n { font-size: 10px; color: var(--ink-dim); }
.sheet .fr .r { font-size: 12px; font-weight: 700; letter-spacing: 1px; min-height: 15px; }
.sheet .fr .s { font-size: 13px; color: var(--accent); font-weight: 800; }
.sheet .fr.cur { background: #2b3252; border-radius: 7px; }
.sheet .tot { min-width: 56px; flex: none; text-align: center; }
.sheet .tot .s { font-size: 17px; }

.hud-mid { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.toast { background: rgba(10,12,22,.9); border: 1px solid #4a5478; border-radius: 12px; padding: 10px 16px; font-weight: 700; text-align: center; max-width: 88vw; }
.toast[hidden] { display: none; }
.toast.big { font-size: clamp(22px, 8vw, 46px); font-weight: 900; letter-spacing: 2px; color: var(--accent); border-color: var(--accent); text-shadow: 0 0 22px rgba(255,198,92,.6); }

.thunder { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; background: rgba(16,19,34,.82); border: 1px solid #6a5a2c; border-radius: 999px; padding: 4px 6px 4px 12px; }
.thunder[hidden] { display: none; }
.thunder-bar { width: 76px; height: 8px; border-radius: 4px; background: #2a2f47; overflow: hidden; }
.thunder-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #ffd35c, #ff8a3d); }
.thunder-btn { min-height: var(--tap); border-radius: 999px; padding: 0 14px; background: #3b3520; border: 1px solid #7b6a30; font-weight: 800; font-size: 14px; }
.thunder-btn.on { background: var(--accent); color: #241c04; }

.ai-gauge { background: rgba(16,19,34,.82); border: 1px solid #39405e; border-radius: 12px; padding: 8px 12px; width: min(280px, 80vw); }
.ai-gauge[hidden] { display: none; }
/* 🔴 폭을 주지 않으면 .hud-bottom(align-items:center) 안에서 내용 폭으로 쪼그라들어
   파워·스핀 막대가 «실 한 오라기»가 된다 — 배포 화면 실측. 판을 깔고 폭을 준다. */
#gauges { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; width: min(440px, 80vw);
  background: rgba(16,19,34,.72); border: 1px solid #39405e; border-radius: 12px; padding: 8px 12px; }
.g-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink); }
.g-row span { width: 38px; flex: none; }
.g-bar { flex: 1; height: 12px; border-radius: 5px; background: rgba(16,19,34,.85); border: 1px solid #39405e; overflow: hidden; position: relative; }
.g-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.g-bar.center i { position: absolute; left: 50%; width: 0%; background: var(--accent2); }

.hud-bottom { display: flex; flex-direction: column; align-items: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pill { min-height: var(--tap); padding: 0 18px; border-radius: 999px; background: rgba(25,29,47,.9); border: 1px solid #454d70; font-weight: 700; font-size: 15px; }
.pill.wide { flex: 1; min-width: 160px; }
.pill.on { background: var(--accent); color: #241c04; border-color: var(--accent); }
.pill[hidden] { display: none; }

.ready-card { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(10,12,22,.93); pointer-events: auto; }
.ready-card[hidden] { display: none; }
.ready-inner { text-align: center; padding: 24px; }
#ready-name { font-size: clamp(26px, 9vw, 48px); font-weight: 900; margin-bottom: 22px; }
.big-btn { min-height: 56px; padding: 0 34px; border-radius: 16px; background: var(--accent); color: #241c04; font-weight: 900; font-size: 19px; }
.hint { margin-top: 14px; color: var(--ink-dim); font-size: 14px; }

.predict { position: absolute; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); background: rgba(16,19,34,.92); border: 1px solid #454d70; border-radius: 14px; padding: 10px 12px; text-align: center; }
.predict[hidden] { display: none; }
.predict-title { font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; }
.predict-opts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 86vw; }
.predict-opts button { min-width: var(--tap); min-height: var(--tap); border-radius: 10px; background: #2b3252; border: 1px solid #454d70; font-weight: 700; }

/* ── 화면 ───────────────────────────────────────────────── */
#screens { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; gap: 14px; padding: calc(18px + var(--safe-t)) 16px calc(18px + var(--safe-b)); overflow-y: auto; background: linear-gradient(180deg, rgba(9,11,20,.93), rgba(9,11,20,.97)); pointer-events: auto; }
.screen.active { display: flex; }
.screen h2 { margin: 0; font-size: clamp(20px, 6vw, 28px); }
.logo { font-size: clamp(34px, 12vw, 64px); font-weight: 900; letter-spacing: -1px; margin: 8px 0 0; text-align: center; line-height: 1.05; }
.logo span { display: block; font-size: 0.28em; letter-spacing: 6px; color: var(--accent); font-weight: 700; margin-top: 6px; }
.logo.small { font-size: clamp(26px, 9vw, 44px); }

.boot { margin: auto; text-align: center; width: min(420px, 88vw); }
.bar { height: 8px; border-radius: 4px; background: #232840; overflow: hidden; margin: 20px 0 10px; }
.bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .25s; }
#boot-msg { color: var(--ink-dim); font-size: 14px; }

.cards { display: flex; flex-direction: column; gap: 10px; }
.card { text-align: left; background: var(--panel); border: 1px solid #39405e; border-radius: var(--radius); padding: 14px 16px; min-height: 68px; }
.card b { display: block; font-size: 19px; }
.card small { color: var(--ink-dim); }
.card:active { background: var(--panel2); }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.col { flex-direction: column; align-items: stretch; }
.tiny { color: var(--ink-dim); font-size: 12px; margin: 2px 0 0; }

.setup-grid { display: flex; flex-direction: column; gap: 12px; }
.fld label { display: block; font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; }
.fld[hidden] { display: none; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { min-height: var(--tap); padding: 0 14px; border-radius: 10px; background: var(--panel); border: 1px solid #39405e; font-weight: 700; font-size: 14px; }
.seg button.on { background: var(--accent); color: #241c04; border-color: var(--accent); }

.balls { display: flex; gap: 8px; flex-wrap: wrap; }
.balls button { width: var(--tap); height: var(--tap); border-radius: 50%; border: 3px solid transparent; }
.balls button.on { border-color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips .chip-btn { min-height: var(--tap); padding: 0 12px; border-radius: 999px; background: var(--panel); border: 1px solid #39405e; font-weight: 700; font-size: 14px; }
.chips .chip-btn.on { border-color: var(--accent); background: #333020; }

.doc { background: var(--panel); border: 1px solid #39405e; border-radius: var(--radius); padding: 14px; font-size: 14px; line-height: 1.7; }
.doc h3 { margin: 14px 0 6px; font-size: 15px; color: var(--accent); }
.doc p, .doc li { color: var(--ink-dim); }
.doc ul { padding-left: 18px; margin: 4px 0; }

.rank-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rank-table th, .rank-table td { padding: 8px 6px; border-bottom: 1px solid #2b3050; text-align: left; }
.rank-table td.sc { text-align: right; font-weight: 800; color: var(--accent); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid #454d70; color: var(--ink-dim); }
.badge.ok { color: #0d1a12; background: var(--ok); border-color: var(--ok); }
.badge.wait { color: var(--accent); border-color: var(--accent); }

.res-card { background: var(--panel); border: 1px solid #39405e; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 12px; }
.res-card .rk { font-size: 22px; font-weight: 900; width: 34px; text-align: center; }
.res-card .nm { flex: 1; font-weight: 700; }
.res-card .sc { font-size: 24px; font-weight: 900; color: var(--accent); }
.res-card .sub { font-size: 12px; color: var(--ink-dim); font-weight: 400; }
.chk { display: flex; align-items: center; gap: 8px; min-height: var(--tap); color: var(--ink-dim); }
.chk input { width: 22px; height: 22px; }

#fatal { position: fixed; inset: 0; z-index: 99; background: #10121f; color: #ffd7d7; padding: 24px; font: 14px/1.6 ui-monospace, monospace; overflow: auto; }
#fatal[hidden] { display: none; }

@media (min-width: 720px) {
  .cards { flex-direction: row; }
  .card { flex: 1; }
  .screen { padding-left: max(16px, calc((100vw - 760px) / 2)); padding-right: max(16px, calc((100vw - 760px) / 2)); }
}
@media (prefers-reduced-motion: reduce) {
  .bar i { transition: none; }
}

/* 남은 핀 미니 표시 — 조준 시점에서 18 m 앞의 핀은 화면 가로의 4 % 라 «어느 핀이 남았는지»가 안 보인다.
   두 번째 투구(스페어)는 그 정보가 없으면 겨눌 수가 없다. 배포 화면 실측 후 추가. */
#pin-view { width: 66px; height: 56px; flex: none; align-self: flex-start; border-radius: 10px;
  background: rgba(16,19,34,.82); border: 1px solid #39405e; }
#pin-view[hidden] { display: none; }
@media (max-width: 400px) { #pin-view { width: 54px; height: 46px; } }

.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 0 0 auto; min-width: 118px; }
#practice-chip { display: none; align-items: center; gap: 8px; background: rgba(16,19,34,.82); border: 1px solid #39405e;
  border-radius: 999px; padding: 8px 14px; min-height: var(--tap); font-weight: 700; font-size: 15px; }
#practice-chip.on { display: flex; }
