: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 {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#game {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  text-align: center;
  cursor: pointer;
  transition: background 0.08s linear;
}

#game[data-state="waiting"] { background: #7a1f1f; }
#game[data-state="go"]      { background: #1f7a3f; }

.big {
  font-size: 32px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.result {
  font-size: 64px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.04em;
  line-height: 1;
}

.result .unit {
  font-size: 22px;
  font-weight: 600;
  color: #c0c0c0;
  margin-left: 6px;
  letter-spacing: 0;
}

.best {
  font-size: 15px;
  margin: 0;
  color: #a0a0a0;
}

.hint {
  font-size: 14px;
  margin: 6px 0 0 0;
  color: #a0a0a0;
}

.save-btn {
  font: inherit;
  color: #fff;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 10px 20px;
  min-height: 44px;
  margin-top: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.save-btn:active {
  background: rgba(255, 255, 255, 0.18);
}

@media (hover: hover) {
  .save-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
  }
}

/* 좌상단 ← 홈, 우상단 🏆 명예의 전당. 같은 시각 언어로 양쪽 코너에. */
.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: opacity 0.15s ease, background 0.15s ease;
}

.home-link { left:  max(12px, env(safe-area-inset-left)); }
.hof-link  {
  right: max(12px, env(safe-area-inset-right));
  border: none;
  cursor: pointer;
  font-family: inherit;
}

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

/* 플레이 중(빨강/초록 풀스크린)에는 살짝 투명하게 — 시각 충돌 줄이고
   실수 탭 가능성도 감소. 완전히 숨기지는 않아 항상 탈출 가능. */
body:has(#game[data-state="waiting"]) .home-link,
body:has(#game[data-state="waiting"]) .hof-link,
body:has(#game[data-state="go"])      .home-link,
body:has(#game[data-state="go"])      .hof-link {
  opacity: 0.35;
}
