/* 猫猫打地鼠 · 竖屏界面样式
 * 基线：Chrome 61 / Android 8.1 WebView。现代能力只做增强层。
 * - 不用 inset / aspect-ratio；Flex 间距基线用子项 margin，检测到支持后启用 gap
 * - clamp()/max() 一律先写 vmin 兜底；backdrop-filter 只放 @supports
 * - 安全区 var(--safe-area-inset-*, env(...))，PC 模拟器可注入变量
 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(120% 90% at 50% 0%, #fff6ea 0%, #ffe6cd 60%, #ffd9b8 100%);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: #5b3b2e;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  padding-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
  padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  padding-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(180, 110, 70, 0.22);
  background: #ffeede;
}
#app.full { border-radius: 0; box-shadow: none; }

#game { display: block; width: 100%; height: 100%; touch-action: none; }

#ui {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  font-size: 3.4vmin;
  font-size: clamp(13px, 3.4vmin, 20px);
}
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }

/* ---------------- 顶部 HUD ---------------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  z-index: 5;
  pointer-events: none;
}
.hud-score {
  display: flex;
  align-items: baseline;
  color: #5b3b2e;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  padding: 6px 16px;
  box-shadow: 0 4px 12px rgba(190, 130, 95, 0.16);
}
.hud-score b {
  font-size: 28px;
  font-size: max(28px, 6.4vmin);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hud-score span { font-size: 12px; font-size: max(12px, 2.6vmin); margin-left: 3px; opacity: 0.75; }

.hud-mid { flex: 1; min-width: 0; padding: 0 10px; }
.time-bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(160, 110, 80, 0.2);
}
.time-bar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ed957 0%, #ffd166 62%, #ff6b4a 100%);
  transform-origin: left center;
}
.hud-row { display: flex; align-items: center; margin-top: 6px; }
.hud-row > * + * { margin-left: 8px; }
.hud-row > *:first-child { margin-left: 0; }
#time-text { font-size: 12px; font-size: max(12px, 2.6vmin); font-weight: 700; color: rgba(120, 84, 62, 0.9); }
.combo {
  font-size: 11px;
  font-size: max(11px, 2.4vmin);
  font-weight: 800;
  color: #fff;
  background: #ff7f4d;
  border-radius: 999px;
  padding: 2px 10px;
  transform: rotate(-3deg);
}
.combo b { font-size: 1.25em; }

.hud-coll {
  font-size: 11px;
  font-size: max(11px, 2.4vmin);
  font-weight: 700;
  color: #7a5747;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  padding: 6px 12px;
}

.coll-chip {
  position: absolute;
  left: 12px;
  top: 64px;
  top: max(64px, 13vmin);
  background: rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11px;
  font-size: max(11px, 2.4vmin);
  font-weight: 700;
  color: #7a5747;
  z-index: 5;
}

/* ---------------- 角落按钮 ---------------- */
.corner-btns {
  position: absolute;
  right: 10px;
  right: max(10px, 2.2vmin);
  bottom: 10px;
  bottom: max(10px, 2.2vmin);
  display: flex;
  z-index: 8;
}
.corner-btns > * + * { margin-left: 8px; }
.icon-btn {
  width: 38px;
  width: max(38px, 7vmin);
  height: 38px;
  height: max(38px, 7vmin);
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #a2653f;
  font-size: 14px;
  font-size: max(14px, 2.6vmin);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(170, 110, 70, 0.18);
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
}
.icon-btn:active { transform: scale(0.92); background: #fff; }

/* ---------------- 弹层 ---------------- */
.screen {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.4vmin;
  padding: clamp(16px, 4vmin, 40px);
  background: rgba(255, 244, 232, 0.985);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.98);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  z-index: 6;
}
.screen > * + * { margin-top: 2.2vmin; }
.screen.show { opacity: 1; visibility: visible; transform: scale(1); }

@supports ((-webkit-backdrop-filter: blur(10px)) or (backdrop-filter: blur(10px))) {
  .screen {
    background: rgba(255, 244, 232, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
  .icon-btn {
    background: rgba(255, 255, 255, 0.62);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }
}

/* ---------------- 首页 ---------------- */
.logo-wrap { text-align: center; }
.logo-sub {
  font-size: 10px;
  font-size: max(10px, 2.1vmin);
  letter-spacing: 0.35em;
  color: rgba(176, 120, 92, 0.75);
  font-weight: 700;
  margin-bottom: 4px;
}
.logo {
  font-size: 12vmin;
  font-size: clamp(38px, 12vmin, 74px);
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #5b3b2e;
  line-height: 1.08;
  text-shadow: 0 2px 0 #fff, 0 6px 0 rgba(255, 255, 255, 0.6), 0 12px 22px rgba(200, 130, 90, 0.28);
}
.logo span { color: #f4661e; }
.tagline {
  margin-top: 8px;
  font-size: 13px;
  font-size: max(13px, 3vmin);
  font-weight: 600;
  color: rgba(150, 96, 70, 0.9);
}

.daily {
  font-size: 11px;
  font-size: max(11px, 2.5vmin);
  font-weight: 700;
  color: #a2653f;
  background: rgba(255, 233, 208, 0.9);
  border: 1px dashed rgba(226, 150, 102, 0.6);
  border-radius: 999px;
  padding: 4px 14px;
}

.rival {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(255, 127, 77, 0.5);
  border-radius: 999px;
  padding: 4px 6px 4px 14px;
  font-size: 11px;
  font-size: max(11px, 2.5vmin);
  color: #7a5747;
}
.rival b { color: #f4661e; }
.btn-mini {
  margin-left: 8px;
  border: none;
  background: #ff7f4d;
  color: #fff;
  font-family: inherit;
  font-size: 11px;
  font-size: max(11px, 2.4vmin);
  font-weight: 800;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}

.best-line { font-size: 12px; font-size: max(12px, 2.7vmin); color: rgba(140, 92, 68, 0.9); }
.best-line b { color: #5b3b2e; font-size: 1.2em; }

.coll-row { display: flex; align-items: center; width: 100%; max-width: 420px; }
.coll-row > * + * { margin-left: 10px; }
.coll-progress { flex: 1; min-width: 0; display: flex; align-items: center; }
.coll-bar {
  flex: 1;
  min-width: 0;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  overflow: hidden;
  margin-right: 8px;
  box-shadow: inset 0 1px 2px rgba(160, 110, 80, 0.18);
}
.coll-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb066 0%, #ff8a3d 100%);
  transition: width 0.3s;
}
.coll-progress span { font-size: 11px; font-size: max(11px, 2.4vmin); font-weight: 700; color: #7a5747; white-space: nowrap; }

.nick-row { display: flex; align-items: center; font-size: 12px; font-size: max(12px, 2.6vmin); color: rgba(140, 92, 68, 0.95); }
.nick-row label { margin-right: 8px; font-weight: 700; }
#nick {
  width: 7em;
  border: 2px solid rgba(226, 150, 102, 0.45);
  background: rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  font-size: max(12px, 2.5vmin);
  color: #5b3b2e;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
}
#nick:focus { outline: none; border-color: #ff8a3d; }

/* ---------------- 按钮 ---------------- */
.btn-main {
  border: none;
  cursor: pointer;
  padding: 0.72em 2.1em;
  border-radius: 999px;
  font-size: 4.6vmin;
  font-size: clamp(18px, 4.6vmin, 28px);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #fff8ef;
  background: linear-gradient(180deg, #ffb066 0%, #ff8a3d 100%);
  box-shadow: 0 8px 0 #e2702a, 0 16px 26px rgba(226, 112, 42, 0.32);
  transition: transform 0.1s, box-shadow 0.1s;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.btn-main:active { transform: translateY(5px); box-shadow: 0 3px 0 #e2702a, 0 8px 14px rgba(226, 112, 42, 0.3); }
.btn-main.small {
  font-size: 15px;
  font-size: clamp(15px, 3.4vmin, 22px);
  padding: 0.66em 1.4em;
  letter-spacing: 0.06em;
}
.btn-main[disabled] { opacity: 0.5; box-shadow: 0 4px 0 #d08a5e; }

.btn-ghost {
  border: 2px solid rgba(226, 112, 42, 0.45);
  background: rgba(255, 255, 255, 0.66);
  color: #c9682b;
  cursor: pointer;
  padding: 0.6em 1.5em;
  border-radius: 999px;
  font-size: 14px;
  font-size: max(14px, 3.2vmin);
  font-weight: 700;
  font-family: inherit;
  transition: transform 0.1s, background 0.12s;
  -webkit-appearance: none;
  appearance: none;
}
.btn-ghost:active { transform: scale(0.96); background: #fff; }
.btn-ghost.wide { width: 100%; max-width: 420px; }
.btn-ghost[disabled] { opacity: 0.45; }

.row-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 440px;
}
.row-btns > * + * { margin-left: 10px; }

.footnote {
  font-size: 11px;
  font-size: max(11px, 2.4vmin);
  color: rgba(150, 100, 76, 0.78);
  text-align: center;
  line-height: 1.6;
}

/* ---------------- 结算 ---------------- */
.over-head { display: flex; align-items: center; }
.over-head > * + * { margin-left: 10px; }
.over-label {
  font-size: 12px;
  font-size: max(12px, 2.6vmin);
  letter-spacing: 0.3em;
  color: rgba(150, 96, 70, 0.85);
  font-weight: 700;
}
.record {
  background: linear-gradient(180deg, #ff7aa2, #ff4d7d);
  color: #fff;
  font-size: 12px;
  font-size: max(12px, 2.6vmin);
  font-weight: 900;
  letter-spacing: 0.14em;
  padding: 4px 12px;
  border-radius: 999px;
  transform: rotate(-6deg) scale(0);
  transition: transform 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
  box-shadow: 0 4px 12px rgba(255, 77, 125, 0.4);
}
.record.show { transform: rotate(-6deg) scale(1); }
.over-score {
  font-size: 20vmin;
  font-size: clamp(72px, 20vmin, 140px);
  font-weight: 900;
  line-height: 1;
  color: #f4661e;
  text-shadow: 0 4px 0 #fff, 0 10px 0 rgba(255, 255, 255, 0.7), 0 18px 30px rgba(226, 112, 42, 0.3);
  font-variant-numeric: tabular-nums;
}
.stat-grid { display: flex; width: 100%; max-width: 440px; }
.stat-grid > div + div { margin-left: 8px; }
.stat-grid > div {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 16px;
  padding: 10px 4px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(190, 130, 95, 0.12);
}
.stat-grid span { display: block; font-size: 10px; font-size: max(10px, 2.2vmin); color: rgba(150, 100, 76, 0.8); margin-bottom: 2px; }
.stat-grid b { font-size: 15px; font-size: max(15px, 3.4vmin); color: #5b3b2e; }
.over-coll { font-size: 12px; font-size: max(12px, 2.6vmin); color: rgba(140, 92, 68, 0.9); }
.over-coll b { color: #5b3b2e; font-size: 1.15em; }

/* ---------------- 挑战卡 ---------------- */
#challenge-img {
  max-width: 100%;
  max-height: 55%;
  max-height: 55vh;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(180, 110, 70, 0.28);
  background: #fff;
}
#challenge-tip { min-height: 2.6em; line-height: 1.55; }
#challenge-tip.show-text {
  white-space: pre-wrap;
  text-align: left;
  max-height: 30%;
  overflow: auto;
  -webkit-user-select: text;
  user-select: text;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 8px 10px;
  width: 100%;
  max-width: 440px;
}

/* ---------------- 图鉴 ---------------- */
.coll-total { font-size: 13px; font-size: max(13px, 2.9vmin); font-weight: 800; color: #f4661e; }
.gal-grid {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  max-width: 460px;
  justify-content: center;
}
.gal-cell {
  width: 46%;
  width: calc(50% - 6px);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  padding: 8px 4px 6px;
  margin: 0 6px 10px 0;
  text-align: center;
  box-shadow: 0 4px 12px rgba(190, 130, 95, 0.12);
}
.gal-cell:nth-child(2n) { margin-right: 0; }
.gal-cell canvas { display: block; margin: 0 auto; width: 66px; height: 66px; }
.gal-cell .gal-name { font-size: 12px; font-size: max(12px, 2.5vmin); font-weight: 800; color: #5b3b2e; margin-top: 2px; }
.gal-cell.locked .gal-name { color: rgba(122, 87, 71, 0.45); }
.gal-cell .gal-stars { font-size: 10px; font-size: max(10px, 2.1vmin); color: #ffa73d; letter-spacing: 0.1em; height: 1.2em; }
.gal-cell .gal-meta { font-size: 9px; font-size: max(9px, 2vmin); color: rgba(140, 96, 74, 0.75); }
.gal-cell.locked { background: rgba(255, 255, 255, 0.5); }

/* ---------------- 暂停 ---------------- */
.pause-title {
  font-size: 7vmin;
  font-size: clamp(26px, 7vmin, 42px);
  font-weight: 900;
  color: #5b3b2e;
  letter-spacing: 0.08em;
  text-shadow: 0 3px 0 #fff;
}

/* ---------------- 提示 / 晕眩 ---------------- */
.toast {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -12px);
  background: rgba(91, 59, 46, 0.9);
  color: #fff7ec;
  font-size: 12px;
  font-size: max(12px, 2.6vmin);
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s, transform 0.24s, visibility 0.24s;
  z-index: 9;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

.stun {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 7;
}
.stun span {
  background: rgba(255, 77, 94, 0.92);
  color: #fff;
  font-size: 15px;
  font-size: max(15px, 3.4vmin);
  font-weight: 900;
  padding: 10px 22px;
  border-radius: 999px;
  transform: rotate(-4deg);
  box-shadow: 0 8px 20px rgba(200, 50, 70, 0.35);
  animation: stunPop 0.3s ease-out;
}
@keyframes stunPop {
  0% { transform: rotate(-4deg) scale(0.6); }
  60% { transform: rotate(-4deg) scale(1.1); }
  100% { transform: rotate(-4deg) scale(1); }
}

/* ---------------- Flex gap 增强层 ---------------- */
.supports-flex-gap .corner-btns { column-gap: 8px; }
.supports-flex-gap .corner-btns > * + * { margin-left: 0; }
.supports-flex-gap .screen { row-gap: 2.2vmin; row-gap: clamp(10px, 2.2vmin, 22px); }
.supports-flex-gap .screen > * + * { margin-top: 0; }
.supports-flex-gap .hud-row { column-gap: 8px; }
.supports-flex-gap .hud-row > * + * { margin-left: 0; }
.supports-flex-gap .coll-row { column-gap: 10px; }
.supports-flex-gap .coll-row > * + * { margin-left: 0; }
.supports-flex-gap .row-btns { column-gap: 10px; }
.supports-flex-gap .row-btns > * + * { margin-left: 0; }
.supports-flex-gap .stat-grid { column-gap: 8px; }
.supports-flex-gap .stat-grid > div + div { margin-left: 0; }
.supports-flex-gap .over-head { column-gap: 10px; }
.supports-flex-gap .over-head > * + * { margin-left: 0; }
.supports-flex-gap .gal-grid { column-gap: 12px; }
.supports-flex-gap .gal-cell { margin-left: 0; margin-right: 0; }

@media (max-height: 560px) {
  .footnote { display: none; }
  .logo { font-size: 9vmin; font-size: clamp(28px, 9vmin, 46px); }
  .over-score { font-size: 15vmin; font-size: clamp(56px, 15vmin, 96px); }
  .gal-cell canvas { width: 52px; height: 52px; }
}
