:root {
  --bg-cream: #f7efe1;
  --clay-card: rgba(255, 249, 238, 0.88);
  --clay-border: rgba(164, 120, 86, 0.24);
  --terracotta: #df6f51;
  --terracotta-dark: #c05236;
  --sage: #6fa388;
  --ochre: #e9b965;
  --ink: #382a27;
  --ink-soft: #756058;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f2dfd0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#slash-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

/* 准星 */
.reticle {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 8;
}

.reticle-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.reticle-track {
  fill: none;
  stroke: rgba(255, 250, 240, 0.45);
  stroke-width: 2.5;
}

.reticle-charge {
  fill: none;
  stroke: #ffd166;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 138.23;
  stroke-dashoffset: 138.23;
  transition: stroke 0.15s ease;
}

.reticle-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  transform: translate(-50%, -50%);
  background: var(--terracotta);
  border: 1.5px solid #fff8eb;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(223, 111, 81, 0.65);
}

.reticle-hint {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: #fffaf0;
  text-shadow: 0 2px 6px rgba(56, 42, 39, 0.7);
  opacity: 0.92;
}

/* 顶部提示横幅 */
.event-banner {
  position: fixed;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(56, 42, 39, 0.85);
  color: #fff6e5;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.4px;
  box-shadow: 0 10px 24px rgba(56, 42, 39, 0.28);
  z-index: 15;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.event-banner.hidden {
  opacity: 0;
  transform: translate(-50%, -10px);
}

/* 粘土卡片质感 */
.clay-card {
  background: var(--clay-card);
  backdrop-filter: blur(12px);
  border: 2px solid var(--clay-border);
  border-radius: 22px;
  box-shadow:
    0 12px 26px rgba(98, 66, 42, 0.16),
    inset 0 2px 5px rgba(255, 255, 255, 0.9),
    inset 0 -4px 7px rgba(176, 134, 102, 0.18);
}

/* 顶部 HUD */
.hud-top {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  pointer-events: none;
  z-index: 10;
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  pointer-events: auto;
}

.brand-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff9f7d, var(--terracotta));
  box-shadow:
    inset -2px -2px 4px rgba(0, 0, 0, 0.22),
    0 0 12px rgba(223, 111, 81, 0.55);
  flex-shrink: 0;
}

.brand-pill h1 {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.brand-pill p {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.stats-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: auto;
}

.stat-pill {
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 78px;
}

.stat-label {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 600;
}

.stat-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  margin-top: 1px;
}

.top-buttons {
  display: flex;
  gap: 8px;
}

/* 底部魔法栏 */
.hud-bottom {
  position: fixed;
  bottom: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  pointer-events: none;
  z-index: 10;
}

.gesture-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  pointer-events: auto;
  max-width: calc(100% - 210px);
}

.gesture-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
  border: 1.5px solid rgba(164, 120, 86, 0.16);
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.gesture-chip:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.85);
}

.gesture-chip.active {
  background: linear-gradient(180deg, #ffe9c7, #ffd79e);
  border-color: var(--terracotta);
  box-shadow:
    0 5px 12px rgba(223, 111, 81, 0.25),
    inset 0 2px 3px rgba(255, 255, 255, 0.9);
}

.gesture-chip .icon {
  font-size: 18px;
  line-height: 1;
}

.chip-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.chip-text strong {
  font-size: 12px;
  font-weight: 800;
}

.chip-text small {
  font-size: 11px;
  color: var(--ink-soft);
}

/* 未解锁技能：压暗 + 价格标签，点击即可购买 */
.gesture-chip.locked {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(164, 120, 86, 0.1);
  filter: grayscale(0.55);
  opacity: 0.78;
}

.gesture-chip.locked .icon {
  opacity: 0.6;
}

.gesture-chip.locked:hover {
  opacity: 1;
  filter: none;
  background: rgba(255, 240, 210, 0.95);
  border-color: var(--terracotta);
}

.chip-lock {
  font-size: 10.5px;
  font-weight: 800;
  color: #b5793f;
  background: rgba(233, 185, 101, 0.24);
  border-radius: 8px;
  padding: 2px 6px;
  white-space: nowrap;
}

.chip-lock:empty {
  display: none;
}

.gesture-chip.affordable .chip-lock {
  color: #fff;
  background: linear-gradient(180deg, #8fbf6a, #6ea54b);
}

.gesture-chip.poor:hover .chip-lock {
  background: rgba(223, 111, 81, 0.35);
  color: #a2402a;
}

/* 收钱飘字 */
.float-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  overflow: hidden;
}

.float-coin {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #b5793f;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.85), 0 6px 14px rgba(120, 80, 40, 0.25);
  animation: floatUp 1.35s cubic-bezier(0.22, 0.9, 0.3, 1) forwards;
  white-space: nowrap;
}

.float-coin.big {
  font-size: 25px;
  letter-spacing: 0.5px;
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.7);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -60%) scale(1.12);
  }
  40% {
    transform: translate(-50%, -95%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -190%) scale(0.94);
  }
}

/* 钱包 */
.money-value {
  color: #b5793f;
  font-variant-numeric: tabular-nums;
}

.money-pill.gain {
  animation: moneyPop 0.36s ease;
}

@keyframes moneyPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.11); }
  100% { transform: scale(1); }
}

.action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}

/* 粘土立体按钮 */
.clay-btn {
  border: none;
  border-radius: 16px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
  background: linear-gradient(180deg, #fff9ef, #efe0cb);
  box-shadow:
    0 6px 0 #cbb294,
    0 10px 18px rgba(84, 54, 34, 0.16),
    inset 0 2px 3px rgba(255, 255, 255, 0.95);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.clay-btn:hover {
  filter: brightness(1.03);
}

.clay-btn:active {
  transform: scale(0.97);
  box-shadow:
    0 3px 0 #cbb294,
    0 5px 10px rgba(84, 54, 34, 0.16);
}

.clay-btn.small {
  padding: 8px 13px;
  font-size: 12px;
  border-radius: 14px;
}

.clay-btn.large {
  padding: 12px 24px;
  font-size: 15px;
}

.clay-btn.primary {
  color: #fffaf0;
  background: linear-gradient(180deg, #ee8264, var(--terracotta));
  box-shadow:
    0 6px 0 var(--terracotta-dark),
    0 12px 22px rgba(192, 82, 54, 0.3),
    inset 0 2px 3px rgba(255, 224, 210, 0.65);
}

.clay-btn.primary:active {
  box-shadow:
    0 3px 0 var(--terracotta-dark),
    0 6px 12px rgba(192, 82, 54, 0.3);
}

.clay-btn.active-toggle {
  background: linear-gradient(180deg, #86be9f, var(--sage));
  color: #fffef9;
  box-shadow:
    0 6px 0 #4d7e64,
    0 10px 18px rgba(77, 126, 100, 0.28);
}

.hidden {
  display: none !important;
}

/* 摄像头画中画 */
.camera-pip {
  position: fixed;
  right: 14px;
  bottom: 84px;
  width: 230px;
  height: 172px;
  overflow: hidden;
  padding: 0;
  z-index: 12;
}

.camera-pip video,
.camera-pip canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.gesture-badge {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(45, 32, 28, 0.78);
  color: #fff8eb;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  z-index: 2;
}

/* 欢迎引导弹窗 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(56, 40, 32, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}

.modal-card {
  max-width: 660px;
  width: 100%;
  padding: 26px 28px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(223, 111, 81, 0.16);
  color: var(--terracotta-dark);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}

.modal-card h2 {
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
  margin-bottom: 16px;
}

.modal-tips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.tip-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid rgba(164, 120, 86, 0.16);
  font-size: 12px;
  line-height: 1.45;
}

.tip-item span {
  font-size: 20px;
  flex-shrink: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 820px) {
  .gesture-guide {
    max-width: 100%;
  }
  .modal-tips {
    grid-template-columns: 1fr;
  }
  .camera-pip {
    width: 170px;
    height: 128px;
    bottom: 118px;
  }
}

/* 启动加载遮罩：模块没起来时把原因显示出来，而不是留一片空白 */
.boot-status {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f6e6d2;
  transition: opacity 0.32s ease;
}

.boot-status.done {
  opacity: 0;
  pointer-events: none;
}

.boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 78vw;
  padding: 26px 30px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    0 18px 40px rgba(150, 108, 72, 0.18),
    inset 0 2px 4px rgba(255, 255, 255, 0.9);
  text-align: center;
}

.boot-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: #8a6647;
  font-weight: 600;
  word-break: break-all;
}

.boot-card p b {
  color: #b4552f;
  font-weight: 800;
}

.boot-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid rgba(196, 148, 104, 0.22);
  border-top-color: #d98b5f;
  animation: bootSpin 0.9s linear infinite;
}

.boot-status.failed .boot-spinner {
  border-color: rgba(200, 90, 60, 0.25);
  border-top-color: #c9563a;
  animation: none;
  transform: rotate(45deg);
}

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