/* ===== 小鲸鱼深海射击 · 样式 ===== */

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;                 /* 禁止页面滚动 */
  overscroll-behavior: none;
  touch-action: none;               /* 禁止触摸手势 */
  background: #140c3a;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;                /* 禁止长按选中 */
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, "Helvetica Neue", sans-serif;
}

#game {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.label {
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.75;
}

.value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(127, 247, 255, 0.5);
}

/* ===== 顶部信息栏 ===== */
.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 10px 0;
  pointer-events: none;             /* 不挡住下面的触摸操作 */
}

.hud-box {
  display: flex;
  flex-direction: column;
  min-width: 84px;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(30, 14, 80, 0.45);
  border: 1px solid rgba(160, 140, 255, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

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

.hud-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
}

.lives {
  display: flex;
  align-items: center;
  min-height: 16px;
}

.pill {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(127, 247, 255, 0.18);
  border: 1px solid rgba(127, 247, 255, 0.4);
  color: #bffcff;
}

/* 小爱心（纯 CSS 绘制，表示剩余生命） */
.heart {
  position: relative;
  width: 13px;
  height: 13px;
  margin: 0 7px;
  background: #ff5d8a;
  transform: rotate(-45deg);
  box-shadow: 0 0 10px rgba(255, 93, 138, 0.7);
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: inherit;
}

.heart::before {
  left: -6.5px;
  top: 0;
}

.heart::after {
  left: 0;
  top: -6.5px;
}

.heart.lost {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

/* ===== 连击 / 能量 / 炸弹 ===== */
.combo {
  position: absolute;
  left: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 92px);
  font-size: 14px;
  font-weight: 800;
  color: #ffe36b;
  text-shadow: 0 0 10px rgba(255, 227, 107, 0.6);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.energy-wrap {
  position: absolute;
  left: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: none;
}

.energy {
  display: grid;
  grid-template-columns: repeat(10, 10px);
  gap: 3px;
}

.energy span {
  height: 9px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.energy span.on {
  background: #7ff7ff;
  box-shadow: 0 0 8px rgba(127, 247, 255, 0.8);
}

.bomb {
  position: absolute;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  width: 76px;
  height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  background: radial-gradient(circle at 35% 30%, #5b5fa8, #2a1670 70%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, opacity 0.2s ease, filter 0.2s ease;
}

.bomb small {
  font-size: 10px;
  opacity: 0.7;
  font-weight: 600;
}

.bomb:disabled {
  opacity: 0.4;
  filter: grayscale(0.8);
  cursor: default;
}

.bomb.ready {
  opacity: 1;
  filter: none;
  border-color: #7ff7ff;
  box-shadow: 0 0 18px rgba(127, 247, 255, 0.75), 0 6px 16px rgba(0, 0, 0, 0.35);
  animation: bomb-pulse 1.2s ease-in-out infinite;
}

.bomb.ready:active {
  transform: scale(0.94);
}

.bomb:focus-visible {
  outline: 3px solid #bffcff;
  outline-offset: 4px;
}

@keyframes bomb-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(127, 247, 255, 0.5), 0 6px 16px rgba(0, 0, 0, 0.35); }
  50% { box-shadow: 0 0 26px rgba(127, 247, 255, 0.95), 0 6px 16px rgba(0, 0, 0, 0.35); }
}

/* ===== 遮罩与卡片 ===== */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(12, 6, 40, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;             /* 隐藏时不拦截点击 */
  transition: opacity 0.35s ease;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.card {
  width: min(88vw, 340px);
  padding: 26px 24px 24px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(160deg, rgba(120, 90, 255, 0.4), rgba(20, 30, 100, 0.7));
  border: 1px solid rgba(190, 170, 255, 0.28);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4), 0 0 40px rgba(127, 90, 255, 0.25);
  transform: translateY(14px) scale(0.97);
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.overlay.show .card {
  transform: none;
}

h1 {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
  text-shadow: 0 0 16px rgba(127, 247, 255, 0.45);
}

h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  text-shadow: 0 0 16px rgba(127, 247, 255, 0.45);
}

.sub {
  font-size: 14px;
  line-height: 1.6;
  opacity: 0.88;
  margin-bottom: 14px;
}

.tips {
  list-style: none;
  text-align: left;
  font-size: 13px;
  line-height: 1.85;
  margin: 0 auto 22px;
  padding-left: 4px;
  opacity: 0.92;
}

.tips li::before {
  content: "· ";
  color: #7ff7ff;
  font-weight: 700;
}

.new-record {
  display: inline-block;
  margin-bottom: 12px;
  padding: 4px 14px;
  border-radius: 999px;
  background: #ffe36b;
  color: #3d2a00;
  font-size: 13px;
  font-weight: 700;
}

.new-record[hidden] {
  display: none;
}

.result {
  display: flex;
  justify-content: space-around;
  margin: 14px 0 12px;
}

.result strong {
  display: block;
  margin-top: 4px;
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(127, 247, 255, 0.4);
}

.kills {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 22px;
}

.kills span {
  font-weight: 800;
  color: #7ff7ff;
  font-variant-numeric: tabular-nums;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-block;
  min-width: 184px;
  padding: 14px 28px;
  border: 0;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  color: #2a1670;
  background: linear-gradient(180deg, #ffffff, #d6dcff);
  box-shadow: 0 8px 0 #8f7ce6, 0 14px 26px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #8f7ce6, 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn:focus-visible {
  outline: 3px solid #bffcff;
  outline-offset: 4px;
}

/* 小屏手机收紧 */
@media (max-width: 360px) {
  h1 { font-size: 23px; }
  .value { font-size: 19px; }
  .hud-box { min-width: 72px; padding: 5px 9px; }
  .bomb { width: 66px; height: 66px; font-size: 13px; }
}

/* 横屏时收起教程列表 */
@media (orientation: landscape) and (max-height: 500px) {
  .card { padding: 16px 20px; }
  .tips { display: none; }
  .sub { margin-bottom: 10px; }
}

/* ===== 本地排行榜 ===== */
:root {
  --accent: #7ff7ff;              /* 强调色：与本项目霓虹青色一致 */
}

/* 全局隐藏属性：确保 hidden 一定生效 */
[hidden] {
  display: none !important;
}

.btn-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* 次级按钮：半透明玻璃感，用于「排行榜」入口 */
.btn.ghost {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1.5px rgba(127, 247, 255, 0.6), 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn.ghost:active {
  box-shadow: inset 0 0 0 1.5px rgba(127, 247, 255, 0.6), 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 小号按钮（排行榜底部操作） */
.btn.small {
  min-width: 0;
  padding: 10px 20px;
  font-size: 14px;
}

.btn.danger {
  color: #fff;
  background: linear-gradient(180deg, #ff9fc4, #ff4f9a);
  box-shadow: 0 6px 0 #b82a6a, 0 10px 18px rgba(0, 0, 0, 0.3);
}

.btn.danger:active {
  box-shadow: 0 2px 0 #b82a6a, 0 4px 10px rgba(0, 0, 0, 0.3);
}

.history-rank {
  margin: -4px 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(127, 247, 255, 0.45);
}

.rank-screen {
  z-index: 20;                    /* 盖在开始 / 结束界面之上 */
}

.rank-card {
  width: min(92vw, 360px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 22px 18px 18px;
}

.rank-card h2 {
  margin-bottom: 4px;
}

.rank-note {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 14px;
}

.rank-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
  max-height: min(48vh, 400px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;            /* 允许列表内部上下滑动 */
  padding-right: 2px;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  text-align: left;
  border-radius: 14px;
  background: rgba(30, 14, 80, 0.4);
  border: 1px solid rgba(160, 140, 255, 0.25);
}

.rank-no {
  flex: 0 0 26px;
  height: 26px;
  line-height: 26px;
  border-radius: 50%;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.14);
}

.rank-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.rank-main strong {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rank-meta {
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 前三名：金 / 银 / 铜 */
.rank-item.medal-1 {
  background: linear-gradient(90deg, rgba(255, 215, 106, 0.3), rgba(30, 14, 80, 0.4));
  border-color: rgba(255, 215, 106, 0.6);
}
.rank-item.medal-1 .rank-no { background: #ffd76a; color: #4a3200; }

.rank-item.medal-2 {
  background: linear-gradient(90deg, rgba(217, 226, 239, 0.28), rgba(30, 14, 80, 0.4));
  border-color: rgba(217, 226, 239, 0.55);
}
.rank-item.medal-2 .rank-no { background: #d9e2ef; color: #26324a; }

.rank-item.medal-3 {
  background: linear-gradient(90deg, rgba(224, 160, 112, 0.3), rgba(30, 14, 80, 0.4));
  border-color: rgba(224, 160, 112, 0.6);
}
.rank-item.medal-3 .rank-no { background: #e0a070; color: #3d2208; }

/* 本局高亮 */
.rank-item.current {
  box-shadow: 0 0 0 2px var(--accent), 0 0 16px rgba(127, 247, 255, 0.5);
}

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  background: var(--accent);
  color: #1a1040;
}

.rank-empty {
  padding: 26px 0;
  font-size: 14px;
  opacity: 0.8;
}

.rank-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.clear-confirm {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 14px;
  font-size: 13px;
  background: rgba(255, 90, 150, 0.16);
  border: 1px solid rgba(255, 140, 190, 0.45);
}

.clear-confirm p {
  margin-bottom: 10px;
  line-height: 1.5;
}
