:root {
    --primary-yellow: #FFD93D;  /* 小鸡黄作为主色调 */
    --primary-pink: #FF6B9D;    /* 活力粉 */
    --primary-blue: #6BC5F2;    /* 科技蓝 */
    --geek-purple: #9D4EDD;     /* 极客紫 */
    --dark-bg: #1A1A2E;         /* 深色背景 */
    --neon-glow: 0 0 20px rgba(255, 217, 61, 0.5);
  }
body, html {
margin: 0;
padding: 0;
overflow: hidden;
height: 100%;
background: black;
color: white;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.background-blur {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
backdrop-filter: blur(10px);
z-index: 0;
}
.controls {
position: absolute;
top: 20px;
right: 58px;
/* background: rgba(0, 0, 0, 0.8); */
background: rgba(40, 40, 40, 0.8);
border: 1px solid rgba(255, 255, 255, 0.1);
padding: 20px;
border-radius: 12px;
z-index: 1000;
width: 280px;
box-sizing: border-box; /* 不设的话 padding+border 会把实际宽度撑到 322px */
max-height: 90vh; /* 限制最大高度 */
overflow-y: auto; /* 添加滚动条 */
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
display: none; /* 默认隐藏 */
}
.controls.visible {
display: block; /* 显示 */
}
.controls label {
display: block;
margin: 12px 0 6px;
font-size: 14px;
color: #fff;
font-weight: 500;
}
.controls input, .controls select, .controls button, .controls .checkbox-group {
width: 100%;
margin-bottom: 12px;
padding: 8px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
font-size: 14px;
background: rgba(255, 255, 255, 0.1);
color: white;
outline: none;
transition: border-color 0.3s, background 0.3s;
}
.controls input:focus, .controls select:focus, .controls button:focus {
border-color: #007bff;
background: rgba(255, 255, 255, 0.2);
}
.controls button {
background: #007bff;
color: white;
cursor: pointer;
border: none;
font-weight: 500;
transition: background 0.3s;
}
.controls button:hover {
background: #0056b3;
}
.controls .checkbox-group {
display: flex;
flex-direction: column;
gap: 8px;
padding: 12px;
}
.controls .checkbox-group label {
margin: 0;
font-size: 13px;
}

/* Effects: disabled/unsupported state (e.g. brush incompatible effects) */
.controls .effect-group label.effect-option-disabled {
  opacity: 0.35;
  filter: grayscale(1);
  cursor: not-allowed;
}

.controls .effect-group label.effect-option-disabled input[type="checkbox"] {
  cursor: not-allowed;
}
.controls .collapse-btn {
background: transparent;
border: none;
color: white;
text-align: left;
padding: 0;
margin: 12px 0 6px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
}
.controls .collapse-btn i {
transition: transform 0.3s;
}
.controls .collapse-btn.collapsed i {
transform: rotate(-90deg);
}
.controls .collapse-content {
overflow: hidden;
transition: max-height 0.3s ease-out;
}
.controls .collapse-content.collapsed {
max-height: 0 !important;
}
.toggle-btn {
position: absolute;
top: 20px;
right: 20px;
/* background: rgba(0, 0, 0, 0.8); */
background: rgba(40, 40, 40, 0.8);
border: 1px solid rgba(255, 255, 255, 0.1);
/* border: none; */
color: white;
padding: 10px;
border-radius: 8px;
cursor: pointer;
z-index: 1000;
transition: background 0.3s;
}
.toggle-btn:hover {
background: rgba(0, 0, 0, 0.9);
}
.eraser-notice {
position: absolute;
top: 20px;
right: 100px;
background: rgba(255, 0, 0, 0.7);
color: white;
padding: 10px;
border-radius: 8px;
display: none;
z-index: 1000;
font-size: 14px;
font-weight: 500;
}
.watermark {
position: absolute;
bottom: 20px;
right: 20px;
font-size: 14px;
color: rgba(255, 255, 255, 0.5);
z-index: 1000;
cursor: pointer; /* Add cursor pointer to indicate clickable */
}

.qr-code {
position: absolute;
bottom: 38px;
right: 20px;
max-width: 38px;
display: none;
z-index: 1000;
}

.qr-code img {
width: 100%;
height: auto;
}

.top-icons-row {
    display: flex;
    gap: 10px;
    justify-content: center;
  }
  
  .top-icons-main {
    margin-bottom: 6px;
  }
  
  .controls .top-icons-row button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
  }
  
  .controls .top-icons-row button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
  }
  
  .controls .top-icons-row button.active {
    background: #007bff;
  }

.recording-notice {
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%);
background: rgba(255, 0, 0, 0.7);
color: white;
padding: 10px;
border-radius: 8px;
display: none;
z-index: 1000;
font-size: 14px;
font-weight: 500;
}
.lazy-mode-notice {
position: absolute;
top: 60px;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 123, 255, 0.7);
color: white;
padding: 10px;
border-radius: 8px;
display: none;
z-index: 1000;
font-size: 14px;
font-weight: 500;
}
.color-preview {
width: 20px;
height: 20px;
border-radius: 4px;
display: inline-block;
margin-left: 10px;
vertical-align: middle;
}
.effect-group {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px;
}
#gptInput {
    width: 88.8%;      
    height: auto;     
    resize: vertical;  
    min-height: 80px;   
    padding: 10px;    
    border: 1px solid #ccc;
    border-radius: 4px;  
    font-size: 12px;    
}

#gptGenerateBtn {
    color: white; 
    padding: 10px 15px; 
    border: none; 
    border-radius: 5px; 
    cursor: pointer; 
    font-size: 14px; 
    transition: background 0.3s; 
}
#gptGenerateBtn:disabled {
    background: #6c757d; 
    color: rgba(255, 255, 255, 0.65); 
    cursor: not-allowed; 
    opacity: 0.65; 
}

#gptBtn {
    width: 88.8%;   
    display: flex; /* 使用 flexbox 布局 */
    justify-content: space-between; /* 在按钮之间留出空间 */
    align-items: center; /* 垂直居中对齐 */
}

#gptGenerateBtn {
    height: 38px; 
}

#refreshPromptBtn {
    width: 38px; /* 设置宽度 */
    height: 38px; /* 设置高度，使其为正方形 */
    margin-left: 8px; /* 将按钮推到右侧 */
}

/* 游戏示例链接样式 */
.game-link {
display: block;
width: 100%;
margin: 8px 0 0 0;
padding: 10px 12px;
background: linear-gradient(135deg, #1f65ff 0%, #6c5ce7 100%);
color: #ffffff;
text-decoration: none;
text-align: center;
border-radius: 10px;
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
transition: transform 0.15s ease, box-shadow 0.3s ease, filter 0.3s ease;
font-size: 14px;
font-weight: 600;
}

.game-link:hover {
transform: translateY(-1px);
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
filter: brightness(1.08);
}

.game-link:active {
transform: translateY(0);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* 图层控制按钮组 */
.layer-btn {
    flex: 1;
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid #555;
    background: #2a2a2a;
    color: #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    outline: none; /* 👈 关键：去掉默认蓝色聚焦边框 */
    box-shadow: none; /* 防止浏览器默认 focus shadow */
  }
  
  .layer-btn:hover {
    background: #3a3a3a;
    color: #fff;
  }
  
  /* 高亮选中状态 */
  .layer-btn.active {
    background: #007acc;      /* 蓝色背景 */
    color: #000000;             /* 白色文字 */
    border-color: #007acc;    /* 边框同色 */
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.3); /* 可选：轻微外发光 */
  }

  .brush-preview-wrapper {
    display: flex;
    justify-content: center;
  }
  #brushPreview {
    width: 100%;
    height: 24px;
    background: #111;
    border-radius: 3px;
    border: 1px solid #444;
    max-width: 180px;
  }
  .color-picker-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  
  .color-swatch {
    width: 40px;
    height: 40px;
    border: 2px solid #555;
    border-radius: 4px;
    cursor: pointer;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
  }
  
  .hidden-color-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }
  
  .recent-colors {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    max-width: 200px;
  }
  
  .recent-colors .color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 3px;
  }

  .size-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
  }
  
  .size-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
  }
  
  .size-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
  }
  
  .size-btn:active {
    transform: scale(0.95);
  }

  /* 通用滑块样式（适用于所有 range 输入） */
input[type="range"] {
    /* 左右留白 */
    padding: 0 8px;
    /* 确保高度一致 */
    height: 24px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
  }
  
  /* 滑块轨道（track） */
  input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
  }
  
  input[type="range"]::-moz-range-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
  }
  
  /* 滑块圆球（thumb）—— 关键：调小尺寸 */
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;          /* ← 圆球宽度 */
    height: 12px;         /* ← 圆球高度 */
    border-radius: 50%;
    background: #007acc;
    cursor: pointer;
    margin-top: -4px;     /* 垂直居中（(12 - 4) / 2 ≈ 4）*/
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  }
  
  input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #007acc;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  }

  .playback-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    z-index: 1000;
    font-family: 'Noto Sans JP', sans-serif;
  }
  
  .playback-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
  }
  
  .progress-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 200px;
  }
  
  .progress-bar {
    width: 100%;
    height: 6px;
    background: #444;
    border-radius: 3px;
    position: relative;
    cursor: pointer;
  }
  
  .progress-fill {
    height: 100%;
    background: #ff6b6b;
    border-radius: 3px;
    width: 0%;
  }
  
  .progress-handle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
  }
  
  .progress-bar:hover .progress-handle {
    opacity: 1;
  }
  
  .time-display {
    font-size: 12px;
    margin-top: 4px;
    color: #ccc;
  }
  
  .playback-speed {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
  }

  
/* ============================================================
   移动端适配（原来整份样式表 0 个媒体查询）
   问题：.controls 固定 right:58px + width:280px，加上 padding/border 实际占 322px，
   390 宽的手机左侧只剩 10px，375/360 直接溢出屏幕、左边内容被裁。
   手机上改成底部抽屉：宽度自适应、左右对称，不再从右侧挤占画布。
   ============================================================ */
@media (max-width: 720px) and (orientation: portrait) {
  .controls {
    position: fixed;
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: 58vh;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px;
    /* 桌面端 0.8 的透明度够用，手机上画布就在正下方，透出来会显得脏 */
    background: rgba(26, 26, 30, 0.96);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* 图标行允许换行，窄屏不再横向溢出 */
  .controls .top-icons-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .controls .top-icons-row button {
    width: 42px;
    height: 42px;
  }

  /* 收起按钮固定右上角，不跟着面板走 */
  .toggle-btn {
    position: fixed;
    top: 10px;
    right: 10px;
  }

  .eraser-notice {
    top: 10px;
    right: 58px;
    font-size: 12px;
    padding: 6px 10px;
  }

  /* 播放条抬到抽屉上方，避免被压住 */
  .playback-controls {
    bottom: calc(58vh + 18px);
    max-width: calc(100vw - 20px);
  }

  /* 水印和二维码在手机上会和底部抽屉打架，且手机扫码没意义，直接隐藏 */
  .watermark,
  .qr-code {
    display: none;
  }
}

/* 横屏不改成底部抽屉：本来高度就矮，抽屉会吃掉大半个画布。
   横屏宽度一般 ≥667，右侧面板（280 + 58）放得下。 */
@media (max-width: 720px) and (orientation: landscape) {
  .controls {
    top: 10px;
    right: 58px; /* 留出右上角收起按钮的位置 */
    max-height: calc(100vh - 20px);
    padding: 12px;
    background: rgba(26, 26, 30, 0.96);
  }

  .toggle-btn {
    top: 10px;
    right: 10px;
  }
}

/* ===== 「同款起点」提示条 =====
   从作品页点「同款做一个」进来时，告诉用户当前画布是照着哪个作品起的，
   并给一个「清空重来」的出口。
   z-index 压在控制面板之上，但它不拦事件，只有按钮可点。 */
.same-one-bar {
  position: fixed;
  top: 14px;
  /* 用 left/right + margin auto 居中，而不是 left:50% + translateX：
     后者在 width:auto 时，可用宽度只算到 left 那一半（187px @375），
     文字会被压成「同款起点 · 水…」。 */
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  z-index: 1002;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(calc(100vw - 130px), 430px);
  padding: 7px 8px 7px 13px;
  border-radius: 999px;
  background: rgba(18, 18, 25, 0.93);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font: 500 12.5px/1 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #e8eaee;
  pointer-events: none;
  animation: sameOneIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* 只用 opacity 做入场，transform 留给居中的 translateX(-50%) */
@keyframes sameOneIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.same-one-bar.is-gone {
  opacity: 0;
  transition: opacity 0.6s ease;
}

.same-one-bar > i {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #ffd54a;
  box-shadow: 0 0 9px rgba(255, 213, 74, 0.85);
}

.same-one-bar > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.same-one-bar > span > b {
  font-weight: 600;
  color: #ffd54a;
}

.same-one-bar .same-one-clear {
  flex: none;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.06);
  color: #dfe3e8;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.same-one-bar .same-one-clear:hover,
.same-one-bar .same-one-clear:focus-visible {
  background: rgba(255, 213, 74, 0.16);
  border-color: rgba(255, 213, 74, 0.7);
  color: #ffe9a3;
  outline: none;
}

.same-one-bar .same-one-x {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #b6bcc4;
  font: 400 15px/1 system-ui, sans-serif;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0.6;
  transition: opacity 0.2s, color 0.2s;
}

.same-one-bar .same-one-x:hover {
  opacity: 1;
  color: #f2f2f2;
}

@media (max-width: 560px) {
  .same-one-bar {
    top: 10px;
    gap: 7px;
    padding: 6px 8px 6px 11px;
    font-size: 12px;
    /* 右上角有收起按钮（约 48px），条子居中时右侧要留够 */
    max-width: calc(100vw - 108px);
  }

  /* 手机上不放关闭键：12 秒自动退场，省下的宽度留给作品名 */
  .same-one-bar .same-one-x {
    display: none;
  }

  .same-one-bar .same-one-clear {
    height: 22px;
    padding: 0 8px;
    font-size: 11.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .same-one-bar {
    animation: none;
  }
}
