/* 基础布局：16:9 舞台、竖屏提示、字体与通用按钮 */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #050404;
  color: var(--paper);
  font-family: var(--font-serif);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  display: grid;
  place-items: center;
}

/* hidden 属性优先于组件的 display 声明 */
[hidden] { display: none !important; }

/* ---------- 16:9 舞台 ---------- */
.stage {
  position: relative;
  width: min(100vw, 177.78vh);
  height: min(56.25vw, 100vh);
  /* hidden 仍然是个滚动容器：焦点跑到画面外时，浏览器会把舞台内部滚走。
     clip 不产生滚动容器，舞台永远钉在 0，弹窗里的按钮也不会把整页顶上去 */
  overflow: hidden;
  overflow: clip;
  background: #000;
  container-type: size;          /* 让 cqw / cqh 生效 */
  box-shadow: 0 0 12vh rgba(0, 0, 0, .9) inset;
}

/* 手机浏览器：100vh 是"地址栏收起时"的高度，非全屏时会让舞台底部被工具栏压住，
   道具栏正好在底部。改用动态视口单位，舞台跟着可视高度收缩。 */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
  .stage {
    width: min(100vw, 177.78dvh);
    height: min(56.25vw, 100dvh);
  }
}

/* 舞台外的暗角，弱化黑边存在感 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: 0 0 18vh 4vh #000 inset;
  z-index: 90;
}

/* ---------- 竖屏提示 ---------- */
.rotate-hint {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3vh;
  background: radial-gradient(circle at 50% 40%, #1a1512, #050404 70%);
  text-align: center;
  font-size: 1.05rem;
  letter-spacing: .12em;
  color: var(--paper-2);
}
.rotate-hint__icon {
  width: 13vh;
  height: 13vh;
  border: 2px solid var(--gold);
  border-radius: 1.2vh;
  position: relative;
  animation: tilt 2.4s var(--ease-in-out) infinite;
}
/* 补充提示：方向锁定 / 全屏，别抢主文案 */
.rotate-hint__tip {
  max-width: 24em;
  margin: -2vh 0 0;
  font-size: .84rem;
  line-height: 1.9;
  letter-spacing: .05em;
  color: rgba(200, 163, 90, .58);
}
.rotate-hint__tip + .rotate-hint__tip { margin-top: -1.8vh; }
.rotate-hint__icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 1.2vh;
  width: 3vh;
  height: 2px;
  background: var(--gold);
  transform: translateX(-50%);
  border-radius: 2px;
}
@keyframes tilt {
  0%, 30%   { transform: rotate(0deg); }
  60%, 90%  { transform: rotate(-90deg); }
  100%      { transform: rotate(-90deg); }
}
/* 只有触屏才用“请横置手机”接管画面：电脑上窄高窗口直接 letterbox 游玩 */
@media (orientation: portrait) and (max-width: 1100px) and (pointer: coarse) {
  .rotate-hint { display: flex; }
  .stage { visibility: hidden; }
}

/* ---------- 通用按钮 ---------- */
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
.btn {
  padding: .9cqw 1.8cqw;
  font-size: 1.05cqw;
  letter-spacing: .16em;
  border: 1px solid var(--line);
  color: var(--paper-2);
  background: linear-gradient(180deg, rgba(60, 48, 33, .55), rgba(20, 16, 12, .8));
  clip-path: polygon(4% 0, 100% 0, 96% 100%, 0 100%);
  transition: color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.btn:hover:not(:disabled) { color: var(--amber); border-color: var(--gold); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: default; }
.btn--primary { color: #1a1206; background: linear-gradient(180deg, var(--gold), #8a6a2e); border-color: #e0c07a; }
.btn--primary:hover:not(:disabled) { color: #000; }

/* ---------- 提示条 ---------- */
.toast-wrap {
  position: absolute;
  left: 50%;
  bottom: 19cqh;
  transition: bottom var(--dur) var(--ease-out);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1cqh;
  pointer-events: none;
  z-index: 270;             /* 高于模态层，解词 / 开箱时的自动合成提示才看得见 */
}
.toast {
  padding: .85cqw 1.8cqw;
  font-size: 1.12cqw;
  letter-spacing: .08em;
  color: var(--paper);
  background: linear-gradient(180deg, rgba(28, 22, 16, .94), rgba(10, 8, 6, .96));
  border: 1px solid var(--line);
  box-shadow: 0 1cqh 3cqh rgba(0, 0, 0, .6);
  animation: toast-in .28s var(--ease-out);
  max-width: 60cqw;
  text-align: center;
  line-height: 1.6;
  white-space: pre-line;
}
.toast[data-kind="warn"] { color: #f0c9a0; border-color: rgba(196, 68, 47, .5); }
.toast.is-out { animation: toast-out .3s var(--ease-in-out) forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(1.2cqh); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-.8cqh); } }

/* ---------- 存档提示 ---------- */
.saved {
  position: absolute;
  right: 1.6cqw;
  bottom: 1.6cqw;
  font-family: var(--font-sans);
  font-size: .78cqw;
  letter-spacing: .24em;
  color: rgba(200, 163, 90, .55);
  opacity: 0;
  transition: opacity var(--dur);
  pointer-events: none;
  z-index: 61;
}
.saved.show { opacity: 1; }
