/* 토큰: 값의 이유는 web/DESIGN.md 4절 */
:root {
  --bg: #0B0D10;
  --panel: rgba(11, 13, 16, 0.72);
  --panel-solid: #15181D;
  --line: rgba(255, 255, 255, 0.12);
  --text: #F5F7FA;
  --muted: #A7B0BA;
  --accent: #FF7A1A;
  --accent-ink: #1A0D02;
  --make: #22C55E;
  --miss: #F05252;
  --rim: #22D3EE;
  --r-panel: 16px;
  --r-btn: 12px;
  --gap: 12px;
  --num: clamp(44px, 13vh, 120px);
  --font: system-ui, -apple-system, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); word-break: keep-all; }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.stage { position: fixed; inset: 0; overflow: hidden; }
video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.overlay { position: absolute; left: 0; top: 0; pointer-events: none; }

/* 점수판 */
.hud {
  position: absolute; top: max(var(--gap), env(safe-area-inset-top)); left: max(var(--gap), env(safe-area-inset-left));
  right: max(var(--gap), env(safe-area-inset-right)); display: flex; justify-content: space-between; gap: var(--gap);
  pointer-events: none;
}
.board {
  background: var(--panel); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--r-panel); padding: 10px 18px 12px; min-width: 9em;
}
.board-label { font-size: 14px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); }
.board-num { font-size: var(--num); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; margin-top: 4px; }
.board-num .slash { color: var(--muted); font-weight: 600; margin: 0 0.12em; }
.board-sub { font-size: 15px; font-weight: 600; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.board-dribbles { text-align: right; }

.status {
  position: absolute; left: 50%; transform: translateX(-50%); top: max(var(--gap), env(safe-area-inset-top));
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.status.warn { color: var(--accent); }

.toast {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: clamp(40px, 12vh, 104px); font-weight: 800; padding: 0.2em 0.6em; border-radius: var(--r-panel);
  background: var(--panel); border: 3px solid currentColor; animation: fade 0.15s ease-out;
}
.toast.make { color: var(--make); }
.toast.miss { color: var(--miss); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.prompt {
  position: absolute; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--panel-solid); border: 1px solid var(--rim); color: var(--text); border-radius: var(--r-panel);
  padding: 10px 16px; font-size: 16px; font-weight: 600; max-width: calc(100% - 32px); text-align: center;
}
.rotate {
  position: absolute; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--panel-solid); border: 1px solid var(--accent); border-radius: var(--r-panel);
  padding: 10px 14px; font-size: 15px; text-align: center;
}

/* 림 확대 창 */
.loupe {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(0, 0, 0, 0.7); z-index: 7; padding: 16px;
}
.loupe canvas { border: 2px solid var(--rim); border-radius: 8px; touch-action: none; cursor: crosshair; }
.loupe-text { margin: 0; font-size: 17px; font-weight: 700; text-align: center; }

/* 도구줄 */
.toolbar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: max(var(--gap), env(safe-area-inset-bottom));
  display: flex; gap: 8px; padding: 8px; background: var(--panel); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--r-panel); max-width: calc(100% - 16px); overflow-x: auto;
}
.btn {
  min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: var(--r-btn); border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); color: var(--text); font: 600 15px/1 var(--font); white-space: nowrap; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:focus-visible { outline: 3px solid var(--rim); outline-offset: 2px; }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-size: 17px; min-height: 52px; padding: 0 22px; }
.btn-secondary { font-size: 16px; min-height: 52px; padding: 0 18px; }
.btn-ghost { background: transparent; }

/* 시작 화면 */
.start { position: absolute; inset: 0; overflow-y: auto; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 24px 16px; z-index: 10; }
.start-inner { max-width: 34em; width: 100%; }
.start h1 { font-size: clamp(30px, 6vw, 44px); margin: 0 0 12px; font-weight: 800; }
.start p { font-size: 16px; line-height: 1.5; color: var(--text); margin: 0 0 20px; }
.start-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.load-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.load-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.load-text { font-size: 14px; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }
.start-error { color: var(--miss) !important; font-weight: 600; }
.start .start-note { font-size: 14px; color: var(--muted); margin-top: 20px; }

/* 기록 시트 */
.sheet {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); background: var(--panel-solid);
  border-left: 1px solid var(--line); padding: max(16px, env(safe-area-inset-top)) 16px 16px; overflow-y: auto; z-index: 6;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-summary { color: var(--muted); font-size: 15px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.sheet-empty { color: var(--muted); font-size: 15px; }
.shot-list { list-style: none; padding: 0; margin: 0; }
.shot-list li { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 16px; font-variant-numeric: tabular-nums; }
.shot-list .make { color: var(--make); font-weight: 700; }
.shot-list .miss { color: var(--miss); font-weight: 700; }

@media (orientation: portrait) {
  .hud { flex-direction: row; }
  .board { min-width: 0; flex: 1; padding: 8px 12px 10px; }
  :root { --num: clamp(36px, 9vh, 72px); }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .load-fill { transition: none; }
}
