*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  overflow: hidden;
  background: #1a1a2e;
  font-family: monospace;
}

#c {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* 시작 오버레이 */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  z-index: 10;
}

#overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
}

.overlay-content h1 {
  font-size: 3rem;
  letter-spacing: 0.3em;
  margin-bottom: 1rem;
  color: #ff4444;
}

.overlay-content p {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.mode-select {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin: 22px 0 18px;
}

.mode-btn {
  min-width: 132px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.42);
  color: rgba(255, 255, 255, 0.88);
  font-family: monospace;
  font-size: 1rem;
  padding: 12px 18px;
  cursor: pointer;
  letter-spacing: 0.12em;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.mode-btn:hover {
  border-color: #ff4444;
  color: #ff4444;
  background: rgba(255, 68, 68, 0.08);
}

.overlay-content small {
  font-size: 0.9rem;
  opacity: 0.5;
}

/* 크로스헤어 */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.6rem;
  line-height: 1;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

/* HUD */
#hud {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 48px;
  color: white;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
}

#ammo {
  color: #ffcc00;
}

/* 조준경 오버레이 */
#scope-overlay {
  position: fixed;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 6;
}

/* 타이머 */
#timer {
  color: #00ccff;
  letter-spacing: 0.05em;
}

/* 게임 완료 메시지 */
#completion-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #ff4444;
  border-radius: 8px;
  padding: 36px 48px;
  text-align: center;
  color: white;
  z-index: 20;
  font-family: monospace;
}

#completion-message.hidden {
  display: none;
}

#completion-time {
  font-size: 2rem;
  color: #00ccff;
  letter-spacing: 0.1em;
  margin-bottom: 20px;
}

#restart-btn {
  background: transparent;
  border: 1px solid #ff4444;
  color: #ff4444;
  font-family: monospace;
  font-size: 1rem;
  padding: 10px 28px;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: background 0.15s, color 0.15s;
}

#restart-btn:hover {
  background: #ff4444;
  color: #000;
}

/* 기록보기 버튼 */
#records-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: rgba(255, 255, 255, 0.8);
  font-family: monospace;
  font-size: 0.85rem;
  padding: 7px 16px;
  cursor: pointer;
  letter-spacing: 0.1em;
  z-index: 20;
  transition: border-color 0.15s, color 0.15s;
}

#records-btn:hover {
  border-color: #ff4444;
  color: #ff4444;
}

/* 기록 모달 */
#records-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

#records-modal.hidden {
  display: none;
}

#records-modal-inner {
  background: #0d0d1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 32px 40px;
  width: min(360px, calc(100vw - 32px));
  max-height: 80vh;
  overflow-y: auto;
  font-family: monospace;
  color: white;
  text-align: center;
}

#records-modal-inner h2 {
  color: #ff4444;
  letter-spacing: 0.2em;
  margin-bottom: 20px;
  font-size: 1.2rem;
}

#records-list {
  list-style: none;
  padding-left: 0;
  margin-bottom: 20px;
  text-align: left;
}

#records-list li {
  display: grid;
  grid-template-columns: 48px 104px minmax(82px, 1fr);
  align-items: center;
  column-gap: 16px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

#records-list li.no-record {
  list-style: none;
  text-align: center;
  color: rgba(255,255,255,0.4);
  padding-left: 0;
}

.rank-num {
  color: rgba(255, 255, 255, 0.5);
}

.rank-time {
  color: #00ccff;
  font-weight: bold;
  letter-spacing: 0.05em;
  text-align: center;
}

.rank-date {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
  text-align: right;
  white-space: nowrap;
}

#records-list li.empty-rank .rank-date {
  color: rgba(255, 255, 255, 0.48);
}

#my-latest-record {
  margin-bottom: 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 16px;
}

.my-latest {
  color: #ffcc00;
  font-size: 0.9rem;
  line-height: 1.8;
}

.my-latest .rank-time {
  color: #ffcc00;
  font-size: 1.1rem;
}

#modal-close-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.7);
  font-family: monospace;
  font-size: 0.9rem;
  padding: 8px 24px;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: border-color 0.15s, color 0.15s;
}

#modal-close-btn:hover {
  border-color: white;
  color: white;
}

.hidden {
  display: none !important;
}

#map-credit {
  position: fixed;
  bottom: 12px;
  right: 16px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  pointer-events: none;
  z-index: 10;
}

#scope-overlay svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(50vw, 50vh);
  height: min(50vw, 50vh);
}
