* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #0a0c12;
  color: #e8edff;
  font-family: -apple-system, "SF Pro Text", "Pretendard", system-ui, sans-serif;
  overflow: hidden;
  height: 100%;
}

#app {
  position: fixed;
  inset: 0;
}

#cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  transform: scaleX(-1);
  filter: brightness(0.55) saturate(1.05);
  z-index: 0;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

#hud {
  position: absolute;
  top: 24px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
  pointer-events: none;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.8);
}

#timer {
  font-size: 18px;
  font-weight: 600;
  color: #b9c0dc;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  opacity: 0.85;
}

#score {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

#combo {
  font-size: 22px;
  color: #9aa3c7;
  margin-top: -4px;
}

/* ===== 라이프 하트 (3개) ===== */
#lives {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  justify-content: center;
}
#lives .heart {
  position: relative;
  width: 38px;
  height: 36px;
  transition: width 0.4s ease-out, opacity 0.4s ease-out;
}
#lives .heart.collapsed {
  width: 0;
  opacity: 0;
  pointer-events: none;
  margin: 0;
}
#lives .heart .half {
  position: absolute;
  inset: 0;
  filter: drop-shadow(0 0 6px rgba(255, 58, 92, 0.65));
}
#lives .heart .half.left {
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}
#lives .heart .half.right {
  clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%);
}
#lives .heart .heart-shape {
  width: 100%;
  height: 100%;
  display: block;
}

/* 깨짐 — 좌/우 두 조각이 양쪽으로 회전하며 떨어진다. */
#lives .heart.dying .half.left {
  animation: heart-shatter-left 0.65s ease-in forwards;
}
#lives .heart.dying .half.right {
  animation: heart-shatter-right 0.65s ease-in forwards;
}

@keyframes heart-shatter-left {
  0%   { transform: translate(0, 0) rotate(0); opacity: 1; }
  20%  { transform: translate(-6px, -2px) rotate(-8deg); opacity: 1; }
  100% { transform: translate(-30px, 36px) rotate(-55deg); opacity: 0; }
}
@keyframes heart-shatter-right {
  0%   { transform: translate(0, 0) rotate(0); opacity: 1; }
  20%  { transform: translate(6px, -2px) rotate(8deg); opacity: 1; }
  100% { transform: translate(30px, 36px) rotate(55deg); opacity: 0; }
}

#judge {
  margin-top: 12px;
  font-size: 28px;
  font-weight: 700;
  height: 36px;
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

#judge.show { opacity: 1; }
#judge.perfect { color: #6ad8ff; text-shadow: 0 0 24px rgba(106, 216, 255, 0.6); }
#judge.good { color: #b6ff7a; text-shadow: 0 0 18px rgba(182, 255, 122, 0.5); }
#judge.miss { color: #ff6b8a; text-shadow: 0 0 14px rgba(255, 107, 138, 0.5); }

/* 디버그 좌표 HUD와 음소거 버튼은 숨김 처리.
   마크업과 JS 핸들러는 유지(나중에 부활 가능). */
#debug-hud { display: none; }
#muteBtn { display: none; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(8, 10, 18, 0.85) 0%, rgba(8, 10, 18, 0.65) 100%);
  z-index: 5;
  text-align: center;
  padding: 32px;
}

.screen.hidden { display: none; }

h1 {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
  background: linear-gradient(90deg, #6ad8ff, #ff6b8a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ============= 90년대 코인업 시작 화면 ============= */

#overlay.arcade {
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.02) 0px,
      rgba(255, 255, 255, 0.02) 1px,
      transparent 1px,
      transparent 4px
    ),
    radial-gradient(ellipse at center, #0e1426 0%, #060814 70%, #020308 100%);
  font-family: "Impact", "Arial Black", "Helvetica Neue", system-ui, sans-serif;
  text-transform: uppercase;
}

.arcade-marquee {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4em;
  color: #ffd86a;
  margin-bottom: 28px;
  text-shadow:
    0 0 10px rgba(255, 216, 106, 0.6),
    0 0 20px rgba(255, 216, 106, 0.3);
  animation: arcade-marquee-pulse 2.4s ease-in-out infinite;
}

@keyframes arcade-marquee-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.arcade-title {
  background: none !important;
  -webkit-text-fill-color: initial !important;
  color: initial !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0 0 32px;
  font-family: inherit;
  line-height: 0.9;
}

.arcade-title-row {
  font-size: 96px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #ffe066;
  -webkit-text-stroke: 4px #c0151f;
  text-shadow:
    6px 6px 0 #6a0d11,
    8px 8px 0 #2a0507,
    10px 10px 24px rgba(0, 0, 0, 0.8);
  font-style: italic;
  transform: skewX(-6deg);
}

.arcade-title-amp {
  font-size: 56px;
  font-weight: 900;
  color: #ff5577;
  -webkit-text-stroke: 3px #6a0d11;
  text-shadow:
    4px 4px 0 #2a0507,
    6px 6px 18px rgba(0, 0, 0, 0.8);
  margin: -6px 0;
  font-style: italic;
}

.arcade-rules {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 36px;
  padding: 14px 28px;
  border: 2px solid rgba(255, 216, 106, 0.35);
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 24px rgba(255, 216, 106, 0.12) inset;
}

/* 표적 미리보기 갤러리 */
.arcade-gallery {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0 0 32px;
  padding: 18px 24px;
  border: 2px solid rgba(255, 216, 106, 0.32);
  background: rgba(0, 0, 0, 0.55);
  box-shadow: 0 0 24px rgba(255, 216, 106, 0.1) inset;
  min-width: 480px;
}

.arcade-gallery-row {
  display: flex;
  align-items: center;
  gap: 18px;
}

.arcade-gallery-label {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.18em;
  width: 100px;
  flex-shrink: 0;
  text-align: left;
  font-style: italic;
  -webkit-text-stroke: 1.5px rgba(0, 0, 0, 0.85);
}

.arcade-gallery-row.good .arcade-gallery-label {
  color: #b6ff7a;
}
.arcade-gallery-row.bad .arcade-gallery-label {
  color: #ff6b8a;
}

.arcade-gallery-items {
  display: flex;
  gap: 14px;
  align-items: center;
}

.arcade-gallery-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.arcade-gallery-cell canvas {
  width: 56px;
  height: 56px;
  display: block;
}

.arcade-gallery-cell .lab {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 700;
  text-transform: none;
}

.arcade-gallery-row.good .arcade-gallery-cell .lab {
  color: #ffd86a;
}
.arcade-gallery-row.bad .arcade-gallery-cell .lab {
  color: #ff8aa3;
}

.arcade-rule {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.16em;
  font-variant-numeric: tabular-nums;
}
.arcade-rule-key { font-weight: 900; }
.arcade-rule.treasure .arcade-rule-key { color: #ffe066; }
.arcade-rule.treasure .arcade-rule-val { color: #b6ff7a; }
.arcade-rule.pest .arcade-rule-key { color: #b46aff; }
.arcade-rule.pest .arcade-rule-val { color: #ff6b8a; }
.arcade-rule.bomb .arcade-rule-key { color: #ff5577; }
.arcade-rule.bomb .arcade-rule-val { color: #ff6b8a; }

button.arcade-start {
  margin: 0 0 18px;
  padding: 16px 56px;
  background: #ffd83a;
  color: #2a0507;
  border: 4px solid #2a0507;
  border-radius: 0;
  font-family: inherit;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-style: italic;
  transform: skewX(-8deg);
  box-shadow:
    6px 6px 0 #c0151f,
    9px 9px 0 #2a0507;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
button.arcade-start:hover {
  transform: skewX(-8deg) translate(-2px, -2px);
  box-shadow:
    8px 8px 0 #c0151f,
    11px 11px 0 #2a0507;
}
button.arcade-start:active {
  transform: skewX(-8deg) translate(2px, 2px);
  box-shadow:
    4px 4px 0 #c0151f,
    6px 6px 0 #2a0507;
}
button.arcade-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.arcade-button-row {
  display: flex;
  gap: 28px;
  align-items: center;
  margin-top: 20px;
}
/* 시작 화면처럼 PRESS START + ARCADE를 한 줄에 둘 때 두 버튼 폭을 통일. */
.arcade-button-row > button.arcade-start {
  flex: 0 0 auto;
  min-width: 280px;
  text-align: center;
}

/* HOME 버튼 — RETRY와 같은 스큐/그림자 형태에 색만 푸른 톤. */
button.arcade-start.arcade-secondary {
  background: #6ad8ff;
  color: #0a1a2a;
  box-shadow:
    6px 6px 0 #1a4a6a,
    9px 9px 0 #0a1a2a;
}
button.arcade-start.arcade-secondary:hover {
  box-shadow:
    8px 8px 0 #1a4a6a,
    11px 11px 0 #0a1a2a;
}
button.arcade-start.arcade-secondary:active {
  box-shadow:
    4px 4px 0 #1a4a6a,
    6px 6px 0 #0a1a2a;
}

/* 게임 시작 카운트다운 — 화면 정중앙 큰 숫자. */
#countdown {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-family: "Impact", "Arial Black", system-ui, sans-serif;
  font-size: 240px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.04em;
  color: #ffd83a;
  -webkit-text-stroke: 6px #c0151f;
  text-shadow:
    8px 8px 0 #6a0d11,
    12px 12px 0 #2a0507,
    16px 16px 28px rgba(0, 0, 0, 0.85);
  animation: countdown-pop 0.85s ease-out;
}
#countdown.go {
  font-size: 180px;
  color: #b6ff7a;
  -webkit-text-stroke: 6px #1a4a14;
  text-shadow:
    8px 8px 0 #2a4a14,
    12px 12px 0 #0a1a06,
    16px 16px 28px rgba(0, 0, 0, 0.85);
}
#countdown.hidden { display: none; }

@keyframes countdown-pop {
  0%   { transform: scale(0.55); opacity: 0; }
  30%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.0);  opacity: 1; }
}

/* Pause 화면 안내 텍스트 강조 + 깜빡임. */
#pause .hint {
  font-size: 16px;
  letter-spacing: 0.28em;
  color: #ffd86a;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(255, 216, 106, 0.55);
  margin: 0 0 20px;
  animation: arcade-coin-blink 1.1s steps(2, end) infinite;
  text-transform: uppercase;
}

.arcade-coin {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: #ff5577;
  text-shadow: 0 0 12px rgba(255, 85, 119, 0.6);
  animation: arcade-coin-blink 0.9s steps(2, end) infinite;
  margin-bottom: 8px;
}

@keyframes arcade-coin-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

#overlay.arcade .hint.small {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: #6f7898;
  text-transform: none;
}

h2 {
  font-size: 40px;
  font-weight: 800;
  margin: 0 0 16px;
}

#result-grade {
  font-family: "Impact", "Arial Black", system-ui, sans-serif;
  font-size: 200px;
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.04em;
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
  font-style: italic;
  -webkit-text-stroke: 5px rgba(0, 0, 0, 0.85);
}

#result-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
}
#result-score-wrap .lab {
  font-size: 14px;
  letter-spacing: 0.18em;
  color: #6f7898;
  font-weight: 600;
}
#result-score {
  font-size: 72px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

#result-stats {
  display: flex;
  flex-direction: row;
  gap: 32px;
  align-items: center;
  margin-bottom: 8px;
}
#result-stats > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 96px;
}
#result-stats .lab {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #6f7898;
  font-weight: 600;
}
#result-stats .val {
  font-size: 24px;
  font-weight: 700;
  color: #e8edff;
  font-variant-numeric: tabular-nums;
}

.hint {
  font-size: 17px;
  color: #b9c0dc;
  margin: 4px 0;
}

.hint.small { font-size: 13px; color: #6f7898; }

button {
  margin-top: 32px;
  background: linear-gradient(180deg, #2c365a, #1a2140);
  color: #e8edff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 16px 48px;
  font-size: 18px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

button:hover { transform: translateY(-1px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
