/* ===========================================================================
   军训靶场射击 · 样式表
   军营绿色系：深松绿底 + 卡其/金色点缀 + 少量正红强调。
   布局用 flex 垂直三段（HUD / 舞台 / 底部），舞台撑满剩余高度。
   =========================================================================== */

:root {
  --bg-0: #0e1a13;
  --bg-1: #16291d;
  --bg-2: #1f3b2a;
  --line: rgba(190, 214, 176, 0.16);
  --cream: #f2efe2;
  --khaki: #cbb98d;
  --gold: #e5b84b;
  --red: #c9432f;
  --green-soft: #93bb8a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC",
    system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 让 hidden 属性始终生效（覆盖下面 .overlay 的 display 声明） */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--cream);
  background:
    radial-gradient(1200px 700px at 50% -15%, #26402f 0%, transparent 62%),
    radial-gradient(900px 620px at 108% 112%, #1b3324 0%, transparent 58%),
    var(--bg-0);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* -------- 整体骨架 -------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px clamp(10px, 2vw, 20px) 10px;
  gap: 10px;
}

/* ===========================================================================
   顶部 HUD
   =========================================================================== */
.hud {
  display: grid;
  grid-template-columns: 1fr minmax(170px, 1.5fr) 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(33, 62, 44, 0.95), rgba(17, 32, 23, 0.95));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3);
  flex: 0 0 auto;
}

.hud__cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hud__cell--right {
  align-items: flex-end;
}

.hud__label {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--green-soft);
}

.hud__value {
  font-size: clamp(20px, 3.2vw, 28px);
  line-height: 1.1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.hud__unit {
  font-size: 12px;
  color: var(--khaki);
  margin-left: 2px;
}

/* 倒计时进度条 */
.hud__cell--timer {
  align-items: center;
}

.timer {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timer__bar {
  width: 100%;
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.timer__bar > i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7ec38a, var(--gold) 65%, var(--red));
  transition: width 0.12s linear;
}

.timer__bar > i.is-low {
  animation: pulseLow 0.7s ease-in-out infinite;
}

@keyframes pulseLow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.timer__text {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

/* 生命（五角星） */
.lives {
  display: flex;
  gap: 4px;
  font-size: clamp(18px, 2.6vw, 24px);
  line-height: 1;
}

.life::before {
  content: "★";
  color: var(--gold);
  text-shadow: 0 0 10px rgba(229, 184, 75, 0.55);
  transition: opacity 0.25s ease, transform 0.25s ease, filter 0.25s ease;
}

.life.is-lost::before {
  opacity: 0.22;
  filter: grayscale(1);
  text-shadow: none;
  transform: scale(0.86);
}

/* ===========================================================================
   游戏舞台
   =========================================================================== */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 40%, rgba(126, 178, 126, 0.16), transparent 62%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.026) 0 2px, transparent 2px 16px),
    linear-gradient(180deg, #17301f 0%, #12241a 58%, #0c1a12 100%);
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.55), var(--shadow);
  isolation: isolate;
}

/* 舞台地面基准线，增加“靶场”纵深感 */
.stage::after {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 11%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
  pointer-events: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* 隐藏系统指针，游戏内自绘准星 */
  cursor: none;
  touch-action: none;
}

/* 连击徽标 */
.combo {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #241a05;
  background: linear-gradient(180deg, #f3d478, #cfa334);
  box-shadow: 0 6px 18px rgba(229, 184, 75, 0.35);
  pointer-events: none;
  animation: comboPop 0.25s ease;
  z-index: 2;
}

@keyframes comboPop {
  from { transform: translateX(-50%) scale(0.8); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* 提示条 */
.toast-layer {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 3;
  width: max-content;
  max-width: 92%;
}

.toast {
  padding: 7px 16px;
  border-radius: 99px;
  font-size: 13px;
  color: #fdfbf3;
  background: rgba(12, 26, 18, 0.88);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  animation: toastIn 0.18s ease, toastOut 0.28s ease 0.72s forwards;
  white-space: nowrap;
}

.toast--bad {
  border-color: rgba(201, 67, 47, 0.55);
  background: rgba(74, 20, 14, 0.9);
}

@keyframes toastIn {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
  to { transform: translateY(-6px); opacity: 0; }
}

/* ===========================================================================
   弹层（开始 / 结算共用）
   =========================================================================== */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 28px);
  overflow: auto;
  background: rgba(7, 16, 11, 0.74);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.overlay.is-in {
  opacity: 1;
  transform: none;
}

.panel {
  width: min(560px, 100%);
  padding: clamp(18px, 3.4vw, 32px);
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #223d2c, #15271b);
  box-shadow: var(--shadow);
  text-align: center;
}

/* 靶心徽记 */
.emblem {
  position: relative;
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #f6f1e0 0 42%, #c8442f 42% 62%, #f6f1e0 62% 80%, #c8442f 80% 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
  animation: emblemIn 0.5s cubic-bezier(0.2, 1.4, 0.5, 1);
}

.emblem__ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px dashed rgba(229, 184, 75, 0.45);
  animation: spin 18s linear infinite;
}

.emblem__dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--gold);
}

@keyframes emblemIn {
  from { transform: scale(0.6) rotate(-25deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

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

.title {
  margin: 0 0 6px;
  font-size: clamp(24px, 4.6vw, 34px);
  letter-spacing: 0.08em;
  color: #fff;
}

.subtitle {
  margin: 0 0 18px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--khaki);
}

/* 规则列表 */
.rules {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 9px;
  text-align: left;
}

.rules li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13.5px;
  line-height: 1.55;
  color: #dfe7da;
}

.rules__icon {
  flex: 0 0 auto;
  font-size: 16px;
  line-height: 1.4;
}

.rules em {
  font-style: normal;
  color: var(--gold);
}

.rules b {
  color: #fff;
}

.best {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--khaki);
}

.best b {
  color: var(--gold);
  font-size: 16px;
}

.best--sm {
  margin: 14px 0 16px;
}

/* 主按钮 */
.btn {
  display: inline-block;
  width: 100%;
  padding: 14px 26px;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #241c05;
  background: linear-gradient(180deg, #f0d179, #c99a2f);
  box-shadow: 0 6px 0 #7d5f1a, 0 12px 26px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #7d5f1a, 0 6px 14px rgba(0, 0, 0, 0.4);
}

.btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

.hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: rgba(203, 185, 141, 0.72);
}

/* -------- 结算面板专属 -------- */
.result__label {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--green-soft);
}

.result__score {
  margin: 0 0 12px;
  font-size: clamp(46px, 11vw, 68px);
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 6px 28px rgba(229, 184, 75, 0.28);
  animation: scoreIn 0.45s cubic-bezier(0.2, 1.4, 0.5, 1);
}

.result__score small {
  font-size: 16px;
  font-weight: 500;
  color: var(--khaki);
  margin-left: 4px;
}

@keyframes scoreIn {
  from { transform: scale(0.75); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.rank {
  display: inline-block;
  padding: 7px 22px;
  border-radius: 99px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.16em;
  margin-bottom: 8px;
}

.rank--top {
  color: #2a1d02;
  background: linear-gradient(180deg, #ffe08a, #dd9f1f);
  box-shadow: 0 8px 24px rgba(221, 159, 31, 0.45);
}

.rank--good {
  color: #06210f;
  background: linear-gradient(180deg, #a8e0a4, #5fae5c);
}

.rank--ok {
  color: #161f10;
  background: linear-gradient(180deg, #d8e6c6, #9fb887);
}

.rank--low {
  color: #2b1a0c;
  background: linear-gradient(180deg, #f0c9a0, #cf9a63);
}

.rank--poor {
  color: #2a110c;
  background: linear-gradient(180deg, #f0a89c, #c9604f);
}

.result__desc {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: #dfe7da;
  min-height: 20px;
}

/* 数据四宫格 */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
}

.stats > div {
  padding: 10px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stats dt {
  font-size: 11px;
  color: var(--green-soft);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.stats dd {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ===========================================================================
   底部信息条
   =========================================================================== */
.footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
  font-size: 12px;
  color: rgba(203, 185, 141, 0.8);
}

.footer__best b {
  color: var(--gold);
  font-size: 14px;
}

.footer__hint {
  flex: 1 1 auto;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sound {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--cream);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sound:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ===========================================================================
   小屏适配
   =========================================================================== */
@media (max-width: 640px) {
  .app {
    padding: 8px;
    gap: 8px;
  }

  .hud {
    grid-template-columns: 1fr 1.3fr 1fr;
    padding: 8px 10px;
    gap: 6px;
  }

  .hud__label {
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  .footer__hint {
    display: none;
  }

  .footer {
    justify-content: space-between;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .rules li {
    padding: 8px 10px;
    font-size: 13px;
  }
}

@media (max-height: 620px) {
  .emblem {
    display: none;
  }

  .rules {
    gap: 6px;
    margin-bottom: 12px;
  }

  .rules li {
    padding: 6px 10px;
  }
}
