/* a.kiwi · 1-bit 像素小游戏页
   原则：只用黑白两色；无圆角/阴影/渐变；像素字体；网格化留白。 */

@font-face {
  font-family: 'Press Start 2P';
  src: url('../assets/fonts/press-start-2p-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Fusion Pixel 12px';
  src: url('../assets/fonts/fusion-pixel-12px-sc.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #000;
  --paper: #fff;
  --px: 'Press Start 2P', 'Courier New', monospace;
  --zh: 'Fusion Pixel 12px', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --line: 2px solid var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
}

body {
  font-family: var(--zh);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  min-height: 100svh;
}

button { font: inherit; color: inherit; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(14px, 2.2vw, 26px) clamp(16px, 4vw, 44px) clamp(12px, 2vw, 20px);
}

/* ---------- 顶栏 ---------- */
.topbar {
  width: 100%;
  max-width: 1240px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { display: block; height: 22px; width: auto; }

.tools { display: flex; gap: 8px; }

.tool-btn {
  height: 32px;
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 4px;
  background: var(--paper);
  border: var(--line);
  cursor: pointer;
}
#langBtn { padding: 0 7px; }
.lang-mark {
  font-family: var(--zh);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0;
  min-width: 11px;
}
.tool-btn:hover { background: var(--ink); color: var(--paper); }
.tool-btn:active { transform: translate(1px, 1px); }
.tool-btn svg { fill: currentColor; display: block; }
.tool-btn svg[hidden] { display: none; }
.tool-btn[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.tool-btn:focus-visible,
.brand:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- 舞台 ---------- */
.stage {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.6vw, 18px);
  padding: clamp(14px, 3vh, 34px) 0;
}

/* ---------- 游戏区 ---------- */
.game-wrap {
  position: relative;
  border: var(--line);
  background: var(--paper);
  line-height: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  cursor: pointer;
}

/* ---------- 覆盖层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 8px;
  pointer-events: none;
  line-height: 1.45;
}
.overlay[hidden] { display: none; }

.prompt { margin: 0; }
.prompt-key {
  font-family: var(--px);
  font-size: 12px;
  letter-spacing: 0.06em;
  animation: blink 1.4s steps(1, end) infinite;
}
.prompt-touch {
  display: none;
  font-family: var(--zh);
  font-size: 12px;
  letter-spacing: 0.24em;
}

.panel {
  background: var(--paper);
  border: var(--line);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: min(80%, 300px);
}
.panel-sm { min-width: 0; }

.big {
  margin: 0;
  font-family: var(--px);
  font-size: 14px;
  letter-spacing: 0.06em;
  line-height: 1.3;
}
html[lang='zh-CN'] .big {
  font-family: var(--zh);
  font-size: 14px;
  letter-spacing: 0.2em;
}
html[lang='zh-CN'] .prompt-key {
  font-family: var(--zh);
  font-size: 13px;
  letter-spacing: 0.22em;
}

/* 大画布（桌面 2x）时，覆盖层文字同步放大 */
html.wide .prompt-key { font-size: 16px; }
html[lang='zh-CN'].wide .prompt-key { font-size: 16px; letter-spacing: 0.24em; }
html.wide .big { font-size: 20px; }
html[lang='zh-CN'].wide .big { font-size: 20px; }
html.wide .panel { padding: 14px 22px; gap: 8px; }
html.wide .hint { font-size: 13px; }
html.wide .label, html.wide .btn { font-size: 12px; }

.scores {
  margin: 0;
  display: flex;
  gap: 14px;
  font-family: var(--zh);
  font-size: 12px;
  letter-spacing: 0.06em;
  flex-wrap: wrap;
  justify-content: center;
}
.scores .label { opacity: 1; }
.scores b { font-weight: 400; }

.record {
  margin: 0;
  font-family: var(--zh);
  font-size: 12px;
  letter-spacing: 0.1em;
  animation: blink 0.6s steps(1, end) infinite;
}
.record[hidden] { display: none; }

.btn {
  margin-top: 2px;
  padding: 6px 12px;
  background: var(--paper);
  border: var(--line);
  font-family: var(--zh);
  font-size: 12px;
  letter-spacing: 0.16em;
  cursor: pointer;
  pointer-events: auto;
}
.btn:hover, .btn:focus-visible { background: var(--ink); color: var(--paper); outline: none; }
.btn:active { transform: translate(1px, 1px); }

.hint { margin: 0; font-family: var(--zh); font-size: 12px; letter-spacing: 0.1em; }

/* ---------- 操作提示 ---------- */
.hints {
  margin: 0;
  font-family: var(--zh);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-align: center;
}

/* ---------- 页脚 ---------- */
.foot {
  width: 100%;
  max-width: 1240px;
  display: flex;
  justify-content: center;
  gap: 10px;
  font-family: var(--zh);
  font-size: 12px;
  letter-spacing: 0.2em;
  padding-top: 6px;
}
.foot .dot { letter-spacing: 0; }

/* ---------- 触屏 / 小屏 ---------- */
@media (pointer: coarse), (max-width: 640px) {
  .prompt-key { display: none; }
  .prompt-touch { display: block; }
  .brand img { height: 18px; }
  .tool-btn { height: 28px; min-width: 28px; }
  .tool-btn svg { width: 14px; height: 14px; }
  .lang-mark { font-size: 10px; }
  .big { font-size: 8px; letter-spacing: 0.04em; }
  html[lang='zh-CN'] .big { font-size: 12px;letter-spacing: 0.16em; }
  .panel { padding: 8px 10px; gap: 4px; min-width: min(92%, 280px); }
  .scores { font-size: 12px; gap: 10px; }
  .record { font-size: 12px; }
  .btn { padding: 5px 10px; font-size: 12px; }
  .hints { font-size: 12px; }
}

@keyframes blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .prompt-key, .record { animation: none; }
}
