/*!
 * base.css — 变量、重置、整体布局、通用组件（按钮 / 弹窗 / 面板）
 * 视觉：清新明亮风（浅底、圆角、柔和阴影、糖果色）
 */

:root {
  /* 背景与表面 */
  --bg-1: #eaf4ff;
  --bg-2: #f6fbff;
  --bg-3: #fdf8ff;
  --surface: #ffffff;
  --surface-2: #f2f8ff;
  --border: #dde9f7;
  --border-strong: #c7dcf4;

  /* 文字 */
  --text: #1f2b3a;
  --text-dim: #6d7f96;
  --text-faint: #9aabc0;

  /* 主题色 */
  --accent: #4aa3ff;
  --accent-dark: #2b7fe0;
  --mint: #35c9a3;
  --danger: #ff5c5c;
  --warn: #ffab00;

  /* 形状 */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;

  --shadow-1: 0 1px 2px rgba(31, 43, 58, .05), 0 6px 18px rgba(31, 43, 58, .07);
  --shadow-2: 0 6px 18px rgba(31, 43, 58, .12), 0 20px 50px rgba(31, 43, 58, .14);
  --shadow-in: inset 0 0 0 1px rgba(255, 255, 255, .7);

  /* 布局尺寸：格子尺寸由 render.js 按容器实测算出后写到 --cell，
     这里只给一个首帧默认值，避免初始化前出现明显的尺寸跳变 */
  --cell: 48px;

  /* 字体：显式写全 emoji 字体栈。
     彩色 emoji 字体的行高普遍偏大，会顶破格子，所以处处配套 line-height: 1 */
  --font-ui: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
             "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;                 /* 游戏内不整页滚动 */
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;       /* 干掉双击缩放与 300ms 点击延迟 */
}

body {
  /* 刘海 / 灵动岛 / 手势条 */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
button:disabled { cursor: not-allowed; }

h1, h2, h3, p { margin: 0; }

/* ==========================================================
 * 整体骨架
 * ========================================================== */
.app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 10px;
}

/* 数字统一等宽，避免分数跳动时整块重排 */
.value, .time-text, .mode-best, b, .score-num { font-variant-numeric: tabular-nums; }

/* ==========================================================
 * 顶部提示条
 * ========================================================== */
.error-bar, .note-bar {
  position: fixed;
  left: 8px; right: 8px;
  z-index: 999;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow-2);
  max-height: 40vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.error-bar {
  top: 8px;
  background: #fff2f2;
  border: 1px solid #ffc9c9;
  color: #a11616;
}
.note-bar {
  bottom: 8px;
  background: #fffaf0;
  border: 1px solid #ffe0a8;
  color: #8a5a00;
}
.error-bar .close, .note-bar .close {
  position: absolute; top: 6px; right: 8px;
  font-size: 14px; color: inherit; opacity: .6;
}

/* ==========================================================
 * 通用面板 / 弹窗
 * ========================================================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(226, 238, 252, .72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.overlay[hidden] { display: none; }

.panel {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow: auto;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  animation: panelIn 220ms cubic-bezier(.2, .9, .3, 1.05);
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ==========================================================
 * 按钮
 * ========================================================== */
.icon-btn {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 15px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  transition: transform 120ms, color 120ms, background 120ms;
}
.icon-btn:active { transform: scale(.94); }

.ghost-btn {
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 120ms, background 120ms;
}
.ghost-btn:active { transform: scale(.96); }

.primary-btn {
  padding: 12px 24px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #5cb0ff, var(--accent-dark));
  box-shadow: 0 4px 12px rgba(43, 127, 224, .35);
  transition: transform 120ms, filter 120ms;
}
.primary-btn:active { transform: scale(.96); }
.primary-btn.alt {
  background: linear-gradient(180deg, #49d6b0, #23a987);
  box-shadow: 0 4px 12px rgba(35, 169, 135, .35);
}
.primary-btn.muted {
  background: var(--surface-2);
  color: var(--text-dim);
  box-shadow: none;
  border: 1px solid var(--border);
}

/* 只在真有鼠标指针时才启用 hover —— 否则触摸端点过的元素会一直保持高亮 */
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { color: var(--accent); background: var(--surface-2); }
  .ghost-btn:hover { background: #e8f2ff; color: var(--accent-dark); }
  .primary-btn:hover { filter: brightness(1.06); }
}

/* ==========================================================
 * 通用小组件
 * ========================================================== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.chip.warn { background: #fff4e0; border-color: #ffdca8; color: #9a6200; }
.chip.bad  { background: #fff0f0; border-color: #ffcdcd; color: #b52a2a; }
.chip.good { background: #e8fbf4; border-color: #b6efdd; color: #12775c; }

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-dim); }
.kv .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.kv .v.big { font-size: 20px; color: var(--accent-dark); }

/* 得分加倍进行中：让分数本身发光，不用再额外塞一条 UI */
.hud-stat .value.boost {
  color: #e8630a;
  text-shadow: 0 0 12px rgba(255, 150, 40, .75);
}

.hintline {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-faint);
}
