/* ==========================================================
   仙侠 · 御剑斩妖
   竖屏 H5 游戏 · 晚霞云海 / 橙金剑气
   ========================================================== */

:root {
  --orange: #FF8A3D;
  --orange-hot: #FF6F24;
  --orange-light: #FFB45E;
  --gold: #FFD28A;
  --cream: #FFF6E6;
  --mint: #BFEBDC;
  --teal-deep: #081C24;
  --ink: #2A1204;
  --font-serif: "STKaiti", "KaiTi", "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #090e16;
  color: var(--cream);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

/* 竖屏游戏舞台：手机满宽，桌面预览时居中成手机画幅 */
.stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
}

/* ================= 背景 ================= */

.scene {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100%;
  max-width: 560px;
  transform: translateX(-50%);
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.scene-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.scene-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7, 7, 20, .5) 0%, rgba(8, 8, 22, .16) 13%, transparent 30%, transparent 61%, rgba(6, 14, 20, .34) 80%, rgba(4, 11, 16, .84) 100%),
    radial-gradient(132% 72% at 50% 4%, transparent 52%, rgba(4, 10, 17, .26) 100%);
  pointer-events: none;
}

.scene-grain {
  position: absolute;
  inset: 0;
  opacity: .14;
  mix-blend-mode: overlay;
  background-image: radial-gradient(rgba(255, 244, 220, .55) .55px, transparent .9px);
  background-size: 3px 3px;
  pointer-events: none;
}

.sun {
  transform-box: fill-box;
  transform-origin: center;
  animation: sunBreathe 9s ease-in-out infinite alternate;
}

.clouds-back {
  animation: cloudDriftA 28s ease-in-out infinite alternate;
  will-change: transform;
}

.clouds-mid {
  animation: cloudDriftB 34s ease-in-out infinite alternate;
  will-change: transform;
}

.cloud-sea {
  animation: cloudDriftA 23s ease-in-out infinite alternate-reverse;
  will-change: transform;
}

.island-left {
  animation: islandFloat 8s ease-in-out infinite alternate;
  will-change: transform;
}

.island-right {
  animation: islandFloat 10.5s ease-in-out infinite alternate-reverse;
  will-change: transform;
}

.crane {
  transform-box: fill-box;
  transform-origin: center;
}

.crane-a {
  animation: craneFlyA 19s ease-in-out infinite alternate;
}

.crane-b {
  animation: craneFlyB 24s ease-in-out infinite alternate;
}

.crane-c {
  animation: craneFlyC 29s ease-in-out infinite alternate;
}

@keyframes sunBreathe {
  from { opacity: .9; transform: scale(.985); }
  to   { opacity: 1;   transform: scale(1.025); }
}

@keyframes cloudDriftA {
  from { transform: translateX(-14px); }
  to   { transform: translateX(15px); }
}

@keyframes cloudDriftB {
  from { transform: translateX(17px); }
  to   { transform: translateX(-17px); }
}

@keyframes islandFloat {
  from { transform: translateY(-3px); }
  to   { transform: translateY(7px); }
}

@keyframes craneFlyA {
  from { transform: translate(-6px, 5px); }
  to   { transform: translate(22px, -9px); }
}

@keyframes craneFlyB {
  from { transform: translate(8px, -4px); }
  to   { transform: translate(-16px, 8px); }
}

@keyframes craneFlyC {
  from { transform: translate(-4px, -3px); }
  to   { transform: translate(18px, 4px); }
}

/* ================= 画布 ================= */

.game-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ================= 首页 ================= */

.home {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top, 0px) + 26px)
    22px
    calc(env(safe-area-inset-bottom, 0px) + 14px);
  pointer-events: none;
  transition: opacity .5s ease, transform .65s cubic-bezier(.3, .8, .3, 1);
}

.home.hide {
  opacity: 0;
  transform: translateY(-18px) scale(.985);
  pointer-events: none;
}

.home.hide .btn-primary {
  pointer-events: none;
}

.home-top {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}

.seal {
  width: 38px;
  height: 52px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 158, 84, .72);
  border-radius: 7px;
  background: linear-gradient(160deg, rgba(255, 138, 61, .24), rgba(255, 138, 61, .05));
  box-shadow: inset 0 0 14px rgba(255, 138, 61, .18), 0 7px 20px rgba(0, 0, 0, .28);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  color: #FFC890;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.06;
  letter-spacing: .02em;
  transform: rotate(-2deg);
  animation: sealIn .9s cubic-bezier(.2, .9, .3, 1.2) both .25s;
}

.seal span {
  display: block;
}

.home-kicker {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 224, 190, .82);
  font-size: 10px;
  letter-spacing: .18em;
  font-weight: 500;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
  animation: fadeRise .9s ease both .4s;
  white-space: nowrap;
}

.home-kicker i {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 9px rgba(255, 138, 61, .95);
}

.home-hero {
  margin-top: clamp(64px, 16vh, 142px);
  animation: fadeRise 1s ease both .1s;
}

.game-title {
  margin: 0;
  display: flex;
  align-items: flex-end;
  gap: .02em;
  font-family: var(--font-serif);
  font-size: clamp(76px, 20vw, 98px);
  font-weight: 700;
  line-height: .92;
  letter-spacing: .04em;
  padding: .04em 0 .1em;
  filter: drop-shadow(0 10px 30px rgba(255, 128, 54, .3));
}

.game-title span {
  display: inline-block;
  background: linear-gradient(178deg, #FFFBEF 6%, #FFEDC6 42%, #FFD08A 72%, #FFAB5C 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleRise 1s cubic-bezier(.15, .9, .25, 1.15) both;
}

.game-title span:nth-child(1) {
  animation-delay: .12s;
}

.game-title span:nth-child(2) {
  animation-delay: .26s;
}

.title-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(248px, 72%);
  margin: 10px 0 0;
  animation: fadeRise .9s ease both .5s;
}

.title-rule i {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, rgba(255, 196, 132, .72));
}

.title-rule i:last-child {
  background: linear-gradient(90deg, rgba(255, 196, 132, .72), transparent);
}

.title-rule b {
  color: #FFCE93;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .3em;
  white-space: nowrap;
  text-shadow: 0 0 14px rgba(255, 138, 61, .52);
}

.title-sub {
  margin: 14px 0 0;
  color: rgba(255, 235, 211, .78);
  font-size: 12.5px;
  line-height: 1.85;
  letter-spacing: .1em;
  font-weight: 400;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .55);
  animation: fadeRise .9s ease both .62s;
}

.home-bottom {
  position: relative;
  margin-top: auto;
  margin-bottom: clamp(150px, 20vh, 188px);
  animation: fadeRise 1s ease both .72s;
}

.home-bottom::before {
  content: "";
  position: absolute;
  left: -22px;
  right: -22px;
  top: -26px;
  bottom: -30px;
  z-index: -1;
  border-radius: 40px;
  background: radial-gradient(72% 100% at 50% 76%, rgba(5, 11, 16, .68), rgba(5, 11, 16, .28) 54%, transparent 78%);
  filter: blur(10px);
  pointer-events: none;
}

.btn-primary {
  position: relative;
  width: 100%;
  height: 58px;
  border: 1px solid rgba(255, 226, 180, .78);
  border-radius: 18px;
  background: linear-gradient(135deg, #FFB65F 0%, #FF8A3D 52%, #F96D23 100%);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .13em;
  box-shadow:
    0 14px 34px rgba(72, 19, 4, .46),
    0 10px 26px rgba(255, 116, 38, .26),
    0 2px 0 rgba(255, 246, 224, .44) inset,
    0 -8px 16px rgba(160, 56, 8, .18) inset;
  overflow: hidden;
  pointer-events: auto;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  animation: ctaGlow 3.8s ease-in-out infinite;
}

.btn-primary::after {
  content: "";
  position: absolute;
  top: -40%;
  left: -30%;
  width: 46%;
  height: 180%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .36), transparent);
  transform: rotate(16deg);
  pointer-events: none;
  animation: sheen 5.2s ease-in-out infinite;
}

.btn-primary:active {
  transform: translateY(1px) scale(.976);
  box-shadow:
    0 5px 14px rgba(72, 19, 4, .36),
    0 1px 0 rgba(255, 246, 224, .3) inset;
  filter: brightness(.98);
}

.btn-primary .btn-ico {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: rgba(42, 18, 4, .84);
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .25));
}

.best-line {
  margin-top: 13px;
  text-align: center;
  color: rgba(255, 241, 218, .62);
  font-size: 10.5px;
  letter-spacing: .18em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
}

.best-line strong {
  margin-left: 5px;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .06em;
}

.drag-hint {
  margin-top: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: rgba(255, 232, 206, .56);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .45);
}

.drag-hint svg {
  width: 15px;
  height: 15px;
  color: rgba(255, 181, 112, .86);
  flex: 0 0 auto;
}

/* ================= HUD ================= */

.hud {
  position: absolute;
  z-index: 3;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .4s ease, transform .4s ease;
}

.hud.on {
  opacity: 1;
  transform: none;
}

.hud-hp {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(8, 21, 28, .58);
  border: 1px solid rgba(255, 201, 146, .24);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.hud-blade {
  width: 17px;
  height: 17px;
  color: #FF9C4A;
  filter: drop-shadow(0 0 5px rgba(255, 138, 61, .6));
  transition: color .25s ease, opacity .25s ease, transform .25s ease;
}

.hud-blade.off {
  color: rgba(196, 218, 208, .2);
  filter: none;
  transform: scale(.84);
}

.hud-hp.hurt {
  animation: hpShake .34s ease;
}

.hud-score {
  height: 38px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(8, 21, 28, .58);
  border: 1px solid rgba(255, 201, 146, .24);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.hud-score-label {
  color: rgba(255, 222, 186, .68);
  font-size: 10px;
  letter-spacing: .18em;
}

.hud-score strong {
  color: #FFD28A;
  font-family: var(--font-serif);
  font-size: 21px;
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(255, 138, 61, .4);
}

.play-hint {
  position: absolute;
  z-index: 4;
  top: 24%;
  left: 50%;
  transform: translate(-50%, -8px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(8, 21, 28, .6);
  border: 1px solid rgba(255, 201, 146, .24);
  color: rgba(255, 243, 227, .86);
  font-size: 11px;
  letter-spacing: .1em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s ease, transform .5s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.play-hint.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.play-hint-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 9px rgba(255, 138, 61, .95);
}

.damage-flash {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 84%, rgba(255, 66, 28, .54), rgba(255, 66, 28, .1) 45%, transparent 68%);
}

/* ================= 结算 ================= */

.over {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 44%, rgba(24, 12, 20, .34), rgba(4, 10, 17, .88));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .4s ease;
}

.over[hidden] {
  display: none;
}

.over.show {
  opacity: 1;
}

.over-card {
  width: min(100%, 340px);
  padding: 28px 22px 18px;
  border-radius: 26px;
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(255, 142, 66, .16), transparent 68%),
    linear-gradient(165deg, rgba(21, 42, 43, .98), rgba(6, 18, 24, .99));
  border: 1px solid rgba(255, 199, 130, .3);
  box-shadow:
    0 28px 86px rgba(0, 0, 0, .62),
    0 1px 0 rgba(255, 236, 200, .14) inset;
  text-align: center;
  transform: translateY(16px) scale(.965);
  transition: transform .5s cubic-bezier(.18, .9, .28, 1.18);
}

.over.show .over-card {
  transform: none;
}

.over-kicker {
  margin: 0;
  color: rgba(255, 178, 112, .9);
  font-size: 10px;
  letter-spacing: .24em;
}

.over-title {
  margin: 13px 0 4px;
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--cream);
  text-shadow: 0 2px 16px rgba(255, 138, 61, .3);
}

.over-score {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  margin: 6px 0 2px;
}

.over-score strong {
  font-family: var(--font-serif);
  font-size: 62px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #FFF8E8 6%, #FFD68F 62%, #FFAE5A 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255, 138, 61, .2));
}

.over-score span {
  color: rgba(255, 212, 161, .62);
  font-size: 12px;
  letter-spacing: .16em;
  margin-bottom: 9px;
}

.over-best {
  margin: 2px 0 20px;
  color: rgba(255, 233, 208, .56);
  font-size: 10.5px;
  letter-spacing: .15em;
}

.over-best b {
  color: var(--gold);
  font-family: var(--font-serif);
  font-size: 14px;
  margin-left: 4px;
  letter-spacing: .05em;
}

.over-card .btn-primary {
  animation: none;
}

.btn-ghost {
  width: 100%;
  height: 46px;
  margin-top: 5px;
  border: 0;
  background: transparent;
  color: rgba(255, 235, 210, .6);
  font-size: 12px;
  letter-spacing: .16em;
  border-radius: 12px;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}

.btn-ghost:active {
  color: rgba(255, 246, 230, .92);
  background: rgba(255, 255, 255, .05);
}

/* ================= 工具 / 动画 ================= */

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

@keyframes titleRise {
  from { opacity: 0; transform: translateY(30px) rotate(1.5deg); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes fadeRise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@keyframes sealIn {
  from { opacity: 0; transform: rotate(-10deg) scale(.8); }
  to   { opacity: 1; transform: rotate(-2deg) scale(1); }
}

@keyframes ctaGlow {
  0%, 100% { box-shadow: 0 14px 34px rgba(72, 19, 4, .44), 0 10px 26px rgba(255, 116, 38, .24), 0 2px 0 rgba(255, 246, 224, .42) inset, 0 -8px 16px rgba(160, 56, 8, .18) inset; }
  50%      { box-shadow: 0 16px 42px rgba(74, 19, 4, .5), 0 14px 38px rgba(255, 126, 44, .42), 0 2px 0 rgba(255, 246, 224, .46) inset, 0 -8px 16px rgba(160, 56, 8, .18) inset; }
}

@keyframes sheen {
  0%, 62%  { left: -40%; opacity: 0; }
  70%      { opacity: 1; }
  88%, 100% { left: 118%; opacity: 0; }
}

@keyframes hpShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  55%      { transform: translateX(3px); }
  80%      { transform: translateX(-2px); }
}

/* 短屏适配 */
@media (max-height: 700px) {
  .home-hero {
    margin-top: 6vh;
  }
  .game-title {
    font-size: clamp(64px, 17vw, 82px);
  }
  .title-sub {
    margin-top: 12px;
    line-height: 1.7;
  }
  .home-bottom {
    margin-bottom: clamp(138px, 19vh, 170px);
  }
  .btn-primary {
    height: 54px;
  }
}

@media (max-height: 600px) {
  .home-kicker { font-size: 9px; }
  .seal { width: 32px; height: 44px; font-size: 15px; }
  .home-hero { margin-top: 2vh; }
  .title-sub { display: none; }
  .home-bottom { margin-bottom: 128px; }
  .drag-hint { display: none; }
}

@media (max-width: 360px) {
  .home {
    padding-left: 18px;
    padding-right: 18px;
  }
  .game-title {
    font-size: 74px;
  }
  .home-kicker {
    letter-spacing: .12em;
  }
}

/* 横屏预览兜底：竖屏仍是主形态 */
@media (orientation: landscape) and (max-height: 520px) {
  .home {
    padding: 16px 22px 12px;
  }
  .home-top {
    display: none;
  }
  .home-hero {
    position: absolute;
    left: 22px;
    top: 17%;
    max-width: 54%;
    margin: 0;
  }
  .game-title {
    font-size: clamp(48px, 9vh, 66px);
  }
  .title-rule {
    width: 180px;
    margin-top: 4px;
  }
  .title-sub {
    display: none;
  }
  .home-bottom {
    position: absolute;
    right: 22px;
    bottom: 22px;
    width: min(300px, 52%);
    margin: 0;
  }
  .btn-primary {
    height: 52px;
  }
  .drag-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sun, .clouds-back, .clouds-mid, .cloud-sea, .island-left, .island-right,
  .crane-a, .crane-b, .crane-c,
  .seal, .home-kicker, .title-rule, .title-sub, .home-bottom, .game-title span,
  .btn-primary, .btn-primary::after {
    animation: none !important;
  }
}

/* 桌面预览时给竖屏舞台一点画框感 */
@media (min-width: 600px) {
  .stage {
    box-shadow: 0 0 90px rgba(1, 10, 16, .66), 0 0 0 1px rgba(255, 200, 140, .07);
  }
}
