body {
  margin: 0;
  background-color: #111;
  color: #eee;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
    Arial, sans-serif;
  overflow: hidden; /* 전체 스크롤 방지 */
  touch-action: none; /* 모바일에서 불필요한 제스처 방지 */
}

/* 눈 내리는 효과를 위한 캔버스 (추가됨) */
#snowCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0; /* 배경보다 위, 트리와 겹치게 배치 */
  pointer-events: none; /* 클릭 이벤트를 통과시켜 조작 방해 안 함 */
}

/* 설정 토글 버튼 (플로팅 버튼) */
.fab-actions {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 10000;
  align-items: center;
}

.toggle-btn {
  position: static;
  width: 50px;
  height: 50px;
  background-color: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  color: white;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10000;
  backdrop-filter: blur(5px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.toggle-btn:active {
  transform: scale(0.9);
}

.share-btn {
  width: 44px;
  height: 44px;
  background-color: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: white;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(5px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.share-btn:active {
  transform: scale(0.95);
}

/* 컨트롤 패널 (모바일 최적화: 하단 서랍형) */
.controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  padding: 20px 20px 40px 20px; /* 하단 여백 확보 */
  border-radius: 20px 20px 0 0;
  z-index: 9999;
  max-height: 60vh; /* 화면의 60%까지만 차지 */
  overflow-y: auto; /* 내부 스크롤 허용 */
  box-sizing: border-box;
  transform: translateY(110%); /* 기본적으로 숨김 */
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.controls.active {
  transform: translateY(0); /* 활성화 시 올라옴 */
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  font-weight: bold;
  font-size: 1.1rem;
}

/* desktop-only share button in the control header */
.share-desktop {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  color: #fff;
  cursor: pointer;
}

@media (min-width: 1024px) {
  .share-desktop {
    display: inline-flex;
    align-items: center;
  }
}

.control-group {
  margin-bottom: 15px;
}

.emoji-palette {
  margin-bottom: 12px;
}
.emoji-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.emoji-btn {
  font-size: 18px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  color: white;
  border-radius: 6px;
  cursor: pointer;
}
.emoji-btn.active {
  outline: 2px solid #4caf50;
  background: rgba(76, 175, 80, 0.12);
}

.emoji-controls {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}
.emoji-tool {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.emoji-tool[aria-pressed='true'] {
  background: rgba(76, 175, 80, 0.12);
  outline: 2px solid rgba(76, 175, 80, 0.16);
}

/* emoji decorations inside tree */
.tree-emoji {
  position: absolute;
  pointer-events: none;
  user-select: none;
  font-size: 18px; /* will be resized in JS to match base dot size */
  transform-origin: center center;
}

label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
  color: #ccc;
}

/* 현재 값 표시용 span */
label span {
  color: #4caf50;
  font-weight: bold;
}

/* 슬라이더 스타일 (터치 친화적) */
input[type='range'] {
  width: 100%;
  height: 6px;
  background: #444;
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; /* 터치 타겟 확대 */
  height: 24px;
  background: #4caf50;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

/* 점 스타일 */
.tree-dot {
  position: absolute;
  border-radius: 50%;
  pointer-events: auto; /* allow clicking for decorations */
  will-change: transform, opacity;
}

/* 1번째: 하얀색, 2번째: 초록색: 3번째:빨간색 */
.tree-dot:nth-child(3n + 1) {
  background-color: #fff;
}
.tree-dot:nth-child(3n + 2) {
  background-color: rgb(101, 248, 101);
}
.tree-dot:nth-child(3n + 3) {
  background-color: rgb(255, 71, 71);
}

/* Modal overlay */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 20000;
  align-items: center;
  justify-content: center;
}
.modal-overlay[aria-hidden='false'] {
  display: flex;
}
.modal-content {
  background: #121212;
  padding: 20px 24px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  color: #fff;
  min-width: 240px;
  text-align: center;
}
.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}
.modal-actions button {
  min-width: 80px;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  background: #4caf50;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* Desktop dashboard: show controls as a left sidebar and hide floating buttons */
@media (min-width: 1024px) {
  .controls {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    max-height: 100vh;
    border-radius: 0;
    transform: none !important; /* always visible */
    padding: 24px 16px;
    overflow-y: auto;
  }

  /* place the control header at the top when it's a left dashboard */
  .control-header {
    margin-bottom: 18px;
  }

  /* hide floating action buttons on desktop since the controls are always visible */
  .fab-actions {
    display: none;
  }

  /* when the panel is a left sidebar, ensure dot container is interactive */
  #dot-container {
    pointer-events: auto;
  }
}
