/* 果园刀光 Orchard Blade — 样式 */
:root {
  --cream: #f7ecd9;
  --gold: #f0b64a;
  --gold-deep: #d98f26;
  --wood-1: #4a3521;
  --wood-2: #33220f;
  --line: #8a6a3a;
  --red: #ff6b5e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #1e140c;
  color: var(--cream);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ============ HUD ============ */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 26px;
  background: linear-gradient(rgba(26,15,7,0.92), rgba(26,15,7,0.62) 70%, rgba(26,15,7,0));
  pointer-events: none;
}
.hud-left { min-width: 0; flex: 1 1 auto; }
.hud-level {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.obj-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(240,182,74,0.45);
  background: rgba(255,230,180,0.10);
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  color: var(--cream);
}
.chip .chip-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, rgba(240,182,74,0.34), rgba(240,182,74,0.16));
  transition: width 0.25s ease;
}
.chip .chip-t { position: relative; }
.chip.done { border-color: #9be564; color: #d8f3b8; }
.chip.done::after { content: " ✓"; color: #9be564; }

.hud-center { text-align: center; flex: 0 0 auto; }
.hud-time {
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  color: var(--cream);
  text-shadow: 0 2px 6px rgba(0,0,0,0.65);
}
.hud-time.low { color: #ff7d6a; animation: pulse-low 0.7s infinite; }
@keyframes pulse-low { 50% { transform: scale(1.08); } }
.hud-time-label { font-size: 11px; opacity: 0.75; letter-spacing: 0.2em; }

.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  pointer-events: none;
}
.hud-score-wrap { text-align: right; }
.hud-score {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  line-height: 1.05;
}
.hud-score-label { font-size: 11px; opacity: 0.75; letter-spacing: 0.2em; text-align: right; }
.hud-lives { display: flex; gap: 3px; align-items: center; }
.hud-lives .heart { width: 20px; height: 20px; fill: #ff5f4a; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); }
.hud-lives .heart.empty { fill: rgba(255,255,255,0.16); }
.miss-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,120,90,0.15);
  border: 1px solid rgba(255,120,90,0.45);
  font-size: 13px;
  font-weight: 700;
  color: #ffb3a3;
}

.icon-btn {
  pointer-events: auto;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(240,182,74,0.5);
  background: rgba(48,30,14,0.85);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s;
}
.icon-btn svg { width: 22px; height: 22px; fill: var(--cream); }
.icon-btn .wave { stroke: var(--cream); stroke-width: 2; fill: none; }
.icon-btn:hover { background: rgba(80,52,24,0.95); }
.icon-btn:active { transform: scale(0.92); }

/* ============ 旋风斩按钮（触屏） ============ */
#btn-burst {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 12;
  width: 82px; height: 82px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.28), rgba(255,255,255,0) 46%),
    linear-gradient(160deg, #6b3f14, #3a220c);
  color: #ffe9c2;
  font-family: inherit;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 6px 18px rgba(0,0,0,0.5), inset 0 0 14px rgba(240,182,74,0.25);
}
#btn-burst .burst-txt {
  font-size: 34px;
  font-weight: 900;
  text-shadow: 0 2px 6px rgba(0,0,0,0.7);
  position: relative;
}
#btn-burst .burst-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(rgba(140,225,255,0.85) calc(var(--cd, 0) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(closest-side, transparent 82%, #000 86%);
  mask: radial-gradient(closest-side, transparent 82%, #000 86%);
  pointer-events: none;
}
#btn-burst:active { transform: scale(0.93); }
@media (pointer: coarse) {
  #btn-burst:not(.hidden) { display: flex; }
}

/* ============ 屏幕遮罩 ============ */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 30%, rgba(58,38,18,0.55), rgba(14,8,4,0.78));
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  overflow-y: auto;
}

/* ============ 主菜单 ============ */
.menu-inner {
  width: min(920px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 10px 0;
}
.menu-head { text-align: center; }
.menu-badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.5em;
  color: rgba(247,236,217,0.55);
  border: 1px solid rgba(247,236,217,0.25);
  border-radius: 999px;
  padding: 4px 14px 4px 18px;
  margin-bottom: 10px;
}
.menu-title {
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--cream);
  text-shadow: 0 4px 0 rgba(0,0,0,0.35), 0 10px 30px rgba(0,0,0,0.6);
}
.title-accent { color: var(--gold); }
.menu-sub {
  margin-top: 6px;
  font-size: 15px;
  color: rgba(247,236,217,0.8);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.level-card {
  position: relative;
  text-align: left;
  font-family: inherit;
  color: var(--cream);
  border-radius: 16px;
  padding: 16px 16px 14px;
  border: 2px solid rgba(138,106,58,0.6);
  background: linear-gradient(165deg, rgba(84,58,30,0.95), rgba(44,28,12,0.95));
  box-shadow: 0 8px 22px rgba(0,0,0,0.45);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s, box-shadow 0.15s;
}
.level-card:hover { transform: translateY(-3px); border-color: var(--gold); }
.level-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240,182,74,0.35), 0 10px 26px rgba(0,0,0,0.5);
}
.level-card.locked { opacity: 0.55; cursor: not-allowed; filter: saturate(0.5); }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.lv-no {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--gold);
}
.lv-lock { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: rgba(247,236,217,0.7); }
.lv-lock svg { width: 13px; height: 13px; fill: rgba(247,236,217,0.7); }
.lv-name { font-size: 24px; font-weight: 800; margin-top: 6px; }
.lv-tag { font-size: 12.5px; color: rgba(247,236,217,0.65); margin-top: 4px; line-height: 1.5; }
.lv-obj {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #ffe3ae;
  background: rgba(240,182,74,0.12);
  border: 1px dashed rgba(240,182,74,0.4);
  border-radius: 8px;
  padding: 6px 8px;
}
.lv-best {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(247,236,217,0.75);
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 16px;
}
.lv-best .star { width: 14px; height: 14px; fill: var(--gold); }
.lv-best .star.empty { fill: rgba(255,255,255,0.18); }

.menu-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.menu-hint { text-align: center; font-size: 12.5px; color: rgba(247,236,217,0.55); }

/* ============ 按钮 ============ */
.btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--cream);
  padding: 13px 30px;
  border-radius: 14px;
  border: 1.5px solid rgba(138,106,58,0.8);
  background: linear-gradient(165deg, rgba(84,58,30,0.95), rgba(44,28,12,0.95));
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.96); }
.btn-primary {
  color: #33210a;
  border-color: var(--gold-deep);
  background: linear-gradient(170deg, #ffd07a, var(--gold) 40%, var(--gold-deep));
  box-shadow: 0 6px 18px rgba(217,143,38,0.35);
}
.btn-ghost { background: transparent; }

/* ============ 面板（暂停/结算） ============ */
.panel {
  width: min(460px, 100%);
  border-radius: 20px;
  padding: 28px 30px 26px;
  border: 1.5px solid var(--line);
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(255,214,150,0.10), transparent 50%),
    linear-gradient(170deg, var(--wood-1), var(--wood-2));
  box-shadow: 0 24px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,230,180,0.15);
  text-align: center;
}
.panel-title { font-size: 30px; font-weight: 900; letter-spacing: 0.05em; }
.panel-title.win-title { color: #b8e986; text-shadow: 0 3px 0 rgba(0,0,0,0.3); }
.panel-title.lose-title { color: #ff8d7a; }
.panel-obj { margin: 14px 0 4px; }
.pause-obj-row { font-size: 15px; padding: 4px 0; color: rgba(247,236,217,0.85); }
.pause-obj-row.done { color: #b8e986; }

.stars { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.stars .star { width: 42px; height: 42px; fill: var(--gold); filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5)); }
.stars .star.empty { fill: rgba(255,255,255,0.14); filter: none; }
.record-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd76e, #ff9d4a);
  color: #4a2a05;
  font-weight: 800;
  font-size: 14px;
  animation: pulse-low 0.9s infinite;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0 22px;
}
.stat {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(138,106,58,0.4);
  border-radius: 12px;
  padding: 10px 8px;
}
.stat-l { font-size: 12px; color: rgba(247,236,217,0.6); }
.stat-v { font-size: 20px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.lose-reason { margin-top: 10px; font-size: 15px; color: rgba(247,236,217,0.85); }
.panel-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ============ Toast ============ */
#toast {
  position: fixed;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%) translateY(20px);
  z-index: 40;
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(30,17,6,0.92);
  border: 1px solid var(--gold);
  color: #ffe9c2;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 响应式 ============ */
@media (max-width: 760px) {
  .level-grid { grid-template-columns: 1fr; gap: 10px; }
  .level-card { padding: 12px 14px 10px; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "top top" "name best" "tag tag" "obj obj"; column-gap: 10px; }
  .card-top { grid-area: top; }
  .lv-name { grid-area: name; font-size: 20px; margin-top: 2px; }
  .lv-tag { display: none; }
  .lv-obj { grid-area: obj; margin-top: 6px; }
  .lv-best { grid-area: best; margin-top: 0; justify-self: end; }
  .menu-inner { gap: 12px; }
  .menu-title { font-size: 44px; }
}

@media (max-width: 640px) {
  #hud { padding: 8px 10px 20px; gap: 8px; }
  .hud-level { font-size: 13px; max-width: 34vw; }
  .chip { font-size: 11px; padding: 3px 8px; }
  .hud-time { font-size: 24px; }
  .hud-time-label { letter-spacing: 0.1em; }
  .hud-score { font-size: 20px; }
  .hud-score-label { letter-spacing: 0.1em; }
  .hud-lives .heart { width: 16px; height: 16px; }
  .icon-btn { width: 38px; height: 38px; }
  .panel { padding: 20px 18px; }
  .panel-title { font-size: 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-v { font-size: 17px; }
}
