/* PIXEL MECH ARENA - 复古街机风界面样式 */
:root {
  --bg: #02030a;
  --cyan: #5fe8ff;
  --blue: #4a90ff;
  --red: #ff4d6d;
  --amber: #ffd166;
  --text: #dff2ff;
  --muted: #7b8ba8;
  --ink: #070b16;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 50% -10%, rgba(95, 232, 255, 0.10), transparent 55%),
    radial-gradient(circle at 85% 95%, rgba(255, 77, 109, 0.07), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: "Courier New", "Consolas", "SimHei", monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(95, 232, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95, 232, 255, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.85), transparent 75%);
  pointer-events: none;
}

.app {
  position: relative;
  width: min(1000px, 96vw);
}

.topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 4px;
  font-size: clamp(8px, 1.6vw, 11px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.logo {
  color: var(--cyan);
  font-weight: 700;
  text-shadow: 0 0 14px rgba(95, 232, 255, 0.55);
}

.tag { opacity: 0.65; }

.frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  container-type: inline-size;
  background: #03050d;
  border: 1px solid rgba(95, 232, 255, 0.32);
  border-radius: 4px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.85),
    0 0 34px rgba(60, 150, 255, 0.16),
    inset 0 0 70px rgba(0, 0, 0, 0.75);
}

.frame::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(95, 232, 255, 0.07);
  pointer-events: none;
  z-index: 5;
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.scanlines {
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.22) 0,
    rgba(0, 0, 0, 0.22) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.75;
}

.vignette {
  background: radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, 0.55) 100%);
}

.flare {
  background: linear-gradient(
    180deg,
    rgba(95, 232, 255, 0.05),
    transparent 22%,
    transparent 78%,
    rgba(255, 77, 109, 0.05)
  );
}

/* ================= HUD ================= */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 2cqw;
  padding: 2.2cqw 3cqw;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.hud.inactive { opacity: 0; }

.hud-side { min-width: 0; }
.hud-right { text-align: right; }

.hud-name {
  display: flex;
  align-items: center;
  gap: 0.8cqw;
  font-size: clamp(8px, 1.25cqw, 14px);
  letter-spacing: 0.12em;
  color: #cfe6ff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
}

.hud-right .hud-name { justify-content: flex-end; }

.p-tag {
  padding: 0.1em 0.35em;
  background: rgba(95, 232, 255, 0.16);
  border: 1px solid rgba(95, 232, 255, 0.45);
  color: var(--cyan);
  font-size: 0.8em;
}

.hud-right .p-tag {
  background: rgba(255, 77, 109, 0.14);
  border-color: rgba(255, 77, 109, 0.45);
  color: #ff9bae;
}

.mech-name { font-weight: 700; }

.style {
  font-size: 0.78em;
  color: var(--muted);
  letter-spacing: 0.2em;
}

.meter {
  position: relative;
  height: clamp(6px, 1.4cqw, 15px);
  margin-top: 0.55cqw;
  background: #0a1120;
  border: 1px solid rgba(120, 160, 220, 0.26);
  overflow: hidden;
  clip-path: polygon(0 0, 100% 0, 100% 70%, 95% 100%, 0 100%);
}

.meter i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  transition: width 0.14s linear;
}

.meter.hp i {
  background: linear-gradient(90deg, #1f4dff, #5fe8ff 70%, #b8f7ff);
  box-shadow: 0 0 10px rgba(95, 232, 255, 0.55);
}

.hud-right .meter.hp i {
  left: auto;
  right: 0;
  background: linear-gradient(270deg, #ff2d55, #ff8f5e 70%, #ffd166);
  box-shadow: 0 0 10px rgba(255, 77, 109, 0.55);
}

.meter.en {
  height: clamp(3px, 0.6cqw, 6px);
  margin-top: 0.45cqw;
  border-color: rgba(120, 160, 220, 0.14);
  background: rgba(255, 255, 255, 0.04);
  clip-path: none;
}

.meter.en i {
  background: linear-gradient(90deg, rgba(95, 232, 255, 0.85), rgba(74, 144, 255, 0.7));
}

.hud-right .meter.en i {
  left: auto;
  right: 0;
  background: linear-gradient(270deg, rgba(255, 209, 102, 0.85), rgba(255, 77, 109, 0.7));
}

.meter.en.deny i { background: rgba(255, 209, 102, 0.9); }

.meter-segs {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(8.333% - 1px),
    rgba(2, 4, 10, 0.9) calc(8.333% - 1px),
    rgba(2, 4, 10, 0.9) 8.333%
  );
  pointer-events: none;
}

.meter.hp.low i { animation: hpLow 0.55s steps(2, end) infinite; }
@keyframes hpLow { 50% { opacity: 0.35; } }

.hud-center {
  text-align: center;
  min-width: 9cqw;
}

.timer {
  font-size: clamp(20px, 4.4cqw, 46px);
  line-height: 0.9;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #f3fbff;
  text-shadow:
    0 0 16px rgba(95, 232, 255, 0.6),
    0 3px 0 rgba(0, 0, 0, 0.65);
}

.round {
  margin-top: 0.5cqw;
  font-size: clamp(6px, 0.8cqw, 9px);
  letter-spacing: 0.28em;
  color: var(--muted);
}

/* ================= 公告文字 ================= */
.announce {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6cqw;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

.announce.show { animation: annPop 1.1s ease-out both; }
.announce.hold { animation-duration: 2.6s; }
.announce.show .main {
  font-size: clamp(26px, 7cqw, 76px);
  font-weight: 700;
  letter-spacing: 0.07em;
  color: #eaf6ff;
  text-shadow:
    0 0 22px rgba(95, 232, 255, 0.65),
    0 4px 0 rgba(0, 0, 0, 0.6);
}

.announce.show .sub {
  font-size: clamp(7px, 1cqw, 12px);
  letter-spacing: 0.3em;
  color: var(--muted);
  text-transform: uppercase;
}

.announce.fight .main {
  color: var(--amber);
  text-shadow:
    0 0 26px rgba(255, 209, 102, 0.6),
    0 4px 0 rgba(0, 0, 0, 0.6);
}

@keyframes annPop {
  0% { opacity: 0; transform: scale(1.35); }
  14% { opacity: 1; transform: scale(1); }
  76% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.96); }
}

/* ================= 覆盖层 ================= */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4cqw;
  background: radial-gradient(ellipse at center, rgba(4, 7, 18, 0.70), rgba(2, 4, 10, 0.95));
  text-align: center;
}

.overlay.hidden { display: none; }

.menu-inner {
  width: min(680px, 92%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.eyebrow {
  margin: 0;
  font-size: clamp(7px, 0.95cqw, 11px);
  letter-spacing: 0.32em;
  color: var(--cyan);
  opacity: 0.75;
  text-transform: uppercase;
}

.title {
  margin: 0.5cqw 0 0;
  font-size: clamp(24px, 5.3cqw, 56px);
  line-height: 0.92;
  letter-spacing: 0.05em;
  color: #f4fcff;
  text-shadow:
    0 0 32px rgba(95, 232, 255, 0.30),
    0 0.55cqw 0 #071426;
}

.title small {
  display: block;
  margin-top: 0.4cqw;
  font-size: 0.42em;
  letter-spacing: 0.44em;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(95, 232, 255, 0.55);
}

.sub {
  margin: 1.4cqw 0 0;
  font-size: clamp(9px, 1.2cqw, 13px);
  line-height: 1.8;
  letter-spacing: 0.08em;
  color: #9fb6d4;
}

.modes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.1cqw;
  margin: 2.4cqw 0 1.6cqw;
}

.mode-btn {
  appearance: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35cqw;
  min-width: 15cqw;
  padding: 1.15cqw 2.4cqw;
  background: rgba(8, 14, 28, 0.85);
  border: 1px solid rgba(95, 232, 255, 0.28);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%);
}

.mode-btn strong {
  font-size: clamp(10px, 1.35cqw, 16px);
  letter-spacing: 0.14em;
}

.mode-btn span {
  font-size: clamp(6px, 0.8cqw, 9px);
  letter-spacing: 0.18em;
  color: var(--muted);
}

.mode-btn.primary {
  background: linear-gradient(135deg, rgba(95, 232, 255, 0.95), rgba(74, 144, 255, 0.92));
  border-color: rgba(255, 255, 255, 0.5);
  color: #02101f;
  box-shadow: 0 0 22px rgba(95, 232, 255, 0.35);
}

.mode-btn.primary span { color: rgba(2, 16, 31, 0.6); }

.mode-btn:hover {
  border-color: rgba(95, 232, 255, 0.75);
  box-shadow: 0 0 26px rgba(95, 232, 255, 0.28);
  transform: translateY(-1px);
}

.mode-btn:active { transform: translateY(1px); }

.tips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6cqw 1.6cqw;
  font-size: clamp(6px, 0.82cqw, 9px);
  letter-spacing: 0.14em;
  color: rgba(123, 139, 168, 0.85);
}

.tips span::before {
  content: "▸ ";
  color: var(--cyan);
}

.result-inner {
  width: min(620px, 92%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

#resultTitle {
  margin: 0.8cqw 0 0;
  font-size: clamp(24px, 5.6cqw, 62px);
  letter-spacing: 0.06em;
  line-height: 1;
  color: #f4fcff;
  text-shadow:
    0 0 30px rgba(95, 232, 255, 0.45),
    0 0.5cqw 0 #071426;
}

#resultTitle.crimson {
  color: #ffe3e8;
  text-shadow:
    0 0 30px rgba(255, 77, 109, 0.5),
    0 0.5cqw 0 #1a0710;
}

#resultTitle.draw {
  color: var(--amber);
  text-shadow:
    0 0 30px rgba(255, 209, 102, 0.4),
    0 0.5cqw 0 #141006;
}

#resultSub {
  margin: 1.3cqw 0 0;
  font-size: clamp(8px, 1.05cqw, 12px);
  letter-spacing: 0.16em;
  color: #9fb6d4;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.1cqw;
  margin-top: 2.6cqw;
}

/* ================= 底部按键说明 ================= */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 22px;
  margin-top: 12px;
  padding: 0 4px;
  font-size: clamp(9px, 1.4vw, 11px);
  color: var(--muted);
}

.ctrl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.ctrl b {
  color: var(--cyan);
  letter-spacing: 0.12em;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 2px 5px;
  border: 1px solid rgba(95, 232, 255, 0.22);
  border-radius: 2px;
  background: #060c18;
  color: #cfe9ff;
  font-family: inherit;
  font-size: 0.9em;
  text-align: center;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.65);
}

.sfx-btn {
  appearance: none;
  cursor: pointer;
  padding: 5px 10px;
  border: 1px solid rgba(95, 232, 255, 0.22);
  background: rgba(6, 12, 24, 0.9);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.9em;
  letter-spacing: 0.14em;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.sfx-btn.on {
  color: var(--cyan);
  border-color: rgba(95, 232, 255, 0.5);
}

@media (max-width: 760px) {
  body { padding: 10px 8px; align-items: flex-start; }
  .legend { font-size: 9px; gap: 6px 12px; }
  .legend .ctrl span { white-space: nowrap; }
  .tips { display: none; }
  .mode-btn { min-width: 0; padding: 10px 16px; }
  .sub { display: none; }
  .topline .tag { display: none; }
}

/* ================= CPU 难度选择 ================= */
.diff {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6cqw;
  margin: 1.6cqw 0 0.4cqw;
  font-size: clamp(7px, 0.95cqw, 11px);
  letter-spacing: 0.14em;
  color: var(--muted);
}

.diff-label {
  width: 100%;
  margin-bottom: 0.4cqw;
  font-size: clamp(6px, 0.8cqw, 9px);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.7;
}

.diff-btn {
  appearance: none;
  cursor: pointer;
  min-width: 9cqw;
  padding: 0.7cqw 1.4cqw;
  background: rgba(8, 14, 28, 0.85);
  border: 1px solid rgba(95, 232, 255, 0.26);
  color: var(--text);
  font-family: inherit;
  font-size: clamp(9px, 1.1cqw, 13px);
  letter-spacing: 0.16em;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.diff-btn:hover { border-color: rgba(95, 232, 255, 0.6); }

.diff-btn.active {
  background: linear-gradient(135deg, rgba(95, 232, 255, 0.95), rgba(74, 144, 255, 0.92));
  border-color: rgba(255, 255, 255, 0.5);
  color: #02101f;
  box-shadow: 0 0 18px rgba(95, 232, 255, 0.32);
}

/* ================= 回合比分点 ================= */
.pips {
  margin-top: 0.4cqw;
  min-height: 1.2cqw;
  font-size: clamp(8px, 1.3cqw, 13px);
  line-height: 1;
  letter-spacing: 0.2em;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(95, 232, 255, 0.6);
}
.pips.right {
  text-align: right;
  color: #ff9bae;
  text-shadow: 0 0 8px rgba(255, 77, 109, 0.6);
}

/* ================= 连胜提示 ================= */
.streak {
  margin: 1cqw 0 0;
  min-height: 1.2em;
  font-size: clamp(7px, 0.95cqw, 11px);
  letter-spacing: 0.22em;
  color: var(--amber);
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 209, 102, 0.45);
}

/* ================= 暂停层 ================= */
.pause { z-index: 7; }

/* ================= 触屏控制 ================= */
.touchpad {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  padding: 3cqw 4cqw;
  pointer-events: none;
}

.touchpad .pad-move,
.touchpad .pad-act {
  display: flex;
  gap: 2cqw;
  pointer-events: auto;
}

.tbtn {
  appearance: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 13cqw;
  height: 13cqw;
  max-width: 78px;
  max-height: 78px;
  border-radius: 50%;
  border: 1px solid rgba(95, 232, 255, 0.4);
  background: rgba(8, 14, 28, 0.72);
  color: var(--text);
  font-family: inherit;
  font-size: clamp(10px, 2.4cqw, 16px);
  letter-spacing: 0.06em;
  box-shadow: 0 0 14px rgba(95, 232, 255, 0.18);
  transition: transform 0.08s ease, background 0.12s ease;
}

.tbtn:active {
  transform: scale(0.92);
  background: rgba(95, 232, 255, 0.28);
}

.tbtn.act-light { border-color: rgba(95, 232, 255, 0.55); color: #cfe9ff; }
.tbtn.act-heavy { border-color: rgba(255, 209, 102, 0.6); color: #ffe3a8; }
.tbtn.act-guard { border-color: rgba(255, 77, 109, 0.55); color: #ffc2cf; }

/* 仅在触屏 / 粗指针设备上显示虚拟按键 */
@media (pointer: coarse) {
  .touchpad { display: flex; }
  .legend { display: none; }
}

/* ===== 移动端适配 ===== */

/* 触屏设备：占满动态视口、禁滚动/橡皮筋/双击缩放 */
@media (pointer: coarse) {
  html, body {
    height: 100dvh;
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
  }
  body {
    padding:
      max(6px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(6px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }
  .app { width: 100%; }
}

/* 虚拟按键保证最小可点区（iOS 建议 ≥44px） */
.tbtn {
  width: clamp(46px, 13cqw, 84px);
  height: clamp(46px, 13cqw, 84px);
}

/* 竖屏提示：仅触屏 + 竖屏时显示 */
.rotate-hint {
  display: none;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  padding: 6px 14px;
  border: 1px solid rgba(95, 232, 255, 0.4);
  border-radius: 999px;
  background: rgba(8, 14, 28, 0.82);
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0.12em;
  pointer-events: none;
  white-space: nowrap;
}

@media (pointer: coarse) and (orientation: portrait) {
  .rotate-hint { display: block; }
  /* 竖屏画面扁：菜单允许滚动 + 紧凑排版 */
  .overlay { overflow-y: auto; align-items: flex-start; padding: 14px 10px; }
  .menu-inner { width: 100%; }
  .title { font-size: clamp(20px, 7.5vw, 32px); }
  .sub { font-size: 11px; }
  .modes { gap: 8px; }
  /* 触控键位收拢到画面外沿 */
  .touchpad { padding: 2cqw 2cqw; }
}

/* 手机横屏：压缩页眉，画面最大化 */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .topline { display: none; }
  body { padding: 0; }
  .frame { border-radius: 0; border-left: 0; border-right: 0; }
}

/* 小屏通用微调 */
@media (max-width: 760px) {
  body { padding: 10px 8px; }
  .topline { margin-bottom: 6px; }
  .app { width: 100%; }
  .diff-btn { min-width: 0; padding: 8px 14px; }
}
