/* =========================================================
   Focus Games · 样式表
   设计令牌 1:1 取自 PRD/prototype-spotify（Spotify 暗色）
   覆盖：首页 / 难度 / 游戏 / 成败结果 / 记录 / 设置
   ========================================================= */

:root {
  /* ---------- 颜色（设计令牌） ---------- */
  --c-bg:    #121212;  /* 页面底色 */
  --c-card:  #181818;  /* 卡片表面 */
  --c-btn:   #1F1F1F;  /* 次级按钮 / 数字格子 */
  --c-green: #1ED760;  /* 唯一功能色 */
  --c-t1:    #FFFFFF;  /* 主文字 */
  --c-t2:    #B3B3B3;  /* 次文字 */
  --c-t3:    #7C7C7C;  /* 三级文字 */
  --c-line:  #4D4D4D;  /* 描边 */
  --c-div:   #252525;  /* 分隔线 */
  --c-fail:  #F3727F;  /* 失败语义色 */

  /* ---------- 交互态 ----------
     原型只定义了 :active，以下悬停色按同一色阶推出，不引入新色相 */
  --c-green-hover:  #22E96A;  /* 主按钮悬停（绿提亮约 8%） */
  --c-green-active: #1BC255;  /* 主按钮按下 */
  --c-btn-hover:    #262626;  /* 次级按钮悬停 */
  --c-btn-active:   #2A2A2A;  /* 次级按钮按下（与原型 :active 一致） */
  --c-t2-hover:     #D6D6D6;  /* 次级按钮悬停文字 */
  --c-card-hover:   #1F1F1F;  /* 难度卡悬停 */
  --c-card-active:  #212121;  /* 难度卡按下（原型 :active） */

  /* ---------- 字体 ----------
     不引外部字体（Google Fonts 在境内不可达，原型也做了系统兜底） */
  --font-app: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'PingFang SC',
              'Microsoft YaHei', 'Hiragino Sans GB', Roboto, Helvetica, Arial, sans-serif;
  --font-num: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* ---------- 版心 ---------- */
  --pad-x: 24px;      /* content 左右内边距 */
  --pad-b: 36px;      /* content 底部内边距 */
  --app-w: 420px;     /* 桌面端内容栏宽度 */
  --radius: 8px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: #000;            /* 桌面端两侧留黑，与原型 stage 一致 */
  color: var(--c-t1);
  font-family: var(--font-app);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* 图标精灵 */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon { display: block; flex: none; }
.icon--20 { width: 20px; height: 20px; }
.icon--16 { width: 16px; height: 16px; }

/* ---------- 应用外壳：移动端满屏 / 桌面端居中窄栏 ---------- */
.app {
  position: relative;
  width: 100%;
  max-width: var(--app-w);
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--c-bg);
  padding-top: env(safe-area-inset-top, 0px);      /* 移动端刘海避让 */
}
@media (min-width: 421px) {
  .app {                          /* 桌面端才需要与黑色底区分 */
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, .06),
      0 24px 60px -18px rgba(0, 0, 0, .9);
  }
}

/* ---------- 页面容器：绝对叠放，切换时淡入 ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--c-bg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .16s ease;
}
.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ---------- 内容区 ---------- */
.content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 var(--pad-x) calc(var(--pad-b) + env(safe-area-inset-bottom, 0px));
}

/* ---------- 通用间距工具 ---------- */
.spacer--flex { flex: 1 1 auto; min-height: 0; }
.gap-8  { flex: none; height: 8px; }
.gap-14 { flex: none; height: 14px; }
.gap-18 { flex: none; height: 18px; }
.gap-20 { flex: none; height: 20px; }
.gap-12 { flex: none; height: 12px; }
.gap-31 { flex: none; height: 31px; }
.gap-72 { flex: none; height: 72px; }

/* =========================================================
   通用组件
   ========================================================= */

/* ---------- 顶部导航（52：返回按钮 + 可选信息） ---------- */
.nav {
  flex: none;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav__gap { flex: 1 1 auto; height: 1px; }
.nav__meta {                       /* 难度：刻意压到 13px 极弱 */
  font-size: 13px;
  line-height: 18px;
  font-weight: 500;
  color: var(--c-t3);
}
.nav__time {                       /* 时间：不做大，避免分心 */
  font-family: var(--font-num);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .4px;
  color: var(--c-t2);
}
.iconbtn {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: var(--c-btn);
  cursor: pointer;
  transition: background .15s ease;
}
@media (hover: hover) {
  .iconbtn:hover { background: var(--c-btn-hover); }
}
.iconbtn:active { background: var(--c-btn-active); }

/* ---------- 按钮 ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-app);
  cursor: pointer;
}

/* 一级：页面唯一主按钮 */
.btn--primary {
  flex: none;
  height: 64px;
  gap: 10px;
  border-radius: 999px;
  background: var(--c-green);
  color: #000;
  font-size: 16px;
  line-height: 22px;
  font-weight: 700;
  letter-spacing: 1.4px;
  transition: background .12s ease, transform .12s ease;
}
@media (hover: hover) {
  .btn--primary:hover { background: var(--c-green-hover); }
}
.btn--primary:active {
  background: var(--c-green-active);
  transform: translateY(1px);
}

/* 三级：明显弱于主按钮 */
.btn--ghost {
  flex: 1 1 0;
  height: 48px;
  border-radius: 999px;
  background: var(--c-btn);
  color: var(--c-t2);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  letter-spacing: .8px;
  transition: background .15s ease, color .15s ease;
}
@media (hover: hover) {
  .btn--ghost:hover { background: var(--c-btn-hover); color: var(--c-t2-hover); }
}
.btn--ghost:active { background: var(--c-btn-active); color: var(--c-t2-hover); }

.btn-row {
  flex: none;
  display: flex;
  gap: 12px;
  height: 48px;
}

/* ---------- 键盘可达性 ---------- */
.btn:focus-visible,
.iconbtn:focus-visible,
.card:focus-visible,
.cell:focus-visible,
.records__clear:focus-visible,
.switch:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .75);
  outline-offset: 3px;
}
.btn--primary:focus-visible { outline-color: #FFFFFF; }

/* =========================================================
   01 首页 /home
   ========================================================= */

.brand {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 48px;
}
.brand__mark { width: 36px; height: 36px; }
.brand__wordmark {
  margin: 0;
  font-family: var(--font-num);
  font-size: 26px;
  line-height: 34px;
  font-weight: 800;
  letter-spacing: 1.4px;
  color: var(--c-t1);
}

/* 弹性留白：让主按钮落在屏幕中部偏下（原型 152 / 224 两段） */
.home__gap--top    { flex: 100 1 0; min-height: 40px; display: flex; align-items: center; justify-content: center; }
.home__gap--bottom { flex: 147 1 0; min-height: 56px; }

/* 首页吉祥物 */
.home__pet { width: 132px; height: 132px; object-fit: contain; user-select: none; pointer-events: none; }

/* 个人最佳（无标题，直接展示分数） */
.best {
  flex: none;
  display: flex;
  align-items: center;
  padding: 16px 4px;
  background: var(--c-card);
  border-radius: var(--radius);
}
.best__item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.best__val {
  font-family: var(--font-num);
  font-size: 17px;
  line-height: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--c-t1);
}
.best__val--empty { color: var(--c-t3); }
.best__lbl {
  font-size: 11px;
  line-height: 16px;
  font-weight: 500;
  color: var(--c-t2);
}
.best__div {
  flex: none;
  width: 1px;
  height: 28px;
  background: var(--c-div);
}

/* =========================================================
   02 难度选择 /mode
   ========================================================= */

.mode-content { gap: 12px; }   /* 画布 Content itemSpacing 12 */

.card {
  flex: none;
  height: 104px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  text-align: left;
  background: var(--c-card);
  border: 0;
  border-radius: var(--radius);
  font-family: var(--font-app);
  cursor: pointer;
  transition: background .15s ease;
}
@media (hover: hover) {
  .card:hover { background: var(--c-card-hover); }
}
.card:active { background: var(--c-card-active); }
.card__icon { flex: none; width: 44px; height: 44px; }
.card__text { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.card__name { font-size: 22px; line-height: 30px; font-weight: 700; color: var(--c-t1); }
.card__best { font-size: 12px; line-height: 17px; font-weight: 400; color: var(--c-t2); }

/* =========================================================
   03 游戏进行中 /play
   ========================================================= */

.play-board {
  position: relative;
  flex: none;
  align-self: center;
  width: min(100%, 372px, calc(100dvh - 260px));
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--n, 5), 1fr);
  grid-template-rows: repeat(var(--n, 5), 1fr);
  gap: var(--cell-gap, 8px);
  width: 100%;
  aspect-ratio: 1 / 1;
  transition: opacity .18s ease;
}
/* 各难度：格子间距 / 圆角 / 字号，按原型 5×5（59px 格 / 18px 字）等比推得 */
.grid[data-grid="3"] { --cell-gap: 12px; --cell-radius: 14px; --cell-fs: 34px; }
.grid[data-grid="5"] { --cell-gap: 8px;  --cell-radius: 8px;  --cell-fs: 20px; }
.grid[data-grid="7"] { --cell-gap: 6px;  --cell-radius: 6px;  --cell-fs: 15px; }
.grid[data-grid="9"] { --cell-gap: 4px;  --cell-radius: 5px;  --cell-fs: 11px; }

/* 倒计时阶段：隐藏数字、禁止点击，仅留盘面作底 */
.grid--countdown { opacity: .35; pointer-events: none; }
.grid--countdown .cell { color: transparent; }

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  background: var(--c-btn);
  border: 0;
  border-radius: var(--cell-radius, 8px);
  font-family: var(--font-num);
  font-size: var(--cell-fs, 18px);
  line-height: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--c-t1);
  cursor: pointer;
  transition: background .1s ease, color .1s ease;
}
@media (hover: hover) {
  .cell:hover:not(:disabled) { background: var(--c-btn-hover); }
}
/* 按下：只给视觉状态，不判断（判断在抬起时） */
.cell:active:not(:disabled),
.cell.is-pressed:not(:disabled) {
  background: var(--c-btn-active);
  transform: scale(.96);
}
.cell:disabled { cursor: default; }

/* 正确点击：≤150ms 极短确认，不残留颜色 */
@keyframes cellHit {
  0%   { transform: scale(1);    background: #2E2E2E; }
  45%  { transform: scale(.93);  background: #2E2E2E; }
  100% { transform: scale(1); }
}
.cell.is-hit { animation: cellHit .15s ease; }

/* 错误点击：短暂错误状态，随后立即进入失败页 */
.cell.is-bad {
  background: rgba(243, 114, 127, .22);
  color: var(--c-fail);
  transform: none;
}

/* 「记忆辅助」开启时才保留已点标记 */
.cell.is-done {
  background: var(--c-card);
  color: var(--c-t2);
  cursor: default;
}

/* 倒计时 / GO 覆盖层 */
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .14s ease;
}
.countdown.is-visible { opacity: 1; }
.countdown__text {
  font-family: var(--font-num);
  font-size: 84px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -2px;
  color: var(--c-t1);
}
.countdown__text.is-go {
  font-size: 60px;
  letter-spacing: 2px;
  color: var(--c-green);
}
@keyframes countPop {
  0%   { transform: scale(.72); opacity: 0; }
  40%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(1);   opacity: 1; }
}
.countdown__text.is-pop { animation: countPop .26s var(--ease); }

/* =========================================================
   04 / 05 结果页
   ========================================================= */

.result {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.result__mark { flex: none; width: 72px; height: 72px; }
.result__time {
  font-family: var(--font-num);
  font-size: 44px;
  line-height: 52px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1.2px;
  color: var(--c-t1);
}
.result__hint { font-size: 13px; line-height: 19px; font-weight: 400; color: var(--c-t2); }
.result__best { font-size: 13px; line-height: 19px; font-weight: 700; letter-spacing: .6px; }
.result__best.is-record { color: var(--c-green); }
.result__best.is-normal { font-weight: 400; color: var(--c-t3); }

/* 主按钮落在屏幕中部偏下（原型 170 / 247 两段） */
.result-gap--top    { flex: 170 1 0; min-height: 24px; }
.result-gap--bottom { flex: 247 1 0; min-height: 40px; }

/* =========================================================
   06 游戏记录 /records
   ========================================================= */

.records-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.rec {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.rec__diff { flex: 1 1 0; min-width: 0; font-size: 15px; line-height: 21px; font-weight: 500; color: var(--c-t1); }
.rec__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.rec__time {
  font-family: var(--font-num);
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
  color: var(--c-t1);
}
.rec__date {
  font-family: var(--font-num);
  font-size: 11px;
  line-height: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--c-t3);
}
.rec-div { height: 1px; background: var(--c-div); }

.records-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 0;
  font-size: 13px;
  line-height: 19px;
  color: var(--c-t3);
}
.records-footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 12px;
}
/* 删除属危险 / 低频操作，不做成主要视觉 */
.records__clear {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-app);
  font-size: 12px;
  line-height: 17px;
  color: var(--c-t3);
  cursor: pointer;
  transition: color .15s ease;
}
@media (hover: hover) {
  .records__clear:hover { color: var(--c-t2); }
}
.records__clear.is-armed { color: var(--c-fail); }

/* =========================================================
   07 游戏设置 /settings
   ========================================================= */

/* 设置项从顶部下移一段（原型 190px），不参与弹性分配 */
.settings-gap { flex: none; height: min(190px, 24vh); }

.setting {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  text-align: left;
  background: var(--c-card);
  border-radius: var(--radius);
}
.setting--tall { min-height: 84px; padding-top: 12px; padding-bottom: 12px; }
.setting__text { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.setting__text--gap4 { gap: 4px; }
.setting__name { font-size: 15px; line-height: 21px; font-weight: 500; color: var(--c-t1); }
.setting__value { font-size: 12px; line-height: 17px; font-weight: 400; color: var(--c-t2); }

.setting__input {
  width: 100%;
  padding: 0 0 3px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  color: var(--c-t2);
  font-family: var(--font-app);
  font-size: 12px;
  line-height: 17px;
  transition: color .15s ease, border-color .15s ease;
}
.setting__input::placeholder { color: var(--c-t3); }
.setting__input:focus {
  outline: none;
  color: var(--c-t1);
  border-bottom-color: var(--c-line);
}

.switch {
  flex: none;
  width: 48px;
  height: 28px;
  padding: 3px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--c-line);
  cursor: pointer;
  transition: background .18s ease;
}
.switch.is-on { background: var(--c-green); }
.switch__knob {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  transition: transform .18s ease;
}
.switch.is-on .switch__knob { transform: translateX(20px); }

/* =========================================================
   短屏适配
   ========================================================= */
@media (max-height: 700px) {
  .brand { padding-top: 28px; }
  .home__gap--top { min-height: 24px; }
  .home__gap--bottom { min-height: 32px; }
  .btn--primary { height: 58px; }
  .card { height: 88px; }
  .gap-72 { height: 44px; }
  .result__mark { width: 60px; height: 60px; }
  .result__time { font-size: 36px; line-height: 44px; }
}
@media (max-height: 620px) {
  .card { height: 76px; }
  .card__name { font-size: 19px; line-height: 26px; }
  .gap-72 { height: 28px; }
}

/* ---------- 动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
