/* ============================================================================
 * cheats.css — 作弊控制台样式
 * 沿用 game.css 里已定义的 token（--signal / --plate-solid / --f-mono …），
 * 独立成文件，避免污染原始样式表。
 * ========================================================================== */

#cheat-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  font-family: var(--f-label);
  color: var(--bone);
}

/* ------------------------------------------------------------- 触发按钮 */

#cheat-trigger {
  position: absolute;
  top: calc(12px + var(--sat));
  right: var(--gr);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px 7px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--plate);
  color: rgba(232, 228, 218, .62);
  font: 600 10px/1 var(--f-label);
  letter-spacing: .22em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
#cheat-trigger .ct-k {
  font: 700 12px/1 var(--f-mono);
  letter-spacing: 0;
  color: var(--signal);
}
#cheat-trigger .ct-t { margin-right: -.22em; }
#cheat-trigger:hover {
  color: var(--bone);
  border-color: rgba(255, 179, 71, .55);
  background: rgba(11, 13, 15, .82);
}
#cheat-trigger.on,
#cheat-trigger.armed {
  color: var(--signal);
  border-color: rgba(255, 179, 71, .7);
  background: rgba(255, 179, 71, .14);
}
#cheat-trigger:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
}

/* --------------------------------------------------------- 生效状态标签 */

#cheat-badge {
  position: absolute;
  top: calc(46px + var(--sat));
  right: var(--gr);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}
#cheat-badge span {
  padding: 5px 8px 4px;
  border: 1px solid rgba(255, 179, 71, .45);
  background: rgba(255, 179, 71, .12);
  color: var(--signal);
  font: 600 10px/1 var(--f-label);
  letter-spacing: .16em;
  margin-right: -.16em;
  text-transform: uppercase;
  box-shadow: 0 0 2px rgba(0, 0, 0, .6);
}

/* --------------------------------------------------------------- 面板 */

#cheat-panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 8, 10, .74);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  /* 打开时 visibility 立刻生效（0s），关闭时延迟到淡出结束，避免元素在过渡期不可聚焦 */
  transition: opacity .18s ease, visibility 0s linear .18s;
}
#cheat-panel.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .18s ease, visibility 0s;
}

.cp-card {
  width: min(430px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 20px 20px 18px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--signal);
  background: var(--plate-solid);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .62);
  transform: translateY(6px);
  transition: transform .18s ease;
}
#cheat-panel.open .cp-card { transform: none; }

.cp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.cp-eyebrow {
  margin: 0;
  font: 600 10px/1 var(--f-mono);
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--steel);
}
.cp-title {
  margin: 9px 0 0;
  font: 900 26px/1.1 var(--f-display);
  letter-spacing: .06em;
  color: var(--bone);
}
.cp-x {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  background: none;
  color: var(--bone-dim);
  font: 400 13px/1 var(--f-label);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: color .16s ease, border-color .16s ease;
}
.cp-x:hover { color: var(--alarm); border-color: rgba(255, 90, 64, .6); }

/* ------------------------------------------------- 头部动作区 / 全屏开关 */

.cp-headtxt { min-width: 0; }
.cp-acts {
  display: flex;
  flex: none;
  gap: 8px;
}
.cp-hbtn {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: none;
  color: var(--bone-dim);
  font: 600 10px/1 var(--f-label);
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.cp-hbtn:hover {
  color: var(--bone);
  border-color: rgba(255, 179, 71, .55);
  background: rgba(255, 179, 71, .07);
}
.cp-hbtn[aria-pressed="true"] {
  color: var(--signal);
  border-color: rgba(255, 179, 71, .7);
  background: rgba(255, 179, 71, .12);
}
.cp-hbtn:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

/* ------------------------------------------------- 全屏视图专属实时读数 */
/* 默认不显示；只有 #cheat-panel 带 .wide 时才摊开。 */

.cp-live {
  display: none;
  margin: 18px 0 0;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .28);
}

.lv-cell {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  padding: 13px 14px;
}
.lv-cell + .lv-cell { border-left: 1px solid var(--line); }

.lv-k {
  font: 600 9px/1 var(--f-label);
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--steel);
}
.lv-bar {
  display: block;
  height: 4px;
  overflow: hidden;
  background: rgba(232, 228, 218, .14);
}
/* 条宽走 CSS 变量，JS 只设 --p，不写内联 width */
.lv-bar b {
  display: block;
  width: var(--p, 0%);
  height: 100%;
  background: var(--bone);
  transition: width .18s linear;
}
.lv-bar--ammo b { background: var(--signal); }
.lv-bar--res b { background: var(--steel); }

.lv-n {
  font: 500 12px/1 var(--f-mono);
  letter-spacing: .04em;
  color: var(--bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lv-state {
  font: 600 13px/1 var(--f-label);
  letter-spacing: .1em;
  color: var(--signal);
}

/* ------------------------------------------------------------ 全屏布局 */
/* 用纯 CSS 铺满视口，不调 requestFullscreen —— 避免和游戏自己的 #app 全屏争
   document.fullscreenElement（详见 cheats.js 文件头注释）。 */

#cheat-panel.wide {
  padding: 0;
  background: rgba(6, 8, 10, .93);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}

#cheat-panel.wide .cp-card {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  display: flex;
  flex-direction: column;
  /* 大屏时内容居中并限宽 1040px，避免 1440/4K 下全挤在左边。
     纵向用 safe center：内容不满一屏时垂直居中，超一屏时自动退化成从顶部
     开始（plain center 在 overflow 下会裁掉标题）。 */
  align-items: center;
  justify-content: center;        /* 兜底：不支持 safe 关键字的浏览器 */
  justify-content: safe center;   /* 支持的浏览器用这个，溢出时不裁标题 */
  padding: clamp(28px, 7vh, 84px) clamp(18px, 4vw, 64px) clamp(20px, 3.2vw, 44px);
  border-left-width: 3px;
  box-shadow: none;
  transform: none;
}

#cheat-panel.wide .cp-title { font-size: clamp(26px, 3.2vw, 44px); }

#cheat-panel.wide .cp-head,
#cheat-panel.wide .cp-rows,
#cheat-panel.wide .cp-live,
#cheat-panel.wide .cp-code,
#cheat-panel.wide .cp-hint,
#cheat-panel.wide .cp-note { max-width: 1040px; width: 100%; }

#cheat-panel.wide .cp-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 28px;
}
#cheat-panel.wide .cp-row { padding: 18px 16px; }
#cheat-panel.wide .cp-name { font-size: 17px; }

#cheat-panel.wide .cp-live {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 20px;
}
#cheat-panel.wide .lv-cell { padding: 15px 16px; }
#cheat-panel.wide .cp-code { margin-top: 22px; }
#cheat-panel.wide #cheat-code { padding: 15px 0; font-size: 14px; }
#cheat-panel.wide .cp-quick {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 1040px;
  width: 100%;
  margin-top: 14px;
}
#cheat-panel.wide .cp-note {
  margin-top: 32px;
  padding-top: 22px;
}

@media (max-width: 720px) {
  #cheat-panel.wide .cp-live { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #cheat-panel.wide .lv-cell:nth-child(n+3) {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

/* --------------------------------------------------------------- 开关行 */

.cp-rows {
  margin: 18px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 12px 13px;
  margin: 0;
  border: 1px solid var(--line);
  background: rgba(232, 228, 218, .03);
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .16s ease, background .16s ease;
}
.cp-row:hover {
  border-color: rgba(255, 179, 71, .5);
  background: rgba(255, 179, 71, .07);
}
.cp-row[aria-pressed="true"] {
  border-color: rgba(255, 179, 71, .75);
  background: rgba(255, 179, 71, .12);
}
.cp-row:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}
.cp-name {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font: 600 15px/1 var(--f-label);
  letter-spacing: .08em;
}
.cp-name em {
  font: 400 11px/1.35 var(--f-label);
  font-style: normal;
  letter-spacing: .04em;
  color: rgba(232, 228, 218, .55);
}

.cp-sw {
  position: relative;
  flex: none;
  width: 42px;
  height: 22px;
  border: 1.5px solid var(--bone-faint);
  border-radius: 999px;
  transition: border-color .16s ease, background .16s ease;
}
.cp-sw i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(232, 228, 218, .5);
  transition: transform .16s ease, background .16s ease;
}
.cp-row[aria-pressed="true"] .cp-sw {
  border-color: var(--signal);
  background: rgba(255, 179, 71, .18);
}
.cp-row[aria-pressed="true"] .cp-sw i {
  transform: translateX(19px);
  background: var(--signal);
}

/* ------------------------------------------------------------- 作弊码框 */

.cp-code {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .38);
  transition: border-color .16s ease;
}
.cp-code:focus-within { border-color: var(--signal); }
.cp-prompt {
  color: var(--signal);
  font: 700 14px/1 var(--f-mono);
}
#cheat-code {
  flex: 1;
  min-width: 0;
  padding: 12px 0;
  border: 0;
  background: none;
  color: var(--bone);
  font: 500 13px/1 var(--f-mono);
  letter-spacing: .06em;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
  appearance: none;
}
#cheat-code::placeholder {
  color: rgba(232, 228, 218, .32);
  letter-spacing: .04em;
}

.cp-hint {
  margin: 12px 0 0;
  font: 400 11px/1.8 var(--f-mono);
  color: rgba(232, 228, 218, .6);
  letter-spacing: .02em;
}
.cp-note {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font: 400 11px/1.75 var(--f-label);
  color: rgba(232, 228, 218, .45);
}
.cp-note b {
  font-weight: 600;
  color: var(--signal);
}

/* ----------------------------------------------------- 快捷命令（全屏专属） */

.cp-quick {
  display: none;
  gap: 8px;
  margin-top: 10px;
}
.cp-q {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(232, 228, 218, .03);
  color: var(--bone);
  font: 600 13px/1 var(--f-label);
  letter-spacing: .06em;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .16s ease, background .16s ease;
}
.cp-q em {
  font: 400 10px/1 var(--f-mono);
  font-style: normal;
  letter-spacing: .04em;
  color: var(--steel);
}
.cp-q:hover {
  border-color: rgba(255, 179, 71, .5);
  background: rgba(255, 179, 71, .07);
}
.cp-q:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- toast */

#cheat-toast {
  position: absolute;
  left: 50%;
  bottom: calc(9% + var(--sab));
  transform: translate(-50%, 6px);
  padding: 9px 14px 8px;
  border-left: 2px solid var(--signal);
  background: var(--plate-solid);
  color: var(--bone);
  font: 600 12px/1 var(--f-label);
  letter-spacing: .14em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .55);
}
#cheat-toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 全屏视图下说明文字在底部，toast 上移一点别压住它 */
#cheat-panel.wide ~ #cheat-toast {
  bottom: calc(18% + var(--sab));
}

/* ------------------------------------------------------- 触屏位置修正 */

@media (hover: none) and (pointer: coarse) {
  #cheat-trigger { top: calc(62px + var(--sat)); }
  #cheat-badge { top: calc(96px + var(--sat)); }
  #cheat-panel { padding: 16px; }
  .cp-title { font-size: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  #cheat-trigger,
  #cheat-panel,
  .cp-card,
  .cp-row,
  .cp-sw,
  .cp-sw i,
  .cp-hbtn,
  .lv-bar b,
  #cheat-toast { transition-duration: .01ms; }
}
