:root {
  --bg: #fdf6ec;
  --panel: #ffffff;
  --ink: #3d3a34;
  --accent: #ff8c42;
  --accent-dark: #e6722a;
  --primary: #3498db;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(61, 58, 52, 0.12);
}

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ===== 头部 ===== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header h1 { font-size: 1.5rem; }

.mode-tabs { display: flex; gap: 8px; }

.tab {
  border: none;
  background: #f0ece4;
  color: var(--ink);
  font-size: 1rem;
  padding: 10px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tab.active { background: var(--accent); color: #fff; font-weight: bold; }
.tab:hover:not(.active) { background: #e4ddcf; }

main { flex: 1; padding: 24px; }

/* ===== 布局 ===== */
.challenge-layout {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

.studio-layout {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

.canvas-column { display: flex; flex-direction: column; gap: 12px; }

/* ===== 画板 ===== */
.canvas-wrap {
  position: relative;
  width: min(600px, 92vw);
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: #fff;
}

.canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

#studio-canvas { position: static; width: 100%; height: 100%; }

/* ===== 关卡面板 ===== */
.level-panel, .tool-panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  width: 220px;
}

.level-panel h2, .tool-panel h2 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: #8a8478;
}

.level-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.level-btn {
  border: 2px solid #ece5d8;
  background: #fffdf8;
  border-radius: 10px;
  padding: 10px 4px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: border-color 0.2s, transform 0.1s;
}

.level-btn:hover { transform: translateY(-2px); }
.level-btn.active { border-color: var(--accent); background: #fff3e8; }
.level-btn.locked { opacity: 0.45; cursor: not-allowed; transform: none; }
.level-btn .stars { color: #f1c40f; font-size: 0.75rem; letter-spacing: 1px; }

.hint { margin-top: 14px; font-size: 0.8rem; color: #a39c8e; line-height: 1.6; }

/* ===== 状态栏 ===== */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 16px;
}

.level-name { font-weight: bold; white-space: nowrap; }

.timer-wrap {
  flex: 1;
  height: 10px;
  background: #f0ece4;
  border-radius: 999px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #2ecc71, #a3e048);
  border-radius: 999px;
  transition: width 1s linear, background 0.5s;
}

.timer-bar.warning { background: linear-gradient(90deg, #f1c40f, #e67e22); }
.timer-bar.danger { background: linear-gradient(90deg, #e74c3c, #c0392b); }

.timer-text { font-variant-numeric: tabular-nums; font-weight: bold; }

/* ===== 工具栏 ===== */
.toolbar, .tool-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar label, .size-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  background: var(--panel);
  padding: 8px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.size-label { margin-top: 14px; }

.btn {
  border: none;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--accent); color: #fff; font-weight: bold; }
.btn-primary:hover { background: var(--accent-dark); }

/* ===== 画室工具 ===== */
.brush-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.brush-btn {
  border: 2px solid #ece5d8;
  background: #fffdf8;
  border-radius: 10px;
  padding: 10px 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

.brush-btn.active { border-color: var(--primary); background: #eaf4fc; }

.tool-panel h2:not(:first-child) { margin-top: 18px; }

.palette { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.08);
  background: var(--c);
  cursor: pointer;
  transition: transform 0.1s;
}

.color-btn:hover { transform: scale(1.15); }
.color-btn.active { border-color: var(--ink); transform: scale(1.15); }

#custom-color {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

.tool-actions { margin-top: 18px; flex-direction: column; align-items: stretch; }
.tool-actions .btn { width: 100%; }

.tool-panel input[type="range"] { flex: 1; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(61, 58, 52, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--panel);
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  padding: 36px 48px;
  text-align: center;
  animation: pop 0.3s ease;
}

@keyframes pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-stars { font-size: 3rem; color: #f1c40f; letter-spacing: 8px; }

.result-score { font-size: 2.2rem; font-weight: bold; margin-top: 8px; }

.result-comment { margin: 12px 0 20px; color: #8a8478; }

.modal-actions { display: flex; gap: 12px; justify-content: center; }

/* ===== 页脚 ===== */
.site-footer {
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  color: #a39c8e;
}

@media (max-width: 720px) {
  .level-panel, .tool-panel { width: 100%; }
  .site-header { justify-content: center; }
}
