:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  touch-action: manipulation;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100dvh;
  overflow: hidden;
  background: #0a0a0a;
  color: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

main {
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    max(60px, env(safe-area-inset-top))
    16px
    max(20px, env(safe-area-inset-bottom));
  gap: 16px;
}

/* 점수바: SCORE | BEST | New 버튼 */
.score-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.score-box {
  flex: 1;
  background: #161616;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 8px 12px;
  text-align: center;
  min-width: 0;
}

.score-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a0a0a0;
}

.score-val,
.best-val {
  display: block;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: #f5f5f5;
  margin-top: 2px;
  line-height: 1.1;
}

.new-btn {
  flex: 0 0 auto;
  font: inherit;
  color: #fff;
  background: #4f9eff;
  border: none;
  border-radius: 12px;
  padding: 0 18px;
  min-height: 56px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

.new-btn:active { background: #3d8ae8; }

/* ─── Eye Gauge ──────────────────────────────────────────────── */
main { gap: 10px; }

#game {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.ag-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #b8c0d0;
  min-height: 24px;
}
.ag-round { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ag-type {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(94, 224, 200, 0.14);
  color: #7ff0da;
  white-space: nowrap;
}
.ag-type[data-kind="ratio"] { background: rgba(167, 139, 250, 0.16); color: #c4b5fd; }
.ag-type[data-kind="split"] { background: rgba(255, 179, 64, 0.14); color: #ffc66e; }
.ag-dots { margin-left: auto; display: flex; gap: 3px; flex: 0 1 auto; min-width: 0; justify-content: flex-end; }
.ag-dots i {
  flex: 0 1 7px; min-width: 4px; height: 7px; border-radius: 50%;
  background: #2a3040;
}
.ag-dots i.now { background: #e8eefc; box-shadow: 0 0 0 2px rgba(232, 238, 252, 0.25); }
.ag-dots i.hi { background: #5ee0c8; }
.ag-dots i.mid { background: #ffb340; }
.ag-dots i.lo { background: #ff6b6b; }

.ag-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 18px;
  background:
    radial-gradient(120% 90% at 50% 40%, #182035 0%, #0d1320 70%);
  border: 1px solid #222a3a;
  overflow: hidden;
}
.ag-fig { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ag-q {
  position: absolute; left: 0; right: 0; top: 8px;
  margin: 0; padding: 0 12px;
  text-align: center;
  font-size: 14px; font-weight: 700;
  color: #e8eefc;
  line-height: 1.25;
  pointer-events: none;
}
.ag-timebar {
  position: absolute; left: 12px; right: 12px; bottom: 8px;
  height: 4px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  pointer-events: none;
}
.ag-timebar i {
  display: block; height: 100%;
  background: linear-gradient(90deg, #5ee0c8, #a78bfa);
  transform-origin: left center;
  transform: scaleX(1);
}
.ag-feedback {
  position: absolute; left: 50%; top: 4px;
  transform: translate(-50%, -6px);
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(8, 11, 18, 0.9);
  border: 1px solid #2a3346;
  font-size: 14px; font-weight: 600;
  color: #d6dcea;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
}
.ag-feedback.show { opacity: 1; transform: translate(-50%, 0); transition: opacity 0.2s ease, transform 0.25s ease; }
.ag-stage.revealing .ag-q { visibility: hidden; }
.ag-feedback b { font-size: 16px; }
.ag-feedback.hi b { color: #5ee0c8; }
.ag-feedback.mid b { color: #ffb340; }
.ag-feedback.lo b { color: #ff8a8a; }

.ag-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex: 0 0 auto;
}
.ag-step {
  font: inherit;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid #2f3a50;
  background: #161c29;
  color: #e8eefc;
  font-size: 26px; font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
}
.ag-step:active { background: #222b3d; }
.ag-dial {
  position: relative;
  width: clamp(118px, 22dvh, 172px);
  height: clamp(118px, 22dvh, 172px);
  border-radius: 50%;
  touch-action: none;
  cursor: grab;
  outline: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.ag-dial:focus-visible { box-shadow: 0 0 0 3px #5ee0c8; }
.ag-ring { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ag-readout {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.ag-val { font-size: 1em; font-weight: 800; letter-spacing: -0.03em; color: #fff; }
.ag-readout { align-items: baseline; padding-top: calc(50% - 0.62em); font-size: clamp(26px, 4.4dvh, 36px); }
.ag-unit { font-size: 0.55em; font-weight: 700; color: #9aa6bd; margin-left: 2px; }
.ag-unit.deg { align-self: flex-start; font-size: 0.6em; margin-left: 1px; }
.ag-hint {
  position: absolute; inset: -6px;
  pointer-events: none;
  display: flex; align-items: flex-start; justify-content: flex-end;
}
.ag-hint span {
  font-size: 26px; line-height: 1; font-weight: 800;
  color: #ffb340;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  animation: ag-spin 1.6s ease-in-out infinite;
  transform-origin: -40% 140%;
}
.ag-hint[hidden] { display: none; }
@keyframes ag-spin {
  0%, 100% { transform: rotate(-14deg); opacity: 0.6; }
  50% { transform: rotate(22deg); opacity: 1; }
}

.ag-lock {
  flex: 0 0 auto;
  font: inherit;
  min-height: 50px;
  border-radius: 14px;
  border: none;
  background: #5ee0c8;
  color: #06231d;
  font-size: 16px; font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.ag-lock:active { filter: brightness(0.9); }
.ag-lock.next { background: #e8eefc; color: #0d1320; }

/* start + result cards */
.ag-start { gap: 14px; }
.ag-start-ico { line-height: 0; }
.ag-intro { margin: 0; font-size: 14px; line-height: 1.5; color: #cfd6e4; }
.ag-plan { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.ag-plan li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #d6dcea; }
.ag-plan .k {
  flex: 0 0 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; color: #0d1320;
}
.ag-plan .k.angle { background: #5ee0c8; }
.ag-plan .k.ratio { background: #a78bfa; }
.ag-plan .k.split { background: #ffb340; }
.overlay-card .start-btn { background: #5ee0c8; border-color: #5ee0c8; color: #06231d; font-weight: 800; }

.ag-sum { display: flex; gap: 6px; width: 100%; }
.ag-sum div {
  flex: 1; min-width: 0;
  background: #0f141f; border: 1px solid #242c3c; border-radius: 10px;
  padding: 6px 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.ag-sum span { font-size: 11px; color: #9aa6bd; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.ag-sum b { font-size: 16px; font-variant-numeric: tabular-nums; }
.ag-sum-note { margin: -6px 0 0; font-size: 11px; color: #8a95ab; }
.ag-chips { display: flex; align-items: flex-end; gap: 3px; height: 34px; width: 100%; }
.ag-chips i { flex: 1; height: var(--h); border-radius: 3px 3px 1px 1px; background: #ff6b6b; }
.ag-chips i.hi { background: #5ee0c8; }
.ag-chips i.mid { background: #ffb340; }

/* 좌상단 ← 홈, 우상단 🏆 명예의 전당 — 모든 게임 공통 chrome */
.home-link,
.hof-link {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  z-index: 10;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  text-decoration: none;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.15s ease;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.home-link { left:  max(12px, env(safe-area-inset-left)); }
.hof-link  { right: max(12px, env(safe-area-inset-right)); }

@media (hover: hover) {
  .home-link:hover,
  .hof-link:hover {
    background: rgba(0, 0, 0, 0.55);
  }
}

/* 오버레이 (게임 종료 / 완료 시 점수 + 저장 버튼) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 20px;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.overlay[hidden] { display: none; }

.overlay-card {
  background: #161616;
  border: 1px solid #2a2a2a;
  border-radius: 18px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
  min-width: 240px;
  max-width: 320px;
  width: 100%;
}

.overlay-card h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.overlay-score {
  margin: 0;
  font-size: 56px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}

.overlay-card button {
  font: inherit;
  color: #fff;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 12px 20px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.overlay-card button:active {
  background: rgba(255, 255, 255, 0.18);
}

.overlay-card .save-btn {
  background: #4f9eff;
  border-color: #4f9eff;
}

.overlay-card .save-btn:active {
  background: #3d8ae8;
}

/* short phones: give the figure more room */
@media (max-height: 640px) {
  main { gap: 8px; }
  #game { gap: 8px; }
  .ag-dial { width: clamp(104px, 20dvh, 172px); height: clamp(104px, 20dvh, 172px); }
  .ag-step { width: 46px; height: 46px; font-size: 24px; }
  .ag-lock { min-height: 46px; }
  .ag-q { font-size: 13px; }
}
