/* h5/styles/shell.css - Candy Nuts Sort H5 桌面与移动端自适应外壳样式 (任务卡-121 + L5 unslop 精修) */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* 温暖木质工作台单色阶（高对比中性色，克制单一强调色） */
  --wb-bg: #F1E5D3;
  --wb-bg-edge: #E5D4BA;
  --wb-surface: #FFF9F0;
  --wb-surface-muted: #F4E7D4;
  --wb-border: rgba(74, 40, 16, 0.14);
  --wb-border-strong: rgba(74, 40, 16, 0.22);
  --wb-ink: #3E220D;
  --wb-ink-secondary: #68462A;
  --wb-ink-muted: #846346;
  --wb-accent: #C45214;
  --wb-accent-strong: #9F3E0A;
  --wb-keycap-bg: #FFFDF9;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--wb-ink);
  background: radial-gradient(circle at 50% 40%, var(--wb-bg) 0%, var(--wb-bg-edge) 100%);
}

#h5-viewport {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 24px;
}

#h5-stage-frame {
  position: relative;
  aspect-ratio: 9 / 16;
  height: min(calc(100dvh - 80px), 920px);
  width: auto;
  max-width: calc(100vw - 48px);
  max-height: calc(100dvh - 80px);
  border-radius: 16px;
  overflow: hidden;
  background: #FFEAF3;
  border: 1px solid var(--wb-border);
  box-shadow: 0 16px 40px rgba(45, 24, 10, 0.14), 0 2px 8px rgba(45, 24, 10, 0.06);
}

#game-container {
  width: 100%;
  height: 100%;
  background: #FFEAF3;
}

#game-container canvas {
  display: block;
}

/* HTML 首屏暖粉加载层：消除紫粉渐变与紫色光晕，无缝托底至 BootScene */
.h5-boot-loader {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  background: #FFEAF3;
  transition: opacity 0.24s ease-out;
}

.h5-boot-loader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.h5-boot-mark {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  border: 2px solid #FFF9F0;
  box-shadow: 0 6px 16px rgba(74, 40, 16, 0.12);
}

.h5-boot-label {
  font-size: 16px;
  font-weight: 500;
  color: var(--wb-ink);
}

/* 桌面端底部键盘提示条（移动端隐藏，严格 4px 栅格与克制圆角） */
.h5-key-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 32px;
  padding: 4px 16px;
  border-radius: 10px;
  background: rgba(255, 249, 240, 0.88);
  border: 1px solid var(--wb-border);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--wb-ink-secondary);
}

.h5-key-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.h5-key-item kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--wb-keycap-bg);
  border: 1px solid var(--wb-border-strong);
  border-bottom-width: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--wb-ink);
}

/* 预留 H5 横幅槽：默认折叠 0px 高度，激活后才在游戏框外部占高 */
.h5-banner-slot {
  display: none;
  width: min(728px, 100%);
  min-height: 56px;
  max-height: 90px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--wb-surface);
  border: 1px solid var(--wb-border);
  color: var(--wb-ink-muted);
  font-size: 13px;
  font-weight: 500;
}

/* 可控 H5 激励广告预览弹框（去毛玻璃模糊与全大写胶囊，对齐 4px 栅格） */
.h5-ad-preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999950;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(34, 18, 8, 0.72);
}

.h5-ad-preview-card {
  width: min(392px, 100%);
  padding: 20px;
  border-radius: 16px;
  background: var(--wb-surface);
  border: 1px solid var(--wb-border-strong);
  box-shadow: 0 18px 40px rgba(24, 12, 4, 0.28);
  color: var(--wb-ink);
}

.h5-ad-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.h5-ad-preview-meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--wb-ink-muted);
}

.h5-ad-preview-timer {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--wb-accent-strong);
}

.h5-ad-preview-title {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--wb-ink);
}

.h5-ad-preview-desc {
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--wb-ink-secondary);
}

.h5-ad-preview-actions {
  display: flex;
  gap: 12px;
}

.h5-ad-btn {
  flex: 1;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease-out, opacity 0.15s ease-out;
}

.h5-ad-btn-cancel {
  background: var(--wb-surface-muted);
  border-color: var(--wb-border-strong);
  color: var(--wb-ink);
}

.h5-ad-btn-cancel:hover {
  background: #EAD4B7;
}

.h5-ad-btn-claim {
  background: var(--wb-accent);
  color: #FFFFFF;
}

.h5-ad-btn-claim:hover:not(:disabled) {
  background: var(--wb-accent-strong);
}

.h5-ad-btn-claim:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.h5-ad-btn:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 2px;
}

@media (max-width: 640px), (pointer: coarse) {
  #h5-viewport {
    padding: 0;
    gap: 0;
  }

  #h5-stage-frame {
    width: 100%;
    height: 100dvh;
    max-width: 100%;
    max-height: 100dvh;
    aspect-ratio: auto;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  .h5-key-bar {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .h5-boot-loader,
  .h5-ad-btn {
    transition: none;
  }
}
