/* ============================================================
   复古像素游戏 · 共享机柜外壳（所有游戏复用）
   5 色板:  #0F172A 背景 / #192134 卡片 / #DC2626 红 / #2563EB 蓝
            #22C55E 绿 / #FACC15 黄 / #E2E8F0 像素白
   字体:    Press Start 2P (标题/数字，拉丁) · VT323 (正文，拉丁)
            Noto Sans SC / 思源黑体 (中文，lang-zh 时启用)
   ============================================================ */

:root {
  --navy:   #0F172A;
  --card:   #192134;
  --red:    #DC2626;
  --blue:   #2563EB;
  --green:  #22C55E;
  --yellow: #FACC15;
  --white:  #E2E8F0;
  --grey:   #8B949E;
  --border: #30363D;

  --px: 'Press Start 2P', 'Courier New', monospace;
  --vt: 'VT323', 'Courier New', monospace;
  --zh: 'Noto Sans SC', 'Source Han Sans SC', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--navy);
  color: var(--white);
  font-family: var(--vt);
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
  overflow-x: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  background:
    radial-gradient(120% 120% at 50% 0%, #16233f 0%, var(--navy) 60%);
}

/* CRT 外壳整体轻微透视 */
/* margin:auto 在 flex 容器内：内容低于视口时居中，高于视口时可滚动到顶，避免移动端顶部被裁切 */
.crt { width: 100%; max-width: 640px; margin: auto; }

.cabinet {
  background: var(--card);
  border: 4px solid var(--border);
  box-shadow:
    0 0 0 4px var(--navy),
    8px 8px 0 0 rgba(0,0,0,0.5),
    0 0 48px -8px rgba(37, 99, 235, 0.35);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- 标题条 ---------- */
.marquee { text-align: center; }
.blocks {
  display: flex; gap: 6px; justify-content: center; margin-bottom: 14px;
}
.blocks i {
  width: 20px; height: 20px; display: block;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.4);
}
.title {
  font-family: var(--px);
  font-size: clamp(20px, 6vw, 34px);
  line-height: 1.1;
  letter-spacing: 2px;
  text-shadow: 4px 4px 0 rgba(0,0,0,0.6);
}
.subtitle {
  font-family: var(--vt);
  font-size: clamp(16px, 3.4vw, 22px);
  color: var(--yellow);
  letter-spacing: 1px;
  margin-top: 10px;
}

.t-green  { color: var(--green); }
.t-white  { color: var(--white); }
.t-yellow { color: var(--yellow); }
.t-blue   { color: var(--blue); }
.t-red    { color: var(--red); }

/* 中文态：用思源黑体（Noto Sans SC）渲染文案，保留像素美术感 */
.crt.lang-zh .title,
.crt.lang-zh .subtitle,
.crt.lang-zh .hud-label,
.crt.lang-zh .ov-big,
.crt.lang-zh .ov-final,
.crt.lang-zh .ov-best,
.crt.lang-zh .ov-blink,
.crt.lang-zh .ov-hint,
.crt.lang-zh .foot { font-family: var(--zh); }

/* 语言切换按钮 */
.lang-toggle {
  margin-left: 6px;
  background: var(--navy);
  color: var(--white);
  border: 2px solid var(--border);
  font-family: var(--vt);
  font-size: 16px;
  padding: 2px 10px;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}
.lang-toggle:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 rgba(0,0,0,0.5); }

/* ---------- HUD ---------- */
.hud {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: var(--navy);
  border: 3px solid var(--border);
  padding: 12px 16px;
}
.hud-item { display: flex; flex-direction: column; gap: 6px; align-items: center; flex: 1; }
.hud-label {
  font-family: var(--vt);
  font-size: 18px;
  color: var(--grey);
  letter-spacing: 2px;
}
.hud-value {
  font-family: var(--px);
  font-size: clamp(14px, 3.6vw, 20px);
  color: var(--white);
  min-width: 2ch;
  text-align: center;
  transition: transform .08s steps(2);
}
.hud-value.bump { transform: scale(1.4); }

/* ---------- 屏幕 ---------- */
.screen-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--navy);
  border: 4px solid var(--border);
  overflow: hidden;
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* 屏幕抖动（死亡/失败时） */
.screen-wrap.shake { animation: shake .32s steps(2) 1; }
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-4px, 3px); }
  50% { transform: translate(4px, -3px); }
  75% { transform: translate(-3px, -3px); }
}

/* CRT 扫描线 */
.scanlines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.18) 3px,
    rgba(0,0,0,0.18) 4px
  );
  mix-blend-mode: multiply;
}
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 80px 12px rgba(0,0,0,0.55);
}

/* ---------- 遮罩层 ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(15, 23, 42, 0.86);
  text-align: center;
  padding: 20px;
}
.overlay.hidden { display: none; }

.ov-big {
  font-family: var(--px);
  font-size: clamp(22px, 6.5vw, 40px);
  letter-spacing: 2px;
  text-shadow: 4px 4px 0 rgba(0,0,0,0.6);
}
.ov-final { font-family: var(--px); font-size: clamp(14px,4vw,20px); color: var(--white); }
.ov-final span { color: var(--yellow); }
.ov-best { font-family: var(--px); font-size: 14px; color: var(--yellow); animation: blink .5s steps(1) infinite; }
.ov-blink {
  font-family: var(--vt); font-size: clamp(18px,4vw,26px); color: var(--green);
  letter-spacing: 1px; animation: blink .7s steps(1) infinite;
}
.ov-hint { font-family: var(--vt); font-size: clamp(15px,3.2vw,20px); color: var(--grey); }
@keyframes blink { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }

/* ---------- 触屏控制 ---------- */
.touchpad {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.tbtn-mid { display: flex; gap: 8px; align-items: center; }
.tbtn {
  width: 64px; height: 56px;
  background: var(--navy);
  color: var(--white);
  border: 3px solid var(--border);
  font-size: 22px;
  font-family: var(--vt);
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.5);
  transition: transform .05s steps(1), background .05s;
}
.tbtn:active { transform: translate(2px,2px); background: var(--blue); box-shadow: 1px 1px 0 rgba(0,0,0,0.5); }
.tbtn-ok:active { background: var(--green); }

/* ---------- 页脚 ---------- */
.foot {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  justify-content: center; align-items: center;
  font-family: var(--vt); font-size: 18px; color: var(--grey);
  letter-spacing: 1px;
}
.foot .dot { width: 14px; height: 14px; display: inline-block; margin-right: 4px; box-shadow: 2px 2px 0 rgba(0,0,0,0.4); }

/* ---------- 触屏设备显示控制 ---------- */
@media (hover: none) and (pointer: coarse) {
  .touchpad { display: flex; }
}
@media (max-width: 480px) {
  .cabinet { padding: 16px; gap: 14px; }
  .hud { padding: 10px; }
}
