: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-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;
}

.target-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;
}

.target-val { color: #4f9eff; }

.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; }

.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

/* 메인 액션 버튼 — 큰 원형, 상태별 색 */
.action-btn {
  width: min(70vw, 280px);
  height: min(70vw, 280px);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  color: #fff;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.06em;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  padding: 0;
  margin: 0;
}

.action-btn[data-state="idle"] {
  background: #4f9eff;
  box-shadow: 0 0 24px rgba(79, 158, 255, 0.35);
}

.action-btn[data-state="running"] {
  background: #e74c3c;
  box-shadow: 0 0 32px rgba(231, 76, 60, 0.5);
  animation: pulse 1.4s ease-in-out infinite;
}

.action-btn[data-state="done"] {
  background: #4caf50;
  box-shadow: 0 0 24px rgba(76, 175, 80, 0.35);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

.action-btn:active {
  transform: scale(0.97);
}

/* 결과 표시 */
.result {
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-height: 60px;
}

.result[hidden] { display: none; }

.result-actual {
  margin: 0;
  font-size: 17px;
  color: #c0c0c0;
}

.result-error {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #f4d03f;
}

.result .save-btn {
  margin-top: 16px;
  padding: 12px 24px;
  border-radius: 999px;
  background: #4f9eff;
  border: 1px solid #4f9eff;
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

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

.result .save-btn[hidden] {
  display: none;
}

/* 좌상단 ← 홈, 우상단 🏆 명예의 전당 */
.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);
  }
}
