/* 谁是枪王 - 页面样式（放大窗口 + 手机自适应） */
:root {
  --bg-deep: #0a0c10;
  --bg-mid: #141820;
  --panel: #7a7a7a;
  --accent: #c84c28;
  --accent-dark: #a03818;
  --gold: #e0b040;
  --text: #f2f2f2;
  --muted: #8a9099;
  --frame: #2a3038;
  --screen: #000;
  /* 战场 + 侧栏必须一起塞进视口，不能只用 92vw 给主画布 */
  --body-x: 24px;
  --frame-pad: 24px;
  --frame-border: 6px;
  --stage-gap: 8px;
  --stage-inner: calc(100vw - var(--body-x) - var(--frame-pad) - var(--frame-border));
  --game-w: min(720px, calc((var(--stage-inner) - var(--stage-gap)) * 416 / 504));
  --panel-w: calc(var(--game-w) * 88 / 416);
  --stage-h: var(--game-w);
  --touch-reserve: 0px;
}

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

html, body { height: 100%; }

body {
  min-height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, #2a1810 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 80% 100%, #1a2030 0%, transparent 50%),
    linear-gradient(160deg, var(--bg-deep), var(--bg-mid) 45%, #0d1016);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 12px 24px;
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.top-bar {
  width: min(100%, calc(var(--game-w) + var(--panel-w) + var(--frame-pad) + var(--frame-border)));
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  min-height: 36px;
  padding: 0 2px;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
}

.brand-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.35));
}

.brand-tip {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}

.age-tip {
  color: #e87878;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* 顶栏：全屏 / 个人中心 / 返回官网 */
.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.top-actions .btn {
  padding: 7px 12px;
  font-size: 0.78rem;
  text-decoration: none;
  white-space: nowrap;
}

.top-actions .btn[hidden] {
  display: none !important;
}

.btn {
  border: 1px solid #3a4450;
  background: linear-gradient(180deg, #2a323c, #1a2028);
  color: var(--text);
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: transform 0.12s, border-color 0.12s;
}

.btn:hover { border-color: var(--gold); }
.btn:active { transform: scale(0.96); }
.btn.primary {
  background: linear-gradient(180deg, #c84c28, #8a3018);
  border-color: #e07040;
}

.stage-wrap {
  width: min(100%, calc(var(--game-w) + var(--panel-w) + var(--frame-pad) + var(--frame-border)));
  max-width: 100%;
}

.stage-frame {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: var(--stage-gap);
  background: var(--frame);
  padding: calc(var(--frame-pad) / 2);
  border: 3px solid #3a424c;
  border-radius: 10px;
  box-shadow:
    0 0 0 1px #1a1e24,
    0 18px 48px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.stage-frame.is-fullscreen {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  padding: 0;
  align-items: center;
  justify-content: center;
  background: #000;
  box-shadow: none;
}

#game {
  display: block;
  flex: 0 0 auto;
  width: var(--game-w);
  height: auto;
  aspect-ratio: 1 / 1;
  max-width: calc(100% - var(--panel-w) - var(--stage-gap));
  max-height: min(78vh, 720px);
  background: var(--screen);
  border-radius: 4px;
}

#panel {
  display: block;
  flex: 0 0 auto;
  width: var(--panel-w);
  height: auto;
  aspect-ratio: 88 / 416;
  max-height: min(78vh, 720px);
  background: var(--panel);
  margin-left: 0;
  border-radius: 4px;
}

/* 全屏：整屏黑底，画面尽量铺满 */
body.is-fullscreen-page {
  padding: 0 !important;
  margin: 0 !important;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  justify-content: center;
  align-items: center;
  background: #000 !important;
}

body.is-fullscreen-page .top-bar,
body.is-fullscreen-page .footer,
body.is-fullscreen-page .diy-bar,
body.is-fullscreen-page .asset-tip {
  display: none !important;
}

body.is-fullscreen-page .stage-wrap {
  width: 100vw;
  height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.is-fullscreen-page .stage-frame {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  padding: 0;
  border: none;
  border-radius: 0;
  background: #000;
  box-shadow: none;
}

body.is-fullscreen-page #game,
body.is-fullscreen-page #panel {
  max-height: none;
  border-radius: 0;
}

body.is-fullscreen-page #panel {
  margin-left: 0;
}

.fs-exit {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
}

body.is-fullscreen-page .fs-exit {
  display: inline-flex;
}

.footer {
  width: min(100%, calc(var(--game-w) + var(--panel-w) + var(--frame-pad) + var(--frame-border)));
  max-width: 100%;
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}

.footer a {
  color: var(--gold);
  text-decoration: none;
}

.footer strong { color: var(--gold); font-weight: 600; }

.hint-desktop {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
  line-height: 1.45;
}

/* 手机 / 平板触控：底部浮层，不挤占横向宽度 */
.mobile-only { display: none; }

.touch-pad {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 0;
  pointer-events: none;
}

.touch-pad > * { pointer-events: auto; }

.stick-wrap {
  display: flex;
  align-items: flex-end;
}

.stick-zone {
  position: relative;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.stick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(58,69,85,0.92), rgba(21,26,34,0.88) 70%);
  border: 2px solid rgba(74,85,100,0.9);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.45);
}

.stick-zone.is-active .stick-base {
  border-color: #e07040;
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: linear-gradient(160deg, #e8b060, #c84c28);
  border: 2px solid #f0d090;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  pointer-events: none;
}

.fire-cluster {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.menu-row {
  display: flex;
  gap: 6px;
}

.fire-btn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid #e07040;
  background: radial-gradient(circle at 35% 30%, #e07040, #8a3018 70%);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow: 0 5px 0 #4a1808, 0 8px 18px rgba(0,0,0,0.4);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.fire-btn:active,
.fire-btn.is-active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #4a1808;
}

.mini-btn {
  min-width: 44px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid #3a4450;
  background: rgba(28,34,44,0.92);
  color: #ddd;
  font-size: 0.78rem;
  padding: 0 8px;
}

#game {
  touch-action: none;
}

/* 窄屏 / 触屏：整列不超出，触控浮在底部 */
@media (max-width: 900px), (pointer: coarse) {
  :root {
    --body-x: 12px;
    --frame-pad: 8px;
    --frame-border: 4px;
    --stage-gap: 4px;
    --touch-reserve: 132px;
    --stage-inner: calc(100vw - var(--body-x) - var(--frame-pad) - var(--frame-border));
    --game-w: calc((var(--stage-inner) - var(--stage-gap)) * 416 / 504);
    --panel-w: calc(var(--game-w) * 88 / 416);
  }

  .hint-desktop { display: none; }

  .mobile-only {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 8px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(0,0,0,0.72) 35%, transparent);
    pointer-events: none;
  }

  body {
    justify-content: flex-start;
    align-items: stretch;
    padding: 6px 6px calc(var(--touch-reserve) + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
  }

  .top-bar {
    width: 100%;
    max-width: 100%;
    margin-bottom: 2px;
    padding: 0 2px;
  }
  .brand-logo { width: 20px; height: 20px; }
  .brand-tip { font-size: 0.62rem; }
  .btn { padding: 7px 10px; font-size: 0.78rem; }

  .stage-wrap {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }

  .stage-frame {
    padding: 4px;
    border-width: 2px;
    border-radius: 8px;
  }

  #game,
  #panel {
    max-height: min(calc(100vh - 56px - var(--touch-reserve)), 720px);
  }

  #game {
    max-width: calc(100% - var(--panel-w) - var(--stage-gap));
  }

  .footer {
    width: 100%;
    max-width: 100%;
    font-size: 0.62rem;
    margin-top: 6px;
    padding: 0 2px;
  }
}

@media (max-width: 380px) {
  .stick-zone { width: 92px; height: 92px; }
  .stick-knob { width: 38px; height: 38px; margin: -19px 0 0 -19px; }
  .fire-btn { width: 68px; height: 68px; font-size: 0.85rem; }
  .mini-btn { min-width: 38px; height: 30px; font-size: 0.72rem; }
  :root { --touch-reserve: 118px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  :root { --touch-reserve: 0px; }
  .mobile-only {
    padding: 6px 16px calc(6px + env(safe-area-inset-bottom, 0px));
    background: none;
  }
  .stick-zone { width: 88px; height: 88px; }
  .fire-btn { width: 64px; height: 64px; }
  .menu-row { display: none; }
  body { padding-bottom: 8px; }
}

body.is-fullscreen-page .top-bar,
body.is-fullscreen-page .footer {
  display: none !important;
}

@media (max-width: 900px), (pointer: coarse) {
  body.is-fullscreen-page {
    padding: 0 0 var(--touch-reserve) !important;
  }
  body.is-fullscreen-page .mobile-only {
    display: block !important;
  }
  body.is-fullscreen-page #panel {
    margin-left: 0;
  }
}

/* DIY 自定义战场工具条 */
.diy-bar {
  width: min(100%, calc(var(--game-w) + var(--panel-w) + 40px));
  max-width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #2a3440;
}

.diy-bar[hidden] { display: none !important; }

body.diy-open .diy-bar { display: block !important; }
body.diy-open .mobile-only { display: none !important; }
body.diy-open .hint-desktop { display: none; }
body.diy-open {
  padding-bottom: 12px !important;
}

.diy-tools,
.diy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.diy-tool {
  border: 1px solid #3a4450;
  background: #1c2430;
  color: #eee;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
}

.diy-tool.active,
.diy-tool:active {
  background: linear-gradient(180deg, #c84c28, #8a3018);
  border-color: #e07040;
}

.diy-tip {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}

/* —— 手柄提示 / 配置 —— */
.gp-toast {
  position: fixed;
  left: 50%;
  top: 72px;
  transform: translateX(-50%) translateY(-8px);
  z-index: 120;
  max-width: min(92vw, 420px);
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(18, 22, 30, 0.96);
  border: 1px solid #e0b040;
  color: #fff;
  font-size: 0.86rem;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.gp-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.gp-bar {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(96vw, 560px);
  padding: 8px 10px 8px 14px;
  border-radius: 999px;
  background: rgba(14, 16, 22, 0.92);
  border: 1px solid #2a3340;
  color: #9aa3ae;
  font-size: 0.75rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.gp-bar.is-ready { border-color: #806020; color: #e0c080; }
.gp-bar.is-duo { border-color: #e0b040; color: #f0e0b0; }
.gp-bar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-bar-btn {
  border: 1px solid #3a4450;
  background: #222833;
  color: #eee;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}

body.is-touch .gp-bar {
  bottom: calc(var(--touch-reserve, 120px) + 8px + env(safe-area-inset-bottom, 0px));
}
body.is-fullscreen-page .gp-bar { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }

.gp-modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: rgba(0,0,0,.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  backdrop-filter: blur(4px);
}
@media (min-width: 720px) {
  .gp-modal { align-items: center; }
}
.gp-modal[hidden] { display: none !important; }

.gp-sheet {
  width: min(480px, 100%);
  max-height: min(88vh, 640px);
  overflow: auto;
  background: linear-gradient(165deg, #1a202b, #12161e);
  border: 1px solid #2a3340;
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
  color: #f0f2f5;
}
.gp-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #2a3340;
  position: sticky;
  top: 0;
  background: #161b24;
  z-index: 1;
}
.gp-sheet-head h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #e07040;
  letter-spacing: .06em;
}
.gp-close {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: #9aa3ae;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.gp-body { padding: 14px 16px 18px; }
.gp-status { margin-bottom: 12px; }
.gp-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #3a4450;
  color: #8b939e;
  font-size: 0.75rem;
  margin-bottom: 8px;
}
.gp-pill.on {
  border-color: #e0b040;
  color: #e0b040;
  background: rgba(224,176,64,.12);
}
.gp-slot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #222833;
  font-size: 0.85rem;
}
.gp-slot strong { color: #e0b040; }
.gp-slot span { color: #c8ced6; text-align: right; }
.gp-guide h4,
.gp-cfg h4 {
  margin: 14px 0 8px;
  font-size: 0.9rem;
  color: #e0b040;
}
.gp-guide ol {
  margin: 0 0 8px 1.1em;
  padding: 0;
  color: #c8ced6;
  font-size: 0.84rem;
  line-height: 1.65;
}
.gp-keys {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.84rem;
  color: #c8ced6;
}
.gp-keys li {
  padding: 6px 0;
  border-bottom: 1px solid #222833;
}
.gp-keys em {
  font-style: normal;
  color: #e07040;
  margin-right: 8px;
}
.gp-note {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: #8b939e;
  line-height: 1.5;
}
.gp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  font-size: 0.85rem;
  color: #c8ced6;
}
.gp-row input[type="range"] { flex: 1; }
.gp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.gp-actions .btn { flex: 1; min-width: 110px; }
