:root {
  --navy: #0f1b2d;
  --panel: rgba(13, 24, 42, 0.86);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f7fb;
  --muted: #9fb0c8;
  --accent: #ff6b35;
  --good: #35d69a;
  --warn: #ffd166;
  --bad: #ef476f;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--navy);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
canvas { display: block; position: fixed; inset: 0; touch-action: none; }
.hidden { display: none !important; }
b, .res-dist, .chip b { font-variant-numeric: tabular-nums; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
.hud-top {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; justify-content: space-between; gap: 8px;
}
.chip {
  display: flex; align-items: baseline; gap: 4px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 999px; font-size: 14px;
}
.chip-label { color: var(--muted); font-size: 12px; margin-right: 2px; }
.chip b { font-size: 18px; }
.chip small { color: var(--muted); font-size: 11px; }
#hud-wind-dir { font-size: 12px; margin-left: 4px; font-weight: 700; }
.head { color: var(--good); }
.tail { color: var(--bad); }

#prompt {
  position: absolute; left: 0; right: 0; top: 22%;
  text-align: center; font-size: clamp(20px, 5.5vw, 30px); font-weight: 800;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45); letter-spacing: -0.01em;
}
#feedback {
  position: absolute; left: 0; right: 0; top: 31%;
  text-align: center; font-size: clamp(26px, 8vw, 46px); font-weight: 900;
  font-style: italic; opacity: 0; transform: scale(0.9);
  transition: opacity .2s, transform .2s;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
}
#feedback.show { opacity: 1; transform: scale(1); }

.meter {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 16px));
  width: min(86vw, 420px);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 14px 14px;
}
.meter-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 600;
}
#timing .meter-label { justify-content: center; }
.meter-bar {
  position: relative; height: 16px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.12); overflow: hidden;
}
.zone { position: absolute; top: 0; bottom: 0; }
.zone-ok { background: rgba(255, 209, 102, 0.55); }
.zone-best { background: var(--good); }
.zone-danger { background: var(--bad); right: 0; }
.needle {
  position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px;
  background: #fff; border-radius: 2px; box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}

/* ---------- 패널 ---------- */
.panel {
  position: fixed; inset: 0; overflow-y: auto;
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(8, 16, 30, 0.35), rgba(8, 16, 30, 0.6));
  -webkit-user-select: text; user-select: text;
}
.panel-inner {
  width: 100%; max-width: 400px; margin: auto 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 22px; padding: 24px 20px 20px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.eyebrow { font-size: 11px; letter-spacing: 0.16em; color: var(--accent); font-weight: 800; text-align: center; }
h1 {
  font-size: 46px; font-weight: 900; font-style: italic; letter-spacing: -0.03em;
  text-align: center; margin: 4px 0 16px; line-height: 1;
}
h2 { font-size: 15px; margin: 18px 0 8px; }
.howto { list-style: none; display: grid; gap: 8px; font-size: 14px; color: #d8e1ee; line-height: 1.45; }
.howto li { background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 9px 12px; }
.howto b { color: var(--accent); margin-right: 6px; }
.howto em { color: var(--good); font-style: normal; font-weight: 700; }
.next-wind { text-align: center; font-size: 13px; color: var(--muted); margin: 14px 0 10px; }
.next-wind b { color: var(--text); }
.my-best { text-align: center; font-size: 13px; color: var(--muted); margin-top: 10px; }
.my-best b { color: var(--text); }

button { font: inherit; cursor: pointer; border: 0; }
.btn-primary {
  width: 100%; padding: 15px; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 18px; font-weight: 800;
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.35);
}
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  padding: 0 16px; border-radius: 12px; background: #fff; color: var(--navy);
  font-weight: 800; font-size: 15px; white-space: nowrap;
}
.btn-secondary:disabled { opacity: 0.5; cursor: default; }

/* 랭킹 */
.board { list-style: none; display: grid; gap: 6px; counter-reset: rank; min-height: 40px; }
.board li {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) 64px 56px; gap: 8px; align-items: center;
  background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 9px 12px; font-size: 14px;
}
.board li.me { outline: 2px solid var(--good); }
.board .rk { font-weight: 900; color: var(--muted); text-align: center; }
.board li:nth-child(1) .rk { color: #ffd166; }
.board li:nth-child(2) .rk { color: #d9e2ec; }
.board li:nth-child(3) .rk { color: #e6a06b; }
.board .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board .ds { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.board .sc { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.board li.msg { display: block; text-align: center; }
.board .empty { color: var(--muted); font-size: 13px; }

/* 결과 */
.res-dist { text-align: center; font-size: 64px; font-weight: 900; line-height: 1; margin-top: 6px; letter-spacing: -0.03em; }
.res-dist small { font-size: 24px; margin-left: 4px; color: var(--muted); }
.res-total { display: flex; justify-content: center; align-items: baseline; gap: 6px; margin: 8px 0 14px; }
.res-total span { color: var(--muted); font-size: 14px; }
.res-total b { font-size: 30px; color: var(--accent); }
.res-total small { color: var(--muted); }
.res-rows { display: grid; gap: 4px; font-size: 14px; }
.res-rows div { display: flex; justify-content: space-between; padding: 4px 2px; border-bottom: 1px solid var(--line); }
.res-rows dt { color: var(--muted); }
.res-rows dd { font-weight: 700; font-variant-numeric: tabular-nums; }
.judges { display: flex; justify-content: center; gap: 6px; margin: 12px 0 16px; flex-wrap: wrap; }
.judges span {
  font-size: 13px; font-weight: 700; padding: 5px 8px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.08); font-variant-numeric: tabular-nums;
}
.judges span.drop { opacity: 0.35; text-decoration: line-through; }
#submit-form { display: flex; gap: 8px; }
.qualify-msg { text-align: center; font-size: 15px; font-weight: 800; margin-bottom: 10px; color: var(--muted); }
.qualify-msg.in { color: var(--good); }
#name-input {
  flex: 1; min-width: 0; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.08);
  color: var(--text); font: inherit; font-size: 16px; /* 16px: iOS 확대 방지 */
}
#name-input:focus { outline: 2px solid var(--accent); }
.submit-msg { min-height: 18px; font-size: 13px; color: var(--muted); margin-top: 6px; text-align: center; }
.submit-msg.ok { color: var(--good); }
.submit-msg.err { color: var(--bad); }
#result-panel .btn-primary { margin-top: 16px; }
#hud.landed #prompt { font-size: clamp(44px, 13vw, 72px); font-weight: 900; letter-spacing: -0.03em; top: 18%; }
#hud.landed #feedback { top: calc(18% + clamp(56px, 15vw, 88px)); }
