* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: -webkit-fill-available;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* 移动端视口高度适配 */
@supports (height: 100dvh) {
  html, body {
    height: 100dvh;
    min-height: 100dvh;
  }
}

/* 电脑端：限制为手机屏幕尺寸，居中显示 */
@media (min-width: 481px) {
  html {
    background: #1a1a1a;
  }
  body {
    width: 375px;
    max-width: 100%;
    height: 812px;
    max-height: 100vh;
    max-height: 100dvh;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 20px 60px rgba(0,0,0,0.5);
  }
  .section {
    min-height: 100%;
  }
}

.hidden {
  display: none !important;
}

/* 音乐按钮 */
.music-btn {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 100;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.music-btn:hover {
  background: rgba(0, 0, 0, 0.6);
}

.music-btn:active {
  transform: scale(0.95);
}

.music-icon {
  width: 24px;
  height: 24px;
}

.music-icon--hidden {
  display: none;
}

.music-btn.playing .music-icon--hidden {
  display: block;
}

.music-btn.playing #musicIconPlay {
  display: none;
}

.music-btn:not(.playing) #musicIconPause {
  display: none;
}

/* 通用 section */
.section {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 视频区域 */
.section--video {
  background: #000;
  cursor: pointer;
}

.entry-gif {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.video-cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.video-tap-hint {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.4);
  border-radius: 24px;
  pointer-events: none;
}

/* 贺卡区域 */
.section--card {
  flex-direction: column;
  background: #1a1a1a;
}

.card-draw-area {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.card-bg-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.card-bg-img {
  width: 100%;
  height: 100%;
  /* object-fit: cover; */
  object-position: center;
  display: block;
}

.draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.card-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
}

.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.color-swatch {
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  border: 3px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

@media (max-width: 480px) {
  .color-swatch {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch--active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.erase-btn {
  padding: 8px 16px;
  min-width: 42px;
  min-height: 42px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: rgba(100, 100, 100, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 21px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

.erase-btn:hover {
  background: rgba(80, 80, 80, 0.9);
  transform: scale(1.05);
}

.erase-btn:active {
  transform: scale(0.98);
}

@media (max-width: 480px) {
  .erase-btn {
    min-width: 40px;
    min-height: 40px;
    font-size: 13px;
    padding: 6px 12px;
  }
}

.card-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.generate-btn {
  padding: 14px 40px;
  min-height: 48px;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  background: linear-gradient(135deg, #f5e6a3, #d4af37);
  border: 2px solid #fff;
  border-radius: 28px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.refresh-btn {
  padding: 14px 24px;
  min-height: 48px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #fff;
  border-radius: 28px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

@media (max-width: 480px) {
  .generate-btn {
    padding: 12px 32px;
    min-height: 48px;
    font-size: 16px;
  }
  .refresh-btn {
    padding: 12px 20px;
    min-height: 48px;
    font-size: 15px;
  }
}

.generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.generate-btn:active {
  transform: translateY(0);
}

.refresh-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: translateY(-2px);
}

.refresh-btn:active {
  transform: translateY(0);
}

.blessing-btn {
  padding: 14px 24px;
  min-height: 48px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #fff;
  border-radius: 28px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.blessing-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: translateY(-2px);
}

.card-logos {
  position: absolute;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  justify-content: center;
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
  background: rgba(200, 200, 200, 0.5);
  border-radius: 12px;
  z-index: 10;
}

.card-logo {
  height: 48px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}

.card-blessing {
  width: 100%;
  padding: 0 16px 8px;
  pointer-events: none;
  color: #d4af37;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.6;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.card-blessing .blessing-line {
  text-align: left;
}

@media (min-width: 480px) {
  .card-blessing {
    font-size: 22px;
  }
}

.blessing-modal__content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 320px;
  width: 90%;
  z-index: 1;
}

.blessing-modal__title {
  margin: 0 0 20px;
  font-size: 18px;
  color: #333;
  text-align: center;
}

.blessing-form__label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.blessing-form__label span {
  font-size: 14px;
  color: #666;
}

.blessing-form__label input[type="text"] {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}

.blessing-form__label--checkbox {
  flex-direction: row;
  align-items: center;
}

.blessing-form__label--checkbox input {
  margin-right: 8px;
}

.blessing-save-btn {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #c41e3a, #8b0000);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* 模态框 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  min-height: 100vh;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

.modal__content {
  position: relative;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
}

.modal__close {
  position: absolute;
  top: -48px;
  right: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.modal__image {
  max-width: 100%;
  max-height: calc(90dvh - 60px);
  max-height: calc(90vh - 60px);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: default;
  pointer-events: auto;
}

.modal__tip {
  margin-top: 16px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 480px) {
  .modal__tip {
    font-size: 13px;
  }
}
