
:root {
  --red: #c7162b;
  --deep-red: #8d0b1f;
  --gold: #f2c94c;
  --gold-2: #ffe7a1;
  --black: #1f1a15;
  --cream: #fff7ec;
  --ink: #1d1c1a;
  --cyber: #21f6ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--black);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: radial-gradient(circle at top, #ffe7cc 0%, #fff3e0 40%, #fff 100%);
}

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.hero {
  text-align: center;
  padding: 16px 12px 6px;
}

.hero-badge {
  display: inline-block;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--red), var(--deep-red));
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 2px;
}

.hero h1 {
  margin: 12px 0 4px;
  font-size: 34px;
  color: var(--deep-red);
  font-weight: 700;
}

.hero p {
  margin: 0;
  color: #7d5b4a;
}

.panel {
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  margin-top: 16px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
  border: 1px solid #f1e3d1;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
  color: #4b2a19;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.result-head h2 {
  margin: 0;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: #fffaf0;
  border: 2px dashed #e2c8a4;
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
}

#doodleCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.canvas-mask {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b08d6a;
  pointer-events: none;
  font-size: 14px;
  opacity: 0.7;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  background: #f1e3d1;
  color: #4b2a19;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.08);
}

.btn.primary {
  background: linear-gradient(135deg, var(--red), var(--deep-red));
  color: #fff;
  width: 100%;
  font-size: 16px;
  margin-top: 12px;
}

.btn.accent {
  background: linear-gradient(135deg, #101010, #2a1b14);
  color: var(--gold-2);
  font-weight: 700;
  border: 1px solid #b08d6a;
  box-shadow: 0 0 12px rgba(242, 201, 76, 0.4);
}

.btn.ghost {
  background: #fff;
  border: 1px solid #ecd6bc;
}

.style-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.style-item {
  border: 1px solid #edd9c4;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: #fffdf8;
}

.style-item input {
  display: none;
}

.style-item.active {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(199, 22, 43, 0.15);
}

.style-item img {
  width: 26px;
  height: 26px;
  color: var(--deep-red);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.result-card {
  border: 1px solid #ecd6bc;
  border-radius: 16px;
  padding: 10px;
  background: #fffdf8;
}

.result-card img {
  width: 100%;
  border-radius: 12px;
  display: block;
  cursor: pointer;
}

.card-title {
  margin: 8px 0 6px;
  font-size: 14px;
  color: #4b2a19;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.card-actions .btn {
  padding: 8px 6px;
  font-size: 12px;
}

.loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.loading-card {
  background: #fff;
  padding: 24px;
  border-radius: 18px;
  text-align: center;
  min-width: 220px;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid #f1e3d1;
  border-top-color: var(--red);
  margin: 0 auto 12px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-body {
  position: relative;
  background: #fff;
  padding: 16px;
  border-radius: 16px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  z-index: 1;
}

.modal-body img {
  max-width: 80vw;
  max-height: 80vh;
}

.cover-body {
  width: min(92vw, 520px);
  text-align: center;
}

.cover-title {
  font-size: 18px;
  margin-bottom: 10px;
  color: #4b2a19;
}

.cover-stage {
  display: flex;
  justify-content: center;
}

.cover-frame {
  width: 240px;
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid #f1d27a;
  box-shadow: 0 0 0 rgba(242, 201, 76, 0.6);
  transform: scale(0.6);
  opacity: 0;
}

.cover-frame.animate {
  animation: coverOpen 1.5s ease forwards;
}

@keyframes coverOpen {
  0% { transform: scale(0.6); opacity: 0; box-shadow: 0 0 0 rgba(242, 201, 76, 0.0); }
  60% { transform: scale(1.05); opacity: 1; box-shadow: 0 0 18px rgba(242, 201, 76, 0.6); }
  100% { transform: scale(1); opacity: 1; box-shadow: 0 0 8px rgba(242, 201, 76, 0.4); }
}

.cover-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 14px;
}

.text-body {
  width: min(92vw, 480px);
}

.text-title {
  font-size: 18px;
  margin-bottom: 12px;
}

.preset-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.preset-item {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #ecd6bc;
  text-align: center;
  cursor: pointer;
  background: #fffdf8;
}

.preset-item.active {
  border-color: var(--red);
  background: #fff4f6;
}

.input-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.input-row input {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #ecd6bc;
  font-size: 14px;
}

.hint {
  font-size: 12px;
  color: #b08d6a;
}

.final-body {
  width: min(92vw, 520px);
  text-align: center;
}

.final-body img {
  width: 240px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 16px;
  border: 2px solid #f1d27a;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
}

.hidden {
  display: none !important;
}

@media (max-width: 480px) {
  .panel {
    padding: 14px;
  }
  .result-grid {
    grid-template-columns: 1fr;
  }
  .btn-row {
    flex-direction: column;
  }
  .cover-frame,
  .final-body img {
    width: 210px;
  }
}
