/* ==========================================================================
   俄罗斯方块 · 页面样式（浅色科技风）
   与 tetris.js 的 DOM 契约：#board #boardWrap #side #nextList #holdCanvas
   #overlay(.hidden) .screen(.active) #recordBadge(.hidden) #keys #score
   #level #lines #best —— 改这些 id/class 前请同步 JS。
   断点 859px 与 JS 中 matchMedia('(max-width: 859px)') 必须一致。
   ========================================================================== */

/* 游戏区由 game-shell.css 的 .gstage 负责居中与撑满视口，
   本文件只管棋盘、侧栏与遮罩。 */

#stage {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(184px, 224px);
  grid-template-areas: "board side";
  gap: 18px;
  justify-content: center;
  align-items: start;
  width: 100%;
  padding-bottom: 4px;
}

/* ---- 棋盘：浅底 + 冷色描边 + 顶部科技光条 ---- */
#boardWrap {
  grid-area: board;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #eef2f8 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow:
    0 0 0 1px rgba(10, 92, 255, 0.06),
    var(--sh-3);
}
#boardWrap::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 3;
  background: linear-gradient(90deg, var(--brand), #ff6a3d 38%, var(--tech));
}
#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---- 侧栏 ---- */
#side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
#side .mini {
  display: block;
  width: 100%;
  min-width: 0;
  height: 56px;
  touch-action: manipulation;
}
#nextList { display: flex; flex-direction: column; gap: 5px; }
#nextList .mini { height: 46px; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* ---- 帮助条 ---- */
#help { margin: 14px 0 0; }

/* ---- 窄屏：砍掉大按键区，HUD 压成两行，把高度全部还给棋盘 ---- */
@media (max-width: 859px) {
  #stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "side" "board";
    gap: 8px;
  }
  /* 手机改用「手指抓块 + 顶栏三键」，九键大按键区整体隐藏 */
  #keys { display: none; }

  #side {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 5px;
  }
  #side .panel { min-width: 0; padding: 5px 7px; }
  #side .panel:nth-of-type(1) { grid-column: 1; grid-row: 1; }
  #side .panel:nth-of-type(2) { grid-column: 2; grid-row: 1; }
  #side .panel.stats { grid-column: 1 / -1; grid-row: 2; }
  #side .panel h2 { font-size: 8px; letter-spacing: 1px; margin: 0 0 2px; }

  #side .mini { height: 26px; }
  #nextList { flex-direction: row; gap: 3px; }
  #nextList .mini { flex: 1 1 0; height: 26px; }

  /* 四项数据排成一行小字，不再占一整块面板高度 */
  .stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 13px; padding: 2px 6px; }
  .stats .stat {
    display: flex; align-items: baseline; gap: 5px;
    padding: 0; background: none; border: 0; box-shadow: none;
    min-width: 0; overflow: visible;
  }
  .stats .stat:hover { background: none; border-color: transparent; }
  .stats .stat span { font-size: 8.5px; letter-spacing: 0.9px; }
  .stats .stat b { font-size: 15px; }

  #boardWrap { justify-self: center; border-radius: var(--r-md); }
  /* 遮罩只覆盖棋盘，卡片宽度受限，收紧内边距换回正文空间 */
  #overlay { padding: 10px; }
  #overlay .screen { padding: 20px 15px; }
  #overlay .screen h3 { font-size: 21px; }
  #overlay .screen ul { padding: 11px 12px; font-size: 11.5px; line-height: 1.95; }
  #overlay .screen p { font-size: 12.5px; }
  #help { display: none; }
}

/* 极窄屏：HUD 再收一档 */
@media (max-width: 430px) {
  #stage { gap: 6px; }
  #side { gap: 4px; }
  #side .panel { padding: 4px 5px; }
  #side .mini { height: 22px; }
  #nextList .mini { height: 22px; }
  .stats { gap: 1px 10px; padding: 3px 5px; }
  .stats .stat b { font-size: 14px; }
}