* { box-sizing: border-box; }

:root { color-scheme: dark; }

html, body {
  margin: 0;
  height: 100%;
  background: #0e0e0c;
  color: #f3f1ea;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: #161616;
  background: #f3f1ea;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.7;
  cursor: default;
}

.panel {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 9vw, 3.6rem);
  font-weight: 760;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.lead, .msg, #win-count {
  margin: 0;
  max-width: 22rem;
  font-size: clamp(1.05rem, 4.2vw, 1.3rem);
  line-height: 1.35;
}

#start-btn, #again {
  margin-top: 8px;
  min-width: 9rem;
  min-height: 3.25rem;
  padding: 0.85rem 1.8rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.msg { color: #f3f1ea; }

#score {
  position: fixed;
  z-index: 3;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  margin: 0;
  font-size: clamp(1.25rem, 5vw, 1.7rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

#cam {
  position: fixed;
  z-index: 1;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  width: 112px;
  height: 148px;
  object-fit: cover;
  border-radius: 12px;
  transform: scaleX(-1);
  background: #1a1a17;
  pointer-events: none;
}

#dodge {
  position: fixed;
  z-index: 2;
  left: 0;
  top: 0;
  width: clamp(132px, 36vw, 188px);
  height: clamp(92px, 16vh, 124px);
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  font-weight: 760;
  letter-spacing: -0.03em;
  transition: left 0.28s ease, top 0.28s ease;
}

.got {
  margin: 0;
  font-size: clamp(4.5rem, 22vw, 9rem);
  font-weight: 760;
  letter-spacing: -0.05em;
  line-height: 0.9;
}

#face-hint {
  position: fixed;
  z-index: 3;
  top: max(48px, calc(env(safe-area-inset-top) + 36px));
  left: max(16px, env(safe-area-inset-left));
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.7;
}

#gaze-dot {
  position: fixed;
  z-index: 4;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  background: rgba(61, 220, 110, 0.9);
  border: 3px solid #fff;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(243, 241, 234, 0.35);
}

#calibrate {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: transparent;
  pointer-events: none;
}

body.is-cal #cam {
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  z-index: 4;
}

body.is-cal #score,
body.is-cal #face-hint { display: none; }

.oval {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(68vw, 280px);
  height: min(78vw, 360px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(14, 14, 12, 0.55);
}

#cal-ring {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(92vw, 440px);
  height: min(108vw, 540px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(#3ddc6e calc(var(--p, 0) * 360deg), rgba(61, 220, 110, 0.28) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 18px), #000 calc(100% - 14px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 18px), #000 calc(100% - 14px));
}

#cal-label {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: max(72px, calc(env(safe-area-inset-bottom) + 56px));
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

#cal-hint {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: max(28px, env(safe-area-inset-bottom));
  opacity: 0.9;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

#cal-arrow {
  position: absolute;
  top: 42%;
  margin: 0;
  transform: translateY(-50%);
  font-size: 5.5rem;
  font-weight: 760;
  line-height: 1;
  color: #3ddc6e;
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.85);
}

#cal-arrow.arrow-left { left: max(16px, env(safe-area-inset-left)); }
#cal-arrow.arrow-right { right: max(16px, env(safe-area-inset-right)); }
#cal-arrow.arrow-up { left: 50%; top: max(28px, env(safe-area-inset-top)); transform: translate(-50%, 0); }
#cal-arrow.arrow-down { left: 50%; top: auto; bottom: max(148px, calc(env(safe-area-inset-bottom) + 128px)); transform: translate(-50%, 0); }

#gaze-dot.practice-dot {
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  background: #3ddc6e;
  border: 4px solid #fff;
  box-shadow: 0 0 24px rgba(61, 220, 110, 0.85);
}
