/* ============================================
 * 为彩画规 · 复刻版
 * ============================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body, #app { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f6f8;
  color: #333;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
.hidden { display: none !important; }
button { border: none; outline: none; cursor: pointer; font-family: inherit; background: transparent; }

/* ===== 顶部 ===== */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: 44px; background: var(--theme, #66ddac); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 6px rgba(0,0,0,.18);
}
#page-title { font-size: 18px; font-weight: 600; letter-spacing: 4px; }

/* 彩种下拉 */
.dropdown {
  position: absolute; top: 44px; left: 0; z-index: 35;
  background: rgba(50,50,50,.95); border-radius: 0 14px 14px 0;
  box-shadow: 2px 4px 16px rgba(0,0,0,.3); overflow: hidden;
  animation: slideIn .18s ease;
}
@keyframes slideIn { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
#lottery-list { list-style: none; }
#lottery-list li {
  padding: 12px 26px; color: #ddd; font-size: 15px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.08); white-space: nowrap;
}
#lottery-list li:last-child { border-bottom: none; }
#lottery-list li.active { color: #fff; background: rgba(255,255,255,.1); }

/* ===== 工具条 ===== */
#actionbar {
  position: fixed; top: 44px; left: 0; right: 0; z-index: 28;
  height: 60px; background: var(--theme, #66ddac);
  display: flex; box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.abtn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: rgba(255,255,255,.85); font-size: 12px; gap: 2px;
  transition: color .15s, background .15s;
}
.abtn .icon {
  width: 22px; height: 22px; display: block;
  background: no-repeat center / contain;
}
.abtn.active, .abtn:active { color: #fff; background: rgba(0,0,0,.08); }
.abtn:disabled { opacity: .45; }

.icon-swap    { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M7 7 H 18 L 14 3'/><path d='M17 17 H 6 L 10 21'/></svg>"); }
.icon-undo    { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 14 L 4 9 L 9 4'/><path d='M4 9 H 14 a 6 6 0 0 1 0 12 H 10'/></svg>"); }
.icon-redo    { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M15 14 L 20 9 L 15 4'/><path d='M20 9 H 10 a 6 6 0 0 0 0 12 H 14'/></svg>"); }
.icon-trash   { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 7 H 20'/><path d='M9 7 V 5 a 1 1 0 0 1 1 -1 h 4 a 1 1 0 0 1 1 1 V 7'/><path d='M6 7 L 7 20 a 2 2 0 0 0 2 2 h 6 a 2 2 0 0 0 2 -2 L 18 7'/></svg>"); }
.icon-save    { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 3 V 15'/><path d='M7 10 L 12 15 L 17 10'/><path d='M4 17 V 20 a 1 1 0 0 0 1 1 h 14 a 1 1 0 0 0 1 -1 V 17'/></svg>"); }
.icon-settings{ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='3'/><path d='M12 2 V 5 M12 19 V 22 M4.2 4.2 L 6.3 6.3 M17.7 17.7 L 19.8 19.8 M2 12 H 5 M19 12 H 22 M4.2 19.8 L 6.3 17.7 M17.7 6.3 L 19.8 4.2'/></svg>"); }

/* ===== 画板 ===== */
#board-wrap { position: absolute; top: 104px; bottom: 0; left: 0; right: 0; overflow: hidden; }
#board { width: 100%; height: 100%; display: block; touch-action: none; }
#scroll-hint {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.45); color: #fff; font-size: 12px;
  padding: 4px 14px; border-radius: 20px; pointer-events: none;
  transition: opacity .4s; z-index: 5;
}
#scroll-hint.fade { opacity: 0; }
#loading-tip {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.5); color: #fff; font-size: 12px;
  padding: 5px 16px; border-radius: 20px; z-index: 5;
}

/* ===== 底部浮动按钮 ===== */
#fab-row {
  position: fixed; bottom: 16px; left: 0; right: 0; z-index: 25;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 14px; pointer-events: none;
}
.fab, .fab-capsule, .fab-row > * { pointer-events: auto; }
.fab {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,.22);
  color: #fff;
}
.fab-pen { background: var(--theme, #7dba68); }
.fab-lock { background: #666; }
/* 锁定态 = 关闭锁头（默认）；解锁态 = 打开锁头 */
.fab-lock.locked svg #lock-svg path { /* 默认关闭 */ }
.fab-lock.unlocked #lock-svg path[d^="M12 15 V 11 a 4"] { opacity: .3; }
.fab-capsule {
  display: flex; align-items: center; gap: 4px;
  background: rgba(60,60,60,.85); padding: 6px;
  border-radius: 22px; box-shadow: 0 3px 10px rgba(0,0,0,.22);
}
.capsule-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.1); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.capsule-btn.active { background: var(--theme, #66ddac); }

/* ===== 通用弹层 ===== */
.mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideLeft { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* ===== 画笔弹窗 ===== */
#pen-panel {
  background: #fff; border-radius: 14px; padding: 12px;
  display: flex; gap: 10px; align-items: stretch;
  animation: pop .18s ease;
}
#pen-colors {
  display: flex; flex-direction: column; gap: 8px;
  background: #f5f6f8; padding: 8px 6px; border-radius: 10px;
}
.pen-color {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; position: relative;
}
.pen-color.active::after {
  content: "✓"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 700;
}
#pen-modes {
  display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center;
  background: #f5f6f8; padding: 8px; border-radius: 10px;
}
.pen-mode {
  width: 40px; height: 32px; border-radius: 6px;
  background: #fff; color: #666; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent;
}
.pen-mode.active { border-color: var(--theme, #66ddac); color: var(--theme, #66ddac); }
.pen-mode .pwave { width: 22px; height: 14px; }

/* ===== 画线方式弹窗（S） ===== */
#tool-panel {
  background: rgba(60,60,60,.92); border-radius: 12px; padding: 4px 0;
  margin-left: auto; margin-right: 14px; min-width: 130px;
  animation: pop .18s ease;
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 80px;
}
.tool-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; color: #fff; font-size: 14px;
  background: transparent; width: 100%;
}
.tool-row .tool-icon { font-size: 18px; opacity: .9; }
.tool-row.active { color: var(--theme, #66ddac); }

/* ===== 智能笔设置弹窗（底部） ===== */
#smart-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 16px 16px 0 0; padding: 16px 18px;
  animation: slideUp .2s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,.2);
}
#smart-panel h3 {
  font-size: 15px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}
#smart-panel h3 .bar {
  display: inline-block; width: 4px; height: 16px;
  background: var(--theme, #e74c3c); border-radius: 2px;
}
.smart-row {
  display: flex; align-items: center; gap: 14px; padding: 6px 0;
}
.smart-label { font-size: 14px; color: #333; min-width: 38px; }

/* ===== 设置页（右侧滑出） ===== */
#settings-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 320px; max-width: 86vw; background: #fff;
  padding: 18px 18px 24px; overflow-y: auto;
  animation: slideLeft .2s ease;
}
#settings-panel h3 { font-size: 17px; font-weight: 600; margin-bottom: 18px; }
.set-row { margin-bottom: 18px; }
.set-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.set-sub { font-size: 12px; color: #888; margin-bottom: 8px; }

/* 选项按钮组 */
.opt-row {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.opt-row.inline { margin-left: auto; }
.opt {
  padding: 6px 12px; border-radius: 6px; background: #fff;
  border: 1px solid #ddd; color: #555; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.opt.active { border-color: var(--theme, #e74c3c); color: var(--theme, #e74c3c); background: #fff; }
.opt .dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #ccc; background: #fff;
}
.opt.active .dot { background: var(--theme, #e74c3c); border-color: var(--theme, #e74c3c); }
.ballstyle .opt { padding: 8px 10px; min-width: 60px; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; margin-left: auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #ccc; border-radius: 22px; transition: .2s;
}
.slider::before {
  content: ""; position: absolute; width: 18px; height: 18px;
  left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--theme, #e74c3c); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* 皮肤 */
.skin-row { display: flex; gap: 14px; }
.skin-item {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid transparent;
}
.skin-item.active { border-color: #333; transform: scale(1.1); }

/* 主按钮 */
.primary-btn {
  display: block; width: 100%; height: 44px; margin-top: 10px;
  background: var(--theme, #e74c3c); color: #fff;
  border-radius: 22px; font-size: 15px; font-weight: 600;
}

/* ===== 保存预览 ===== */
#save-panel {
  position: absolute; inset: 0; background: #1d1d1f;
  display: flex; flex-direction: column; animation: pop .18s ease;
}
#save-head {
  height: 44px; padding: 0 12px;
  display: flex; align-items: center; justify-content: space-between;
  color: #fff; background: rgba(0,0,0,.2);
}
#save-tip { font-size: 15px; }
.close-btn { color: #fff; font-size: 22px; padding: 0 6px; line-height: 1; }
#save-canvas-wrap {
  flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center;
  padding: 8px;
}
#save-canvas { max-width: 100%; height: auto; background: #fff; }
#save-foot {
  height: 60px; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: space-around;
}
.foot-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: #fff; font-size: 12px; padding: 4px 10px;
}
.foot-icon { font-size: 18px; }
#save-period-val { font-weight: 600; }

/* ===== 期数选择 ===== */
#period-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #fff; border-radius: 16px 16px 0 0; padding: 12px 0;
  max-height: 70vh; animation: slideUp .2s ease;
}
.period-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 16px 12px; border-bottom: 1px solid #eee;
}
.period-head span { font-size: 15px; font-weight: 600; }
.period-head button { color: var(--theme, #e74c3c); font-size: 14px; padding: 4px 6px; }
#period-list {
  overflow-y: auto; max-height: 60vh; padding: 4px 0;
  text-align: center;
}
.period-item {
  padding: 10px; font-size: 15px; color: #888; cursor: pointer;
}
.period-item.active { color: var(--theme, #e74c3c); font-weight: 600; }

/* ===== 文字输入弹窗 ===== */
#text-panel {
  width: 300px; max-width: 88vw; background: #fff; border-radius: 14px;
  padding: 18px; animation: pop .18s ease;
}
#text-panel h3 { font-size: 16px; margin-bottom: 14px; color: #333; }
#text-input {
  width: 100%; height: 40px; border: 1px solid #ddd; border-radius: 8px;
  padding: 0 12px; font-size: 15px; margin-bottom: 14px;
}
.text-btns { display: flex; gap: 10px; }
.menu-btn {
  flex: 1; height: 40px; border-radius: 9px; background: #f0f1f4;
  color: #444; font-size: 14px;
}
.menu-btn.primary { background: var(--theme, #66ddac); color: #fff; }

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 8px 20px;
  border-radius: 22px; font-size: 13px; z-index: 80;
  max-width: 80vw; text-align: center;
}