/* ==========================================================================
   《站军姿耐力挑战》样式表
   --------------------------------------------------------------------------
   配色：军营绿 + 迷彩卡其 + 烈日橙
   布局：HUD 顶栏 / 占满屏幕的画布舞台 / 覆盖面板
   ========================================================================== */

/* ---------- 1. 主题变量与基础重置 ---------- */
:root {
  --army-dark: #0d1f14;
  --army: #1c3a26;
  --army-light: #2f5c3c;
  --khaki: #c8b98a;
  --khaki-dim: #9b8f68;
  --sun: #ffb03a;
  --sun-deep: #ff6b1a;
  --danger: #ff4d4d;
  --ok: #7ee787;
  --ink: #eaf3e8;
  --panel-bg: rgba(10, 22, 15, 0.9);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --radius: 16px;
  --hud-h: 74px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #050b07;
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
    system-ui, -apple-system, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid rgba(200, 185, 138, 0.5);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(200, 185, 138, 0.12);
  font-family: inherit;
  font-size: 0.86em;
}

/* ---------- 2. 整体布局 ---------- */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- 3. 顶部 HUD ---------- */
.hud {
  position: relative;
  z-index: 30;
  height: var(--hud-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  background: linear-gradient(180deg, #16301f 0%, #0e2015 100%);
  border-bottom: 2px solid rgba(200, 185, 138, 0.35);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

.hud__group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud__group--center {
  flex: 1 1 auto;
  max-width: 360px;
}

.stat {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 92px;
}

.stat__label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--khaki-dim);
}

.stat__value {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 0 0 14px rgba(126, 231, 135, 0.25);
}

.stat__value small {
  font-size: 13px;
  margin-left: 2px;
  color: var(--khaki);
}

.stat--score .stat__value {
  color: var(--sun);
  text-shadow: 0 0 16px rgba(255, 176, 58, 0.4);
}

.stat--small {
  min-width: 70px;
}

.stat--small .stat__value {
  font-size: 18px;
  color: var(--khaki);
}

/* 体力条 */
.stamina {
  width: 100%;
}

.stamina__head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--khaki-dim);
  margin-bottom: 5px;
}

.stamina__track {
  height: 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(200, 185, 138, 0.35);
  overflow: hidden;
  position: relative;
}

.stamina__fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3ddc84 0%, #b6e34a 55%, #ffd33d 100%);
  transition: width 0.12s linear, background 0.25s linear;
  box-shadow: 0 0 16px rgba(126, 231, 135, 0.5);
}

.stamina__fill.is-warn {
  background: linear-gradient(90deg, #ffb03a 0%, #ff7a18 100%);
  box-shadow: 0 0 16px rgba(255, 122, 24, 0.6);
}

.stamina__fill.is-danger {
  background: linear-gradient(90deg, #ff5b5b 0%, #b81f1f 100%);
  box-shadow: 0 0 18px rgba(255, 60, 60, 0.75);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(200, 185, 138, 0.35);
  background: rgba(200, 185, 138, 0.1);
  color: var(--khaki);
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(200, 185, 138, 0.22);
  transform: translateY(-1px);
}

/* ---------- 4. 画布舞台 ---------- */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #0a1a10;
}

.stage__canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none; /* 光标由游戏自己绘制，避免和手部图标重影 */
}

/* 危险红闪 */
.warn-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 0, 0, 0) 42%,
    rgba(255, 20, 20, 0.45) 100%
  );
}

.warn-flash.is-active {
  animation: warnPulse 0.75s ease-in-out infinite;
}

@keyframes warnPulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.85;
  }
}

/* 飘字层 */
.float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.float-text {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 20px;
  white-space: nowrap;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  animation: floatUp 1s ease-out forwards;
}

.float-text--bad {
  color: #ff6b6b;
}
.float-text--good {
  color: #7ee787;
}
.float-text--warn {
  color: #ffcc4d;
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.7);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -160%) scale(1);
  }
}

/* ---------- 5. 覆盖面板 ---------- */
.overlay {
  position: absolute;
  inset: var(--hud-h) 0 44px 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: radial-gradient(
    ellipse at center,
    rgba(4, 12, 7, 0.55) 0%,
    rgba(4, 12, 7, 0.88) 100%
  );
  backdrop-filter: blur(3px);
  overflow: auto;
}

.overlay.is-hidden {
  display: none;
}

.panel {
  width: min(760px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 26px 28px 22px;
  border-radius: var(--radius);
  background: var(--panel-bg);
  border: 1px solid rgba(200, 185, 138, 0.35);
  box-shadow: var(--shadow);
  text-align: center;
  animation: panelIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.is-hidden {
  display: none !important;
}

.panel__badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--khaki);
  background: rgba(200, 185, 138, 0.14);
  border: 1px solid rgba(200, 185, 138, 0.3);
}

.panel__title {
  margin: 14px 0 8px;
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 1.15;
  color: #f4fbf2;
  text-shadow: 0 4px 26px rgba(0, 0, 0, 0.6);
}

.panel__title span {
  display: block;
  font-size: 0.62em;
  letter-spacing: 10px;
  color: var(--sun);
  text-shadow: 0 0 24px rgba(255, 176, 58, 0.45);
}

.panel__title--sm {
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: 6px;
}

.panel__sub {
  margin: 6px auto 18px;
  max-width: 560px;
  font-size: 15px;
  line-height: 1.8;
  color: #cfe3cd;
}

.panel__sub b {
  color: var(--sun);
}

.rules {
  margin: 0 auto 20px;
  padding: 0;
  max-width: 620px;
  list-style: none;
  text-align: left;
  display: grid;
  gap: 8px;
}

.rules li {
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--army-light);
  font-size: 14px;
  line-height: 1.65;
  color: #d9ead7;
}

.rules li b {
  color: var(--sun);
}

.panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 6px;
}

.panel__hint {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--khaki-dim);
  line-height: 1.7;
}

/* 按钮 */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 13px 24px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn--primary {
  color: #1a1405;
  background: linear-gradient(180deg, #ffd15c 0%, var(--sun) 45%, var(--sun-deep) 100%);
  box-shadow: 0 10px 26px rgba(255, 122, 24, 0.35);
}

.btn--primary:hover {
  box-shadow: 0 12px 32px rgba(255, 122, 24, 0.5);
}

.btn--ghost {
  color: var(--khaki);
  background: rgba(200, 185, 138, 0.1);
  border-color: rgba(200, 185, 138, 0.38);
}

.btn--ghost:hover {
  background: rgba(200, 185, 138, 0.2);
}

/* ---------- 6. 结算面板细节 ---------- */
.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 2px;
}

.result-score__value {
  font-size: clamp(46px, 9vw, 76px);
  font-weight: 900;
  line-height: 1;
  color: var(--sun);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 34px rgba(255, 176, 58, 0.5);
}

.result-score__unit {
  font-size: 15px;
  letter-spacing: 3px;
  color: var(--khaki-dim);
}

.result-grade {
  display: inline-block;
  margin: 10px 0 16px;
  padding: 5px 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #10240f;
  background: linear-gradient(90deg, #b6e34a, #3ddc84);
}

.result-grade.is-bad {
  background: linear-gradient(90deg, #ff8a5b, #ff4d4d);
  color: #2a0b0b;
}

.result-grade.is-mid {
  background: linear-gradient(90deg, #ffe066, #ffb03a);
  color: #2a1c05;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.result-grid > div {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(200, 185, 138, 0.16);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-grid span {
  font-size: 12px;
  color: var(--khaki-dim);
  letter-spacing: 1px;
}

.result-grid b {
  font-size: 17px;
  color: #eef7ec;
  font-variant-numeric: tabular-nums;
}

.name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 16px;
  flex-wrap: wrap;
}

.name-row label {
  font-size: 13px;
  color: var(--khaki-dim);
}

.name-row input {
  width: min(300px, 100%);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(200, 185, 138, 0.38);
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.name-row input:focus {
  border-color: var(--sun);
  box-shadow: 0 0 0 3px rgba(255, 176, 58, 0.18);
}

/* ---------- 7. 排行榜 ---------- */
.rank-list {
  list-style: none;
  margin: 16px 0 20px;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 46vh;
  overflow: auto;
  text-align: left;
}

.rank-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(200, 185, 138, 0.14);
  font-size: 14px;
}

.rank-list li.is-top {
  background: linear-gradient(90deg, rgba(255, 176, 58, 0.2), rgba(255, 176, 58, 0.05));
  border-color: rgba(255, 176, 58, 0.4);
}

.rank-list__no {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(200, 185, 138, 0.16);
  color: var(--khaki);
  font-weight: 800;
  font-size: 13px;
}

.rank-list__name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-list__meta {
  font-size: 12px;
  color: var(--khaki-dim);
  white-space: nowrap;
}

.rank-list__score {
  font-weight: 800;
  color: var(--sun);
  font-variant-numeric: tabular-nums;
  min-width: 62px;
  text-align: right;
}

.rank-list__empty {
  justify-content: center;
  color: var(--khaki-dim);
  background: transparent;
  border-style: dashed;
}

/* ---------- 8. 底部提示条 ---------- */
.tips {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--khaki);
  background: linear-gradient(0deg, #16301f 0%, #0e2015 100%);
  border-top: 2px solid rgba(200, 185, 138, 0.3);
}

.tips__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--khaki-dim);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.tips.is-playing .tips__dot {
  background: var(--ok);
  box-shadow: 0 0 12px var(--ok);
  animation: dotBlink 1.1s ease-in-out infinite;
}

.tips.is-danger .tips__dot {
  background: var(--danger);
  box-shadow: 0 0 12px var(--danger);
}

@keyframes dotBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ---------- 9. 小屏 / 手机适配 ---------- */
@media (max-width: 720px) {
  :root {
    --hud-h: 64px;
  }

  .hud {
    padding: 0 10px;
    gap: 8px;
  }

  .hud__group--right .stat--small:last-of-type,
  .hud__group--left .stat:first-child {
    display: none;
  }

  .stat__value {
    font-size: 21px;
  }

  .hud__group--center {
    max-width: 150px;
  }

  .panel {
    padding: 20px 16px 16px;
  }

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

  .btn {
    padding: 12px 16px;
    font-size: 15px;
    flex: 1 1 190px;
  }

  .overlay {
    padding: 10px;
  }
}

/* 用户系统开启“减少动态效果”时，关闭装饰性动画（游戏核心抖动保留在画布内） */
@media (prefers-reduced-motion: reduce) {
  .warn-flash.is-active,
  .tips.is-playing .tips__dot {
    animation: none;
  }
}
