:root{
  --bg:#0f1115; --panel:#1a1d24; --line:#2a2f3a;
  --text:#e8eaf0; --muted:#8b93a7; --accent:#4f8cff;
}
*{margin:0;padding:0;box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
html,body{height:100%}
body{
  background:var(--bg); color:var(--text);
  font-family:Arial,"Microsoft YaHei","PingFang SC",sans-serif;
  display:flex; align-items:center; justify-content:center;
  touch-action:manipulation;
  overscroll-behavior:none;
}
canvas{
  -webkit-touch-callout:none; -webkit-user-select:none; user-select:none;
}
.page{padding:16px}
.back{
  color:var(--muted); text-decoration:none; font-size:13px;
  display:inline-block; margin-bottom:10px;
}
.back:hover{color:var(--text)}
.game{display:flex; gap:14px; align-items:flex-start; justify-content:center}
.side{display:flex; flex-direction:column; gap:12px; width:130px}
.panel{
  background:var(--panel); border:1px solid var(--line);
  border-radius:10px; padding:10px;
}
.panel-title{
  font-size:11px; color:var(--muted); letter-spacing:2px; margin-bottom:8px;
}
.panel canvas{display:block; margin:0 auto}
#hold{width:96px;height:96px}
#next{width:96px;height:264px}
.stats .stat{
  display:flex; justify-content:space-between; align-items:baseline;
  padding:5px 2px;
}
.stat .label{font-size:12px; color:var(--muted)}
.stat .value{font-size:17px; font-weight:bold; font-variant-numeric:tabular-nums}
.keys{font-size:12px; color:var(--muted); line-height:1.9}
.key-row b{color:var(--text); display:inline-block; min-width:38px}

.board-wrap{position:relative; touch-action:none}
#board{
  display:block; background:#12151c;
  border:1px solid var(--line); border-radius:6px;
  width:300px; height:600px;
}
.overlay{
  position:absolute; inset:0; border-radius:6px;
  background:rgba(10,12,16,.82); backdrop-filter:blur(2px);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:14px; text-align:center;
}
.overlay.hidden{display:none}
.overlay-title{font-size:24px; font-weight:bold; letter-spacing:2px}
.overlay-sub{font-size:13px; color:var(--muted); line-height:2}
.btn{
  background:var(--accent); color:#fff; border:none; border-radius:8px;
  padding:10px 28px; font-size:15px; cursor:pointer;
  font-family:inherit;
}
.btn:hover{filter:brightness(1.1)}

/* 手机竖屏：面板压缩成顶栏，棋盘按剩余高度缩放，目标一屏放下不滚动 */
@media (max-width:640px){
  body{align-items:flex-start}
  .page{
    padding:8px calc(8px + env(safe-area-inset-right))
            calc(8px + env(safe-area-inset-bottom))
            calc(8px + env(safe-area-inset-left));
    padding-top:calc(8px + env(safe-area-inset-top));
    width:100%;
  }
  .back{margin-bottom:6px}
  .p-keys{display:none}
  .game{display:grid; grid-template-columns:auto 1fr auto; gap:8px; align-items:stretch}
  .side{display:contents}
  .p-hold{grid-row:1; grid-column:1}
  .p-stats{grid-row:1; grid-column:2}
  .p-next{grid-row:1; grid-column:3}
  .board-wrap{grid-row:2; grid-column:1 / -1; margin:0 auto}
  #board{width:min(88vw, calc((100dvh - 250px) / 2)); height:auto; aspect-ratio:1/2}
  #hold{width:48px;height:48px}
  #next{width:44px;height:121px}
  .panel{padding:8px}
  .panel-title{margin-bottom:4px; letter-spacing:1px}
  .stats .stat{padding:2px}
  .stat .label{font-size:11px}
  .stat .value{font-size:14px}
}
