/* 界面布局：灰色页面底上一块白色面板，面板里自上而下——标题区（游戏名、层数、评级、
   引导句、时间条）→ 画板 → 工具区 → 主按钮。
   只有题目本身（画板）和工具区描框，标题那一行和画板外面都不再套一层框，
   免得一眼看过去全是框。所有取值来自 tokens.css。 */

.app-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  overflow: hidden;
  padding: var(--safe-top) var(--space-4) var(--safe-bottom);
}

/* 中央面板：与页面底拉开层次。圆角比色鬼更小更紧，不用胶囊形状 */
.stage {
  display: flex;
  user-select: none;
  flex-direction: column;
  gap: var(--space-3);
  width: min(100%, var(--stage-max));
  /* 屏幕很高时不跟着拉：这本来就是一个竖屏的小游戏，面板再高画板就成了细长条，
     题目摆在里面全是空。到 --stage-tall 为止，多出来的高度留白 */
  height: min(100%, var(--stage-tall));
  min-height: 0;
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
  transition: background var(--transition-theme), border-color var(--transition-theme);
}

/* 手机上面板铺满整屏，没有两侧可分 */
@media (max-width: 639px) {
  .app-shell {
    padding: 0;
  }

  .stage {
    /* 手机上铺满整屏，不留那圈底色，也不套高度上限 */
    height: 100%;
    padding: var(--safe-top) var(--space-3) var(--safe-bottom);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

/* 区块外框：目前只有工具区用。圆角小而统一，和外层面板拉开一级 */
.box {
  border: var(--border-width-strong) solid var(--color-line-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  transition: background var(--transition-theme), border-color var(--transition-theme);
}

/* --- 标题区第一行：左暂停、中是游戏名、右骰子点数。
       这一行和层数同在标题区的框里，中间不再横一道边框 --- */

.masthead__top {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  min-height: 36px;
}

/* 游戏名与本层骰子并排，整体居中 */
.masthead__brand {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: center;
  min-width: 0;
}

/* 标题区的底色就是面板色，暂停键 hover 要比它再深一档才看得出来 */
.masthead__top .icon-button--flat:hover:not(:disabled) {
  background: var(--color-surface-soft);
}

.masthead__name {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 700;
  letter-spacing: 0.22em;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

/* 本层难度：单独一行落在层数下面。一百层之前是一个 1~10 的等级，之后换成抽到的那一档。
   难度一变就弹一下，免得悄悄变难没人发现 */
.masthead__level-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
  min-width: 0;
}

.level-diff {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 26px;
  padding: 0 var(--space-2);
  border: var(--border-width) solid currentColor;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

/* 英文的「Difficulty: Normal」比中文长不少，窄屏上收一档字号 */
@media (max-width: 420px) {
  .level-diff {
    padding: 0 6px;
    font-size: var(--font-size-xs);
  }
}

.level-diff:empty {
  display: none;
}

.level-diff--easy { color: var(--color-text-faint); }
.level-diff--normal { color: var(--color-text); }
.level-diff--hard { color: var(--color-tier-hard); }
.level-diff--hell { color: var(--color-danger); }

@keyframes diff-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.level-diff--changed {
  transform-origin: left center;
  animation: diff-bump 520ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 本层骰子：地狱版掷完挂在游戏名旁边。这里不用灰底方块——评级方块就是灰底方块，
   两者挨在一起会被当成同一类信息。改成一颗裸骰子加「×几」，说的是数量不是评级 */
.level-dice {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
  align-items: center;
  color: var(--color-accent);
}

.level-dice[hidden] {
  display: none;
}

.level-dice__cube {
  --dice-size: 22px;
  display: flex;
}

.level-dice .dice__face {
  border-width: var(--border-width);
  border-radius: 24%;
}

.level-dice__value {
  font-size: var(--font-size-md);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
}

/* 骰子点数：只报数，不接受点击——要花点数是在底部那个按钮上操作的。
   描边而不是浅底块：浅底块是评级方块的样子，两种东西挨在一起会被当成同一类。
   已经选了「维持难度」时整块填上强调色 */
.dice-points {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 36px;
  padding: 0 var(--space-2);
  border: var(--border-width-strong) solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font-size: var(--font-size-md);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.dice-points svg {
  width: 18px;
  height: 18px;
}


.dice-points--armed {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-ink);
}


/* --- 标题区：游戏名、层数与评级、引导句、时间条，全在同一个框里 --- */

.masthead {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: var(--space-2);
  align-items: stretch;
  padding: 0 var(--space-1) var(--space-1);
}

/* 主辅分栏：左边是层数与引导句（一组），右边贴着两个评级方块（另一组）。
   不再是「左要求、中层数、右得分」的三段式对称——那样三块互相争视觉中心，
   谁也不统属谁 */
.masthead__row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  justify-content: space-between;
}

.masthead__main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.masthead__grades {
  display: flex;
  flex: 0 0 auto;
  gap: var(--space-2);
}

.masthead__level {
  min-width: 0;
  overflow: hidden;
  font-size: clamp(21px, 6.6vw, 34px);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.15;
  text-align: left;
  white-space: nowrap;
}

/* 引导句独占一整行：挤在层数左边那一栏里的话，右边两个方块一占位就把它压成两行，
   而这句话本来就该一行说完。结算没通关时它会被清空，这里留一行的高度，
   免得整块跟着塌下去 */
.masthead__guide {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 22px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
}

/* 时间条：宽度由脚本每帧写入，不能加 width 过渡。方角矩形，不用胶囊形状 */
.timer-bar {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-soft);
}

.timer-bar__fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--color-text);
  transition: background var(--transition-theme);
}

/* 评级方块：左边是本层的通关要求，右边是结算后拿到的评级，分别贴在层数两侧。
   每一块都是三行——顶上一行小字说明这块是什么，中间是评级字母，底下是对应的
   百分比。固定宽高，空的时候就是一个空方块，不放占位符号 */
.grade-box {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 68px;
  min-height: 58px;
  padding: var(--space-1);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sm);
  background: transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.grade-box__caption {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.grade-box__letter {
  font-size: var(--font-size-xl);
  font-weight: 800;
  line-height: 1;
}

/* 百分比是评级下面单独一行，不和字母挤在同一行 */
.grade-box__score {
  min-height: 1em;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
}

/* 窄屏上两个方块收一点，给中间的层数留出位置 */
@media (max-width: 400px) {
  .grade-box {
    width: 60px;
    min-height: 54px;
  }
}

/* 还没结算的那一格放一个问号，和真的评级区分开 */
.grade-box--empty .grade-box__letter {
  color: var(--color-text-faint);
}

/* 过关没过关都是同一套黑白：画面上已经有「完成！」和「你挂了！」在说结果，
   方块再用红绿是重复，也让整页花掉 */
.grade-box--pass,
.grade-box--fail {
  border-color: var(--color-line-strong);
}

.grade-box--pass .grade-box__letter,
.grade-box--fail .grade-box__letter {
  color: var(--color-text);
}

/* 得分揭晓：方块弹一下，数字本身由脚本逐帧滚动到目标值 */
@keyframes grade-reveal {
  0% { transform: scale(0.75); }
  55% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.grade-box--reveal {
  animation: grade-reveal 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 通关要求比上一层高了：弹一下。要求长满之后不再变，这个动画也就不会再播 */
.grade-box--raised {
  animation: grade-reveal 520ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- 内容区：画板吃满剩余空间 --- */

.content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* 画板外面不再套框，这里只留一点点余量，画板自己吃满剩余空间 */
.board-wrap {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: var(--space-1) 0;
  overflow: hidden;
}

.board {
  position: relative;
  width: var(--board-width);
  height: var(--board-height);
  overflow: hidden;
  container-type: inline-size;
  border: var(--border-width-strong) solid var(--color-line-strong);
  border-radius: var(--radius-md);
  background: var(--color-board);
  touch-action: none;
  transition: background var(--transition-theme), border-color var(--transition-theme);
}

.board__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 遮罩必须压在两层画布之上，否则「点击开始」点不到；暂停时也靠它遮住图形 */
.board__overlay {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--color-board);
  color: var(--color-text);
}

.board__overlay[hidden] {
  display: none;
}

/* 结算横幅：盖在画板正中央。没通关是红底白字的「你挂了！」，过关是「完成！」
   加一行小字，都只占文字周围一小块，画板其余地方仍看得见结算对比 */
.board__banner {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  pointer-events: none;
}

.board__banner[hidden] {
  display: none;
}

.board__banner {
  flex-direction: column;
  gap: var(--space-4);
}

/* 中文的句末标点是全角，要补满一个字宽 */
html[lang="zh"] .board__banner-text {
  padding-left: 1em;
}

/* 结算时颜色那一栏整条换成一个副按钮，下面那一栏还是主按钮：两栏各一个按钮、
   位置不动，画板中央只剩一行大字。
   行高和工具区取同一个值：两者互换时整条的高度不变，画板不会跟着重新量一遍尺寸，
   底下的主按钮也不会跳 */
.result-row {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: var(--action-row-height);
}

.result-row[hidden] {
  display: none;
}

.result-row .side-button {
  flex: 1 1 auto;
  min-height: 56px;
  font-size: var(--font-size-lg);
  letter-spacing: 0.06em;
}

.tools[hidden] {
  display: none;
}

/* 结算横幅就是一行大字，不套底色块——底色块压在画板上又厚又挡，
   靠画板底色晕开的一圈阴影把字和下面的线条分开就够了 */
/* 居中只看文字，不把句末那个感叹号算进去：左边补一个标点的宽度，
   居中之后文字本身正好落在中线上（中文是全角，补 1em；英文的叹号窄，补 0.3em） */
.board__banner-text {
  padding-left: 0.3em;
  color: var(--color-text);
  /* 字号跟着画板宽度走（cqw），配上 nowrap，不管画板多窄都是一行；
     前一条是不支持容器查询单位时的退路 */
  font-size: clamp(32px, 12vw, 64px);
  font-size: clamp(32px, 17cqw, 72px);
  white-space: nowrap;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.15;
  text-shadow:
    0 0 16px var(--color-board),
    0 0 16px var(--color-board),
    0 0 8px var(--color-board),
    0 0 3px var(--color-board),
    0 2px 0 var(--color-board),
    0 -2px 0 var(--color-board),
    2px 0 0 var(--color-board),
    -2px 0 0 var(--color-board);
  animation: banner-in 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes banner-in {
  from { transform: scale(0.86); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* 得分揭晓：结算后先在画板正中央把数字滚出来，停一下再收起，
   收起之后标题区右边的方块才接上最终结果 */
.board__reveal {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  pointer-events: none;
}

.board__reveal[hidden] {
  display: none;
}

.board__reveal-grade:empty {
  display: none;
}

/* 中央揭晓的只有分数，字号给足；评级字母留给右上角那个方块 */
.board__reveal-score {
  color: var(--color-text);
  font-size: clamp(44px, 18vw, 88px);
  font-size: clamp(44px, 22cqw, 88px);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
}

@keyframes reveal-in {
  from { transform: scale(0.55); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes reveal-out {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(0.72) translateY(-10%); opacity: 0; }
}

.board__reveal--in {
  animation: reveal-in 380ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 收起要排在入场之后声明：两个类同时挂在元素上时，后写的这条才是生效的那条 */
.board__reveal--out {
  animation: reveal-out 260ms ease forwards;
}

.board__start {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-2xl);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.board__start[hidden] {
  display: none;
}

.board__start:hover {
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 8px;
}

.board__dice {
  --dice-size: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board__dice[hidden] {
  display: none;
}

/* --- 工具区：调色板与撤销重做清空，同一行，各自装在一条托盘里 --- */

.tools {
  display: flex;
  flex: 0 0 auto;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  min-height: var(--action-row-height);
  padding: var(--space-2) var(--space-3);
}

.tray {
  display: flex;
  gap: var(--space-1);
  align-items: center;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--color-surface-soft);
  transition: background var(--transition-theme);
}

.tools__actions {
  margin-left: auto;
}

/* 色块看着是 40，点击区域按 44 给：手机上更小就点不准了。
   选中的那圈画在 ::before 上，跟着看得见的那 40 走，不跟着点击区放大 */
.swatch {
  position: relative;
  display: grid;
  width: var(--control-size);
  height: var(--control-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  place-items: center;
  transition: transform var(--transition-fast);
}

.swatch__dot {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--swatch-color);
  box-shadow: inset 0 0 0 1px var(--color-swatch-edge);
}

/* 观察阶段调色板不可点，但颜色本身要看得清，不跟着按钮统一变淡 */
.swatch:disabled {
  opacity: 1;
}

.swatch:hover:not(:disabled) {
  transform: translateY(-2px);
}

.swatch::before {
  content: '';
  position: absolute;
  width: 40px;
  height: 40px;
  border: var(--border-width-strong) solid transparent;
  border-radius: 50%;
  transition: border-color var(--transition-fast);
}

.swatch[aria-pressed="true"]::before {
  border-color: var(--color-line-strong);
}

/* --- 按钮 --- */

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: var(--control-size);
  height: var(--control-size);
  padding: 0;
  border: var(--border-width-strong) solid var(--color-line-strong);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text);
  place-items: center;
  transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.icon-button:hover:not(:disabled) {
  background: var(--color-surface-soft);
}

/* 托盘里的按钮不再各自描边 */
/* 无框的图标键（暂停、撤销重做清空）。看上去小一圈，但点击区域仍是 44×44：
   手机上比这更小就点不准了 */
.icon-button--flat {
  width: var(--control-size);
  height: var(--control-size);
  border-color: transparent;
  background: transparent;
}

.icon-button--flat svg {
  width: 18px;
  height: 18px;
}

.icon-button--flat:hover:not(:disabled) {
  border-color: transparent;
  background: var(--color-surface);
}

.ghost-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-size);
  padding: 0 var(--space-4);
  border: var(--border-width-strong) solid var(--color-line-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-md);
  font-weight: 700;
  transition: background var(--transition-fast);
}

.ghost-button:hover:not(:disabled) {
  background: var(--color-surface-soft);
}

.primary-button {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 var(--space-5);
  border: var(--border-width-strong) solid var(--color-accent);
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-accent-ink);
  font-size: var(--font-size-lg);
  font-weight: 800;
  letter-spacing: 0.12em;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.primary-button svg {
  width: 24px;
  height: 24px;
}

.primary-button:hover:not(:disabled) {
  border-color: var(--color-accent-hover);
  background: var(--color-accent-hover);
}

.icon-button:active:not(:disabled),
.ghost-button:active:not(:disabled),
.primary-button:active:not(:disabled) {
  transform: translateY(2px);
}

.primary-button:disabled {
  border-color: var(--color-line);
  background: var(--color-surface);
  color: var(--color-text-faint);
  opacity: 1;
}

/* 底部一行：没通关时左边多一个复活，这时两个按钮等宽平分；只有主按钮时它独占整行 */
.bottom-row {
  display: flex;
  flex: 0 0 auto;
  gap: var(--space-2);
  align-items: stretch;
}

.bottom-row .primary-button {
  flex: 1 1 auto;
  min-width: 0;
}

.side-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 var(--space-4);
  border: var(--border-width-strong) solid var(--color-accent);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-accent);
  font-size: var(--font-size-md);
  font-weight: 800;
  white-space: nowrap;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.side-button[hidden] {
  display: none;
}

/* 已经选了「维持难度」：按钮填成实心，再点一次取消 */
.side-button--armed {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}

.side-button--armed:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

@media (max-width: 400px) {
  .side-button {
    padding: 0 var(--space-2);
    font-size: var(--font-size-sm);
  }

  .bottom-row .primary-button {
    padding: 0 var(--space-3);
    letter-spacing: 0.06em;
  }
}

.side-button:hover:not(:disabled) {
  background: var(--color-surface-soft);
}

/* 点数不够时按钮仍在，只是点不动 */
.side-button:disabled {
  border-color: var(--color-line);
  background: var(--color-surface);
  color: var(--color-text-faint);
  opacity: 1;
}

.side-button:active:not(:disabled) {
  transform: translateY(2px);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.primary-button.shake {
  animation: shake 320ms ease;
}

/* 骰子在引导句那一行说了新的一句，暂停键抖一下 */
.icon-button--nudge {
  animation: shake 320ms ease;
}

/* --- 弹窗 --- */

.modal-backdrop {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: var(--color-backdrop);
}

.modal {
  display: flex;
  flex-direction: column;
  user-select: none;
  gap: var(--space-4);
  width: min(100%, 340px);
  padding: var(--space-5);
  border: var(--border-width-strong) solid var(--color-line-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-modal);
  text-align: center;
}

.modal__title {
  font-size: var(--font-size-lg);
  font-weight: 800;
}

.modal__message {
  color: var(--color-text-muted);
  font-size: var(--font-size-md);
}

.modal__actions {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: 1fr 1fr;
}

.modal__actions .ghost-button,
.modal__actions .primary-button {
  min-height: var(--control-size);
  padding: 0 var(--space-4);
  font-size: var(--font-size-md);
  letter-spacing: 0;
}

/* 暂停弹窗：一列按钮，底下是骰子架；整块可以按住拖动 */
.modal--pause {
  gap: var(--space-4);
  /* 中英文的按钮长短不同，不定死的话换一种语言弹窗就变一个高矮，
     这里按长的那一版固定住 */
  min-height: min(560px, calc(100dvh - var(--space-5) * 2));
  max-height: calc(100dvh - var(--space-5) * 2);
  overflow-y: auto;
  cursor: grab;
  user-select: none;
  touch-action: none;
  will-change: transform;
}

.modal--dragging {
  cursor: grabbing;
}

.pause__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: stretch;
}

.pause__actions .ghost-button,
.pause__actions .primary-button {
  height: var(--control-size);
  min-height: var(--control-size);
  padding: 0 var(--space-2);
  font-size: var(--font-size-md);
  letter-spacing: 0;
  white-space: nowrap;
}

/* 骰子架吃掉弹窗多出来的高度，这样中英文两版一样高 */
.pause__rack {
  flex: 1 1 auto;
  justify-content: center;
}

.pause__shelf {
  flex: 1 1 auto;
}

/* 语言二选一：照色鬼的做法框起来摊开，左边中文右边英文，当前这一种是实心的。
   位置在三个操作按钮下面、骰子架上面 */
.pause__choice {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: 1fr 1fr;
  padding: var(--space-2);
  border: var(--border-width) solid var(--color-line-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-soft);
}

.pause__choice .ghost-button,
.pause__choice .primary-button {
  min-height: var(--control-size);
  padding: 0 var(--space-2);
  font-size: var(--font-size-md);
  letter-spacing: 0;
}

/* 骰子架：与按钮之间一道分隔线 */
.pause__rack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: var(--border-width) solid var(--color-line);
}

.pause__shelf {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--dice-size) + var(--space-5));
  border: var(--border-width) solid var(--color-line);
  border-bottom: 4px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-soft);
}

.pause__sign {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 700;
}

@media (max-height: 720px) {
  .pause__shelf {
    min-height: calc(var(--dice-size) + var(--space-4));
  }

  .pause__rack {
    padding-top: var(--space-3);
  }
}

/* --- 工作室标注：暂停弹窗最下面，头像在左、三行说明在右 --- */

.studio {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding-top: var(--space-4);
  border-top: var(--border-width) solid var(--color-line);
  text-align: left;
}

.studio__avatar {
  display: block;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.studio__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.studio__text > * {
  min-width: 0;
}

.studio__maker {
  margin: 0;
  font-size: var(--font-size-sm);
  font-weight: 800;
  line-height: 1.35;
}

.studio__channels {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  line-height: 1.35;
}

.studio__link {
  color: var(--color-text);
  font-size: var(--font-size-xs);
  font-weight: 700;
  line-height: 1.5;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 第二行与链接连读成一句：「……请前往→ 哐哐的个人站。」 */
.studio__channels,
.studio__link {
  display: inline;
}

.studio__link:hover {
  color: var(--color-accent);
}

/* --- 骰子：3D 六面体 --- */

.dice {
  --dice-jiggle: 0;
  --dice-half: calc(var(--dice-size) / 2);
  width: var(--dice-size);
  height: var(--dice-size);
  perspective: calc(var(--dice-size) * 5);
  animation: dice-jiggle 140ms ease-in-out infinite alternate;
}

.dice__cube {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.dice__face {
  position: absolute;
  inset: 0;
  display: grid;
  padding: 15%;
  border: var(--border-width-strong) solid var(--color-line-strong);
  border-radius: 18%;
  background: var(--color-dice);
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  backface-visibility: hidden;
}

/* 对面点数之和为七 */
.dice__face[data-face="1"] { transform: translateZ(var(--dice-half)); }
.dice__face[data-face="6"] { transform: rotateY(180deg) translateZ(var(--dice-half)); }
.dice__face[data-face="2"] { transform: rotateY(90deg) translateZ(var(--dice-half)); }
.dice__face[data-face="5"] { transform: rotateY(-90deg) translateZ(var(--dice-half)); }
.dice__face[data-face="3"] { transform: rotateX(90deg) translateZ(var(--dice-half)); }
.dice__face[data-face="4"] { transform: rotateX(-90deg) translateZ(var(--dice-half)); }

.dice__pip {
  width: 62%;
  height: 62%;
  border-radius: 50%;
  background: var(--color-dice-pip);
  opacity: 0;
}

/* 点的排布：九宫格按行编号 1~9 */
.dice__face[data-face="1"] .dice__pip:nth-child(5),
.dice__face[data-face="2"] .dice__pip:nth-child(3),
.dice__face[data-face="2"] .dice__pip:nth-child(7),
.dice__face[data-face="3"] .dice__pip:nth-child(3),
.dice__face[data-face="3"] .dice__pip:nth-child(5),
.dice__face[data-face="3"] .dice__pip:nth-child(7),
.dice__face[data-face="4"] .dice__pip:nth-child(1),
.dice__face[data-face="4"] .dice__pip:nth-child(3),
.dice__face[data-face="4"] .dice__pip:nth-child(7),
.dice__face[data-face="4"] .dice__pip:nth-child(9),
.dice__face[data-face="5"] .dice__pip:nth-child(1),
.dice__face[data-face="5"] .dice__pip:nth-child(3),
.dice__face[data-face="5"] .dice__pip:nth-child(5),
.dice__face[data-face="5"] .dice__pip:nth-child(7),
.dice__face[data-face="5"] .dice__pip:nth-child(9),
.dice__face[data-face="6"] .dice__pip:nth-child(1),
.dice__face[data-face="6"] .dice__pip:nth-child(3),
.dice__face[data-face="6"] .dice__pip:nth-child(4),
.dice__face[data-face="6"] .dice__pip:nth-child(6),
.dice__face[data-face="6"] .dice__pip:nth-child(7),
.dice__face[data-face="6"] .dice__pip:nth-child(9) {
  opacity: 1;
}

/* 摇晃弹窗时骰子跟着抖，幅度由 --dice-jiggle（0~1）决定 */
@keyframes dice-jiggle {
  from { transform: rotate(calc(var(--dice-jiggle) * -14deg)) translateY(calc(var(--dice-jiggle) * -3px)); }
  to { transform: rotate(calc(var(--dice-jiggle) * 14deg)) translateY(calc(var(--dice-jiggle) * 2px)); }
}

@keyframes dice-land {
  0% { transform: scale(1.18); }
  60% { transform: scale(0.94); }
  100% { transform: scale(1); }
}

.dice--rolling,
.dice--fixed {
  animation: none;
}

.dice--landed {
  animation: dice-land 320ms ease-out;
}

.dice--gone {
  visibility: hidden;
}

/* 从弹窗里掉出来的那颗：固定定位，压在弹窗之上 */
.dice--falling {
  position: fixed;
  z-index: 20;
  margin: 0;
  animation: none;
  pointer-events: none;
}
