:root {
  --bg: #10151c; --card: #1a222d; --line: #2b3746; --text: #e8edf3; --dim: #93a1b3;
  --accent: #ff8a3d; --in: #5ed38a; --out: #ff5d5d;
  --serve: #ffb300; --forehand: #4fc3f7; --backhand: #ba68c8;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Malgun Gothic", system-ui, sans-serif; }
header { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
header h1 { margin: 0; font-size: 20px; color: var(--accent); }
.sub { color: var(--dim); font-size: 13px; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h2 { font-size: 16px; margin: 0 0 8px; }
p { margin: 6px 0; color: var(--dim); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
button, .btn { font: inherit; color: var(--text); background: #263242; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #1b1206; font-weight: bold; }
button:disabled { opacity: .4; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.list li:first-child { border-top: 0; }
.list li:hover { background: #202a37; }
.list .grow { flex: 1; min-width: 0; }
.list small { color: var(--dim); display: block; }
.del { padding: 4px 10px; font-size: 13px; }

.progress { height: 10px; background: #263242; border-radius: 5px; overflow: hidden; margin: 12px 0; }
.progress div { height: 100%; width: 0; background: var(--accent); }

.stage { background: #000; border-radius: 10px; overflow: hidden; }
canvas { display: block; width: 100%; height: auto; }
.timeline { position: relative; height: 26px; background: #263242; border-radius: 6px; margin-top: 8px; cursor: pointer; overflow: hidden; }
.timeline .rally { position: absolute; top: 0; bottom: 0; background: #3b6ea5; }
.timeline .tick { position: absolute; top: 4px; bottom: 4px; width: 2px; background: #fff; }
.timeline .tick.s1 { background: #ffb4a8; }
.timeline .head { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 10px 0 14px; color: var(--dim); font-size: 14px; }
.controls label { cursor: pointer; }
select { font: inherit; background: #263242; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { border: 0; background: none; border-radius: 0; border-bottom: 2px solid transparent; color: var(--dim); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--dim); font-size: 13px; }
.score { font-size: 26px; font-weight: bold; text-align: center; }
.score small { font-size: 13px; color: var(--dim); font-weight: normal; display: block; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--dim); font-weight: normal; }
tr.click { cursor: pointer; }
tr.click:hover { background: #202a37; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chips span { color: var(--dim); font-size: 13px; align-self: center; margin-left: 6px; }
.chip { padding: 3px 10px; font-size: 13px; border-radius: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #1b1206; }
.tag { display: inline-block; padding: 0 7px; border-radius: 9px; font-size: 12px; color: #111; }
.tag.serve { background: var(--serve); } .tag.forehand { background: var(--forehand); } .tag.backhand { background: var(--backhand); }
.in { color: var(--in); } .out { color: var(--out); } .dim { color: var(--dim); }
.map { display: block; margin: 0 auto; width: 100%; max-width: 300px; }
.legend { text-align: center; color: var(--dim); font-size: 13px; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 0 10px; }
.note { font-size: 13px; color: var(--dim); }
.roomCode { font-size: 44px; font-weight: bold; letter-spacing: 10px; text-align: center; margin: 6px 0; color: var(--accent); }

/* 앱(휴대폰) 화면 */
body { -webkit-tap-highlight-color: transparent; padding-bottom: env(safe-area-inset-bottom); }
header { padding-top: max(14px, env(safe-area-inset-top)); }
.wrap { overflow-x: auto; }
.wrap table { min-width: 420px; }
.board td, .board th { text-align: center; }
.board td:first-child { text-align: left; }
.board .pt { color: var(--accent); font-weight: bold; }
.srv { color: var(--serve); }
.replay { border-color: var(--accent); }
video.hl { display: block; width: 100%; margin: 10px 0; border-radius: 8px; background: #000; }
a.btn { text-decoration: none; }
a.btn.primary { background: var(--accent); border-color: var(--accent); color: #1b1206; font-weight: bold; }
code { background: #263242; padding: 0 4px; border-radius: 4px; }
@media (max-width: 520px) {
  main { padding: 10px; }
  .tabs { overflow-x: auto; }
  .tabs button { padding: 8px 10px; white-space: nowrap; }
  .controls { gap: 8px; }
}

/* 촬영 화면: 화면 전체를 덮고, 영상 위에 가이드선 캔버스를 겹침 */
.cam { position: fixed; inset: 0; z-index: 20; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.camBox { position: relative; flex-shrink: 0; }
.camBox video, .camBox canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.camBox video { object-fit: fill; }
.camBar { width: 100%; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); color: var(--text); text-align: center; }
.camBar #camMsg { display: block; min-height: 22px; font-size: 14px; }
.camBar .row { justify-content: center; margin-top: 6px; }
button.rec { background: #c62828; border-color: #c62828; font-weight: bold; min-width: 110px; }
button.rec.on { background: #fff; color: #c62828; }

/* 모서리 찍기: 크게 보기 = 화면 전체에 영상만 크게 */
.calib .hint { color: var(--text); font-weight: bold; }
.calib.big { position: fixed; inset: 0; z-index: 20; margin: 0; border: 0; border-radius: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; background: #000; }
.calib.big .calibHead, .calib.big .calibNote { display: none; }
.calib.big .hint { margin: 2px 0; font-size: 13px; }
.calib.big .calibStage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; border-radius: 0; }
.calib.big .row { margin-top: 4px; gap: 6px; }
.calib.big .row button { padding: 6px 10px; font-size: 13px; }
.calibScene input[type=range] { flex: 1; min-width: 120px; }
.tag.manual { background: var(--accent); }

/* hidden 속성을 단 요소는 항상 숨김 (button 에 display 를 줘서 hidden 이 무시되던 것 고침) */
[hidden] { display: none !important; }
