:root {
  --sand: #f3d9a4;
  --gold: #ffc23d;
  --ink: #1a0f08;
  --good: #7be38f;
  --bad: #ff5a4e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--ink);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--sand); user-select: none; -webkit-user-select: none;
  touch-action: none; overscroll-behavior: none;
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#hud { position: fixed; inset: 0; pointer-events: none; }
.top {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  text-shadow: 0 2px 6px #000a;
}
.top > div { display: flex; flex-direction: column; min-width: 70px; }
.top .r { align-items: flex-end; }
.top .timer { align-items: center; }
.lbl { font-size: 11px; letter-spacing: .1em; opacity: .7; }
.top b { font-size: 26px; font-variant-numeric: tabular-nums; }
.timer b { font-size: 34px; }

#axe {
  position: absolute; top: calc(env(safe-area-inset-top) + 66px); left: 50%;
  width: min(60vw, 260px); height: 6px; transform: translateX(-50%);
  background: #0006; border-radius: 3px; overflow: hidden;
}
#axeFill { height: 100%; width: 50%; background: linear-gradient(90deg, #ff8a3d, var(--gold)); transition: width .2s; }

#cue {
  position: absolute; left: 50%; top: 22%; width: 120px; height: 120px;
  transform: translateX(-50%); opacity: 0; transition: opacity .1s;
}
#cue.on { opacity: 1; }
#cueSvg { position: absolute; inset: 0; overflow: visible; }
.target { fill: #0007; stroke: var(--sand); stroke-width: 3; }
.ring { fill: none; stroke: var(--gold); stroke-width: 5; }
#cueIcon {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 44px; color: #fff; text-shadow: 0 0 12px var(--gold);
}
#cueName {
  position: absolute; top: 124px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 13px; letter-spacing: .08em; opacity: .85;
}

#judge {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  font-size: 40px; font-weight: 900; letter-spacing: .04em; opacity: 0;
  text-shadow: 0 3px 12px #000c; white-space: nowrap;
}
#judge.pop { animation: pop .55s ease-out; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  70% { opacity: 1; transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

#beats {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 54px);
  transform: translateX(-50%); display: flex; gap: 14px;
}
#beats i { width: 14px; height: 14px; border-radius: 50%; background: #fff3; transition: background .08s, transform .08s; }
#beats i.on { background: var(--gold); transform: scale(1.35); }
#hint {
  position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 20px);
  text-align: center; font-size: 12px; opacity: .6;
}

#flash { position: fixed; inset: 0; pointer-events: none; }

#overlay {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, #3a1f0ecc, #0d0703f2);
}
#overlay[hidden] { display: none; }
.card { width: min(100%, 380px); text-align: center; }
h1 { font-size: 64px; margin: 0; letter-spacing: .12em; color: var(--gold); text-shadow: 0 4px 24px #ff8a3d88; }
.sub { margin: 4px 0 24px; opacity: .8; }
.how { list-style: none; padding: 0; margin: 0 0 24px; text-align: left; font-size: 14px; line-height: 1.5; }
.how li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; background: #0005; border-radius: 10px; margin-bottom: 8px; }
.k { flex: none; min-width: 70px; text-align: center; font-weight: 800; color: var(--gold); }
#loading { font-size: 13px; opacity: .7; margin-bottom: 12px; min-height: 18px; }
button {
  font: inherit; font-size: 20px; font-weight: 800; letter-spacing: .1em;
  padding: 14px 48px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--gold); color: var(--ink); box-shadow: 0 6px 24px #ffc23d55;
}
button:disabled { opacity: .35; cursor: default; }
#best { margin-top: 14px; font-size: 13px; opacity: .7; min-height: 18px; }
.result { font-size: 15px; line-height: 1.8; margin-bottom: 20px; }
.result b { color: var(--gold); font-size: 20px; }
