/* ===== 坦克大战 '90 —— CRT 街机机台外壳 =====
   无外部素材：机台面板 / 扫描线 / 荫罩 / 暗角 / 高光全部由 CSS 生成 */

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

:root {
  --room: #0a0a0d;
  --plastic-hi: #3a3a44;
  --plastic: #232329;
  --plastic-lo: #141418;
  --amber: #f8b800;
  --amber-dim: #a87818;
  --green: #58d854;
  --label: #8a8a94;
  --label-dim: #82828c;   /* 暗色提示行：对面板背景对比度 ≥ 4.5:1 (WCAG AA) */
}

html, body {
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 38%, #1a1a20 0%, #0e0e12 46%, var(--room) 100%);
  color: var(--label);
  font-family: "Courier New", "SimSun", monospace;
}

/* 地面反光：机台底下一点点冷色环境光 */
body::before {
  content: "";
  position: fixed;
  left: 50%; bottom: -12%;
  width: 90vw; height: 30vh;
  transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 50%, rgba(88, 120, 248, 0.05), transparent 70%);
  pointer-events: none;
}

.cabinet {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px;
}

/* ---------- 顶部招牌（背光 + 偶发闪烁） ---------- */
.marquee {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 7px 26px 6px;
  background: linear-gradient(180deg, #17171c, #101014);
  border: 1px solid #000;
  border-top-color: #2e2e36;
  border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 0 22px rgba(248, 184, 0, 0.05),
    0 3px 12px rgba(0, 0, 0, 0.6),
    0 0 34px rgba(248, 184, 0, 0.13);
  user-select: none;
  animation: marquee-glow 7s ease-in-out infinite;
}
@keyframes marquee-glow {
  0%, 100% { filter: brightness(1); }
  47% { filter: brightness(1.12); }
  50% { filter: brightness(0.8); }
  53% { filter: brightness(1.1); }
}
.marquee-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 6px;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(248, 184, 0, 0.35), 0 0 26px rgba(248, 184, 0, 0.22);
}
.marquee-sub {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--amber-dim);
}
.marquee-tank {
  width: 14px; height: 10px;
  align-self: center;
  background:
    conic-gradient(from 90deg at 50% 60%, var(--amber) 0 25%, transparent 0) 0 0 / 6px 4px repeat-x,
    linear-gradient(var(--amber), var(--amber)) 0 8px / 14px 2px no-repeat;
  opacity: 0.85;
}
.marquee-tank.flip { transform: scaleX(-1); }

/* ---------- 屏幕外框（塑料机壳 + 机台物理细节） ---------- */
.screen-frame {
  position: relative;
  padding: 18px 18px 34px;
  border-radius: 18px;
  background: linear-gradient(160deg, var(--plastic-hi) 0%, var(--plastic) 38%, var(--plastic-lo) 100%);
  border: 1px solid #000;
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, 0.07),
    inset 0 -3px 6px rgba(0, 0, 0, 0.55),
    0 18px 50px rgba(0, 0, 0, 0.75),
    0 2px 8px rgba(0, 0, 0, 0.5);
}
/* 开机动画：CRT 高压拉起 → 白光过曝 → 收敛（可被 reduced-motion 关闭） */
.crt { animation: crt-on 1.1s cubic-bezier(0.2, 0, 0.18, 1) both; }
@keyframes crt-on {
  0%  { transform: scaleY(0.004) scaleX(1.6); filter: brightness(9); opacity: 0.55; }
  34% { transform: scaleY(0.004) scaleX(1.6); filter: brightness(9); opacity: 0.55; }
  62% { transform: scaleY(1) scaleX(1); filter: brightness(2.4); opacity: 1; }
  100% { transform: scaleY(1) scaleX(1); filter: brightness(1); opacity: 1; }
}
.screw {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a4a54, #1c1c22 70%);
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.05);
}
.screw::after {
  content: "";
  position: absolute;
  left: 1px; right: 1px; top: 50%;
  height: 1px;
  background: #0a0a0c;
  transform: rotate(38deg);
}
.screw.tl { top: 6px; left: 6px; }
.screw.tr { top: 6px; right: 6px; }
.screw.bl { bottom: 26px; left: 6px; }
.screw.br { bottom: 26px; right: 6px; }

/* ---- 扬声器格栅：针孔点阵，右侧 ---- */
.deck-speaker {
  position: absolute;
  right: 22px; bottom: 10px;
  width: 116px; height: 16px;
  border-radius: 3px;
  background:
    radial-gradient(circle at 4px 4px, #0c0c10 1.3px, transparent 1.6px) 0 0 / 9px 8px repeat,
    linear-gradient(180deg, #1b1b22, #101015);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8), inset 0 -1px 0 rgba(255, 255, 255, 0.03);
  opacity: 0.9;
}
/* ---- 投币口：左下，带投币缝与小锁眼 ---- */
.deck-coin {
  position: absolute;
  left: 20px; bottom: 8px;
  width: 34px; height: 20px;
  border-radius: 3px;
  background: linear-gradient(180deg, #16161c, #0d0d11);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(255, 255, 255, 0.04);
}
.deck-coin b {
  position: absolute;
  left: 50%; top: 4px;
  width: 22px; height: 4px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: #000;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 1);
}
.deck-coin::after {
  content: "";
  position: absolute;
  left: 50%; bottom: 3px;
  width: 3px; height: 3px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #2a2a32;
  box-shadow: 0 0 0 1px #000;
}
/* ---- 电源 LED：琥珀色呼吸灯 ---- */
.deck-led {
  position: absolute;
  left: 64px; bottom: 13px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd870, var(--amber) 55%, #7a5a10 100%);
  box-shadow: 0 0 6px rgba(248, 184, 0, 0.75), 0 0 14px rgba(248, 184, 0, 0.35);
  animation: led-breathe 3.2s ease-in-out infinite;
}
@keyframes led-breathe {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(248, 184, 0, 0.75), 0 0 14px rgba(248, 184, 0, 0.35); }
  50% { opacity: 0.62; box-shadow: 0 0 3px rgba(248, 184, 0, 0.5), 0 0 7px rgba(248, 184, 0, 0.18); }
}

/* ---------- CRT 屏幕 ---------- */
.crt {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow:
    inset 0 0 0 1px #000,
    inset 0 0 24px rgba(0, 0, 0, 0.9);
}

canvas#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* 预留招牌/说明条的高度，保证整个机台在视口内完整呈现 */
  width: min(90vw, calc(64vh * 8 / 7));
  aspect-ratio: 8 / 7;
  background: #000;
  outline: none;
}

/* 荫罩：极淡的 RGB 条纹，模拟显像管栅格 */
.crt-grille {
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(90deg,
    rgba(255, 60, 60, 0.045) 0 1px,
    rgba(60, 255, 90, 0.035) 1px 2px,
    rgba(80, 120, 255, 0.045) 2px 3px);
  mix-blend-mode: screen;
}

/* 扫描线 + 缓慢滚动的亮带 */
.crt-scanlines {
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,
    rgba(0, 0, 0, 0.24) 0 1px,
    transparent 1px 3px);
}
.crt-scanlines::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 0;
  height: 90px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.028), transparent);
  transform: translateY(-100px);
  animation: crt-roll 9s linear infinite;
}
@keyframes crt-roll {
  from { transform: translateY(-100px); }
  to   { transform: translateY(110vh); }
}

/* 暗角 + 玻璃反光 */
.crt-vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(115% 115% at 50% 46%, transparent 58%, rgba(0, 0, 0, 0.42) 100%);
}
/* 玻璃反光：随鼠标轻微视差（JS 只改 --gx/--gy，无布局抖动） */
.crt-glare {
  position: absolute; inset: 0;
  pointer-events: none;
  transform: translate(var(--gx, 0), var(--gy, 0));
  background:
    radial-gradient(38% 20% at calc(26% + var(--gx, 0px) * 0.6) calc(6% + var(--gy, 0px) * 0.6), rgba(255, 255, 255, 0.055), transparent 70%),
    radial-gradient(24% 12% at calc(78% + var(--gx, 0px) * 0.6) calc(12% + var(--gy, 0px) * 0.6), rgba(255, 255, 255, 0.03), transparent 70%);
}

@media (prefers-reduced-motion: reduce) {
  .crt-scanlines::after { animation: none; }
  .crt { animation: none; }
  .marquee { animation: none; }
  .deck-led { animation: none; }
}

/* ---------- 底部控制说明条 ---------- */
.cab-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 22px;
  background: linear-gradient(180deg, #121217, #0d0d11);
  border: 1px solid #000;
  border-bottom-color: #26262e;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  user-select: none;
  max-width: 92vw;
}
.hint-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 1px;
}
.hint-row.dim { font-size: 11px; color: var(--label-dim); }
.hint { display: inline-flex; align-items: center; gap: 4px; }
.hint em { font-style: normal; color: var(--label-dim); margin: 0 1px; }
.hint.p2 { color: var(--green); }

kbd {
  display: inline-block;
  min-width: 17px;
  padding: 1px 5px 2px;
  text-align: center;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  color: #d8d8de;
  letter-spacing: 0;
  background: linear-gradient(180deg, #2c2c34, #1a1a20);
  border: 1px solid #000;
  border-bottom-color: #060608;
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 2px 0 #060608;
}
.hint-row.dim kbd { color: #9a9aa4; }
.hint.p2 kbd { color: var(--green); }

.dot {
  width: 3px; height: 3px;
  background: var(--label-dim);
  border-radius: 50%;
  opacity: 0.6;
}

/* 屏幕阅读器专用实时播报区 */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
