/* =========================================================
   梦幻换装派对 — style.css
   Palette: primary #FFB6C1 · secondary #98FB98 · accent #DDA0DD · bg #FFF5EE
   ========================================================= */

:root {
  --primary: #FFB6C1;
  --primary-deep: #ff8fab;
  --secondary: #98FB98;
  --secondary-deep: #6ee76e;
  --accent: #DDA0DD;
  --accent-deep: #c77dcc;
  --bg: #FFF5EE;
  --bg-soft: #ffe8dc;
  --ink: #5a3a4a;
  --ink-soft: #8a6a7a;
  --card: #ffffff;
  --shadow: 0 8px 24px rgba(255, 140, 170, 0.25);
  --shadow-soft: 0 4px 12px rgba(90, 58, 74, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "ZCOOL KuaiLe", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --top-h: 64px;
  --ward-h: 168px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: inherit;
}

.hidden { display: none !important; }

/* ---------- Loading ---------- */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, #ffe0ec 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, #e8d5ff 0%, transparent 45%),
    linear-gradient(160deg, #FFF5EE, #ffe8f0 50%, #f0fff0);
}

.loading-card {
  width: min(360px, 88vw);
  padding: 36px 28px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-radius: 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.loading-logo {
  font-size: 64px;
  animation: bounce-soft 1.2s ease-in-out infinite;
  filter: drop-shadow(0 6px 10px rgba(255, 140, 170, 0.4));
}

.loading-title {
  margin-top: 8px;
  font-size: 28px;
  background: linear-gradient(90deg, #ff6b9d, #c77dcc, #6ec6ff, #6ee76e, #ffd36e, #ff6b9d);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbow-shift 4s linear infinite;
}

.loading-sub {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 14px;
}

.progress-track {
  margin-top: 22px;
  height: 14px;
  border-radius: 999px;
  background: #ffe4ec;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(255, 140, 170, 0.2);
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--secondary));
  background-size: 200% 100%;
  animation: rainbow-shift 2s linear infinite;
  transition: width 0.2s ease;
}

.progress-text {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- App shell ---------- */
#app {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: var(--top-h) 1fr var(--ward-h);
  background:
    radial-gradient(ellipse at top, #fff0f5 0%, transparent 55%),
    var(--bg);
}

/* ---------- Top bar ---------- */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #fff 0%, rgba(255, 245, 238, 0.95) 100%);
  border-bottom: 2px solid rgba(255, 182, 193, 0.45);
  box-shadow: 0 4px 16px rgba(255, 140, 170, 0.12);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.rainbow-logo {
  font-size: 28px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  animation: spin-slow 8s linear infinite;
}

.title {
  font-size: clamp(18px, 4vw, 26px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(90deg, #ff6b9d, #c77dcc, #6ec6ff, #6ee76e, #ffd36e, #ff6b9d);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbow-shift 5s linear infinite;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); filter: brightness(1.04); }
.btn:active { transform: scale(0.95); }

.btn-pink {
  background: linear-gradient(180deg, #ffc9d6, var(--primary));
  color: #7a3048;
  border: 2px solid #ff9bb0;
}
.btn-lilac {
  background: linear-gradient(180deg, #f0d4f5, var(--accent));
  color: #5a3068;
  border: 2px solid #d090d8;
}
.btn-mint {
  background: linear-gradient(180deg, #c8f9c8, var(--secondary));
  color: #2a6a2a;
  border: 2px solid #7ae07a;
}
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  font-size: 18px;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  background: #fff;
  border: 1.5px solid var(--primary);
  border-radius: 999px;
}
.btn-lg {
  padding: 12px 22px;
  font-size: 16px;
}

/* ---------- Main stage ---------- */
#main-stage {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

#bg-picker,
#hair-colors {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 6px;
  z-index: 5;
}

#hair-colors {
  justify-content: flex-start;
}

.side-label {
  font-size: 12px;
  color: var(--ink-soft);
}

.bg-thumb {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid rgba(255, 182, 193, 0.5);
  font-size: 22px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.bg-thumb:hover { transform: scale(1.08); }
.bg-thumb.active {
  border-color: var(--primary-deep);
  box-shadow: 0 0 0 3px rgba(255, 182, 193, 0.55), var(--shadow-soft);
  transform: scale(1.06);
}

#color-swatches {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.active {
  box-shadow: 0 0 0 3px var(--primary), 0 2px 6px rgba(0, 0, 0, 0.18);
  transform: scale(1.15);
}

#stage-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 6px;
}

#game-canvas {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 22px;
  box-shadow:
    0 12px 40px rgba(255, 140, 170, 0.28),
    0 2px 0 rgba(255, 255, 255, 0.8) inset;
  background: #fff;
  touch-action: none;
}

#challenge-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
}

#challenge-banner .challenge-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid var(--accent);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 14px;
  white-space: nowrap;
  flex-wrap: wrap;
  justify-content: center;
}

#toast {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  padding: 10px 18px;
  background: rgba(90, 58, 74, 0.88);
  color: #fff;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

/* ---------- Wardrobe ---------- */
#wardrobe-panel {
  display: grid;
  grid-template-rows: 44px 1fr;
  background: linear-gradient(180deg, #fff7fa 0%, #ffeef4 100%);
  border-top: 2px solid rgba(255, 182, 193, 0.55);
  box-shadow: 0 -6px 20px rgba(255, 140, 170, 0.12);
  padding-bottom: var(--safe-bottom);
  z-index: 20;
}

#category-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px 999px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid transparent;
  border-bottom: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.cat-tab:hover { background: #fff; color: var(--ink); }
.cat-tab.active {
  background: #fff;
  color: #c23a6b;
  border-color: rgba(255, 182, 193, 0.7);
  box-shadow: 0 -2px 8px rgba(255, 140, 170, 0.15);
  transform: translateY(-1px);
}

.wardrobe-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
  background: #fff;
  border-top: 1px solid rgba(255, 182, 193, 0.35);
}
.wardrobe-scroll::-webkit-scrollbar { height: 6px; }
.wardrobe-scroll::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 999px;
}

.wardrobe-items {
  display: flex;
  gap: 10px;
  align-items: center;
  height: 100%;
  min-height: 96px;
}

.item-card {
  position: relative;
  flex: 0 0 auto;
  width: 80px;
  height: 80px;
  border-radius: 16px;
  background: linear-gradient(160deg, #fff, #fff5f8);
  border: 2.5px solid rgba(255, 182, 193, 0.4);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              border-color 0.15s ease,
              box-shadow 0.15s ease;
  cursor: grab;
  padding: 0;
}
.item-card:active { cursor: grabbing; }
.item-card:hover { transform: translateY(-3px) scale(1.04); }
.item-card.selected {
  border-color: var(--primary-deep);
  box-shadow:
    0 0 0 3px rgba(255, 143, 171, 0.55),
    0 0 18px rgba(255, 105, 157, 0.55),
    var(--shadow-soft);
}
.item-card.bounce {
  animation: card-bounce 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.item-card.hidden-item {
  border-color: gold;
  background: linear-gradient(160deg, #fff8dc, #ffeaa7);
}
.item-card canvas,
.item-thumb {
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: block;
  border-radius: 13px;
}
.item-card .item-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2px 3px;
  font-size: 9px;
  text-align: center;
  background: linear-gradient(transparent, rgba(90, 58, 74, 0.72));
  color: #fff;
  line-height: 1.2;
  pointer-events: none;
}

/* Drag ghost */
.drag-ghost {
  position: fixed;
  width: 72px;
  height: 72px;
  border-radius: 14px;
  pointer-events: none;
  z-index: 500;
  opacity: 0.92;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%) scale(1.08);
  border: 2px solid var(--primary);
  background: #fff;
  overflow: hidden;
}

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(90, 40, 60, 0.45);
  backdrop-filter: blur(6px);
  animation: fade-in 0.2s ease;
}

.modal-card {
  width: min(640px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(90, 40, 60, 0.3);
  border: 3px solid var(--primary);
  animation: pop-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 2px solid #ffe4ec;
  background: linear-gradient(180deg, #fff5f8, #fff);
}

.modal-header h2 { font-size: 20px; }

.photo-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
}

#photo-canvas {
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  background: #fafafa;
}

.photo-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-soft);
}

.field input[type="text"] {
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid #ffd0dc;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  background: #fffafc;
}
.field input[type="text"]:focus {
  border-color: var(--primary-deep);
  box-shadow: 0 0 0 3px rgba(255, 182, 193, 0.35);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  background: #fff5f8;
  border: 2px solid #ffd0dc;
  color: var(--ink);
  transition: all 0.15s ease;
}
.chip:hover { background: #ffe8f0; }
.chip.active {
  background: linear-gradient(180deg, #ffc9d6, var(--primary));
  border-color: var(--primary-deep);
  color: #7a3048;
  box-shadow: var(--shadow-soft);
}

.photo-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

/* Result modal */
.result-card {
  width: min(380px, 92vw);
  padding: 28px 22px 22px;
  text-align: center;
  border-color: var(--accent);
}

.result-card h2 {
  font-size: 24px;
  margin-bottom: 12px;
}

.stars {
  font-size: 36px;
  letter-spacing: 4px;
  min-height: 48px;
  color: #ffd166;
  filter: drop-shadow(0 2px 4px rgba(255, 180, 0, 0.4));
}

.result-comment {
  margin: 14px 0 10px;
  font-size: 16px;
  color: var(--ink);
  line-height: 1.5;
}

.result-unlock {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(90deg, #fff8dc, #ffeaa7);
  color: #8a5a00;
  font-size: 14px;
  border: 2px dashed gold;
}

/* ---------- Animations ---------- */
@keyframes rainbow-shift {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}
@keyframes bounce-soft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes card-bounce {
  0% { transform: scale(0.9); }
  55% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.86); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  :root {
    --top-h: 56px;
    --ward-h: 156px;
  }
  .top-actions .btn:not(.btn-icon) {
    padding: 6px 10px;
    font-size: 12px;
  }
  #main-stage {
    grid-template-columns: 48px 1fr 48px;
  }
  .bg-thumb { width: 38px; height: 38px; font-size: 18px; }
  .photo-body {
    grid-template-columns: 1fr;
  }
  .title { font-size: 16px; }
}

@media (max-width: 420px) {
  #btn-challenge, #btn-photo, #btn-reset {
    padding: 6px 8px;
    font-size: 12px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --top-h: 48px;
    --ward-h: 120px;
  }
  .item-card { width: 64px; height: 64px; }
  .loading-card { padding: 20px; }
}
