/* css/style.css — 暖金 + 深色，跟小程序版同一套配色 */

:root {
  --bg: #14110f;
  --bg-soft: #1e1a17;
  --panel: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4efe9;
  --text-dim: #9c9188;
  --accent: #e0a86a;
  --accent-strong: #f0c48c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }

/* 100dvh 在移动端浏览器地址栏收放时不会跳，老浏览器回落到 100vh */
.view {
  height: 100vh;
  height: 100dvh;
}

/* ============================== 关卡选择 ============================== */

#view-home { overflow-y: auto; }

.home {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 40px;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(224, 168, 106, 0.16), transparent 70%);
  min-height: 100%;
}

.hero {
  padding: 40px 0 28px;
  text-align: center;
}
.title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 6px;
  text-indent: 6px;
}
.subtitle {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

/* 分类筛选条：横向可滚动，分类多了也不会换行挤满屏 */
.cats {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip-on {
  color: #2a1d10;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  border-color: transparent;
  font-weight: 600;
}
.chip-n {
  font-size: 11px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.empty-tip {
  padding: 40px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

/* 图库：自适应列数，图多了自动换行 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.cell { min-width: 0; }

/* 竖版缩略图（3:4）。缩略图本身就是开始按钮 */
.thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  cursor: pointer;
}
.thumb:hover { opacity: 0.85; }
.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 有配套视频的图，右上角标一下 */
.thumb-play {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-size: 11px;
  color: #2a1d10;
  background: rgba(240, 196, 140, 0.92);
  border-radius: 50%;
}

.thumb-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 20px 10px 9px;
  background: linear-gradient(to top, rgba(8, 6, 5, 0.92), transparent);
}
.thumb-name {
  font-size: 14px;
  font-weight: 600;
}
.thumb-best {
  margin-top: 2px;
  font-size: 11px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.thumb-dim { color: rgba(244, 239, 233, 0.55); }

/* 难度选择：独立控件，点它不会开局 */
.pick {
  width: 100%;
  margin-top: 7px;
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
  text-align: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.pick option { background: var(--bg-soft); color: var(--text); }

.reset {
  margin-top: 32px;
  text-align: center;
  font-size: 12px;
  color: rgba(156, 145, 136, 0.55);
  cursor: pointer;
}
.reset:hover { color: var(--text-dim); }

/* ================================ 游戏 ================================ */

.page {
  position: relative;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(100% 50% at 50% 0%, rgba(224, 168, 106, 0.12), transparent 65%);
  overflow: hidden;
}

/* 顶部数据 */
.hud {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 12px 0 8px;
}
.hud-item { text-align: center; }
.hud-val {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.hud-grid { color: var(--accent); }
/* 剩余不足 1 分钟 */
.hud-urgent {
  color: #ff6e5f;
  animation: blink 1s steps(2, end) infinite;
}
@keyframes blink {
  50% { opacity: 0.45; }
}
.hud-sub {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 400;
}
.hud-key {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* 画布 */
.stage-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
}
#stage {
  display: block;
  width: 100%;
  height: 100%;
  /* 手指在画布上拖动时不要触发页面滚动/缩放 */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
#stage:active { cursor: grabbing; }

/* 道具条 */
.items {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 4px 12px 0;
}
.item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 0 6px;
  background: var(--panel);
  border: 1px solid rgba(224, 168, 106, 0.3);
  border-radius: 10px;
  cursor: pointer;
}
.item:hover { background: rgba(255, 255, 255, 0.1); }
.item-icon { font-size: 17px; line-height: 1.2; }
.item-name { font-size: 12px; }
.item-tag {
  font-size: 9px;
  color: var(--accent);
  letter-spacing: 0.5px;
}
/* 本局已用过：置灰但仍可点，点了会提示 */
.item-off {
  border-color: var(--line);
  opacity: 0.42;
}
.item-off .item-tag { color: var(--text-dim); }

/* 底部操作条 */
.bar {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
}
.bar-btn {
  flex: 1;
  text-align: center;
  padding: 9px 0;
  font-size: 13px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.bar-btn:hover { background: rgba(255, 255, 255, 0.1); }

/* ============================== 通用弹层 ============================== */

.mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 8, 6, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.card {
  width: 100%;
  max-width: 340px;
  padding: 24px 26px;
  background: #1e1a17;
  border: 1px solid rgba(224, 168, 106, 0.28);
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.card-title {
  font-size: 19px;
  font-weight: 700;
}
.card-actions { margin-top: 20px; }

.btn {
  width: 100%;
  padding: 10px 18px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); }
.btn-accent {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  border-color: transparent;
  color: #2a1d10;
  font-weight: 600;
}
.btn-accent:hover { opacity: 0.9; background: linear-gradient(135deg, var(--accent-strong), var(--accent)); }

.confirm-actions {
  display: flex;
  gap: 12px;
}

/* 结算 · 本关配了视频：卡片放大，上半部分留给视频 */
.card-video { max-width: 420px; }
.win-video {
  width: 100%;
  height: 52vh;
  max-height: 460px;
  display: block;
  object-fit: contain;
  border-radius: 10px;
  background: #000;
  margin-bottom: 12px;
}
/* 视频已经占了大半，下面的信息压紧一点，别把按钮挤出屏幕 */
.card-video .win-time {
  margin-top: 6px;
  font-size: 30px;
}
.card-video .card-actions { margin-top: 14px; }

.act-row {
  display: flex;
  gap: 12px;
}

/* 结算 */
.win-img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: var(--bg-soft);
  margin-bottom: 16px;
}
.win-time {
  margin-top: 10px;
  font-size: 38px;
  font-weight: 700;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.win-best {
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* 时间耗尽 */
.over-sub {
  margin-top: 11px;
  font-size: 15px;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}
.over-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

/* 广告位 */
.ad-desc {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}
.ad-slot {
  margin-top: 14px;
  padding: 20px 12px;
  border: 1px dashed rgba(224, 168, 106, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.ad-slot-tag {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 3px;
}
.ad-slot-note {
  margin-top: 5px;
  font-size: 10px;
  color: rgba(156, 145, 136, 0.7);
}
.ad-secs {
  margin-top: 12px;
  font-size: 30px;
  font-weight: 700;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.ad-secs-done {
  font-size: 20px;
  color: #7bc47f;
}
.ad-hint {
  margin-top: 10px;
  font-size: 10px;
  color: rgba(156, 145, 136, 0.6);
}

/* 通关视频 */
.video-mask { z-index: 120; background: #000; }
.finale-video {
  max-width: 100%;
  max-height: 100%;
}
/* 自动播放被浏览器拦下时才出现 */
.video-tip {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 26px;
  font-size: 16px;
  color: #2a1d10;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.video-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 34px;
  height: 34px;
  line-height: 34px;
  text-align: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

/* ============================== 提示 / 加载 ============================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  z-index: 200;
  max-width: 80vw;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text);
  background: rgba(10, 8, 6, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  pointer-events: none;
  animation: toast-in 0.18s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 6, 0.55);
}
.loading-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  font-size: 13px;
  background: rgba(20, 17, 15, 0.96);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(224, 168, 106, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 窄屏微调 */
@media (max-width: 420px) {
  .hud { gap: 24px; }
  .toast { bottom: 96px; }
}
