* {
  padding: 0;
  margin: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  background: #fff9f2;
  -webkit-tap-highlight-color: transparent; /*消除移动端的灰色背景闪烁*/
  -webkit-touch-callout: none; /*系统默认菜单被禁用*/
  -webkit-user-select: none; /*webkit浏览器*/
  -khtml-user-select: none; /*早期浏览器*/
  -moz-user-select: none; /*火狐*/
  -ms-user-select: none; /*IE10*/
  user-select: none;
}

input,
textarea {
  -webkit-user-select: auto; /*webkit浏览器*/
  margin: 0px;
  padding: 0px;
  outline: none;
}

#container {
  display: flex;
  flex-direction: column;
  position: absolute;
  left: 0;
  top: 0;
  height: 100% !important;
  width: 100%;
}

/* ── 根布局 ─────────────────────────────────────────── */
/* 竖屏：game-area 全屏，sidebar fixed 叠在上方（logo 顶/CTA 底） */
/* 横屏：game-area 左 58%，sidebar 右 42% 固定栏 */

body {
  position: relative;
  overflow: hidden;
}

#game-area {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  /* 与宣传屏背景一致，canvas 透明区及消失后风格统一 */
  background: linear-gradient(160deg, #fff9f2 0%, #ffeedd 100%);
}

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

/* ── 竖屏：sidebar 覆盖 canvas，logo 顶对齐，CTA 底对齐 ── */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  box-sizing: border-box;
}

/* ── 横屏：左右分栏 ─────────────────────────────────── */
@media (orientation: landscape) {
  #game-area {
    width: 58%;
    height: 100%;
  }

  #sidebar {
    left: 58%;
    top: 0;
    width: 42%;
    height: 100%;
    background: linear-gradient(175deg, #fff0e6 0%, #ffdbb4 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 24px 20px;
    box-sizing: border-box;
    pointer-events: auto;
    box-shadow: -2px 0 16px rgba(0, 0, 0, 0.1);
  }
}

#progress-toolbar {
  height: 20px;
}

#toolbar-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  z-index: 2;
  pointer-events: none;
  transition:
    transform 1s ease-in-out,
    opacity 1s ease-in-out;
  padding-bottom: 72px; /* 竖屏：为底部 CTA 留空 */
  box-sizing: border-box;
}

@media (orientation: landscape) {
  #toolbar-bottom {
    padding-bottom: 8px; /* 横屏：CTA 在右侧栏，不需要留底部空间 */
  }
}

.hidden-toolbar-bottom {
  transform: translateY(100%); /* 移出屏幕下方 */
  opacity: 0; /* 完全透明 */
}

.hidden-toolbar-right {
  transform: translateX(150%); /* 移出屏幕右方 */
  opacity: 0; /* 完全透明 */
}

#color-btns {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  padding: 0px 10px 10px 10px;
  overflow-x: scroll;
  height: 60px;
  align-items: center;
  gap: 10px;
  user-select: none;
  /* 隐藏滚动条但保留滚动功能 */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#color-btns::-webkit-scrollbar {
  display: none;
}

.color-btn-container {
  position: relative;
  min-width: 48px;
  width: 48px;
  height: 48px;
}

.color-btn-container-selected {
  transform: scale(1.2);
}

/* SVG 充满容器 */
.color-btn-progress-ring {
  width: 100%;
  height: 100%;
}

/* 进度条轨道 */
.color-btn-progress-ring-track {
  transition: none;
}

/* 动态进度条 */
.color-btn-progress-ring-value {
  transition: stroke-dashoffset 0.5s ease-in-out;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.color-btn {
  position: absolute;
  min-width: 40px;
  width: 40px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  box-sizing: border-box;
  cursor: pointer;
  pointer-events: auto; /*允许button接收事件*/
  transition: all 0.2s;
}

#progress-wrapper {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  flex-direction: row;
  width: 100%;
  padding-left: 10px;
  padding-right: 10px;
  gap: 10px;
}

#progress-bar {
  box-sizing: border-box;
  flex-grow: 1;
  overflow: hidden;
  text-align: left;
  background-color: lightgray;
  border-radius: 2px;
  height: 4px;
}

#progress {
  transition: width 0.5s ease-in-out;
  width: 0%;
  height: 4px;
  background-color: rgb(7, 206, 7);
}

#percent {
  font-size: 12px;
  color: rgb(7, 206, 7);
  line-height: 12px;
  font-weight: 500;
  font-family: Arial, Helvetica, sans-serif;
}

/* 各种工具buuton */
.btn-img {
  width: 100%;
  height: 100%;
}

.btn-img-mask {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0%;
  border-radius: 50%;
  opacity: 0;
  background: black;
}

/* 有兼容性问题， 干脆不用了，直接js代码里监听各种事件来做吧*/
@media (hover: hover) and (pointer: fine) {
  .btn-img-mask:hover {
    opacity: 0.5;
  }
}

/* 移动端，解决按钮按下去再没复原的问题 */
.btn-img-mask:active {
  opacity: 0.5;
}

.btn {
  z-index: 120;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.16);
}

/*adapt firefox*/
@-moz-document url-prefix() {
  .star-rating input:checked ~ label::before {
    font-size: 36px;
    line-height: 21px;
  }
}

/*全部完成的撒花动画wrapper*/
.finish-ani-wrapper {
  position: absolute;
  pointer-events: none;
  width: 95vw;
  height: 95vh;
  z-index: 90;
  top: 0%;
}

/*撒花动画的花片样式*/
.finish-ani-div {
  position: absolute;
  width: 10px;
  height: 10px;
  top: 0%;
  opacity: 1;
  z-index: 90;
  transition:
    top 3s,
    left 3s,
    opacity 3s;
}

/*爆破动画canvas*/
.finish-ani-canvas {
  position: fixed;
  pointer-events: none;
  bottom: 0px;
  z-index: 300;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 4px;
  animation: fadeInOut 2.5s;
  z-index: 9999;
}
.toast-hidden {
  display: none;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
    bottom: -20px;
  }
  20% {
    opacity: 1;
    bottom: 20px;
  }
  80% {
    opacity: 1;
    bottom: 20px;
  }
  100% {
    opacity: 0;
    bottom: -20px;
  }
}

/* ── Canvas 缩小消失动画 ────────────────────────────── */
#canvas.canvas-shrink-out {
  transition:
    transform 0.55s ease-in,
    opacity 0.55s ease-in;
  transform: scale(0.05);
  opacity: 0;
  pointer-events: none;
}

/* ── Logo 栏 ────────────────────────────────────────── */
/* 竖屏：sidebar 顶部，图标+文字横向排列 */
/* 横屏：右侧栏，图标+文字纵向排列，更大 */
#app-logo-bar {
  width: 100%;
  display: flex;
  flex-direction: row; /* 竖屏：横向 */
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px 0;
  box-sizing: border-box;
  pointer-events: none;
  flex-shrink: 0;
}

#app-logo-bar.visible {
  opacity: 1;
}

#app-logo {
  height: 52px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

#app-logo-txt {
  height: 40px;
  width: auto;
  max-width: 55%;
  display: block;
}

@media (orientation: landscape) {
  #app-logo-bar {
    flex-direction: column; /* 横屏：纵向 */
    gap: 10px;
    padding: 0;
    width: 100%;
  }

  #app-logo {
    height: clamp(64px, 17vh, 110px);
    max-width: 70%;
    object-fit: contain;
  }

  #app-logo-txt {
    height: clamp(28px, 8vh, 48px);
    max-width: 88%;
    object-fit: contain;
  }
}

/* ── 广告标识 ────────────────────────────────────────── */
#ad-badge {
  position: fixed;
  top: 6px;
  right: 8px;
  z-index: 300;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 10px;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

/* ── CTA 按钮容器 ────────────────────────────────────── */
/* 竖屏：sidebar flex 末尾（space-between 自动贴底） */
/* 横屏：sidebar flex 内静态排列 */
#cta-btn-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  pointer-events: none;
  flex-shrink: 0;
}

@media (orientation: landscape) {
  #cta-btn-wrapper {
    width: 100%;
  }

  #cta-btn {
    width: 100%;
    max-width: none;
    height: 52px;
    font-size: 16px;
  }
}

#cta-btn {
  pointer-events: auto;
  width: min(300px, 80vw);
  height: 44px;
  border: none;
  border-radius: 22px;
  background: linear-gradient(135deg, #ff5f1f 0%, #ffb300 100%);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 3px;
  font-family: Arial, Helvetica, sans-serif;
  cursor: pointer;
  /* 立体感阴影 */
  box-shadow:
    0 4px 10px rgba(255, 95, 31, 0.45),
    0 2px 0 rgba(255, 255, 255, 0.25) inset,
    0 -3px 0 rgba(0, 0, 0, 0.18) inset;
  /* 按压效果 */
  transition:
    transform 0.1s ease,
    box-shadow 0.1s ease;
  /* 脉冲光晕动画 */
  animation: cta-pulse 2s ease-in-out infinite;
}

#cta-btn:active {
  transform: scale(0.96) translateY(2px);
  box-shadow:
    0 2px 8px rgba(255, 95, 31, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

@keyframes cta-pulse {
  0%,
  100% {
    box-shadow:
      0 4px 10px rgba(255, 95, 31, 0.45),
      0 2px 0 rgba(255, 255, 255, 0.25) inset,
      0 -3px 0 rgba(0, 0, 0, 0.18) inset;
  }
  50% {
    box-shadow:
      0 4px 16px rgba(255, 95, 31, 0.7),
      0 2px 0 rgba(255, 255, 255, 0.25) inset,
      0 -3px 0 rgba(0, 0, 0, 0.18) inset;
  }
}

/* 填色完成后的强化 CTA 状态 */
@keyframes cta-highlight-pulse {
  0%,
  100% {
    transform: scale(1.08);
    box-shadow:
      0 6px 24px rgba(255, 95, 31, 0.8),
      0 2px 0 rgba(255, 255, 255, 0.3) inset,
      0 -3px 0 rgba(0, 0, 0, 0.2) inset;
  }
  50% {
    transform: scale(1.14);
    box-shadow:
      0 8px 32px rgba(255, 95, 31, 1),
      0 2px 0 rgba(255, 255, 255, 0.3) inset,
      0 -3px 0 rgba(0, 0, 0, 0.2) inset;
  }
}

#cta-btn.cta-highlight {
  animation: cta-highlight-pulse 0.8s ease-in-out infinite;
}

/* ── 宣传界面 ──────────────────────────────────────── */
/* 竖屏/横屏均在 game-area 内 absolute 展开：
   竖屏：game-area=全屏，promo 覆盖全屏；sidebar logo/CTA 在 z:100 叠在上方
   横屏：game-area=左58%，promo 填满左侧 */
#promo-screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: linear-gradient(160deg, #fff9f2 0%, #ffeedd 100%);
  z-index: 10;
  /* 竖屏：顶部让出 logo(~80px)，底部让出 CTA(~72px) */
  padding: 80px 2vw 72px;
  box-sizing: border-box;
}

#promo-screen.visible {
  display: flex;
}

@media (orientation: landscape) {
  #promo-screen {
    /* 横屏：logo/CTA 在右侧栏，无需额外留白 */
    padding: 16px 12px;
    gap: 16px;
  }
}

/* coloring-pages：从小（远）到大（近） */
#promo-coloring {
  max-width: 96%;
  max-height: 52vh;
  object-fit: contain;
  opacity: 0;
  transform: scale(0.12);
  transition:
    transform 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.05s,
    opacity 0.4s ease 0.05s;
}
#promo-coloring.animate-in {
  transform: scale(1);
  opacity: 1;
}

/* slogan：从大（近）到小（正常），比 coloring-pages 晚 0.25s */
#promo-slogon {
  max-width: 95%;
  max-height: 20vh;
  object-fit: contain;
  opacity: 0;
  transform: scale(1.9);
  transition:
    transform 0.65s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.3s,
    opacity 0.35s ease 0.3s;
}
#promo-slogon.animate-in {
  transform: scale(1);
  opacity: 1;
}
