/* 타자 테스트 — 폰 키보드가 화면 절반을 먹는 걸 전제로 짠 배치.
   지문은 위, 입력칸은 그 바로 아래. 키보드가 올라와도 지문 첫 줄이 항상 보이게 한다. */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #0a0a0a; color: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
main {
  /* --vvh 는 visualViewport 높이 (키보드가 올라오면 줄어든다). 없으면 100%. */
  height: var(--vvh, 100%); max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 9px;
  padding: max(60px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
}
.score-bar { display: flex; gap: 5px; align-items: stretch; flex: 0 0 auto; }
.score-box {
  flex: 1; background: #161616; border: 1px solid #2a2a2a; border-radius: 11px;
  padding: 5px 2px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-width: 0;
}
.score-label { font-size: 9px; letter-spacing: 0.04em; text-transform: uppercase; color: #a0a0a0; white-space: nowrap; }
.score-val, .best-val, .acc-val, .time-val { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.new-btn {
  flex: 0 0 auto; font: inherit; color: #0a0a0a; background: #4f9eff; border: none;
  border-radius: 11px; padding: 0 11px; min-height: 52px; cursor: pointer;
  font-weight: 700; font-size: 13px;
}
.new-btn:active { background: #3d8ae8; }

/* ── 지문 ───────────────────────────────────────────────────────────────── */
.text {
  /* 세 줄만 보인다. 처음엔 남는 공간을 다 채우게 했더니 17줄이 나왔는데, 타자 테스트에서
     사람이 실제로 읽는 건 현재 줄과 다음 한두 줄뿐이고, 폰에서는 어차피 키보드가
     아래쪽을 덮는다. 현재 줄이 항상 맨 위에 오므로 '지금 줄 + 다음 두 줄'이 보인다. */
  flex: 0 0 auto; height: calc(3 * 1.85em + 24px); overflow: hidden;
  background: #131313; border: 1px solid #242424; border-radius: 14px;
  padding: 12px 13px; line-height: 1.85;
  font-size: 20px; font-weight: 600; color: #6e6e6e;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-spacing: 2px; user-select: none;
}
.word { border-radius: 3px; }
.word.cur { background: rgba(79,158,255,0.16); box-shadow: 0 2px 0 #4f9eff; }
.word.done-ok { color: #4f4f4f; }
.word.done-bad { color: #b05353; text-decoration: underline wavy rgba(224,72,58,0.55); }
.word.over { text-decoration: underline wavy rgba(224,72,58,0.7); }
.word .good { color: #f2f2f2; }
.word .bad { color: #ff6b5c; }

#typed {
  flex: 0 0 auto; width: 100%; min-height: 52px; margin-top: auto;
  font: 600 19px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #f5f5f5; background: #1b1b1b; border: 2px solid #33383f; border-radius: 12px;
  padding: 12px 14px; outline: none;
}
#typed:focus { border-color: #4f9eff; }

.status { margin: 0; text-align: center; font-size: 12px; font-weight: 600; color: #8f8f8f; min-height: 16px; flex: 0 0 auto; }
.status.ok { color: #52d97f; }

.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; border: none; cursor: pointer;
  font-family: inherit; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.home-link { left: max(12px, env(safe-area-inset-left)); }
.hof-link { right: max(12px, env(safe-area-inset-right)); }

.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; }
.overlay-score { margin: 0; font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.overlay-score .unit { font-size: 14px; font-weight: 700; color: #a0a0a0; margin-left: 7px; }
.overlay-sub { margin: -4px 0 0; font-size: 14px; font-weight: 600; color: #a0a0a0; }
.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%;
}
.overlay-card button:active { background: rgba(255,255,255,0.18); }
.overlay-card .save-btn { background: #4f9eff; border-color: #4f9eff; color: #0a0a0a; }
