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

:root {
  --orange: #ff8a3d;
  --orange-deep: #ef6c1a;
  --yellow: #ffd166;
  --red: #ef476f;
  --green: #06d6a0;
  --ink: #4a3328;
  --cream: #fff6e8;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #ffca8a;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: block;
  background: #2a1810;
  overscroll-behavior: none;
}

.wrap {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- 舞台 / 画布：铺满整屏（竖屏横屏都填满） ---------- */
.stage {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: #ffe9c4;
  touch-action: none;
}

canvas { display: block; width: 100%; height: 100%; }

/* ---------- 覆盖层 ---------- */
.screen {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(60, 30, 10, .45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  padding: 18px;
  z-index: 5;
}
.screen.hidden { display: none; }

.panel {
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--cream);
  border-radius: 22px;
  padding: 26px 28px 24px;
  text-align: center;
  box-shadow: 0 12px 0 rgba(180, 110, 60, .35);
  border: 4px solid #fff;
}
.panel.wide { width: min(760px, 100%); }

.logo {
  font-size: clamp(30px, 5.6vw, 46px);
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--orange-deep);
  text-shadow: 0 3px 0 #fff, 0 6px 0 rgba(180, 110, 60, .25);
}
.logo-emoji { font-size: .88em; margin-right: 6px; }
.logo .hl { color: var(--red); }

.panel-title {
  font-size: clamp(20px, 3.8vw, 26px);
  font-weight: 800;
  color: var(--orange-deep);
  margin-bottom: 12px;
}

.tag { font-size: clamp(13px, 2.8vw, 15px); color: #8a6a52; margin: 10px 0 18px; }

.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.btn-row.col { flex-direction: column; align-items: stretch; }

.btn {
  font: inherit;
  font-weight: 800;
  font-size: clamp(15px, 3vw, 17px);
  min-height: 46px;
  color: var(--ink);
  background: #fff;
  border: none;
  border-radius: 14px;
  padding: 12px 20px;
  cursor: pointer;
  box-shadow: 0 5px 0 #e2c7a8;
  transition: transform .07s, box-shadow .07s;
  touch-action: manipulation;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 0 #e2c7a8; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #e2c7a8; }
.btn.primary {
  background: linear-gradient(#ffb057, var(--orange));
  color: #fff;
  box-shadow: 0 5px 0 #cf5f11;
}
.btn.primary:active { box-shadow: 0 1px 0 #cf5f11; }
.btn.ghost { background: transparent; box-shadow: none; color: #a98a70; font-size: 14px; min-height: 40px; }
.btn.shop { background: linear-gradient(#ffe08a, #ffc94d); color: #6b3a10; box-shadow: 0 5px 0 #d99b1c; }
.btn.shop:active { box-shadow: 0 1px 0 #d99b1c; }

.howto {
  margin-top: 16px;
  font-size: clamp(12px, 2.6vw, 13.5px);
  line-height: 1.75;
  color: #7d6050;
  background: #fff2dc;
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
}
.total { margin-top: 12px; font-size: 13px; color: #a07a5c; }

/* ---------- 兑换处 ---------- */
.purse-line { margin-top: 10px; font-size: clamp(12px, 2.6vw, 13.5px); color: #8a6a52; }
.purse-line b { color: var(--orange-deep); }

.purse { display: flex; gap: 8px; margin-bottom: 12px; }
.coin { flex: 1; background: #fff2dc; border-radius: 14px; padding: 8px 2px; }
.coin.e { background: #e6f7ff; }
.coin.g { background: #fdeaf3; }
.coin span { font-size: 17px; }
.coin b { display: block; font-size: clamp(16px, 3.4vw, 20px); color: var(--orange-deep); }
.coin.e b { color: #118ab2; }
.coin.g b { color: #b5179e; }
.coin label { font-size: 10.5px; color: #a3856c; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab {
  flex: 1;
  font: inherit; font-weight: 800; font-size: clamp(13px, 2.8vw, 15px);
  min-height: 44px;
  border: none; border-radius: 12px;
  padding: 10px 4px;
  background: #fff; color: #a3856c;
  cursor: pointer;
  box-shadow: 0 3px 0 #e6d0b6;
  touch-action: manipulation;
}
.tab.on { background: var(--orange); color: #fff; box-shadow: 0 3px 0 #cf5f11; }

.shop-body { max-height: min(42vh, 330px); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px; }

.ex-card {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 16px;
  padding: 12px; margin-bottom: 10px;
  box-shadow: 0 4px 0 #e6d0b6;
}
.ex-icon { font-size: 30px; flex: 0 0 auto; }
.ex-info { flex: 1; text-align: left; min-width: 0; }
.ex-info b { display: block; font-size: 15px; }
.ex-info small { color: #a3856c; font-size: 11.5px; }
.ex-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.mini {
  font: inherit; font-weight: 800; font-size: 13px;
  min-height: 40px;
  border: none; border-radius: 10px; padding: 8px 12px;
  background: var(--orange); color: #fff; cursor: pointer;
  box-shadow: 0 3px 0 #cf5f11;
  touch-action: manipulation;
}
.mini:active { transform: translateY(3px); box-shadow: none; }
.mini.grey { background: #dfd3c3; color: #8a6a52; box-shadow: 0 3px 0 #c7b8a4; }

.item-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.item {
  background: #fff; border-radius: 16px;
  padding: 10px 6px; text-align: center;
  box-shadow: 0 4px 0 #e6d0b6;
  border: 3px solid transparent;
}
.item.on { border-color: var(--green); }
.item canvas { width: 84px; height: 84px; max-width: 100%; display: block; margin: 0 auto; }
.item .big { font-size: 40px; line-height: 1.3; }
.item h4 { font-size: 13.5px; margin: 2px 0; }
.item p { font-size: 11px; color: #a3856c; min-height: 30px; line-height: 1.35; }
.item .price { font-size: 12.5px; font-weight: 800; color: var(--orange-deep); margin-bottom: 6px; }
.item .price.g { color: #b5179e; }
.item .mini { width: 100%; }
.item .owned { font-size: 12px; font-weight: 800; color: var(--green); padding: 5px 0; }

.earn-line { font-size: 12.5px; color: #118ab2; margin: 6px 0 2px; min-height: 18px; }

/* ---------- 选关卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.card {
  background: #fff;
  border-radius: 16px;
  padding: 14px 6px 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #e6d0b6;
  transition: transform .1s;
  border: 3px solid transparent;
  touch-action: manipulation;
}
.card:hover { transform: translateY(-3px); border-color: var(--yellow); }
.card.locked { filter: grayscale(.85); opacity: .6; cursor: not-allowed; }
.card.locked:hover { transform: none; border-color: transparent; }
.card-icon { font-size: 32px; line-height: 1.2; }
.card-name { font-weight: 800; font-size: 14px; margin-top: 4px; }
.card-stars { font-size: 12px; margin-top: 4px; letter-spacing: 1px; }
.card-best { font-size: 10.5px; color: #b09179; margin-top: 2px; }

/* ---------- 结算 ---------- */
.result-face { font-size: clamp(44px, 9vw, 58px); line-height: 1; }
.stars { font-size: clamp(24px, 5vw, 30px); letter-spacing: 4px; margin: 6px 0 12px; }
.stat-row { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; }
.stat {
  flex: 1;
  min-width: 0;
  background: #fff2dc;
  border-radius: 14px;
  padding: 10px 2px;
}
.stat span { display: block; font-size: clamp(16px, 3.6vw, 20px); font-weight: 900; color: var(--orange-deep); }
.stat label { font-size: 10.5px; color: #a3856c; }
.tip-line { font-size: 12.5px; color: #8a6a52; min-height: 18px; }

/* ---------- 角上的小圆钮 ---------- */
.round-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 20;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .9);
  background: rgba(47, 28, 16, .78);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
  touch-action: manipulation;
}
/* 暂停钮：下移到 HUD 下方，避免挡住右上角分数 */
.round-btn.top { bottom: auto; top: 84px; }
/* 声音钮：放在暂停钮正下方 */
#btnSound { bottom: auto; top: 142px; }
.round-btn.hidden { display: none; }

/* ---------- 竖屏提示 ---------- */
.rotate-icon {
  font-size: 62px;
  line-height: 1;
  display: inline-block;
  animation: tipRotate 1.8s ease-in-out infinite;
}
@keyframes tipRotate {
  0%, 35% { transform: rotate(0deg); }
  65%, 100% { transform: rotate(-90deg); }
}

.foot {
  flex: 0 0 auto;
  text-align: center;
  font-size: 12px;
  color: #9c6b3c;
  margin-top: 12px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.hidden { display: none !important; }

/* =========================================================
   竖屏 / 小屏：铺满整屏，面板可滚动，按钮触控友好
   ========================================================= */
@media (max-width: 620px) {
  .grid, .item-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card { padding: 12px 4px 10px; }
  .howto { line-height: 1.65; }
  .purse { gap: 6px; }
  .ex-card { flex-wrap: wrap; }
  .ex-btns { width: 100%; justify-content: flex-start; }
  .foot { display: none; }
}

/* 矮屏（横屏手机）：面板尽量矮、省掉底部说明 */
@media (max-height: 480px) {
  .foot { display: none; }
  .screen { padding: 6px; }
  .panel { padding: 12px 14px; }
  .howto { display: none; }
  .tag { margin: 6px 0 10px; }
  .btn-row { margin-top: 10px; }
  .shop-body { max-height: 34vh; }
  .result-face { font-size: 34px; }
  .stars { font-size: 22px; margin: 4px 0 8px; }
  .stat { padding: 6px 2px; }
}
