/* web/css/main.css — Emoji 炼金术 H5 (手机优先) */
:root {
  --rarity-common: #9e9e9e;
  --rarity-rare: #4db6ff;
  --rarity-epic: #c77dff;
  --bg: #2b1a3e;
  --panel: #3a2452;
  --panel-dark: #241634;
  --gold: #ffd34d;
  --text: #f3ecf9;
  --muted: #b9a8cc;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

[hidden] { display: none !important; }

/* ========== 通用 ========== */
.btn-primary {
  background: linear-gradient(135deg, #ffb347, #ff8c42);
  color: #4a2400;
  font-weight: bold;
  border-radius: 999px;
  padding: 10px 28px;
  border: none;
  font-size: 15px;
  cursor: pointer;
}

.card {
  background: var(--panel);
  border-radius: 14px;
  padding: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translateX(-50%);
  background: rgba(10, 5, 18, 0.92);
  color: var(--text);
  padding: 14px 30px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: bold;
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  z-index: 300;
  animation: toastIn 0.2s ease-out;
}

@keyframes toastIn {
  from { transform: translateX(-50%) scale(0.7); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ========== 底部 Tab ========== */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  background: #1d1129;
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar-item {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  color: #9a8cb0;
  font-size: 14px;
  cursor: pointer;
}

.tabbar-item.active { color: var(--gold); font-weight: bold; }

/* ========== 炼金台 ========== */
.progress {
  padding: 10px 18px 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.stage {
  flex: 0 0 40vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
}

.slots { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; z-index: 2; }

.slot {
  width: clamp(52px, 15vw, 64px);
  height: clamp(52px, 15vw, 64px);
  border-radius: 14px;
  border: 2px dashed #6d5587;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.slot.filled { border-style: solid; border-color: var(--gold); background: var(--panel); }
.slot-hint { color: #6d5587; font-size: 24px; }
.slot img { width: 78%; height: 78%; }

.slot img.fly-in { animation: flyIn 0.6s ease-in forwards; }

@keyframes flyIn {
  to { transform: translateY(90px) scale(0.15); opacity: 0; }
}

.plus { color: var(--gold); font-size: 26px; font-weight: bold; }

.pot-wrap {
  position: relative;
  width: clamp(150px, 42vw, 200px);
  height: clamp(150px, 42vw, 200px);
}

.pot { width: 100%; height: 100%; }

.pot-wrap.shake { animation: shake 0.18s linear infinite; }

@keyframes shake {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  50% { transform: rotate(4deg) translateY(-4px); }
}

.bubbles { position: absolute; left: 50%; top: 12%; }

.bubble {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(178, 255, 158, 0.85);
  animation: rise 1s ease-in infinite;
}

.bubble.b1 { left: -28px; }
.bubble.b2 { left: 0; width: 9px; height: 9px; animation-delay: 0.3s; }
.bubble.b3 { left: 26px; width: 15px; height: 15px; animation-delay: 0.6s; }

@keyframes rise {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(-80px) scale(1.2); opacity: 0; }
}

.smoke {
  position: absolute;
  left: 50%;
  top: 20%;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(80, 80, 80, 0.9), rgba(80, 80, 80, 0));
  animation: puff 0.9s ease-out forwards;
}

@keyframes puff {
  0% { transform: scale(0.3); opacity: 0.9; }
  100% { transform: scale(2.6) translateY(-36px); opacity: 0; }
}

.flash {
  position: fixed;
  left: 0; top: 0; right: 0; bottom: 0;
  background: radial-gradient(circle, rgba(199, 125, 255, 0.95), rgba(199, 125, 255, 0));
  animation: flashOut 0.7s ease-out forwards;
  z-index: 250;
  pointer-events: none;
}

@keyframes flashOut { from { opacity: 1; } to { opacity: 0; } }

.tip { color: var(--muted); font-size: 13px; padding: 8px 0 6px; }

/* ========== 原料托盘 ========== */
.tray {
  flex: 1;
  background: #1d1129;
  border-radius: 18px 18px 0 0;
  padding: 12px 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tray.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.tray-grid { display: flex; flex-wrap: wrap; }

.tray-sep {
  width: 100%;
  color: #6d5587;
  font-size: 12px;
  padding: 10px 4px 2px;
}

.ing {
  width: 12.5%;
  padding: 6px;
  cursor: pointer;
  transition: transform 0.1s;
}

.ing:active { transform: scale(1.25); }
.ing img { width: 100%; aspect-ratio: 1; display: block; }
.ing.dim { opacity: 0.3; }

/* ========== 结果弹窗 ========== */
.overlay {
  position: fixed;
  left: 0; top: 0; right: 0; bottom: 0;
  background: rgba(10, 5, 18, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  position: relative;
  width: min(82vw, 320px);
  background: var(--panel);
  border-radius: 18px;
  padding: 26px 22px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.modal.anim-common { animation: pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1); }
.modal.anim-rare { animation: pop 0.45s cubic-bezier(0.2, 1.8, 0.4, 1); box-shadow: 0 0 30px rgba(77, 182, 255, 0.5); }
.modal.anim-epic { animation: epicIn 0.7s cubic-bezier(0.2, 1.8, 0.4, 1); box-shadow: 0 0 50px rgba(199, 125, 255, 0.8); }

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

@keyframes epicIn {
  0% { transform: scale(0.1) rotate(-12deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(3deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.sparkles { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; }

.spark {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #bfe6ff;
  border-radius: 50%;
  animation: twinkle 1.2s ease-in-out infinite;
}

.s1 { left: 15%; top: 20%; }
.s2 { left: 80%; top: 15%; animation-delay: 0.2s; }
.s3 { left: 25%; top: 65%; animation-delay: 0.4s; }
.s4 { left: 70%; top: 70%; animation-delay: 0.6s; }
.s5 { left: 50%; top: 8%; animation-delay: 0.8s; }

@keyframes twinkle {
  0%, 100% { transform: scale(0.3); opacity: 0.3; }
  50% { transform: scale(1.3); opacity: 1; }
}

.beam {
  position: absolute;
  left: 50%; top: 50%;
  width: 440px; height: 440px;
  margin: -220px;
  background: conic-gradient(from 0deg,
    transparent 0deg, rgba(199, 125, 255, 0.25) 20deg, transparent 40deg,
    transparent 90deg, rgba(199, 125, 255, 0.25) 110deg, transparent 130deg,
    transparent 180deg, rgba(199, 125, 255, 0.25) 200deg, transparent 220deg,
    transparent 270deg, rgba(199, 125, 255, 0.25) 290deg, transparent 310deg);
  animation: spin 4s linear infinite;
  pointer-events: none;
}

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

.badge {
  position: relative; z-index: 1;
  color: #1d1129;
  font-size: 12px;
  font-weight: bold;
  border-radius: 999px;
  padding: 3px 14px;
}

.new-tag {
  position: absolute;
  right: 14px; top: 14px;
  z-index: 2;
  color: #ff5964;
  font-weight: bold;
  font-size: 14px;
  animation: twinkle 0.9s ease-in-out infinite;
}

.result-img { position: relative; z-index: 1; width: min(46vw, 180px); aspect-ratio: 1; margin-top: 8px; }
.name { position: relative; z-index: 1; font-size: 24px; font-weight: bold; color: var(--gold); margin-top: 6px; }
.formula { position: relative; z-index: 1; color: var(--muted); font-size: 16px; margin-top: 6px; }
.desc { position: relative; z-index: 1; font-size: 17px; line-height: 1.6; margin: 12px 0 18px; text-align: center; }
.btns { position: relative; z-index: 1; display: flex; gap: 12px; }

.btn-share {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 10px 24px;
  font-size: 15px;
  cursor: pointer;
}

/* ========== 图鉴 ========== */
.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 4px;
}

.progress-text { color: var(--muted); font-size: 14px; }
.progress-text .num { color: var(--gold); font-size: 20px; font-weight: bold; }

.hint-btn {
  font-size: 13px;
  padding: 6px 16px;
  background: #4a3566;
  color: var(--gold);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

.tabs { display: flex; gap: 10px; padding: 12px 18px; }

.tab {
  padding: 5px 18px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.tab.active { background: var(--gold); color: var(--bg); font-weight: bold; }

.grid-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.grid { display: flex; flex-wrap: wrap; padding: 0 8px 18px; }

.cell { width: 33.33%; padding: 5px; }

.cell-inner {
  background: var(--panel-dark);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}

.cell-img { width: 72%; aspect-ratio: 1; }
.cell-img.locked { filter: brightness(0) opacity(0.55); }

.cell-name {
  margin-top: 6px;
  font-size: 12px;
  color: #d9cdf0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* 图鉴详情 / 昵称弹窗 */
.detail-card {
  width: min(82vw, 300px);
  background: var(--panel);
  border-radius: 18px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: pop 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.detail-img { width: 150px; aspect-ratio: 1; }
.detail-img.locked-big { filter: brightness(0) opacity(0.55); }
.detail-name { font-size: 19px; font-weight: bold; margin-top: 8px; }
.detail-desc { font-size: 14px; margin-top: 8px; text-align: center; }
.detail-recipe { color: var(--muted); font-size: 14px; margin-top: 6px; }
.close-btn { margin-top: 16px; }

.nick-title { color: var(--gold); }

.nick-input {
  margin-top: 16px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #6d5587;
  background: var(--panel-dark);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.nick-input:focus { border-color: var(--gold); }

/* ========== 开始界面 ========== */
.start-card { width: min(86vw, 340px); }

.start-title {
  font-size: 24px;
  font-weight: bold;
  color: var(--gold);
  text-align: center;
  margin-bottom: 20px;
}

.start-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.start-tab {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  border-radius: 999px;
  background: var(--panel-dark);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.start-tab.active { background: var(--gold); color: var(--bg); font-weight: bold; }

.start-btn { width: 100%; margin-top: 14px; }

.id-input {
  text-transform: uppercase;
}

.show-id-label {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-bottom: 12px;
}

.show-id {
  font-size: 34px;
  font-weight: bold;
  letter-spacing: 8px;
  color: var(--gold);
  text-align: center;
  padding: 14px 0;
  background: var(--panel-dark);
  border-radius: 12px;
  margin-bottom: 14px;
}

.my-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.my-id-row b { color: var(--gold); letter-spacing: 2px; }

/* ========== 提示弹窗 ========== */
.hint-card { border: 2px solid rgba(199, 125, 255, 0.4); }

.hint-witch {
  font-size: 44px;
  animation: floatWitch 2.4s ease-in-out infinite;
}

@keyframes floatWitch {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.hint-title {
  color: var(--rarity-epic);
  font-size: 17px;
  font-weight: bold;
  margin-top: 6px;
}

.hint-riddle {
  font-size: 16px;
  line-height: 1.8;
  text-align: center;
  margin-top: 14px;
  padding: 0 6px;
  color: var(--text);
}

.hint-left {
  color: var(--muted);
  font-size: 12px;
  margin-top: 14px;
  margin-bottom: 16px;
}

.hint-btns { display: flex; gap: 8px; }

/* 救救我答案区 */
.hint-answer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 18px;
  background: var(--panel-dark);
  border-radius: 12px;
  animation: pop 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.hint-answer img { width: 48px; height: 48px; }

.ans-plus { color: var(--gold); font-size: 22px; font-weight: bold; }

/* 提示记录 */
.hint-history-card { width: min(88vw, 360px); }

.hint-history-list {
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 14px 0 6px;
}

.hint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.hint-row:last-child { border-bottom: none; }

.hint-row-riddle {
  flex: 1;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.hint-row-ans { display: flex; align-items: center; gap: 6px; }
.hint-row-ans img { width: 34px; height: 34px; }
.hint-row-ans .ans-plus { font-size: 16px; }

.hint-row-help { flex-shrink: 0; }

.mini-btn {
  font-size: 12px;
  padding: 3px 12px;
  background: #4a3566;
  color: var(--muted);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

/* ========== 排行 ========== */
#view-rank { padding: 16px; overflow-y: auto; }

.my-card { margin-bottom: 16px; }

.my-title {
  font-size: 16px;
  font-weight: bold;
  color: var(--gold);
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.edit-nick {
  font-size: 12px;
  font-weight: normal;
  padding: 4px 12px;
  background: #4a3566;
  color: var(--muted);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

.my-row { display: flex; justify-content: space-around; margin-bottom: 16px; }
.my-item { text-align: center; }
.my-num { font-size: 26px; font-weight: bold; }
.my-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.challenge { width: 100%; }

.rank-title { font-size: 16px; font-weight: bold; color: var(--gold); margin-bottom: 12px; }
.rank-loading { color: var(--muted); text-align: center; padding: 30px 0; font-size: 14px; }

.rank-row {
  display: flex;
  align-items: center;
  padding: 10px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 14px;
}

.rank-row:last-child { border-bottom: none; }
.rank-row.me { background: rgba(255, 211, 77, 0.12); border-radius: 8px; }
.rank-no { width: 34px; color: var(--muted); font-weight: bold; }
.rank-row.top3 .rank-no { color: var(--gold); }
.rank-nick { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rank-score { color: var(--gold); font-weight: bold; }
.rank-epic { color: var(--rarity-epic); font-size: 12px; margin-left: 8px; }
