:root {
  --night: #1c2445;
  --ink: #2b1f24;
  --paper: #faf5e6;
  --gold: #ffd647;
  --red: #d63838;
  --green: #59bf66;
  --blue: #3d6ec7;
  --font: "Apple SD Gothic Neo", "Hiragino Sans", "PingFang SC", "Noto Sans KR", "Noto Sans JP", "Noto Sans SC", "Malgun Gothic", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0f1428;
  color: #fff;
  font-family: var(--font);
  font-weight: 800;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  position: relative;
  background: var(--night);
  overflow: hidden;
  touch-action: manipulation;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.screen[hidden] { display: none; }
.dim-35 { background: rgba(0, 0, 0, 0.35); }
.dim-55 { background: rgba(0, 0, 0, 0.55); justify-content: center; }
.dim-60 { background: rgba(0, 0, 0, 0.6); justify-content: center; }

/* 타이틀 */
#title { justify-content: space-between; padding: 64px 0 50px; }
.title-top, .title-bottom { display: flex; flex-direction: column; align-items: center; width: 100%; }
.santa { width: 80px; height: 80px; }
.faces { display: flex; gap: 10px; margin-top: 22px; }
.faces img { width: 44px; height: 44px; object-fit: contain; }
.bob { animation: bob 1.4s ease-in-out infinite; }
.bob.late { animation-delay: -0.7s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

h1 {
  margin: 10px 20px 0;
  font-size: 52px;
  line-height: 1.15;
  color: var(--red);
  text-shadow: 3px 3px 0 #fff;
  white-space: nowrap;
  text-align: center;
}
.sub { margin: 14px 0 0; font-size: 16px; text-shadow: 2px 2px 0 var(--ink); text-align: center; padding: 0 24px; line-height: 1.4; }
.best { margin: 0 0 14px; font-size: 15px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); }
.title-bottom .btn { width: calc(100% - 80px); }

.btn {
  display: block;
  min-height: 48px;
  padding: 8px 10px 14px;
  border: 0;
  border-radius: 0;
  color: #fff;
  font: inherit;
  font-size: 17px;
  cursor: pointer;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.25);
}
.btn:active { transform: translateY(2px); }
.btn.green { background: var(--green); }
.btn.blue { background: var(--blue); }

.link {
  margin-top: 18px;
  background: none;
  border: 0;
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  text-shadow: 1px 1px 0 var(--ink);
}
.links { display: flex; gap: 14px; margin-top: 8px; font-size: 12px; }
.links a { color: rgba(255, 255, 255, 0.6); text-decoration: none; }

/* 규칙 안내·게임 오버 패널 (RetroPanel) */
.panel {
  width: calc(100% - 40px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: var(--paper);
  border: 4px solid var(--ink);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-align: center;
}
.panel .santa-s { width: 56px; height: 56px; }
.panel h2 { margin: 0; font-size: 26px; }
.panel p { margin: 0; font-size: 15px; line-height: 1.4; }
.panel .btn { width: 100%; }
.red { color: var(--red); }
.muted { color: rgba(43, 31, 36, 0.7); }

.rules { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.rules li { display: flex; align-items: center; gap: 12px; font-size: 14px; line-height: 1.35; }
.rules b { color: var(--red); }
.icon { position: relative; flex: 0 0 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.icon img { width: 40px; height: 40px; }
.icon.house .face { position: absolute; width: 30px; height: 30px; top: 9px; left: 7px; }
.icon.faces3 img, .icon.faces2 img { position: absolute; width: 24px; height: 24px; }
.icon.faces3 img:nth-child(1) { left: 0; top: 4px; }
.icon.faces3 img:nth-child(2) { left: 10px; top: 16px; }
.icon.faces3 img:nth-child(3) { left: 20px; top: 4px; }
.icon.faces2 img:nth-child(1) { left: 5px; top: 4px; }
.icon.faces2 img:nth-child(2) { left: 15px; top: 16px; }
.reddish { filter: sepia(1) saturate(4) hue-rotate(-30deg); }

/* 소리 버튼: 시간 막대 오른쪽 (main.js placeSound) */
.sound {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 52px;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  z-index: 5;
}
.sound img { width: 33px; height: 24px; display: block; margin: 0 auto; }
.sound:active img { transform: translateY(2px); }

/* 광고 (카카오 애드핏). 게임 버튼과 떨어뜨려 둔다. 기준은 main.js 의 WIDE 와 같게 */
.rail { display: none; }
.mbanner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom);
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
}
body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) and (min-height: 640px) {
  body { gap: 40px; padding-bottom: env(safe-area-inset-bottom); }
  .mbanner { display: none; }
  .rail {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 160px;
    width: 160px;
    height: 600px;
  }
}
