/* ======================================================
   《神来之牌》样式 · 新中式扁平 + 深墨蓝 + 金色
   对齐 v0.1 锚定参数:
   主色 #1A1A2E  金 #D4AF37  万朱红 #C93756 条翠绿 #2D7A3E 筒琉璃 #2A5599
   ====================================================== */

* { box-sizing: border-box; }
:root { color-scheme: dark; }
html, body { margin: 0; padding: 0; height: 100%; min-height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: radial-gradient(ellipse at center top, #232347 0%, #1A1A2E 70%, #0e0e1c 100%);
  color: #e8e6d6;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app { width: 100vw; min-height: 100dvh; height: 100dvh; position: relative; }

/* ---------- Screen 系统 ---------- */
.screen {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.screen.active { display: flex; }

/* ---------- 主菜单 ---------- */
.menu-box {
  text-align: center;
  padding: 60px 80px;
  background: linear-gradient(145deg, rgba(40,40,70,0.9), rgba(20,20,40,0.9));
  border: 2px solid #D4AF37;
  border-radius: 14px;
  box-shadow: 0 0 60px rgba(212,175,55,0.25);
  width: min(100%, 680px);
}
.title {
  font-size: 56px;
  margin: 0 0 10px;
  color: #D4AF37;
  letter-spacing: 12px;
  text-shadow: 0 0 20px rgba(212,175,55,0.6);
  font-weight: 900;
}
.subtitle { color: #b8b49a; letter-spacing: 4px; margin-bottom: 40px; }
.menu-buttons { display: flex; flex-direction: column; gap: 14px; }
.version { margin-top: 30px; color: #777; font-size: 12px; letter-spacing: 2px; }

/* ---------- 通用按钮 ---------- */
.btn {
  padding: 12px 28px;
  font-size: 16px;
  border: 2px solid #D4AF37;
  background: transparent;
  color: #D4AF37;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
  letter-spacing: 2px;
  font-family: inherit;
  min-height: 48px;
}
.btn:hover:not(:disabled) { background: rgba(212,175,55,0.15); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary { background: #D4AF37; color: #1A1A2E; }
.btn-primary:hover:not(:disabled) { background: #f0c849; }
.btn-warn { border-color: #C93756; color: #ff6a80; }
.btn-warn:hover:not(:disabled) { background: rgba(201,55,86,0.18); }
.btn-gold { background: linear-gradient(90deg,#D4AF37,#f3d56a,#D4AF37); color: #1A1A2E; border-color:#D4AF37; }
.btn-ghost { border-color: #666; color: #aaa; }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.05); }

/* ---------- 面板 ---------- */
.panel {
  background: linear-gradient(145deg, rgba(35,35,60,0.95), rgba(20,20,40,0.95));
  border: 2px solid #D4AF37;
  border-radius: 14px;
  padding: 36px;
  max-width: 640px;
  width: 100%;
  text-align: center;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
}
.panel.wide { max-width: 960px; width: min(100%, 960px); }
.panel h2 {
  color: #D4AF37;
  margin: 0 0 20px;
  letter-spacing: 6px;
}
.how-content { text-align: left; line-height: 1.9; color: #d0cdb4; font-size: 14px; margin-bottom: 20px; }
.how-content b { color: #f0c849; }

/* ---------- HUD ---------- */
#game { justify-content: flex-start; align-items: stretch; padding: 16px; }
#hud {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(212,175,55,0.4);
  border-radius: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap; gap: 8px;
  position: sticky;
  top: 0;
  z-index: 12;
  backdrop-filter: blur(8px);
}
.hud-left, .hud-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hud-chip {
  padding: 5px 12px;
  font-size: 13px;
  background: rgba(212,175,55,0.1);
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 6px;
  color: #b8b49a;
  letter-spacing: 1px;
}
.hud-chip b { color: #f0c849; margin-left: 4px; }

/* Boss Banner */
.boss-banner {
  width: 100%;
  padding: 8px 14px;
  background: linear-gradient(90deg, #4a0f1c, #1A1A2E, #4a0f1c);
  border: 1px solid #C93756;
  border-radius: 6px;
  color: #ff8899;
  font-size: 13px;
  text-align: center;
  letter-spacing: 3px;
  margin-bottom: 10px;
  animation: bossPulse 2.5s ease-in-out infinite;
}
@keyframes bossPulse {
  0%,100% { box-shadow: 0 0 10px rgba(201,55,86,0.3); }
  50%     { box-shadow: 0 0 22px rgba(201,55,86,0.7); }
}
.hidden { display: none !important; }

/* ---------- 牌神槽 ---------- */
.joker-slots {
  width: 100%;
  display: flex; gap: 10px; justify-content: center;
  margin-bottom: 10px; flex-wrap: wrap;
  min-height: 140px;
}
.joker-card {
  width: 100px; height: 140px;
  border-radius: 8px;
  background: #1A1A2E;
  border: 2px solid #666;
  position: relative;
  overflow: hidden;
  cursor: help;
  transition: transform .2s;
  flex-shrink: 0;
}
.joker-card:hover { transform: translateY(-4px); z-index: 5; }
.joker-card.rarity-common,
.joker-card.rarity-huang     { border-color: #d4c078; }
.joker-card.rarity-rare,
.joker-card.rarity-xuan      { border-color: #8e6bd4; box-shadow: 0 0 10px rgba(142,107,212,0.5); }
.joker-card.rarity-epic,
.joker-card.rarity-di        { border-color: #c68744; box-shadow: 0 0 14px rgba(198,135,68,0.6); }
.joker-card.rarity-legendary,
.joker-card.rarity-tian      { border-color: #D4AF37; box-shadow: 0 0 18px rgba(212,175,55,0.8); animation: goldGlow 2s ease-in-out infinite; }
@keyframes goldGlow { 0%,100% { box-shadow: 0 0 12px rgba(212,175,55,0.6); } 50% { box-shadow: 0 0 22px rgba(212,175,55,1); } }
.joker-card.empty {
  border-style: dashed;
  opacity: 0.4;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #666;
}
.joker-card .art { width: 100%; height: 80px; display: flex; align-items: center; justify-content: center; }
.joker-card .name {
  position: absolute; bottom: 22px; left: 0; right: 0;
  text-align: center;
  font-size: 11px; color: #f0c849; letter-spacing: 1px;
}
.joker-card .rarity-tag {
  position: absolute; bottom: 4px; left: 0; right: 0;
  text-align: center;
  font-size: 9px; color: #aaa; letter-spacing: 2px;
}
.joker-tooltip {
  position: absolute;
  bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  min-width: 180px; max-width: 240px;
  padding: 8px 10px;
  background: #0e0e1c;
  border: 1px solid #D4AF37;
  border-radius: 6px;
  font-size: 11px; line-height: 1.5;
  color: #e8e6d6;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 20;
}
.joker-card:hover .joker-tooltip { opacity: 1; }

/* ---------- 牌面 ---------- */
.section-label {
  font-size: 12px; color: #888;
  letter-spacing: 3px;
  margin: 6px 0 6px;
}
.kept-area, .hand-area {
  width: 100%;
  padding: 6px 12px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}

.tile-row {
  display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center;
  min-height: 120px;
  padding: 4px;
}
.tile-row.hand { min-height: 130px; }

.tile {
  width: 70px; height: 100px;
  border-radius: 8px;
  background: #f4ecd6;
  border: 2px solid #D4AF37;
  position: relative;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  flex-shrink: 0;
  box-shadow: 0 3px 6px rgba(0,0,0,0.5), inset 0 -3px 0 rgba(0,0,0,0.15);
}
.tile:hover:not(.disabled) {
  transform: translateY(-6px);
  box-shadow: 0 8px 14px rgba(0,0,0,0.7);
}
.tile.selected {
  transform: translateY(-14px);
  border-color: #f3d56a;
  box-shadow: 0 10px 16px rgba(212,175,55,0.5), 0 0 18px rgba(212,175,55,0.7);
}
.tile.recommended { box-shadow: 0 0 14px #f0c849, 0 4px 8px rgba(0,0,0,0.5); }
.tile.disabled { opacity: 0.5; cursor: not-allowed; }
.tile.small { width: 52px; height: 74px; }

.tile svg { width: 100%; height: 100%; display: block; }

/* ---------- 动作条 ---------- */
.action-bar {
  width: 100%;
  display: flex; gap: 10px; justify-content: center;
  margin-top: 8px; flex-wrap: wrap;
}

/* ---------- 结算面板 ---------- */
.result-panel { max-width: 720px; }
.result-groups { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.result-group-line {
  padding: 6px 12px;
  background: rgba(212,175,55,0.08);
  border-left: 3px solid #D4AF37;
  border-radius: 4px;
  font-size: 13px;
  text-align: left;
  letter-spacing: 1px;
  opacity: 0;
  transform: translateX(-12px);
  animation: slideIn .35s ease forwards;
}
@keyframes slideIn { to { opacity: 1; transform: translateX(0); } }
.result-globals {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.global-badge {
  padding: 4px 12px;
  background: linear-gradient(90deg,#D4AF37,#f0c849);
  color: #1A1A2E;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 2px;
  opacity: 0; animation: popIn .3s ease forwards;
}
@keyframes popIn { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.result-total {
  display: flex; gap: 10px; justify-content: center; align-items: baseline;
  font-size: 18px; margin: 20px 0;
  flex-wrap: wrap;
}
.result-total > div { color: #b8b49a; }
.result-total b { color: #f0c849; font-size: 22px; padding: 0 4px; }
.final-score b { color: #D4AF37 !important; font-size: 36px !important; text-shadow: 0 0 15px #D4AF37; }

.verdict { margin: 12px 0; font-size: 20px; letter-spacing: 4px; }
.verdict.win  { color: #6ee285; }
.verdict.lose { color: #ff6a80; }

/* ---------- 奖励面板 ---------- */
.reward-cards {
  display: flex; gap: 20px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 20px;
}
.reward-card {
  width: 180px;
  padding: 16px;
  background: linear-gradient(145deg, #2a2a4a, #1a1a30);
  border: 2px solid #D4AF37;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .2s;
  text-align: center;
}
.reward-card:hover { transform: translateY(-6px); box-shadow: 0 8px 22px rgba(212,175,55,0.4); }
.reward-card .rw-art { height: 110px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.reward-card .rw-title { color: #f0c849; font-size: 15px; margin-bottom: 6px; letter-spacing: 2px; }
.reward-card .rw-desc  { color: #b8b49a; font-size: 11px; line-height: 1.5; }

/* ---------- 图鉴 ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  max-height: 70vh; overflow-y: auto;
  padding: 10px;
  margin-bottom: 16px;
}
.gallery-item {
  background: #1a1a30;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  border: 2px solid #333;
}
.gallery-item.rarity-common,
.gallery-item.rarity-huang { border-color: #d4c078; }
.gallery-item.rarity-rare,
.gallery-item.rarity-xuan  { border-color: #8e6bd4; }
.gallery-item.rarity-epic,
.gallery-item.rarity-di    { border-color: #c68744; }
.gallery-item.rarity-legendary,
.gallery-item.rarity-tian  { border-color: #D4AF37; }
.g-rarity { color:#f0c849; font-size:10px; letter-spacing:4px; margin-bottom:2px; }
.gallery-item .art-wrap { height: 130px; display:flex; align-items:center; justify-content:center; }
.gallery-item .g-name { color: #f0c849; font-size: 13px; margin: 6px 0 4px; letter-spacing: 1px; }
.gallery-item .g-desc { color: #aaa; font-size: 10px; line-height: 1.4; }

/* ---------- 动画:牌面打出 ---------- */
.tile.flying {
  animation: flyOut .5s ease forwards;
}
@keyframes flyOut {
  0% { transform: translateY(-14px) scale(1); opacity: 1; }
  100% { transform: translateY(-80px) scale(0.85); opacity: 0; }
}

/* ---------- 新增:槽位双栏 + 麻仙 + 双列商店 + 宝箱 + 开局加成 ---------- */
.slots-row {
  width: 100%;
  display: flex; gap: 14px; justify-content: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.slots-group { display: flex; flex-direction: column; align-items: center; }
.slots-label { font-size: 11px; color: #888; letter-spacing: 3px; margin-bottom: 4px; }
.xian-bar {
  display: flex; gap: 8px;
  min-height: 70px;
}
.xian-slot {
  width: 120px; height: 70px;
  border-radius: 8px;
  background: #241540;
  border: 2px solid #b388f0;
  padding: 6px 8px;
  cursor: pointer;
  display: flex; flex-direction: column; justify-content: center;
  transition: transform .15s;
}
.xian-slot:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(179,136,240,0.5); }
.xian-slot.empty {
  border-style: dashed;
  background: transparent;
  opacity: 0.4;
  display: flex; align-items: center; justify-content: center;
  cursor: default;
}
.xian-name { color:#f3d56a; font-size:12px; letter-spacing:1px; margin-bottom:2px; }
.xian-desc { color:#c9b2f5; font-size:10px; line-height:1.3; }

.subtle { color:#888; font-size:12px; letter-spacing:2px; margin-bottom:18px; }

/* 开局加成 */
.blessing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}
.blessing-card {
  background: linear-gradient(145deg, #2a2a4a, #1a1a30);
  border: 2px solid #D4AF37;
  border-radius: 10px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: transform .2s;
}
.blessing-card:hover { transform: translateY(-6px); box-shadow: 0 10px 24px rgba(212,175,55,0.4); }
.blessing-icon { font-size: 36px; margin-bottom: 10px; }
.blessing-name { color:#f3d56a; font-size:16px; letter-spacing:3px; margin-bottom:6px; }
.blessing-desc { color:#b8b49a; font-size:12px; line-height:1.6; }

/* 宝箱 */
.chest-gold-line { color:#f3d56a; font-size:22px; letter-spacing:4px; margin-bottom:20px; }
.chest-hint { color:#aaa; font-size:13px; letter-spacing:2px; margin-bottom:12px; }
.chest-grid {
  display: flex; gap: 18px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 20px;
}
.chest-card {
  width: 170px;
  padding: 12px;
  background: linear-gradient(145deg, #3a2a5a, #2a1a40);
  border: 2px solid #b388f0;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: transform .15s;
}
.chest-card:hover { transform: translateY(-5px); box-shadow: 0 10px 22px rgba(179,136,240,0.5); }
.chest-art { height: 130px; display:flex; align-items:center; justify-content:center; margin-bottom:8px; }
.chest-art.tile-wrap { padding-top: 12px; }
.chest-name { color:#f3d56a; font-size:14px; letter-spacing:2px; margin-bottom:4px; }
.chest-desc { color:#c9b2f5; font-size:11px; line-height:1.4; }
.chest-empty { color:#888; padding:20px; letter-spacing:3px; margin-bottom:16px; }

/* 商店 V0.4 */
.shop-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.shop-header h2 { margin: 0; }
.shop-info { display: flex; gap: 8px; }
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
  padding: 6px;
}
.shop-row-label {
  color: #f3d56a;
  font-size: 12px;
  letter-spacing: 3px;
  margin: 6px 0 4px;
  text-align: left;
}
.shop-item {
  background: linear-gradient(145deg, #2a2a4a, #1a1a30);
  border: 2px solid #D4AF37;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  min-height: 230px;
  display: flex; flex-direction: column; align-items: center;
  transition: transform .15s;
}
.shop-item:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(212,175,55,0.3); }
.shop-item.empty {
  opacity: 0.35;
  border-style: dashed;
  justify-content: center;
  color: #666;
  min-height: 230px;
}
.shop-art {
  height: 130px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.shop-tile-art {
  width: 70px; height: 100px;
  background: #f4ecd6;
  border-radius: 6px;
  overflow: hidden;
}
.shop-title { color: #f0c849; font-size: 13px; letter-spacing: 1px; margin-bottom: 2px; }
.shop-sub   { color: #aaa; font-size: 11px; margin-bottom: 4px; }
.shop-desc  { color: #b8b49a; font-size: 10px; line-height: 1.4; flex: 1; margin-bottom: 8px; }
.shop-buy   {
  padding: 4px 14px; font-size: 12px; letter-spacing: 1px;
  width: 100%;
}
.shop-actions {
  display: flex; gap: 10px; justify-content: center;
  padding-top: 10px;
  border-top: 1px solid rgba(212,175,55,0.2);
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .title { font-size: 40px; letter-spacing: 6px; }
  .tile { width: 52px; height: 76px; }
  .joker-card { width: 80px; height: 110px; }
  .result-total { font-size: 14px; }
  .final-score b { font-size: 28px !important; }
  .menu-box { padding: 30px 24px; }
}

html.embed-mode body {
  background: #0e0e1c;
}

html.embed-mode .screen {
  padding: 12px;
}

html.embed-mode .menu-box {
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.18);
}

@media (max-width: 960px) {
  .panel.wide { max-width: 100%; }
  .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .screen { padding: 12px; }
  .panel,
  .panel.wide { padding: 20px 16px; }
  .menu-box { padding: 30px 18px; }
  .subtitle { letter-spacing: 2px; line-height: 1.7; }
  .slots-row { gap: 10px; }
  .xian-slot { width: min(42vw, 136px); min-height: 74px; height: auto; }
  .kept-area,
  .hand-area { padding: 8px; }
  .tile-row { gap: 6px; }
  .tile-row.hand {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 8px;
  }
  .tile.selected { transform: translateY(-8px); }
  .action-bar {
    position: sticky;
    bottom: 0;
    z-index: 14;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(26, 26, 46, 0) 0%, rgba(26, 26, 46, 0.94) 20%, rgba(26, 26, 46, 0.98) 100%);
  }
  .action-bar .btn {
    flex: 1 1 calc(50% - 10px);
    min-width: 140px;
  }
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }
  .shop-actions { flex-wrap: wrap; }
}

@media (max-width: 520px) {
  #game { padding: 12px; }
  .title { font-size: 34px; letter-spacing: 4px; }
  .btn { width: 100%; }
  .action-bar .btn { flex: 1 1 100%; min-width: 0; }
  .tile { width: 46px; height: 68px; }
  .joker-card { width: 72px; height: 102px; }
  .shop-grid { grid-template-columns: 1fr; }
  .xian-bar {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  .xian-slot { width: 100%; max-width: none; }
}
