/* 俄罗斯方块 · 经典版 — 深夜霓虹主题（与其他小游戏统一交互语言） */
:root {
  --bg: #0e1330;
  --bg-2: #090c20;
  --panel: rgba(255, 255, 255, .055);
  --line: rgba(140, 160, 255, .16);
  --text: #eef1ff;
  --dim: #9aa3c7;
  --accent: #6ea8ff;
  --gold: #ffd27a;
  --neon: #4dd7fa;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(110, 130, 255, .14), transparent 60%),
    radial-gradient(ellipse 70% 50% at 50% 110%, rgba(77, 215, 250, .08), transparent 65%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  overflow: hidden; user-select: none;
  display: flex; flex-direction: column;
}
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.modal[hidden] { display: none !important; }

/* 顶栏 */
.topbar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; padding: 8px 14px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .4), rgba(0, 0, 0, .12));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand .logo { font-size: 25px; filter: drop-shadow(0 0 8px rgba(77, 215, 250, .5)); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand-txt b { font-size: 18px; color: var(--neon); letter-spacing: 1px; text-shadow: 0 0 12px rgba(77, 215, 250, .45); }
.brand-txt small { font-size: 10px; color: var(--dim); letter-spacing: 1px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: flex; align-items: center; gap: 4px;
  background: rgba(0, 0, 0, .32); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 9px; font-size: 12px; color: var(--dim);
}
.chip b { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.chip.score b { color: var(--gold); }
.chip.bump { animation: bump .4s ease; }
@keyframes bump { 40% { transform: scale(1.18); } }
.tools { display: flex; gap: 6px; }
.tool {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .07); color: var(--text); font-size: 15px; cursor: pointer; transition: .15s;
}
.tool:hover { background: rgba(255, 255, 255, .16); }
.tool.off { opacity: .45; }

/* 主区 */
.playfield {
  flex: 1; min-height: 0; display: flex; justify-content: center;
  gap: 12px; padding: 10px 12px;
}
.side { display: flex; flex-direction: column; gap: 10px; flex: 0 0 auto; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; backdrop-filter: blur(4px);
}
.panel-title { font-size: 12px; color: var(--dim); letter-spacing: 2px; margin-bottom: 6px; }
.panel-title small { color: var(--accent); opacity: .8; }
.panel canvas { display: block; }
/* 预览画布固定 CSS 尺寸：防止 drawMini 重设 width 属性导致元素内在尺寸反馈放大 */
#hold { width: 96px; height: 72px; }
.next-stack canvas { width: 96px; height: 60px; }
.next-stack { display: flex; flex-direction: column; gap: 4px; }
.stats .stat, .keys .krow {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--dim); padding: 4px 0; border-bottom: 1px dashed rgba(140, 160, 255, .1);
}
.stats .stat:last-child, .keys .krow:last-child { border-bottom: none; }
.stats .stat b { color: var(--text); font-variant-numeric: tabular-nums; }
.keys .krow span { color: var(--accent); font-weight: 700; }

.center { display: flex; flex-direction: column; align-items: center; min-width: 0; min-height: 0; flex: 0 1 auto; }
.board-wrap { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; width: 100%; }
#board {
  display: block; border-radius: 10px;
  border: 1px solid rgba(140, 160, 255, .25);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5), 0 0 34px rgba(77, 140, 250, .18), 0 18px 44px rgba(0, 0, 0, .55);
  background: #0b102a;
}
.paused-tip {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(8, 10, 26, .72); border-radius: 10px;
  font-size: 16px; letter-spacing: 2px; color: var(--gold); backdrop-filter: blur(3px); z-index: 5;
}
.status { flex: 0 0 auto; text-align: center; font-size: 13px; color: var(--dim); padding: 8px 4px 2px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status .hl { color: var(--gold); }

/* 触屏控制 */
.touchpad { flex: 0 0 auto; display: none; gap: 8px; justify-content: center; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
.tbtn {
  width: 52px; height: 52px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .08); color: var(--text); font-size: 20px; font-weight: 700;
  touch-action: manipulation; transition: transform .08s;
}
.tbtn:active { transform: scale(.92); background: rgba(110, 168, 255, .25); }
.tbtn.hard { background: rgba(110, 168, 255, .22); border-color: rgba(110, 168, 255, .5); }

/* Toast */
.toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%) translateY(-10px);
  background: rgba(10, 14, 34, .92); border: 1px solid rgba(110, 168, 255, .5);
  color: var(--text); padding: 9px 20px; border-radius: 20px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 弹窗（与接龙牌/牌九统一交互语言） */
.modal { position: fixed; inset: 0; background: rgba(4, 6, 18, .82); display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal-card {
  background: linear-gradient(165deg, #1a2350, #101736);
  border: 1px solid rgba(110, 168, 255, .45); border-radius: 18px; padding: 24px 26px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .65), 0 0 40px rgba(77, 140, 250, .12);
  max-width: 94%; width: 430px; max-height: 88vh; overflow-y: auto; text-align: center;
  animation: modalIn .3s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(.94); } to { opacity: 1; transform: none; } }
.modal-card h2 { font-size: 24px; color: var(--neon); margin-bottom: 6px; text-shadow: 0 0 14px rgba(77, 215, 250, .4); }
.modal-card .sub { font-size: 12px; color: var(--dim); margin-bottom: 12px; }
.modal-card p { font-size: 13px; color: var(--text); margin: 6px 0; line-height: 1.6; }
.modal-btns { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.modal-btns .btn {
  border: 1px solid var(--line); background: rgba(255, 255, 255, .08); color: var(--text);
  padding: 10px 22px; border-radius: 10px; cursor: pointer; font-size: 15px; transition: .15s;
}
.modal-btns .btn:hover { background: rgba(255, 255, 255, .17); }
.modal-btns .btn.primary {
  background: linear-gradient(180deg, #79b0ff, #3f6fe0); color: #071033; font-weight: 800; border-color: rgba(140, 180, 255, .7);
  box-shadow: 0 4px 0 #2b4ca8, 0 8px 18px rgba(0, 0, 0, .4);
}
.modal-btns .btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #2b4ca8; }
.modal-btns .btn.ghost { background: transparent; }
.rule-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; text-align: left; }
.rule-table td { border: 1px solid rgba(140, 160, 255, .14); padding: 6px 8px; color: var(--text); }
.rule-table td:first-child { color: var(--accent); white-space: nowrap; font-weight: 700; }
.stats-line { font-size: 12px; color: #ffe2a8; margin-top: 8px; }

/* 结算（大分数 + 徽章 + 结算行，与另外两局统一） */
.result-score { text-align: center; margin: 4px 0 12px; }
.result-score .big { font-size: 44px; font-weight: 900; letter-spacing: 2px; color: var(--gold); text-shadow: 0 0 26px rgba(255, 210, 122, .45); font-variant-numeric: tabular-nums; }
.result-rows { background: rgba(0, 0, 0, .28); border-radius: 12px; padding: 10px 14px; font-size: 13px; }
.result-row { display: flex; justify-content: space-between; padding: 5px 0; color: var(--text); }
.result-row b { color: #fff; font-variant-numeric: tabular-nums; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 10px 0 2px; }
.badge { font-size: 11px; padding: 5px 10px; border-radius: 14px; background: rgba(110, 168, 255, .14); border: 1px solid rgba(110, 168, 255, .45); color: var(--accent); }
.badge.gold { background: rgba(255, 210, 122, .14); border-color: rgba(255, 210, 122, .5); color: var(--gold); }
.stat-line { text-align: center; font-size: 11px; color: var(--dim); margin-top: 12px; }

/* 特效 */
.fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 70; }
.confetti { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .75; } }

/* 响应式 */
@media (max-width: 760px) {
  .brand-txt small { display: none; }
  .chip { font-size: 10px; padding: 3px 7px; }
  .chip b { font-size: 12px; }
  .tool { width: 32px; height: 32px; font-size: 13px; }
  .playfield { flex-direction: column; align-items: center; gap: 6px; padding: 6px 8px 0; }
  .side { flex-direction: row; gap: 8px; align-items: stretch; }
  .panel { padding: 6px 8px; border-radius: 10px; }
  .panel-title { font-size: 10px; margin-bottom: 3px; }
  .panel-title small { display: none; }
  .panel canvas { width: 64px !important; height: 44px !important; }
  .next-stack { flex-direction: row; gap: 4px; }
  .next-stack canvas { width: 54px !important; height: 40px !important; }
  .side-right .keys { display: none; }
  .stats .stat { font-size: 10px; padding: 2px 0; }
  .status { font-size: 11px; padding: 4px; }
  .touchpad { display: flex; flex-wrap: wrap; }
  .tbtn { width: 48px; height: 48px; }
}
@media (max-width: 380px) {
  .tbtn { width: 42px; height: 42px; font-size: 17px; }
  .panel canvas { width: 52px !important; height: 38px !important; }
  .next-stack canvas { width: 44px !important; height: 34px !important; }
}
