/* ==========================================================================
   Questar 增强层 (qs-enhance.css)
   在原有样式之后加载，只做覆盖，不改动游戏逻辑与坐标系统。
   目标：竖屏可玩、窄屏不溢出、移动端更顺滑。
   ========================================================================== */

/* ---------- 1. 竖屏不再整屏拦截 ---------- */
/* 原逻辑用「请转动平板」全屏遮罩挡住竖屏，竖屏下完全无法使用。
   改为允许竖屏游玩，用轻量提示条代替。 */
.rotate {
  display: none !important;
}

/* ---------- 2. 竖屏布局修正 ---------- */
/* 根因：.screen 的 padding-block 用了 --qs-stepper-clear，
   该值按「舞台高度」推算；竖屏时舞台只有屏宽 * 834/1194，
   上下留白各吃掉 300px 以上，内容区被压到几十像素，
   角色轮盘（依赖容器查询高度 100cqh）因此塌缩成一个点。
   这里把步骤条沉到视口底部，内容区恢复满高。 */
@media (orientation: portrait) {
  .app__stepper {
    inset-block-start: auto !important;
    inset-block-end: 0 !important;
    translate: -50% 0 !important;
    width: 100% !important;
    height: calc(var(--qs-stepper-pip) + 3.25rem + env(safe-area-inset-bottom, 0px)) !important;
    aspect-ratio: auto !important;
  }

  .app__stepper-pips {
    inset-block-end: calc(1rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  .screen {
    padding-block:
      calc(clamp(2.25rem, 7vh, 3.5rem) + env(safe-area-inset-top, 0px))
      calc(clamp(3.5rem, 9vh, 4.75rem) + env(safe-area-inset-bottom, 0px)) !important;
  }

  .screen__title {
    font-size: clamp(1.45rem, 6vw, 2.4rem) !important;
  }

  /* 轮盘改为按视口高度取尺寸，彻底摆脱容器高度塌陷 */
  .character__wheel {
    --qs-wheel-height: clamp(240px, 52vh, 520px) !important;
    --qs-wheel-item: min(clamp(180px, 44vw, 440px), 46vh) !important;
  }
}

/* 极矮视口（横屏手机）同样兜底，避免轮盘高度归零 */
@media (max-height: 480px) {
  .character__wheel {
    --qs-wheel-height: clamp(180px, 54vh, 460px) !important;
    --qs-wheel-item: min(clamp(150px, 34vh, 380px), 52vh) !important;
  }
}

/* 横屏手机：队名原本按视口宽度定字号，贴着屏幕下沿几乎被切，
   上提一点并压小字号，给安全区留出余量 */
@media (orientation: landscape) and (max-height: 520px) {
  .board__team {
    top: 84.5% !important;
    font-size: calc(clamp(1.5rem, 4.2vw, 2.6rem) * var(--qs-team-squeeze, 1)) !important;
  }
}

/* ---------- 3. 窄舞台：菜单键不再被挤出屏幕 ---------- */
/* .menu-button 有 min-width:64px，而它在舞台上只有 7.75% 宽。
   舞台宽度 < 826px 时按钮被撑到 64px，从右侧溢出被裁掉。
   改为右对齐锚定 + 48px 最小点击区，向左生长就不会溢出。 */
@media (max-width: 900px) {
  .menu-button {
    left: auto !important;
    right: 5.36% !important;
    min-width: 48px !important;
    min-height: 48px !important;
  }
}

/* ---------- 4. 移动端降低合成开销 ---------- */
/* backdrop-filter 在 iPad / 中低端安卓上很贵，模糊半径降一档观感几乎无损 */
@media (pointer: coarse) {
  :root {
    --qs-glass-blur: 8px;
    --qs-veil-blur: 5px;
  }
}

/* ---------- 5. 触摸细节 ---------- */
html,
body {
  overscroll-behavior: none;
}

img {
  -webkit-user-drag: none;
  user-select: none;
}

/* 关闭 iOS 长按图片弹出的「存储图像」菜单 */
body img {
  -webkit-touch-callout: none;
}

/* ---------- 6. 软键盘避让 ---------- */
/* iOS 弹出键盘时页面不重排，输入框会被挡住；
   qs-enhance.js 会写入 --qs-kb-shift，这里把内容区上推。 */
.screen {
  translate: 0 var(--qs-kb-shift, 0px);
  transition: translate 0.24s cubic-bezier(0.2, 0.9, 0.35, 1);
}

/* ---------- 7. 小游戏倒计时可读性 ---------- */
/* 原始样式把倒计时压到 0.6 透明度，压在花纹背景上几乎看不清；
   儿童用户在最后 10 秒需要明确的时间感，这里提亮并加描边。 */
.sparks__clock {
  opacity: 0.86 !important;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95), 0 0 2px rgba(0, 0, 0, 0.7) !important;
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .qs-hint {
    transition: none !important;
  }
}

/* ---------- 6. 竖屏提示条 ---------- */
.qs-hint {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 4px 6px 4px 12px;
  border: 0.5px solid rgba(247, 239, 227, 0.22);
  border-radius: 999px;
  background: rgba(43, 31, 24, 0.82);
  color: #f7efe3;
  font-family: var(--qs-font-ui, system-ui, sans-serif);
  font-size: 12.5px;
  line-height: 1;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  translate: -50% -8px;
  transition: opacity 0.32s ease, translate 0.32s cubic-bezier(0.2, 1, 0.4, 1);
  pointer-events: none;
}

.qs-hint.is-on {
  opacity: 1;
  translate: -50% 0;
  pointer-events: auto;
}

.qs-hint__icon {
  font-size: 15px;
  color: #f2c230;
  line-height: 1;
}

.qs-hint__close {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #f7efe3;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

/* 视觉上 28px，实际点击区扩到 42px，方便手指按 */
.qs-hint__close::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
}

.qs-hint__close:active {
  background: rgba(255, 255, 255, 0.22);
}
