/* Blockfall — tokens 与布局取自原型 blockfall-prototype.html（2026-11-09 紫色终版）。
 * 原型壳（工具栏/侧栏/设备框/底部 tabs）与旧版布局（.play-layout/.controls/
 * .play-topbar）不在此文件里；生产游戏只保留游戏本身的样式。
 * 间距基准 8px；圆角：卡片 16px / 内嵌 12px / pill 全圆 / 圆钮正圆。
 */
:root {
  --play-bg: #652e94;
  --btn-purple: #4a1f73;
  --btn-line: rgba(219, 196, 255, 0.9);
  --side-panel: #2c0d58;
  --board-bg: #0a0e1f;
  --board-grid: #101629;
  --btn-continue: #7008e7;
  --btn-new: #f5f5f5;
  --ink: #2b3040;
  --ink-soft: #7a8199;
  --pill-border: #e3e3e3;
  --you-bg: #f7e7c3;
  --you-border: #edcf72;
  --r-card: 16px;
  --r-inner: 12px;
  --shadow-card: 0 12px 32px rgba(20, 24, 60, 0.14), 0 2px 6px rgba(20, 24, 60, 0.06);
  --shadow-pop: 0 16px 40px rgba(20, 24, 60, 0.22), 0 3px 8px rgba(20, 24, 60, 0.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--play-bg);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  height: 100dvh;
  display: flex;
  justify-content: center;
  overflow: hidden;
}
button, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* 游戏根：居中窄列（手机设计），填满 iframe 高度 */
.game-root {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- 游玩区 ---------- */
.board-panel {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background-color: var(--play-bg);
  overflow: hidden;
}
.screen-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 6px;
  align-self: center;
  width: 100%;
  max-width: 100%;
  justify-content: center;
  align-items: center;
}
/* 棋盘：宽由 JS 按框定（框宽 − 信息列 − 间距），高 16 行；信息列固定
 * 108px 宽（v1.0.2），「下一个」面板与之一致，不随棋盘变宽而被挤小。 */
.screen-frame .field-wrap { flex: none; min-width: 0; }
.field-wrap {
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--board-bg);
  border: 2px solid #9a67e8;
  border-radius: var(--r-inner);
  box-shadow: 0 0 18px rgba(46, 16, 92, 0.45), inset 0 2px 14px rgba(0, 0, 0, 0.55);
}
#field {
  background: var(--board-bg);
  border: none;
  border-radius: 8px;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.5);
  display: block;
}
/* 消行闪光 / 飘分 / 升级提示（纯展示层，不拦截操作） */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; border-radius: 12px; }
.fx-flash {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at 50% 55%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 65%);
}
.fx-flash.on { animation: flashAnim 0.35s ease-out; }
@keyframes flashAnim { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
.fx-float {
  position: absolute; left: 50%; top: 40%;
  transform: translate(-50%, 0);
  font-size: 26px; font-weight: 800; color: #ffe27a;
  text-shadow: 0 0 14px rgba(255, 173, 0, 0.85), 0 2px 6px rgba(0, 0, 0, 0.55);
  opacity: 0; white-space: nowrap;
}
.fx-float.on { animation: floatUp 1s ease-out; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -52px); }
}
.fx-level {
  position: absolute; left: 50%; top: 14px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #7008e7, #4f6dfe);
  color: #fff; font-size: 13px; font-weight: 800; letter-spacing: 0.04em;
  padding: 6px 18px; border-radius: 999px;
  box-shadow: 0 0 20px rgba(112, 8, 231, 0.65);
  opacity: 0; white-space: nowrap;
}
.fx-level.on { animation: levelPulse 1.2s ease; }
@keyframes levelPulse {
  0% { opacity: 0; transform: translateX(-50%) scale(0.7); }
  25% { opacity: 1; transform: translateX(-50%) scale(1.12); }
  45% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

/* ---------- 右侧信息列：每项独立深色面板 ----------
   顺序：下一个 → 得分 → 最高分 → 级别 → 消除行数 → 本局时长。
   标签居左（9px 浅紫），5 项数值居右（13px 白色粗体，贴面板内右边缘）。 */
.screen-side {
  flex: none; width: 108px; min-width: 0; display: flex; flex-direction: column; min-height: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  gap: 6px;
}
.side-item { display: flex; flex-direction: column; gap: 3px; flex: none; min-height: 0; }
.side-item .side-label { display: block; font-size: 9px; letter-spacing: 0.14em; color: #d9c6f5; line-height: 1.3; text-align: left; }
.side-panel {
  background: var(--side-panel);
  border-radius: 8px;
  padding: 5px 4px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.side-panel .side-num { display: block; font-size: 13px; font-weight: 800; color: #fff; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.side-item.next-item .side-panel { width: 100%; aspect-ratio: 1 / 1; }
.side-panel canvas { width: 72%; height: auto; display: block; }
.side-item.stat .side-panel { flex: none; min-width: 0; justify-content: flex-end; padding: 5px 6px; }
.side-item.stat .side-num { text-align: right; }

/* ---------- 小按钮行：暂停 / 音效 / 重玩居左、排行榜靠右 ---------- */
.function-row { display: flex; width: 100%; gap: 16px; align-items: flex-start; flex: none; padding: 0 8px; position: relative; z-index: 8; }
.small-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.small-btn {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--btn-line);
  background-color: var(--btn-purple);
  line-height: 1; color: #fff; display: flex; align-items: center; justify-content: center; padding: 0;
  box-shadow: 0 1px 3px rgba(30, 10, 60, 0.35);
  transition: filter 0.12s ease, background-color 0.12s ease;
}
.small-btn .ico { width: 12px; height: 12px; }
.small-btn:active { filter: brightness(0.8); }
.small-btn.off { filter: grayscale(0.6); opacity: 0.55; }
.small-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: #ecdcff; white-space: nowrap; text-align: center; }
.function-row .small-wrap.rank-end { margin-left: auto; }
.ico { display: block; flex: none; pointer-events: none; }
.ico .ico-slash { display: none; }
.off .ico .ico-slash { display: block; }
.off .ico .ico-waves { display: none; }

/* 音效设置小面板 */
.sound-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 52px;
  width: 248px;
  background: #ffffff;
  border: 1px solid #ccd5e2;
  border-radius: var(--r-card);
  box-shadow: var(--shadow-pop);
  padding: 16px;
  z-index: 9;
  color: var(--ink);
}
.function-row .sound-panel { top: calc(100% + 6px); left: 52px; right: auto; }
.sp-row { display: flex; align-items: center; gap: 10px; }
.sp-row + .sp-row { margin-top: 12px; }
.sp-title { font-size: 15px; font-weight: 800; flex: 1; }
.sp-label { font-size: 13px; color: var(--ink-soft); flex: none; }
.sp-switch {
  appearance: none;
  border: 1px solid var(--pill-border);
  background: #eef1f6;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  padding: 6px 16px;
  min-height: 34px;
  flex: none;
}
.sp-switch.on { background: var(--btn-continue); border-color: var(--btn-continue); color: #fff; }
.sound-panel input[type="range"] { flex: 1; min-width: 0; accent-color: var(--btn-continue); height: 28px; }
.sp-vol { font-size: 13px; font-weight: 700; width: 42px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }

/* ---------- 大按钮区：左掉落 108px + 右十字键 52px，底对齐 ---------- */
.big-controls { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex: none; padding: 0 10px; }
.drop-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; align-self: stretch; position: relative; }
.big-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--btn-purple);
  border: 1.5px solid var(--btn-line); color: #fff;
  box-shadow: 0 2px 6px rgba(30, 10, 60, 0.35);
  transition: background-color 0.12s ease, filter 0.12s ease;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.big-btn .ico { width: 24px; height: 24px; }
.drop-wrap .big-btn .ico { width: 42px; height: 42px; }
.big-btn:active:not(:disabled) { transform: none; filter: brightness(0.8); }
.big-btn:disabled { opacity: 0.35; cursor: default; }
.drop-wrap .big-btn { width: 108px; height: 108px; }
.big-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: #ecdcff; white-space: nowrap; text-align: center; }
.drop-wrap .big-label { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); }
.cross-pad { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, auto); gap: 2px 6px; align-items: start; }
.cross-cell { display: flex; flex-direction: column; align-items: center; }
.cross-pad .pos-up { grid-area: 1 / 2; } .cross-pad .pos-left { grid-area: 2 / 1; }
.cross-pad .pos-right { grid-area: 2 / 3; } .cross-pad .pos-down { grid-area: 3 / 2; }

/* ---------- 面板遮罩（暂停 / 结束） ---------- */
.panel-overlay {
  position: absolute; inset: 0;
  background: rgba(5, 7, 18, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 12;
}
#overOverlay { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.ov-box { text-align: center; max-width: 400px; width: 100%; }
.ov-title { margin: 0 0 8px; font-size: 30px; font-weight: 800; color: #ffffff; letter-spacing: 0.02em; }
.ov-sub { margin: 0 0 20px; font-size: 14px; color: #aebadd; line-height: 1.6; }
.record-badge {
  display: inline-block;
  background: linear-gradient(180deg, #ffc93c, #ffad00);
  color: #231a00;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  border-radius: 999px;
  padding: 5px 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(255, 173, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.ov-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 24px; }
.ov-stat { background: rgba(255, 255, 255, 0.06); border: 1px solid #2a3350; border-radius: var(--r-inner); padding: 12px 4px 10px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.ov-stat-label { display: block; font-size: 11px; color: #8fa3c8; letter-spacing: 0.08em; margin-bottom: 3px; }
.ov-stat-num { display: block; font-size: 20px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.ov-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  border-radius: 999px;
  padding: 11px 26px;
  min-height: 44px;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 4px 0 rgba(10, 14, 31, 0.28), 0 8px 18px rgba(10, 14, 31, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(10, 14, 31, 0.28), 0 3px 8px rgba(10, 14, 31, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-continue { background: linear-gradient(180deg, #8b2ff0, var(--btn-continue)); color: #fafafa; }
.btn-newlight { background: linear-gradient(180deg, #ffffff, var(--btn-new)); color: #3a3f4d; }
.btn-newwhite { background: linear-gradient(180deg, #ffffff, #e8ecf4); color: #141a2c; }

/* ---------- 排行榜 ---------- */
.rank-card {
  background: #ffffff;
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 24px;
  color: var(--ink);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 8px;
}
.rank-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.back-btn {
  appearance: none;
  background: #fff;
  border: 1px solid var(--pill-border);
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
  box-shadow: 0 2px 8px rgba(20, 24, 60, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 0.06s ease, box-shadow 0.06s ease, background 0.12s ease;
}
.back-btn:hover { background: #f4f6fa; }
.back-btn:active { transform: translateY(1px); box-shadow: 0 1px 4px rgba(20, 24, 60, 0.10); }
.rank-title { margin: 0; font-size: 20px; font-weight: 800; color: var(--ink); line-height: 1.2; }
.demo-tag {
  margin-left: auto;
  flex: none;
  background: #eef1f6;
  border: 1px solid var(--pill-border);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.rank-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid #edf0f5;
  border-radius: var(--r-card);
  background: #fff;
}
.rank-empty { padding: 24px 16px; text-align: center; font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid #eef1f6;
  font-size: 15px;
  color: var(--ink);
}
.rank-row:last-child { border-bottom: none; }
.rank-head-row {
  position: sticky; top: 0;
  background: #f8fafc;
  font-size: 12px;
  color: var(--ink-soft);
  padding-top: 8px; padding-bottom: 8px;
  z-index: 1;
}
.rank-no {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #eef1f6;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: none;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 2px rgba(20, 24, 60, 0.08);
}
.rank-head-row .rank-no-h { width: 30px; flex: none; text-align: center; }
.rank-row.top .rank-no { color: #fff; }
.rank-row.top .rank-name { font-weight: 800; }
.rank-row.top .rank-score { font-weight: 800; }
.rank-row.r1 .rank-no { background: radial-gradient(circle at 32% 28%, #ffe98a, #edc22e 58%, #d9a514); box-shadow: 0 2px 8px rgba(217, 165, 20, 0.45), inset 0 1px 2px rgba(255, 255, 255, 0.6); }
.rank-row.r2 .rank-no { background: radial-gradient(circle at 32% 28%, #f4f4f6, #c9cdd6 58%, #a7adb9); box-shadow: 0 2px 8px rgba(150, 158, 175, 0.40), inset 0 1px 2px rgba(255, 255, 255, 0.7); }
.rank-row.r3 .rank-no { background: radial-gradient(circle at 32% 28%, #f3c48d, #d99a5b 58%, #b97a3e); box-shadow: 0 2px 8px rgba(185, 122, 62, 0.40), inset 0 1px 2px rgba(255, 255, 255, 0.55); }
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { width: 84px; flex: none; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-row.you { background: var(--you-bg); box-shadow: inset 0 0 0 1.5px var(--you-border), 0 2px 10px rgba(217, 165, 20, 0.18); }
.rank-row.you .rank-no { background: #8f7a66; color: #fff; }
.rank-row.you .rank-name { font-weight: 800; }
.rank-row.you .rank-score { font-weight: 800; }
.rank-footer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--you-bg);
  border: 1.5px solid var(--you-border);
  border-radius: var(--r-card);
  padding: 12px 18px;
  margin-top: 16px;
  font-size: 15px;
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(20, 24, 60, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.rank-tag {
  flex: none;
  background: #fff;
  border: 1px solid var(--you-border);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.rank-footer .rank-name { font-weight: 800; }
.rank-footer .rank-score { font-weight: 800; }

/* ---------- 窄屏 ---------- */
@media (max-width: 340px) {
  .cross-pad { grid-template-columns: repeat(3, 46px); }
  .big-btn { width: 46px; height: 46px; }
  .drop-wrap .big-btn { width: 96px; height: 96px; }
  .rank-card { padding: 14px; }
  .ov-stats { grid-template-columns: repeat(2, 1fr); }
  .ov-title { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .fx-flash.on, .fx-float.on, .fx-level.on { animation: none; }
}
