* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(160deg, #1b1f2a, #0d1117);
  color: #e6e6e6;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  /* 화면(.screen)이 위, 푸터가 아래로 쌓이는 세로 배치.
     가로 flex로 두면 넓은 화면에서 푸터가 게임 옆에 나란히 붙어버린다. */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hidden { display: none !important; }

.screen {
  width: 100%;
  max-width: 1280px;
  padding: 32px;
  text-align: center;
  margin: auto; /* 남는 공간이 있을 때만 세로 중앙, 넘치면 정상 스크롤 */
  flex-shrink: 0;
}

h1 { font-size: 2.2rem; margin-bottom: 8px; }
.subtitle { color: #9aa4b2; margin-bottom: 28px; }

.lang-select {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.lang-btn {
  padding: 12px 28px;
  border-radius: 10px;
  border: 2px solid #3a4152;
  background: #1b2130;
  color: #e6e6e6;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.lang-btn:hover { border-color: #5b8cff; }
.lang-btn.selected {
  border-color: #5b8cff;
  background: #223052;
  box-shadow: 0 0 0 2px rgba(91,140,255,0.35);
}

.primary-btn {
  padding: 14px 36px;
  font-size: 1.1rem;
  border-radius: 10px;
  border: none;
  background: #5b8cff;
  color: white;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.primary-btn:hover:not(:disabled) { background: #4172e0; transform: translateY(-1px); }
.primary-btn:disabled { background: #3a4152; cursor: not-allowed; opacity: 0.6; }

.arcade-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1220px;
  margin: 0 auto;
  padding: 14px 20px;
  background: #000;
  border: 2px solid #333;
  border-radius: 6px;
  font-family: "Press Start 2P", monospace;
}
.hud-block { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hud-block-life { align-items: center; flex: 1; padding: 0 24px; }
.hud-label { font-size: 0.8rem; color: #cfd6e2; letter-spacing: 1px; }
.hud-value { font-size: 1.3rem; color: #fff; }

.life-bar {
  width: 100%;
  max-width: 300px;
  height: 20px;
  border: 2px solid #fff;
  display: flex;
  padding: 2px;
  gap: 2px;
}
.life-bar-fill {
  height: 100%;
  width: 100%;
  background: #e8342a;
  transition: width 0.25s linear, background 0.25s linear;
}

/* ---- 레벨 진행 바 ---- */
/* 문장마다 리셋되는 타이머 바(.timer-bar)와 헷갈리지 않도록 색을 금색 계열로 구분한다 */
.level-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1220px;
  margin: 12px auto 0;
  font-size: 0.95rem;
  color: #9aa4b2;
}
.level-progress-label {
  flex-shrink: 0;
}
.level-progress-track {
  position: relative;
  flex: 1;
  height: 10px;
  background: #262d3d;
  border-radius: 5px;
  overflow: hidden;
}
.level-progress-fill,
.level-progress-pending {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  border-radius: 5px;
}
/* 지금 치고 있는 문장의 몫. 완성 전까지는 옅게만 채워 "예고"로 보여준다 */
.level-progress-pending {
  background: rgba(255, 180, 84, 0.3);
  transition: width 0.12s linear;
}
/* 완성한 문장의 합계 */
.level-progress-fill {
  background: linear-gradient(90deg, #ffb454, #ffd479);
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.level-progress-count {
  flex-shrink: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums; /* 숫자가 바뀌어도 폭이 흔들리지 않게 */
}
.level-progress-count #hud-progress,
.level-progress-count #hud-quota {
  color: #fff;
  font-weight: 700;
}
.level-progress-unit {
  color: #6b7488;
}

.sub-hud {
  display: flex;
  justify-content: center;
  gap: 24px;
  max-width: 1220px;
  margin: 10px auto 18px;
  font-size: 1rem;
  color: #9aa4b2;
  flex-wrap: wrap;
}
.sub-hud span span { color: #fff; font-weight: 700; }

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.18) 0px,
    rgba(0,0,0,0.18) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
  z-index: 999;
}

.game-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1220px;
  margin: 0 auto;
}

.typing-side {
  background: #161b26;
  border-radius: 14px;
  padding: 24px;
  border: 1px solid #262d3d;
}

.timer-bar-wrap {
  height: 8px;
  background: #262d3d;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
}
.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #5b8cff, #7ee787);
  transition: width 0.08s linear, background 0.3s;
}
.timer-bar.warning { background: linear-gradient(90deg, #ff9f43, #ffcc66); }
.timer-bar.danger { background: linear-gradient(90deg, #ff4d4d, #ff8080); }

.sentence-display {
  font-size: 1.9rem;
  line-height: 1.8;
  min-height: 120px;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
  word-break: keep-all;
  /* keep-all은 한 단어(공백 없는 구간) 안에서는 줄바꿈을 막는다.
     그 단어가 화면보다 넓으면 넘치므로, 정말 안 들어갈 때만
     강제로 끊어서 화면 밖으로 새지 않게 하는 안전장치 */
  overflow-wrap: break-word;
}
.sentence-display .char-correct { color: #7ee787; }
.sentence-display .char-wrong { color: #ff4d4d; background: rgba(255,77,77,0.18); border-radius: 3px; }
.sentence-display .char-pending { color: #6b7280; }

/* 지금 쳐야 할 글자 한 개만 미리 파란색으로 표시 */
.sentence-display .char-current {
  color: #5b8cff;
}

.typing-input {
  width: 100%;
  padding: 18px 20px;
  font-size: 1.4rem;
  border-radius: 10px;
  border: 2px solid #2c3346;
  background: #0e131c;
  color: #fff;
  outline: none;
  transition: border-color 0.15s;
}
.typing-input:focus { border-color: #5b8cff; }

/* 입력기 모드가 반대일 때 뜨는 안내 */
.ime-hint {
  margin: 12px 0 0;
  padding: 10px 14px;
  border: 1px solid #6b4a1f;
  border-radius: 8px;
  background: rgba(255, 180, 84, 0.12);
  color: #ffb454;
  font-size: 0.95rem;
  text-align: center;
  animation: imeHintIn 0.2s ease-out;
}
@keyframes imeHintIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.typing-input.shake {
  animation: shake 0.25s;
  border-color: #ff4d4d;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.time-row {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  font-family: "Press Start 2P", monospace;
}
.time-label { font-size: 0.75rem; color: #9aa4b2; }
.time-value { font-size: 1.2rem; color: #ffb454; }

.zombie-side {
  background: #161b26;
  border-radius: 14px;
  padding: 24px;
  border: 1px solid #262d3d;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.corridor {
  position: relative;
  height: 320px;
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, #1a1c1e 0%, #24262a 46%, #1a1c1e 52%, #100f10 100%);
  --proximity: 0;
}

.train-ceiling {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 34%;
  background: linear-gradient(180deg, #2b2d31 0%, #1b1c1f 100%);
  box-shadow: 0 6px 14px rgba(0,0,0,0.5);
}
.train-lights {
  position: absolute;
  top: 6%;
  left: 0; right: 0;
  height: 10px;
  background: repeating-linear-gradient(90deg,
    rgba(255,226,150,0.9) 0px, rgba(255,226,150,0.9) 26px,
    transparent 26px, transparent 92px);
  filter: blur(1px);
  opacity: 0.85;
}
.train-floor {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30%;
  background: linear-gradient(0deg, #0c0d0f 0%, #202226 100%);
}
.train-floor::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg,
    rgba(255,255,255,0.05) 0px, rgba(255,255,255,0.05) 2px,
    transparent 2px, transparent 64px);
}
.corridor::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg,
    rgba(0,0,0,0.35) 0px, rgba(0,0,0,0.35) 10px,
    transparent 10px, transparent 96px);
  pointer-events: none;
}

.zombie {
  position: absolute;
  bottom: 9%;
  left: 8%;
  transform: translateX(-50%) scale(1);
  transition: left 0.4s ease-in;
}

/* 좀비 시트: 4프레임, 프레임당 333x508 (비율 0.656) */
.zombie-sprite {
  width: 144px;
  height: 220px;
  background-image: url("assets/zombie_walk_sheet.png");
  background-repeat: no-repeat;
  background-size: 576px 220px; /* 4 frames * 144px */
  filter: drop-shadow(0 5px 8px rgba(0,0,0,0.55));
  animation: zombieWalkCycle 0.72s steps(4) infinite;
}
@keyframes zombieWalkCycle {
  from { background-position-x: 0; }
  to   { background-position-x: -576px; }
}

.player-figure {
  position: absolute;
  bottom: 9%;
  right: 6%;
  width: 99px;
  height: 220px;
  animation: playerIdle 1.6s ease-in-out infinite;
  z-index: 4;
}
/* 주인공 시트: 7프레임, 프레임당 207x459 (비율 0.451) */
.player-sprite {
  width: 99px;
  height: 220px;
  background-image: url("assets/player_walk_sheet.png");
  background-repeat: no-repeat;
  background-size: 693px 220px; /* 7 frames * 99px */
  background-position: -297px 0; /* resting frame */
  filter: drop-shadow(0 5px 8px rgba(0,0,0,0.55));
}
.player-sprite.hurt {
  width: 176px;
  background-image: url("assets/player_hit.png");
  background-size: 176px 220px;
  background-position: 0 0;
}
@keyframes playerIdle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.zombie-shadow {
  position: absolute;
  left: 50%;
  bottom: -6%;
  width: 70%;
  height: 18%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(0,0,0,0.55) 0%, transparent 75%);
  animation: shadowPulse 0.85s ease-in-out infinite;
}
@keyframes shadowPulse {
  0%, 100% { transform: translateX(-50%) scaleX(1); opacity: 0.6; }
  50% { transform: translateX(-50%) scaleX(0.8); opacity: 0.4; }
}

.zombie.hit .zombie-sprite {
  animation: zombieHit 0.25s, zombieShamble 0.85s ease-in-out infinite;
}
@keyframes zombieHit {
  0% { filter: brightness(2.2) drop-shadow(0 0 14px red); }
  100% { filter: drop-shadow(0 6px 10px rgba(0,0,0,0.6)); }
}
.zombie.dying {
  animation: zombieDie 0.35s forwards;
}
@keyframes zombieDie {
  to { opacity: 0; transform: translateX(-50%) scale(0.1) rotate(25deg); }
}

.hit-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 60%, rgba(255,0,0,0.55), transparent 70%);
  opacity: 0;
  pointer-events: none;
}
.hit-flash.flash {
  animation: hitFlash 0.3s ease-out;
}
@keyframes hitFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 60px 20px rgba(0,0,0,0.55),
    inset 0 0 calc(40px + var(--proximity) * 120px) calc(10px + var(--proximity) * 40px) rgba(200,0,0,calc(var(--proximity) * 0.65));
  transition: box-shadow 0.2s linear;
}

.corridor.shake {
  animation: corridorShake 0.25s;
}
@keyframes corridorShake {
  0%, 100% { transform: translate(0,0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-3px, 1px); }
}

.zombie-hint {
  text-align: center;
  color: #7a8494;
  font-size: 0.85rem;
}

#levelclear-screen, #gameover-screen, #victory-screen {
  background: #161b26;
  border-radius: 16px;
  border: 1px solid #262d3d;
  padding: 48px 32px;
}
#gameover-screen h2 { color: #ff5c5c; }
#victory-screen h2 { color: #ffd166; }

/* ---- 최종 점수 크게 강조 ---- */
.final-score {
  margin: 18px auto 26px;
  padding: 22px 32px;
  max-width: 420px;
  border-radius: 16px;
  border: 2px solid rgba(255, 92, 92, 0.35);
  background: radial-gradient(
    ellipse at center,
    rgba(255, 92, 92, 0.16) 0%,
    rgba(255, 92, 92, 0.04) 70%
  );
}
.final-score-label {
  font-size: 0.85rem;
  letter-spacing: 3px;
  color: #9aa4b5;
  margin-bottom: 6px;
}
.final-score-value {
  font-family: "Press Start 2P", monospace;
  font-size: 3.6rem;
  line-height: 1.15;
  color: #ff8a8a;
  text-shadow: 0 0 12px rgba(255, 92, 92, 0.75), 0 4px 0 rgba(0, 0, 0, 0.45);
  animation: scorePop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

/* 승리 화면은 붉은색 대신 금색 계열로 */
.final-score--win {
  border-color: rgba(255, 209, 102, 0.4);
  background: radial-gradient(
    ellipse at center,
    rgba(255, 209, 102, 0.18) 0%,
    rgba(255, 209, 102, 0.04) 70%
  );
}
.final-score--win .final-score-value {
  color: #ffd166;
  text-shadow: 0 0 14px rgba(255, 209, 102, 0.8), 0 4px 0 rgba(0, 0, 0, 0.45);
}

@keyframes scorePop {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 520px) {
  .final-score { padding: 18px 20px; }
  .final-score-value { font-size: 2.4rem; }
  /* 좁은 화면에서는 한 "단어"가 통째로 넘치는 일이 잦아지므로 글자를 줄인다 */
  .sentence-display { font-size: 1.5rem; line-height: 1.65; min-height: 100px; }
  .typing-side { padding: 18px; }

  /* 모바일에서는 좀비 연출 영역을 가로형으로 더 짧게 줄여서, 스크롤 없이
     타이핑 영역(문장·입력창)이 화면에 더 많이 보이게 한다. PC는 그대로 둔다. */
  .zombie-side { padding: 14px; }
  .corridor { height: 190px; margin-bottom: 8px; }
  .zombie-hint { font-size: 0.8rem; }

  /* 복도가 낮아진 만큼 캐릭터 스프라이트도 같은 비율로 줄여서
     복도 밖으로 삐져나오지 않게 한다 (원본 220px -> 130px, 약 59%) */
  .zombie-sprite {
    width: 85px;
    height: 130px;
    background-size: 340px 130px; /* 4 frames * 85px */
    animation-name: zombieWalkCycleMobile;
  }
  @keyframes zombieWalkCycleMobile {
    from { background-position-x: 0; }
    to   { background-position-x: -340px; }
  }

  .player-figure { width: 59px; height: 130px; }
  .player-sprite {
    width: 59px;
    height: 130px;
    background-size: 413px 130px; /* 7 frames * 59px */
    background-position: -177px 0; /* resting frame (3번째 프레임) */
  }
  .player-sprite.hurt {
    width: 104px;
    background-size: 104px 130px;
  }
}

/* ---- 문장 성공 이펙트 ---- */
.burst {
  position: absolute;
  bottom: 40%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 6;
}
.burst i {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6b0 0%, #ffcf4d 55%, rgba(255,180,60,0) 70%);
  animation: burstOut 0.6s ease-out forwards;
}
@keyframes burstOut {
  0%   { transform: translate(0,0) scale(0.4); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.1); opacity: 0; }
}

.praise {
  position: absolute;
  bottom: 52%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  animation: praiseFloat 0.9s ease-out forwards;
}
.praise-word {
  font-family: "Press Start 2P", monospace;
  font-size: 1rem;
  color: #ffe36e;
  text-shadow: 2px 2px 0 #a3560a, 0 0 12px rgba(255,210,90,0.7);
}
.praise-score {
  font-family: "Press Start 2P", monospace;
  font-size: 0.75rem;
  color: #9dffb0;
  text-shadow: 2px 2px 0 #14532d;
}
@keyframes praiseFloat {
  0%   { transform: translate(-50%, 10px) scale(0.6); opacity: 0; }
  25%  { transform: translate(-50%, -6px) scale(1.15); opacity: 1; }
  40%  { transform: translate(-50%, -10px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -46px) scale(1); opacity: 0; }
}

/* ---- 시작 카운트다운 ---- */
.countdown {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 12, 0.55);
  pointer-events: none;
}
.countdown span {
  font-family: "Press Start 2P", monospace;
  font-size: 4rem;
  color: #ffe36e;
  text-shadow: 4px 4px 0 #a3560a, 0 0 24px rgba(255, 210, 90, 0.75);
  animation: countPop 0.9s ease-out;
}
.countdown span.go {
  color: #9dffb0;
  text-shadow: 4px 4px 0 #14532d, 0 0 24px rgba(120, 255, 160, 0.75);
}
.countdown span.long {
  font-size: 1.6rem;
  max-width: 90%;
  text-align: center;
  line-height: 1.6;
  color: #ff8ae2;
  text-shadow: 3px 3px 0 #7a1a5e, 0 0 20px rgba(255, 138, 226, 0.8);
  animation: countPopLong 1.8s ease-out;
}
@keyframes countPopLong {
  0%   { transform: scale(1.4); opacity: 0; }
  15%  { transform: scale(1); opacity: 1; }
  85%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0; }
}
@keyframes countPop {
  0%   { transform: scale(2.2); opacity: 0; }
  25%  { transform: scale(1); opacity: 1; }
  75%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.7); opacity: 0; }
}

/* ---- 칭찬 문구 등급별 색상 ---- */
.praise-word--good { color: #d8dee8; text-shadow: 2px 2px 0 #3a4152, 0 0 10px rgba(216,222,232,0.5); }
.praise-word--nice { color: #7ee787; text-shadow: 2px 2px 0 #14532d, 0 0 12px rgba(126,231,135,0.6); }
.praise-word--perfect { color: #ffe36e; text-shadow: 2px 2px 0 #a3560a, 0 0 12px rgba(255,210,90,0.7); }
.praise-word--combo { color: #ff8ae2; text-shadow: 2px 2px 0 #7a1a5e, 0 0 14px rgba(255,138,226,0.75); }
.praise-word--clean { color: #7ef2ff; text-shadow: 2px 2px 0 #075464, 0 0 16px rgba(126,242,255,0.85); }

/* ---- 구글 로그인 / 프로필 ---- */
.auth-box {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  min-height: 60px;
  align-items: center;
}
/* 구글 브랜딩 가이드라인의 다크 버전 그대로:
   배경 #131314, 글자 #E3E3E3, 테두리 #8E918F, 높이 40px, 모서리 20px(알약형),
   Roboto Medium 14px, 4색 G 로고 18px. 색·비율을 임의로 바꾸지 않는다. */
.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-radius: 20px;
  border: 1px solid #8e918f;
  background: #131314;
  color: #e3e3e3;
  font-family: "Roboto", "Pretendard", "Apple SD Gothic Neo", sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.25px;
  cursor: pointer;
  transition: background 0.15s;
}
.google-btn:hover { background: #1e1f20; }
.google-btn:disabled { opacity: 0.55; cursor: default; }
.google-logo {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.google-logo svg { width: 100%; height: 100%; display: block; }
.auth-hint { color: #7a8494; font-size: 0.8rem; margin-top: 8px; }
.auth-error { color: #ff8a80; font-size: 0.82rem; margin-top: 8px; }

.auth-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #161b26;
  border: 1px solid #262d3d;
  border-radius: 30px;
  padding: 6px 14px 6px 6px;
}
.auth-avatar { width: 32px; height: 32px; border-radius: 50%; }
.auth-name { font-size: 0.9rem; color: #fff; }
.auth-country { font-size: 1.1rem; }
.text-btn {
  background: none;
  border: none;
  color: #9aa4b2;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.text-btn:hover { color: #fff; }

/* ---- 랭킹 ---- */
.leaderboard {
  max-width: 420px;
  margin: 28px auto 0;
  background: #161b26;
  border: 1px solid #262d3d;
  border-radius: 14px;
  padding: 16px 20px;
  text-align: left;
}
.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.leaderboard-title { font-weight: 700; color: #fff; }
.leaderboard-tabs { display: flex; gap: 6px; }
.lb-tab {
  background: #1b2130;
  border: 1px solid #3a4152;
  color: #9aa4b2;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
}
.lb-tab.selected { background: #223052; color: #fff; border-color: #5b8cff; }
.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
.leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #d8dee8;
  padding: 4px 0;
}
.leaderboard-list li .lb-rank { width: 20px; color: #7a8494; font-weight: 700; }
.leaderboard-list li .lb-avatar { width: 22px; height: 22px; border-radius: 50%; }
.leaderboard-list li .lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-list li .lb-score {
  color: #ffe36e;
  font-weight: 700;
  text-align: right;
  line-height: 1.35;
  white-space: nowrap;
}
/* 레벨·시간 아래 한 줄로 붙는 평균 속도 */
.leaderboard-list li .lb-speed {
  display: block;
  color: #7a8494;
  font-weight: 500;
  font-size: 0.78em;
  font-variant-numeric: tabular-nums;
}
.lb-empty { color: #7a8494; font-size: 0.85rem; text-align: center; }

/* ---- 국가 선택 모달 ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-box {
  background: #161b26;
  border: 1px solid #262d3d;
  border-radius: 16px;
  padding: 28px;
  width: 90%;
  max-width: 360px;
  text-align: center;
}
.modal-box h3 { margin: 0 0 8px; color: #fff; }
.modal-hint { color: #9aa4b2; font-size: 0.85rem; margin-bottom: 18px; }
.country-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 2px solid #2c3346;
  background: #0e131c;
  color: #fff;
  font-size: 1rem;
  margin-bottom: 16px;
}

/* ---- 애드센스 광고 슬롯 ---- */
.ad-slot {
  max-width: 1220px;
  margin: 16px auto 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ad-slot .adsbygoogle {
  width: 100%;
}

/* ---- 종료 화면 액션 버튼 그룹 ---- */
.end-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}
.secondary-btn {
  padding: 14px 28px;
  font-size: 1.1rem;
  border-radius: 10px;
  border: 2px solid #3a4152;
  background: transparent;
  color: #d8dee8;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.secondary-btn:hover { border-color: #5b8cff; color: #fff; }

/* ---- 게임 화면 하단 링크 (소개/약관/문의) ---- */
.game-footer {
  flex-shrink: 0;
  width: 100%;
  max-width: 1220px;
  margin: 32px auto 0;
  padding: 20px 16px 28px;
  border-top: 1px solid #262d3d;
  text-align: center;
  font-size: 0.85rem;
}
.game-footer a {
  color: #7a8494;
  text-decoration: none;
  margin: 0 12px;
  transition: color 0.15s;
}
.game-footer a:hover { color: #5b8cff; }
.game-footer-copy {
  margin-top: 10px;
  color: #4b5563;
  font-size: 0.8rem;
}

/* ---- 첫 화면 전체 배경 (지하철 내부) ---- */
/* 첫 화면일 때만 깔리고, 게임이 시작되면 화면과 함께 사라진다 */
#start-screen::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("assets/train_bg.png?v=2") center center / cover no-repeat;
  z-index: -2;
}
/* 글자 가독성을 위한 어둡게 덮는 층 */
#start-screen::after {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(10, 13, 20, 0.55) 0%,
    rgba(10, 13, 20, 0.68) 45%,
    rgba(10, 13, 20, 0.88) 100%
  );
  z-index: -1;
}

/* 배경 위에서도 제목과 패널이 또렷하게 보이도록 보강 */
#start-screen h1 {
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.9);
}
#start-screen .subtitle {
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}
#start-screen .leaderboard,
#start-screen .auth-box {
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

/* ================================================================
   첫 화면 헤드라인 / 로그인 카드 / 시작 버튼
   ================================================================ */

/* ================================================================
   좌측 상단 사이트 메뉴 (홈 | 나의 분당 타수)
   speed.html의 .mini-nav와 같은 구성이고, 여기서는 어두운 배경에 맞춰
   색만 바꾼다. 첫 화면에서만 보이도록 아래에서 다시 숨긴다.
   ================================================================ */
.home-nav {
  position: fixed;
  top: 22px;
  left: 24px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(14, 19, 28, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.home-nav .mini-nav-item {
  color: #aab3c2;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}
.home-nav .mini-nav-item:hover { color: #8fb2ff; }
.home-nav .mini-nav-item.current { color: #fff; font-weight: 700; }
.home-nav .mini-nav-sep { color: #4b5566; font-size: 0.85rem; }

/* 게임/결과 화면에서는 숨긴다. :has()를 모르는 브라우저에서는 계속 보이는데,
   위치가 HUD와 겹치지 않는 여백이라 그대로 둬도 문제되지 않는다. */
body:has(#start-screen.hidden) .home-nav { display: none; }

/* ---- 타이틀 위 작은 설명 문구 ---- */
#start-screen .eyebrow {
  font-size: clamp(0.72rem, 1.4vw, 0.85rem);
  letter-spacing: 2px;
  color: #8fa0b6;
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

/* ---- 타이틀 크게 ---- */
#start-screen h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: -0.5px;
  margin-bottom: 14px;
}
#start-screen .subtitle {
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  color: #b8c2d0;
  margin-bottom: 34px;
}

/* ---- 구글 로그인 카드 ---- */
/* 좀비/빈티지 연출과 분리하고, 아래 언어 버튼·랭킹 카드와 같은 어두운 패널로 맞춘다 */
#start-screen .auth-box {
  margin-bottom: 28px;
}
.auth-guest {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  /* 아래 랭킹 카드와 같은 폭으로 맞춰 세로 흐름이 흐트러지지 않게 한다 */
  width: 100%;
  max-width: 420px;
  padding: 22px 24px;
  border-radius: 14px;
  border: 1px solid #262d3d;
  background: rgba(22, 27, 38, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.38);
}
/* 버튼 자체는 구글 규격을 지켜야 하므로 여기서 모양을 덮어쓰지 않는다 */
.auth-guest .auth-hint {
  color: #8b95a5;
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0;
  text-align: center;
  word-break: keep-all;
}
.auth-guest .auth-error {
  max-width: 320px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 138, 128, 0.35);
  background: rgba(120, 30, 26, 0.3);
  color: #ffb3ab;
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ---- 시작하기 버튼: 언어 버튼과 어울리게 키우고 색 입히기 ---- */
#start-btn {
  min-width: 240px;
  padding: 16px 44px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 12px;
  /* 게임의 시그니처 색(타이머 바와 동일한 파랑→초록) */
  background: linear-gradient(135deg, #5b8cff 0%, #4fc3f7 45%, #7ee787 100%);
  color: #0d1b12;
  box-shadow:
    0 8px 22px rgba(91, 140, 255, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}
#start-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #6d99ff 0%, #63cdf9 45%, #92ee9a 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(91, 140, 255, 0.45);
}
#start-btn:disabled {
  background: #2c3346;
  color: #6b7280;
  box-shadow: none;
}

/* ================================================================
   타이틀 번개 효과
   7초 주기로 두 번 번쩍인다. 제목이 번쩍이는 순간 배경(::after 어둠막)도
   함께 옅어져서, 창밖에서 번개가 친 것처럼 객차 전체가 잠깐 밝아진다.
   ================================================================ */
#start-screen h1 {
  animation: titleLightning 7s infinite;
}

@keyframes titleLightning {
  /* 평상시 */
  0%, 5%, 14%, 43%, 100% {
    color: #fff;
    text-shadow: 0 3px 14px rgba(0, 0, 0, 0.9);
  }
  /* 1차 섬광 — 짧게 두 번 끊어 친다 */
  6% {
    color: #ffffff;
    text-shadow:
      0 0 10px #fff,
      0 0 26px #9fd4ff,
      0 0 52px #4fa8ff,
      0 0 90px rgba(79, 168, 255, 0.7);
  }
  8% {
    color: #cfe4ff;
    text-shadow: 0 3px 14px rgba(0, 0, 0, 0.9);
  }
  10% {
    color: #ffffff;
    text-shadow:
      0 0 14px #fff,
      0 0 34px #bfe3ff,
      0 0 68px #5bb4ff,
      0 0 120px rgba(91, 180, 255, 0.75);
  }
  /* 2차 섬광 — 조금 약하게 */
  45% {
    color: #ffffff;
    text-shadow:
      0 0 10px #fff,
      0 0 28px #a9d9ff,
      0 0 58px #4fa8ff;
  }
}

/* 번개가 칠 때 객차 안이 잠깐 밝아지는 연출 */
#start-screen::after {
  animation: coachFlash 7s infinite;
}
@keyframes coachFlash {
  0%, 5%, 14%, 43%, 100% { opacity: 1; }
  6%  { opacity: 0.55; }
  8%  { opacity: 0.95; }
  10% { opacity: 0.45; }
  45% { opacity: 0.7; }
}

/* 화면 깜빡임에 민감한 사용자를 위해 애니메이션을 끈다 */
@media (prefers-reduced-motion: reduce) {
  #start-screen h1,
  #start-screen::after,
  .mb-track-player,
  .mb-caret {
    animation: none;
  }
  /* 애니메이션을 끄면 키프레임 안의 좌우 반전도 사라지므로 여기서 고정한다
     (좀비 반대 방향을 보고 있어야 한다) */
  .mb-track-player {
    transform: scaleX(-1);
  }
}

/* ---- 음소거 버튼 ---- */
.mute-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid #5b8cff;
  background: rgba(22, 27, 38, 0.9);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 0 0 4px rgba(91, 140, 255, 0.12);
  color: #e6e6e6;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, background 0.15s, box-shadow 0.15s;
}
.mute-btn:hover {
  border-color: #8fb0ff;
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 0 0 6px rgba(91, 140, 255, 0.2);
}
.mute-btn.muted {
  color: #7a8494;
  border-color: #3a4152;
  box-shadow: none;
}

/* ---- 모바일 안내 페이지 ---- */
/* 데스크톱에서는 안내를 통째로 숨긴다 */
#mobile-block {
  display: none;
}

/* 터치 기기이거나 화면이 좁으면 게임 대신 안내 페이지를 보여준다.
   게임은 못 하지만 소개/미리보기/읽을거리는 볼 수 있어야 하므로
   가운데 고정이 아니라 위에서부터 흐르는 스크롤 페이지로 만든다. */
@media (pointer: coarse), (max-width: 860px) {
  body > *:not(#mobile-block) {
    display: none !important;
  }
  body {
    background: #0d1017;
  }
  #mobile-block {
    display: block;
    padding: 36px 20px 56px;
  }
  .mobile-block-inner {
    max-width: 520px;
    margin: 0 auto;
    text-align: center;
  }
  .mobile-block-icon {
    font-size: 2.6rem;
    margin-bottom: 10px;
  }
  .mobile-block-brand {
    margin: 0 0 8px;
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
  }
  .mobile-block-sub {
    margin: 0 0 22px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #8b95a7;
  }

  .mb-notice {
    border: 1px solid #2c3346;
    background: rgba(91, 140, 255, 0.07);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 0.88rem;
    line-height: 1.7;
    color: #b9c2d0;
    text-align: left;
    margin-bottom: 26px;
  }
  .mb-notice strong {
    color: #8fb0ff;
  }

  /* 자동 시연 박스 */
  .mb-demo {
    border: 1px solid #262d3d;
    border-radius: 12px;
    background: #12161f;
    padding: 14px 16px 16px;
    text-align: left;
  }
  .mb-demo-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }
  .mb-demo-label {
    font-size: 0.62rem;
    letter-spacing: 2px;
    color: #5a6478;
  }
  /* 좀비 트랙: 왼쪽 끝(멀리) ~ 오른쪽 플레이어 앞(코앞) */
  .mb-track {
    position: relative;
    height: 30px;
    margin-bottom: 12px;
  }
  .mb-track-zombie,
  .mb-track-player {
    position: absolute;
    top: 0;
    font-size: 1.25rem;
    line-height: 30px;
  }
  .mb-track-zombie {
    left: 0;
    /* 평소에는 아주 느리게 스멀스멀 기어온다.
       글자마다 위치가 갱신되므로 트랜지션을 타이핑 간격보다 길게 잡아야
       계단처럼 툭툭 끊기지 않는다 */
    transition: left 0.9s linear;
  }
  /* 오타가 난 순간에만 붙는다 — 느린 기어옴을 끊고 성큼 달려든다 */
  .mb-track-zombie.lunge {
    transition: left 0.22s cubic-bezier(0.2, 0.75, 0.3, 1);
  }
  /* 플레이어는 러닝머신 위를 달리듯 제자리에서 달린다.
     한 사이클이 두 걸음이라 위아래 반동이 두 번 들어간다.
     앞으로 나아가지 않으므로 좌우 이동은 1px 안쪽으로만 준다.
     🏃 이모지는 기본이 왼쪽을 향하는데 좀비가 왼쪽에서 오므로,
     scaleX(-1)로 뒤집어 좀비 반대 방향(오른쪽)으로 달아나게 한다.
     transform이 애니메이션되므로 반전도 매 키프레임에 함께 넣어야 한다. */
  .mb-track-player {
    right: 0;
    animation: mbRun 0.46s linear infinite;
    transform-origin: 50% 100%;
  }
  @keyframes mbRun {
    0% { transform: scaleX(-1) translateY(0) translateX(0); }
    25% { transform: scaleX(-1) translateY(-4px) translateX(-1px); } /* 첫 걸음 도약 */
    50% { transform: scaleX(-1) translateY(0) translateX(0); }
    75% { transform: scaleX(-1) translateY(-4px) translateX(1px); } /* 반대 발 도약 */
    100% { transform: scaleX(-1) translateY(0) translateX(0); }
  }

  .mb-demo-sentence {
    margin: 0 0 14px;
    font-size: 1.05rem;
    line-height: 1.9;
    word-break: keep-all;
    color: #59627a;
  }
  .mb-demo-sentence .d-done {
    color: #5ddc8f;
  }
  .mb-demo-sentence .d-now {
    color: #5b8cff;
  }
  /* 오타를 낸 순간. 실제 게임의 char-wrong과 같은 색을 쓴다 */
  .mb-demo-sentence .d-wrong {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.18);
    border-radius: 3px;
  }
  .mb-demo-sentence .d-todo {
    color: #59627a;
  }
  .mb-demo-input {
    display: flex;
    align-items: center;
    min-height: 40px;
    border: 1px solid #2f3646;
    border-radius: 8px;
    background: #0b0e15;
    padding: 8px 12px;
    font-size: 0.95rem;
    color: #e6e6e6;
  }
  .mb-caret {
    display: inline-block;
    width: 2px;
    height: 1.05em;
    margin-left: 1px;
    background: #5b8cff;
    animation: mbBlink 1s step-end infinite;
  }
  @keyframes mbBlink {
    50% { opacity: 0; }
  }
  .mb-demo-caption {
    margin: 10px 0 28px;
    font-size: 0.78rem;
    line-height: 1.6;
    color: #6b7488;
  }

  .mb-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 26px;
  }
  .mb-links a {
    display: block;
    border: 1px solid #2c3346;
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 0.92rem;
    font-weight: 600;
    color: #cfd6e2;
    text-decoration: none;
    background: #141922;
  }
  .mb-links a:active {
    border-color: #5b8cff;
  }

  .mb-footnote {
    font-size: 0.85rem;
    line-height: 1.7;
    color: #8b95a7;
    margin: 0 0 24px;
  }
  .mb-footnote strong {
    color: #e6e6e6;
  }

  .mb-foot-links {
    border-top: 1px solid #232a38;
    padding-top: 18px;
  }
  .mb-foot-links a {
    color: #6b7488;
    text-decoration: none;
    font-size: 0.8rem;
    margin: 0 10px;
  }
}

/* 레벨 클리어/게임오버/승리 화면의 평균 속도 한 줄 */
.avg-speed {
  color: #9aa4b2;
  font-size: 0.95rem;
}
.avg-speed span:nth-child(2) {
  color: #8fb2ff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
