* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #87CEEB;
  font-family: 'Fredoka One', 'Noto Sans KR', sans-serif;
}

#canvas-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* UI Overlay */
#ui-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.score-badge {
  background: rgba(255, 255, 255, 0.92);
  border: 4px solid #222;
  border-radius: 18px;
  padding: 10px 24px;
  box-shadow: 0 6px 0 #222;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 110px;
}

.score-title {
  font-size: 13px;
  color: #666;
  font-weight: 800;
  letter-spacing: 1px;
}

.score-value {
  font-size: 40px;
  color: #ff4757;
  line-height: 1;
  margin-top: 4px;
  text-shadow: 2px 2px 0 #ffeaa7;
}

/* 상단 중앙 테마 변경 뱃지 */
.theme-badge {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid #222;
  border-radius: 20px;
  padding: 8px 16px;
  box-shadow: 0 4px 0 #222;
  font-size: 15px;
  color: #2f3542;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.15s ease;
}

.theme-badge:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 0 #222;
}

.theme-badge:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #222;
}

.highscore-badge {
  background: #feca57;
  border: 4px solid #222;
  border-radius: 18px;
  padding: 10px 20px;
  box-shadow: 0 6px 0 #222;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  color: #222;
}

.highscore-badge span {
  font-size: 24px;
  color: #ee5253;
}

/* 조작 안내 힌트 */
.controls-hint {
  align-self: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  padding: 8px 20px;
  border-radius: 30px;
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.5px;
  animation: pulseHint 2s infinite ease-in-out;
  margin-bottom: 8px;
}

@keyframes pulseHint {
  0%, 100% { transform: translateY(0); opacity: 0.9; }
  50% { transform: translateY(-4px); opacity: 1; }
}

/* 캐릭터 선택 독 (하단 좌측) */
.char-dock-container {
  position: absolute;
  bottom: 24px;
  left: 24px;
  pointer-events: auto;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dock-title {
  font-size: 12px;
  color: #ffffff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  padding-left: 6px;
}

.char-dock {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  padding: 8px 10px;
  border-radius: 20px;
  border: 3px solid #222;
  box-shadow: 0 6px 0 #222;
}

.char-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 3px solid #222;
  background: #ffffff;
  box-shadow: 0 3px 0 #222;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.char-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 0 #222;
}

.char-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #222;
}

.char-btn.active {
  background: #feca57;
  border-color: #ee5253;
  transform: translateY(-4px) scale(1.1);
  box-shadow: 0 5px 0 #ee5253;
}

/* Game Over 모달 팝업 */
#modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  pointer-events: auto;
}

.modal-box {
  background: #ffffff;
  border: 6px solid #222;
  border-radius: 28px;
  box-shadow: 0 14px 0 #222;
  width: 90%;
  max-width: 420px;
  padding: 32px 26px;
  text-align: center;
  animation: bounceIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounceIn {
  0% { transform: scale(0.6) translateY(50px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.death-icon {
  font-size: 52px;
  margin-bottom: 8px;
  display: inline-block;
  animation: shakeIcon 0.8s ease;
}

@keyframes shakeIcon {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-15deg); }
  40% { transform: rotate(15deg); }
  60% { transform: rotate(-10deg); }
  80% { transform: rotate(10deg); }
}

.modal-title {
  font-size: 32px;
  color: #ff4757;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.death-reason {
  font-size: 16px;
  color: #57606f;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-scores {
  background: #f1f2f6;
  border: 3px solid #222;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.score-group {
  display: flex;
  flex-direction: column;
}

.score-group .label {
  font-size: 12px;
  color: #747d8c;
  font-weight: 800;
}

.score-group .val {
  font-size: 30px;
  color: #2f3542;
}

.restart-btn {
  background: #2ed573;
  color: #ffffff;
  border: 4px solid #222;
  border-radius: 18px;
  padding: 14px 28px;
  font-size: 20px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 0 #222;
  transition: all 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.restart-btn:hover {
  background: #26af5f;
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #222;
}

.restart-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #222;
}

.key-tip {
  font-size: 12px;
  color: #a4b0be;
  margin-top: 14px;
}

/* 모바일 가상 패드 (터치 기기 지원) */
#mobile-controls {
  display: none;
  position: absolute;
  bottom: 24px;
  right: 24px;
  pointer-events: auto;
  z-index: 50;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 56px);
  gap: 8px;
}

.d-btn {
  background: rgba(255, 255, 255, 0.85);
  border: 3px solid #222;
  border-radius: 14px;
  box-shadow: 0 4px 0 #222;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.d-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #222;
  background: #dfe4ea;
}

@media (pointer: coarse), (max-width: 768px) {
  #mobile-controls {
    display: grid;
  }
  .controls-hint {
    display: none;
  }
  .char-dock-container {
    bottom: 84px;
  }
}

/* Tiny Dash 로고 */
.game-logo {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%);
  font-family: 'Fredoka One', sans-serif; font-size: 22px; letter-spacing: 1px;
  color: #fff; text-shadow: 0 0 4px rgba(0,0,0,0.55), 0 3px 0 rgba(0,0,0,0.3); pointer-events: none; white-space: nowrap;
}
.game-logo span { color: #ffd32a; }

.stage-badge {
  background: rgba(0,0,0,0.35); color: #fff; padding: 6px 14px; border-radius: 14px;
  font-family: 'Fredoka One', sans-serif; font-size: 16px; pointer-events: none;
}
.stage-badge span { color: #ffd32a; }
.stage-toast {
  position: fixed; top: 30%; left: 50%; transform: translate(-50%, -50%) scale(0.6);
  opacity: 0; pointer-events: none; z-index: 50; text-align: center;
  background: rgba(30,39,46,0.82); color: #fff; padding: 18px 34px; border-radius: 20px;
  border: 4px solid #ffd32a; transition: opacity .25s, transform .25s;
}
.stage-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.stage-toast .st-main { font-family: 'Fredoka One', sans-serif; font-size: 40px; color: #ffd32a; }
.stage-toast .st-sub { font-family: 'Noto Sans KR', sans-serif; font-weight: 800; font-size: 18px; margin-top: 4px; }
.stage-toast .st-bonus { font-family: 'Fredoka One', sans-serif; font-size: 16px; color: #7bed9f; margin-top: 4px; }
