/* SCHNAUZER-DIG-001 竖屏样式 · T3 界面规格案（390 宽竖屏、五态界面、热区安全区） */

:root {
  --sand-top: #f7e8c3;
  --sand-mid: #ebd19b;
  --sand-bottom: #ddbe7e;
  --ink-primary: #3d2915;
  --ink-secondary: #6e5030;
  --ink-muted: #8c6f4b;
  --gold-primary: #e29426;
  --gold-hover: #f3ad3b;
  --gold-shadow: #ab6a10;
  --panel-bg-top: #fffcf6;
  --panel-bg-bottom: #fff5e0;
  --panel-border: #dcb878;
  --hole-rim: rgba(175, 132, 75, 0.45);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: linear-gradient(
    180deg,
    var(--sand-top) 0%,
    var(--sand-mid) 48%,
    var(--sand-bottom) 100%
  );
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* 竖屏逻辑宽度 390，全屏安全边距 16px（GDD §5、§8、§9 权威规范） */
#stage {
  width: 100%;
  max-width: 390px;
  height: 100dvh;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 16px 8px;
  position: relative;
  background: radial-gradient(
    circle at 50% 20%,
    rgba(255, 248, 230, 0.35) 0%,
    transparent 70%
  );
}

@media (min-width: 500px) {
  body {
    padding: 16px 0;
    background: #36291a;
  }
  #stage {
    height: calc(100dvh - 32px);
    max-height: 844px;
    border: 3px solid #c4a46a;
    border-radius: 28px;
    background: linear-gradient(180deg, #f9edd0 0%, #ecd49f 48%, #dfc082 100%);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  }
}

/* ==========================================================================
   HUD（顶部信息栏）：关卡徽章 + 目标槽 72×72（GDD §9）
   ========================================================================== */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  padding: 2px 4px 6px;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

/* Menu 状态下隐藏 HUD（GDD §9：Menu 态不必看见目标槽、关卡号） */
#stage.state-menu #hud {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(-8px);
}

.levelBadge {
  background: #fffcf5;
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  padding: 8px 16px;
  box-shadow:
    0 3px 8px rgba(61, 41, 21, 0.08),
    inset 0 1px 0 #ffffff;
}

#levelLabel {
  font-weight: 800;
  font-size: 17px;
  color: var(--ink-primary);
  letter-spacing: 0.5px;
}

#targetSlot {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 目标槽规格：72×72 CSS px（GDD §9 权威尺寸，居中不拉伸变形） */
#targetIcon {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: #fffdf8;
  border: 2.5px dashed #cca86b;
  display: grid;
  place-items: center;
  margin: 0 auto;
  box-shadow:
    inset 0 2px 4px rgba(61, 41, 21, 0.05),
    0 3px 8px rgba(61, 41, 21, 0.08);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

#targetIcon.active {
  border-style: solid;
  border-color: var(--gold-primary);
  box-shadow:
    0 0 0 3px rgba(226, 148, 38, 0.3),
    0 4px 14px rgba(226, 148, 38, 0.25);
  background: #ffffff;
}

#targetIcon .q {
  font-size: 30px;
  color: #c4a369;
  font-weight: 800;
  user-select: none;
}

#targetIcon .prop {
  width: 64px;
  height: 64px;
}

#targetIcon .prop img {
  width: 64px;
  height: 64px;
}

#targetText {
  font-size: 13px;
  margin-top: 4px;
  font-weight: 700;
  color: var(--ink-primary);
  letter-spacing: 0.5px;
}

/* ==========================================================================
   洞场（沙洞区）：热区 ≥ 64×64，远离四边 ≥ 16px，支持 4 / 5 / 6 / 8 洞
   ========================================================================== */
#holeField {
  position: relative;
  flex: 1;
  min-height: 180px;
  margin-top: 10px;
}

#holeField.locked {
  pointer-events: none;
}

.hole {
  position: absolute;
  left: 0;
  top: 0;
  width: 80px;
  height: 72px; /* 热区 ≥ 64×64 CSS 像素（GDD §5） */
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.6, 0.05, 0.3, 1);
  outline: none;
}

.hole .pit {
  position: absolute;
  inset: -4px -2px 0;
  display: block;
  pointer-events: none;
  overflow: visible;
}

.hole .holeSpin {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hole .holeArt {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 128%;
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
}

/* 洞内道具包裹容器：道具规格 56×56（GDD §9），叠在 open 洞口 */
.hole .propWrap {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  text-align: center;
  opacity: 0;
  transform: translateY(18px) scale(0.65);
  transition:
    transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.28s ease;
  pointer-events: none;
  z-index: 2;
}

.hole.up .propWrap {
  opacity: 1;
  transform: translateY(-34px) scale(1);
}

.hole.revealed .propWrap {
  opacity: 1;
  transform: translateY(2px) scale(0.82);
}

.hole.hit .propWrap {
  animation: pop 0.45s ease;
}

.hole.digging .holeSpin {
  animation: dig 0.6s ease;
}

@keyframes dig {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-4px) rotate(-3deg);
  }
  40% {
    transform: translateX(4px) rotate(3deg);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(3px);
  }
}

@keyframes pop {
  0% {
    transform: translateY(8px) scale(0.55);
  }
  60% {
    transform: translateY(-8px) scale(1);
  }
  100% {
    transform: translateY(2px) scale(0.82);
  }
}

.prop {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 56px;
}

.prop img {
  width: 56px;
  height: 56px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28));
  pointer-events: none;
  user-select: none;
}

/* ==========================================================================
   雪纳瑞角色区：高度 ≤ 120px，不遮挡洞，脚底接地投影
   ========================================================================== */
#dogZone {
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  margin-bottom: 2px;
}

.dogShadow {
  width: 130px;
  height: 14px;
  background: radial-gradient(
    ellipse at 50% 50%,
    rgba(55, 36, 15, 0.35) 0%,
    rgba(55, 36, 15, 0) 72%
  );
  border-radius: 50%;
  position: absolute;
  bottom: 8px;
}

.dog {
  position: relative;
  width: 160px;
  height: 96px;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.dogLook {
  transform-origin: 50% 100%;
}

.dog.look-left .dogLook {
  transform: rotate(-8deg);
}

.dog.look-right .dogLook {
  transform: rotate(8deg);
}

.dogPivot {
  width: 150px;
  height: 96px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transform-origin: 50% 100%;
  animation: dogBreathe 3s ease-in-out infinite;
}

.dog img {
  width: 148px;
  height: 132px;
  object-fit: contain;
  object-position: center bottom;
  margin-bottom: -18px;
  display: block;
  pointer-events: none;
  user-select: none;
}

.dog.happy .dogPivot {
  animation: wag 0.5s ease-in-out infinite;
}

.dog.happy img {
  transform: scale(0.8);
  transform-origin: 50% 100%;
  margin-bottom: -6px;
}

.dog.tilt img {
  transform: scale(0.84);
  transform-origin: 50% 100%;
  margin-bottom: -8px;
}

@keyframes dogBreathe {
  0%,
  100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(1.03) translateY(-1px);
  }
}

@keyframes wag {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-3.5deg);
  }
  75% {
    transform: rotate(3.5deg);
  }
}

@keyframes tilt {
  0%,
  100% {
    transform: rotate(0);
  }
  35% {
    transform: rotate(-7deg);
  }
  70% {
    transform: rotate(5deg);
  }
}

/* 页脚：种子与占位说明 */
#foot {
  font-size: 11px;
  color: var(--ink-muted);
  text-align: center;
  padding: 4px 0 8px;
  line-height: 1.4;
}

/* ==========================================================================
   五态界面浮层（Menu / 过关 Win / 失败 Lose / 通关 Clear）
   规格：按钮高度 ≥ 44，宽 ≥ 160，居中，距离屏幕边缘 ≥ 16px（GDD §9）
   ========================================================================== */
#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(38, 24, 7, 0.5);
  backdrop-filter: blur(2.5px);
  z-index: 100;
  transition: opacity 0.2s ease;
}

#overlay.hidden {
  display: none;
}

#overlay .panel {
  background: linear-gradient(
    180deg,
    var(--panel-bg-top) 0%,
    var(--panel-bg-bottom) 100%
  );
  border: 2.5px solid var(--panel-border);
  border-radius: 22px;
  padding: 24px 28px 22px;
  text-align: center;
  box-shadow:
    0 16px 40px rgba(35, 20, 5, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.9);
  max-width: 326px;
  width: calc(100% - 48px);
  position: relative;
  margin: 0 auto;
}

/* 浮层内挖出道具特写徽章（过关与失败态清晰出示） */
.ovPropWrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(61, 41, 21, 0.12);
  transition: all 0.25s ease;
}

.ovPropWrap.hidden {
  display: none;
}

.state-win .ovPropWrap {
  border: 3px solid var(--gold-primary);
  box-shadow:
    0 0 0 4px rgba(226, 148, 38, 0.25),
    0 4px 14px rgba(226, 148, 38, 0.2);
}

.state-lose .ovPropWrap {
  border: 3px solid #d4a373;
  box-shadow:
    0 0 0 4px rgba(212, 163, 115, 0.2),
    0 4px 12px rgba(61, 41, 21, 0.12);
}

#ovTitle {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 800;
  color: var(--ink-primary);
  letter-spacing: 0.5px;
}

#overlay.big #ovTitle {
  font-size: 27px;
}

#ovSub {
  margin: 0 0 18px;
  color: var(--ink-secondary);
  font-size: 14px;
  min-height: 20px;
  line-height: 1.5;
  font-weight: 500;
}

/* 核心行动按钮：宽 ≥ 160，高 ≥ 44，远离边缘 ≥ 16（GDD §9） */
#ovBtn {
  min-width: 180px;
  min-height: 48px;
  font-size: 18px;
  font-weight: 700;
  padding: 12px 34px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(
    180deg,
    var(--gold-hover) 0%,
    var(--gold-primary) 100%
  );
  color: #ffffff;
  cursor: pointer;
  box-shadow:
    0 4px 0 var(--gold-shadow),
    0 6px 16px rgba(226, 148, 38, 0.35);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition:
    transform 0.1s ease,
    box-shadow 0.1s ease;
  user-select: none;
  display: inline-block;
}

#ovBtn:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 var(--gold-shadow),
    0 2px 8px rgba(226, 148, 38, 0.25);
}

/* Menu 状态定制排版 */
#stage.state-menu #overlay .panel {
  padding-top: 30px;
  padding-bottom: 26px;
}

#stage.state-menu #ovTitle {
  font-size: 26px;
  margin-bottom: 10px;
  color: var(--ink-primary);
}

#stage.state-menu #ovSub {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

#stage.state-menu #ovBtn {
  min-width: 200px;
  min-height: 50px;
  font-size: 19px;
}

/* 切后台：CSS 动画随 JS 时钟一起暂停（GDD §3） */
body.paused * {
  animation-play-state: paused !important;
}
