@font-face {
  font-family: 'DenkiChipHangul';
  src: url('fonts/x10y12pxDenkiChipHangul.otf') format('opentype');
}

@font-face {
  font-family: 'DungGeunMo';
  src: url('fonts/DungGeunMo.otf') format('opentype');
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  height: 100dvh; /* 모바일 주소창 유무에 따라 실제 보이는 높이로 갱신됨 (미지원 브라우저는 위 100vh로 폴백) */
  margin: 0;
  background: #000000;
  color: #000000;
  font-family: 'DungGeunMo', sans-serif;
  transition: background-color 0.3s ease;
  /* 더블탭/핀치 확대 같은 제스처가 탭 입력이랑 충돌해서 화면이 흔들리는 걸 방지 */
  touch-action: manipulation;
  overscroll-behavior: none;
}

/* 버튼(input류)은 기본적으로 body 폰트를 상속받지 않아서 명시적으로 지정 */
button {
  font-family: inherit;
}

#game {
  text-align: center;
  width: 900px;
  height: 380px;
  background: #F4F4F4;
  padding: 20px;
  position: relative;
  transform-origin: center center;
}

/* 화면이 900px보다 좁으면(모바일 등) 레이아웃은 그대로 두고 통째로 축소해서
   화면 안에 고정 — 요소 위치 재계산 없이 "풀버전" 그대로 줄어드는 방식 */
@media (max-width: 940px) {
  #game {
    transform: scale(calc((100vw - 20px) / 900px));
  }
}

#beat-bar {
  position: relative;
  margin-top: 30px;
  overflow: hidden;
}

/* 의자(베이스 레이어)는 안 흔들리고, 캐릭터 오버레이만 감싸는 래퍼가 매 박 들썩임.
   래퍼의 transform과 안쪽 img 자신의 transform(active/pending)은 중첩이라 서로 안 겹침 */
.char-bob-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

@keyframes charBob {
  0% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}

.char-bob-wrap.bob {
  animation: charBob 0.15s ease;
}

#beat-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.3s ease;
}

.beat-row {
  display: flex;
  flex-shrink: 0;
}

.slot {
  position: relative;
  width: 120px;
  height: 80px;
  flex-shrink: 0;
}

.slot-x {
  margin-left: -33px;
}

.slot-y {
  margin-left: -20px;
}

.slot-z {
  margin-left: 0px;
}

.slot:first-child {
  margin-left: 0;
}

.slot-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  transform-origin: bottom center;
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s ease;
}

.slot-layer.pending {
  opacity: 0;
  transform: scale(0.6);
}

.slot-layer.active {
  transform: translateY(-8px) scale(1.08);
}

.slot-layer.result-Perfect {
  filter: drop-shadow(0 0 6px #00FFF2) brightness(1.15);
}

.slot-layer.result-Good {
  filter: drop-shadow(0 0 6px #5AFF00) brightness(1.1);
}

.slot-layer.result-Bad {
  filter: drop-shadow(0 0 6px #B0764C) brightness(0.95);
}

.slot-layer.result-Miss {
  filter: drop-shadow(0 0 6px #7A3B3B) grayscale(0.5) brightness(0.85);
}

#game-over {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #F4F4F4;
  clip-path: polygon(
    0% 0%, 16.67% 2.5%, 33.33% 0%, 50% 2.5%, 66.67% 0%, 83.33% 2.5%, 100% 0%,
    97.5% 16.67%, 100% 33.33%, 97.5% 50%, 100% 66.67%, 97.5% 83.33%, 100% 100%,
    83.33% 97.5%, 66.67% 100%, 50% 97.5%, 33.33% 100%, 16.67% 97.5%, 0% 100%,
    2.5% 83.33%, 0% 66.67%, 2.5% 50%, 0% 33.33%, 2.5% 16.67%
  );
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.25));
  padding: 30px 36px;
  max-width: 90vw;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #1C2333;
  text-align: center;
}

#game-over.hidden {
  display: none;
}

#go-ribbon {
  width: 55px;
  height: auto;
  margin-bottom: 4px;
}

#go-title {
  font-size: 1.5em;
  font-weight: 900;
  margin: 2px 0 10px;
}

#go-entered {
  font-size: 0.85em;
  font-weight: 700;
  margin: 0 0 18px;
}

#go-entered-count {
  color: #1C2333;
}

#go-results {
  display: flex;
  gap: 22px;
  justify-content: center;
  margin-bottom: 18px;
}

.go-icon-wrap {
  position: relative;
  width: 84px;
  height: 56px;
}

.go-result-label {
  font-size: 0.75em;
  font-weight: 800;
  margin-top: 4px;
}

.go-result-count {
  font-size: 0.9em;
  font-weight: 800;
  color: #1C2333;
}

#go-score {
  font-size: 1.8em;
  font-weight: 900;
  color: #1C2333;
  margin: 0 0 18px;
}

#restart-btn {
  padding: 10px 24px;
  font-size: 1em;
  background: #6194D7;
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
}

#restart-btn:hover {
  background: #6E6E6E;
}

#pause-btn {
  position: absolute;
  top: 10px;
  left: 16px;
  padding: 7px;
  background: #6E6E6E;
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 이모지 대신 SVG 아이콘 -> currentColor로 채워서 기기/브라우저 상관없이 버튼 color랑 항상 일치 */
#pause-btn svg {
  fill: currentColor;
  display: block;
}

#pause-btn:hover {
  background: #1C2333;
}

#pause-btn.hidden {
  display: none;
}

#how-to-play-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  cursor: pointer;
}

#how-to-play-overlay.hidden {
  display: none;
}

#how-to-play-card {
  width: 400px;
  height: 400px;
  max-width: 90vw;
  max-height: 90vh;
  background: #ffffff;
  /* 지그재그(찢어진 종이/스티커) 테두리 근사 */
  clip-path: polygon(
    0% 0%, 16.67% 2.5%, 33.33% 0%, 50% 2.5%, 66.67% 0%, 83.33% 2.5%, 100% 0%,
    97.5% 16.67%, 100% 33.33%, 97.5% 50%, 100% 66.67%, 97.5% 83.33%, 100% 100%,
    83.33% 97.5%, 66.67% 100%, 50% 97.5%, 33.33% 100%, 16.67% 97.5%, 0% 100%,
    2.5% 83.33%, 0% 66.67%, 2.5% 50%, 0% 33.33%, 2.5% 16.67%
  );
  /* clip-path로 잘린 도형엔 box-shadow가 안 먹혀서 drop-shadow 필터로 대체 */
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.25));
  padding: 26px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #1C2333;
  text-align: center;
  overflow: hidden;
}

#htp-ribbon {
  width: 55px;
  height: auto;
  margin-bottom: 4px;
}

#htp-title {
  font-size: 1.5em;
  font-weight: 900;
  margin: 2px 0 6px;
}

#htp-body {
  font-size: 0.78em;
  line-height: 1.4;
  margin: 0 0 4px;
}

#htp-note {
  font-size: 0.62em;
  color: #6E6E6E;
  margin: 0 0 6px;
}

#htp-controls {
  font-size: 0.68em;
  color: #B5B5B5;
  margin: 0 0 10px;
}

#htp-turns {
  display: flex;
  gap: 30px;
  justify-content: center;
}

.htp-icon-wrap {
  position: relative;
  width: 64px;
  height: 43px;
  margin: 0 auto 4px;
}

/* 매 박마다 트리거되는 인게임 charBob과 별개로, 팝업에서는 계속 스스로 반복되는 버전 */
@keyframes charBobLoop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.char-bob-loop {
  animation: charBobLoop 0.7s ease-in-out infinite;
}

.htp-turn-label {
  font-size: 0.72em;
  font-weight: 700;
  line-height: 1.25;
}

.htp-turn-label span {
  display: block;
  font-size: 0.85em;
  font-weight: 800;
}

#countdown-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  /* 게임방법 팝업이랑 통일: 지그재그(찢어진 종이/스티커) 테두리 */
  clip-path: polygon(
    0% 0%, 16.67% 2.5%, 33.33% 0%, 50% 2.5%, 66.67% 0%, 83.33% 2.5%, 100% 0%,
    97.5% 16.67%, 100% 33.33%, 97.5% 50%, 100% 66.67%, 97.5% 83.33%, 100% 100%,
    83.33% 97.5%, 66.67% 100%, 50% 97.5%, 33.33% 100%, 16.67% 97.5%, 0% 100%,
    2.5% 83.33%, 0% 66.67%, 2.5% 50%, 0% 33.33%, 2.5% 16.67%
  );
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.25));
  padding: 20px 48px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#countdown-overlay.hidden {
  display: none;
}

#countdown-text {
  font-size: 6em;
  font-weight: bold;
  color: #1C2333;
}

#pause-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#pause-overlay.hidden {
  display: none;
}

#pause-card {
  background: #F4F4F4;
  clip-path: polygon(
    0% 0%, 16.67% 2.5%, 33.33% 0%, 50% 2.5%, 66.67% 0%, 83.33% 2.5%, 100% 0%,
    97.5% 16.67%, 100% 33.33%, 97.5% 50%, 100% 66.67%, 97.5% 83.33%, 100% 100%,
    83.33% 97.5%, 66.67% 100%, 50% 97.5%, 33.33% 100%, 16.67% 97.5%, 0% 100%,
    2.5% 83.33%, 0% 66.67%, 2.5% 50%, 0% 33.33%, 2.5% 16.67%
  );
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.25));
  padding: 30px 40px;
  max-width: 90vw;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #1C2333;
  text-align: center;
}

#pause-ribbon {
  width: 55px;
  height: auto;
  margin-bottom: 4px;
}

#pause-title {
  font-size: 1.5em;
  font-weight: 900;
  margin: 2px 0 14px;
}

#pause-buttons {
  display: flex;
  gap: 10px;
}

#resume-btn {
  padding: 10px 24px;
  font-size: 1em;
  background: #6194D7;
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
}

#resume-btn:hover {
  background: #6E6E6E;
}

#pause-restart-btn {
  padding: 10px 24px;
  font-size: 1em;
  background: #B5B5B5;
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
}

#pause-restart-btn:hover {
  background: #6E6E6E;
}

#score-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top:20px
}

#score-value {
  font-family: 'DenkiChipHangul', sans-serif;  
  font-size: 2.4em;
  font-weight: 800;
  line-height: 1.1;
}

#score-value.hidden {
  display: none;
}


#ready-desc {
  position: absolute;
  top: 330px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2em;
  margin-top: 8px;
  max-width: 320px;
  line-height: 1.5;
}
#ready-title {
  position: absolute;
  top: 300px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.5em;
  font-weight: 800;
  letter-spacing: 1px;
}

#mode-select {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.mode-btn {
  padding: 8px 20px;
  font-size: 0.6em;
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0;
}

#easy-mode-btn {
  background: #777777;
}

#easy-mode-btn:hover {
  background: #04bc54;
}

#normal-mode-btn {
  background: #777777;
}

#normal-mode-btn:hover {
  background: #3f807b;
}

#ready-title.hidden,
#ready-desc.hidden {
  display: none;
}

#combo-value {
  font-family: 'DenkiChipHangul', sans-serif;
  font-size: 1em;
  font-weight: 700;
  color: #6E6E6E;
  margin-top: 2px;
  min-height: 1.2em;
  visibility: visible;
}

#combo-value.hidden {
  visibility: hidden;
}

#combo-value.fever {
  color: #FF3B00;
}

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

#score-value.bump,
#combo-value.bump {
  animation: bump 0.25s ease;
}

#turn-flash {
  min-height: 1.0em;
  font-size: 2em;
  font-weight: 900;
  color: #6E6E6E;
}

@keyframes turnFlash {
  0% { opacity: 0; transform: scale(1.6); }
  35% { opacity: 1; transform: scale(1); }
  100% { opacity: 1; transform: scale(1); }
}

#turn-flash.flash {
  animation: turnFlash 0.35s ease;
}

.game-nickname {
  position: absolute;
  bottom: 10px;                  /* 게임 박스 내부 바닥에서 10px 위 */
  left: 35px;
  transform: translateX(-50%);
  
  font-size: 12px;
  color: #888888;                /* #F4F4F4 배경에 잘 어울리는 회색 */
  
  z-index: 10;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}