/* a.kiwi · Kiwi Runner — 纯黑白像素游戏页样式
   原则：只用黑白两色，不用圆角/阴影/渐变；像素字体；网格化留白。 */

@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;
}

/* 中文像素字（Fusion Pixel 12px，OFL）；缺失时回退系统字体 */
@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.4vw, 28px) clamp(16px, 4vw, 40px) clamp(12px, 2vw, 22px);
}

/* ---------- 顶栏 ---------- */
.topbar {
  width: 100%;
  max-width: 1200px;
  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: 24px; width: auto; }

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

.tool-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--paper);
  border: var(--line);
  cursor: pointer;
}
.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: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.6vw, 18px);
  padding: clamp(10px, 2vw, 26px) 0;
}

.title-row { display: flex; align-items: center; justify-content: center; }

.game-title {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: clamp(8px, 1.2vw, 16px);
  font-weight: 400;
}
.game-title .en {
  font-family: var(--px);
  font-size: clamp(12px, 1.6vw, 20px);
  letter-spacing: 0.12em;
}
.game-title .zh {
  font-family: var(--zh);
  font-size: clamp(12px, 1.1vw, 15px);
  letter-spacing: 0.24em;
}

/* ---------- 游戏区 ---------- */
.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: 10px;
  text-align: center;
  padding: 12px;
  pointer-events: none;
  line-height: 1.5;
}
.overlay[hidden] { display: none; }

.overlay-start .prompt-en { animation: blink 1.4s steps(1, end) infinite; }

.overlay-over { pointer-events: none; }

.panel {
  background: var(--paper);
  border: var(--line);
  padding: clamp(14px, 2vw, 24px) clamp(18px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: min(78%, 360px);
}
.panel-sm { min-width: 0; }

.big {
  margin: 0;
  font-family: var(--px);
  font-size: clamp(14px, 1.7vw, 20px);
  letter-spacing: 0.08em;
}

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

.prompt-en {
  margin: 0;
  font-family: var(--px);
  font-size: clamp(9px, 1.4vw, 16px);
  letter-spacing: 0.08em;
}
.prompt-zh { margin: 0; font-family: var(--zh); font-size: 12px; letter-spacing: 0.3em; }
.prompt-touch { display: none; margin: 0; font-family: var(--px); font-size: 9px; line-height: 1.8; letter-spacing: 0.08em; }
.prompt-touch .en { display: block; }
.prompt-touch .zh-cn { display: block; font-family: var(--zh); font-size: 12px; letter-spacing: 0.3em; }

.scores {
  margin: 4px 0 0;
  display: flex;
  gap: clamp(12px, 2vw, 26px);
  font-family: var(--zh);
  font-size: 12px;
  letter-spacing: 0.12em;
  flex-wrap: wrap;
  justify-content: center;
}
.scores b { font-weight: 400; }

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

.btn {
  margin-top: 4px;
  padding: 10px 16px;
  background: var(--paper);
  border: var(--line);
  font-family: var(--px);
  font-size: 9px;
  letter-spacing: 0.08em;
  cursor: pointer;
  pointer-events: auto;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}
.btn .zh-inline { font-family: var(--zh); font-size: 12px; letter-spacing: 0.2em; }
.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.14em; }

/* ---------- 操作提示 ---------- */
.hints {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: var(--zh);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-align: center;
}
.hints .en { font-family: var(--zh); letter-spacing: 0.16em; }
.hints-touch { display: none; }

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

/* ---------- 触屏 / 小屏 ---------- */
@media (pointer: coarse), (max-width: 640px) {
  .hints-desktop { display: none; }
  /* 小屏上结束面板必须塞进 150px 高的画布 */
  .overlay-over .zh,
  .overlay-over .hint,
  .overlay-pause .hint { display: none; }
  .overlay-over .panel,
  .overlay-pause .panel { padding: 8px 10px; gap: 5px; min-width: min(92%, 300px); }
  .overlay-over .big,
  .overlay-pause .big { font-size: 8px; letter-spacing: 0.04em; }
  .overlay-over .scores { font-size: 12px; gap: 10px; margin-top: 2px; }
  .overlay-over .record { font-size: 12px; }
  .overlay .btn { margin-top: 2px; padding: 6px 10px; font-size: 8px; gap: 8px; }
  .overlay .btn .zh-inline { font-size: 12px; }
  .hints { font-size: 12px; }
  .hints-touch { display: flex; }
  .game-title .en { font-size: 12px; }
  .game-title .zh { font-size: 12px; }
  .prompt-en, .prompt-zh { display: none; }
  .prompt-touch { display: block; }
  .brand img { height: 20px; }
  .tool-btn { width: 30px; height: 30px; }
  .tool-btn svg { width: 14px; height: 14px; }
}

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

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