/* =========================================================
   国风水墨跑酷 · 山门与无尽桥
   原生 HTML / CSS / JS，无框架、无外链
   ========================================================= */

:root{
  --ink:#1c1a16;
  --ink-soft:#3a3630;
  --paper:#f1ebdd;
  --paper-deep:#e4dac6;
  --gold:#ffb04a;
  --gold-hot:#ff8a3d;
  --gold-deep:#b9771c;
  --seal:#b13a2b;
  --jade:#d9c79c;
  --safe-t:env(safe-area-inset-top, 0px);
  --safe-b:env(safe-area-inset-bottom, 0px);
  --font-brush:"STKaiti","KaiTi","Kaiti SC","Songti SC","Noto Serif SC","Source Han Serif SC",serif;
  --font-ui:-apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;}
html,body{
  margin:0;padding:0;width:100%;height:100%;
  background:#0d0c0a;color:var(--ink);
  font-family:var(--font-ui);
  overflow:hidden;
  overscroll-behavior:none;
  -webkit-user-select:none;user-select:none;
}
button{font-family:inherit;border:0;background:none;color:inherit;cursor:pointer;}
#app{position:fixed;inset:0;overflow:hidden;background:#0d0c0a;}
.screen{position:absolute;inset:0;}
.hidden{display:none !important;}
[hidden]{display:none !important;}
img{display:block;}

/* =========================================================
   首页
   ========================================================= */
.home{background:#15140f;}

.hero-art{
  position:absolute;inset:-3%;
  background-image:url("images/gen/gptimg_1795327274_look.png");
  background-repeat:no-repeat;
  background-position:54% 52%;
  background-size:cover;
  transform:scale(1.02);
  animation:heroBreath 26s ease-in-out infinite alternate;
  filter:saturate(.94) contrast(1.03);
}
@keyframes heroBreath{
  0%{transform:scale(1.02) translate3d(0,0,0);}
  100%{transform:scale(1.10) translate3d(-.7%,-1.1%,0);}
}

.hero-wash{
  position:absolute;inset:0;pointer-events:none;
  background:
    linear-gradient(180deg,rgba(9,12,14,.48) 0%,rgba(9,12,14,.06) 18%,rgba(9,12,14,0) 38%,rgba(9,12,14,.02) 56%,rgba(12,10,7,.68) 100%),
    radial-gradient(120% 80% at 50% 45%,rgba(10,12,12,0) 45%,rgba(10,12,12,.38) 100%);
}

.mist{
  position:absolute;left:-30%;width:160%;height:36%;pointer-events:none;
  background:radial-gradient(60% 100% at 50% 50%,rgba(238,235,225,.46),rgba(238,235,225,0) 72%);
  filter:blur(16px);
  opacity:.55;mix-blend-mode:screen;
}
.mist-a{top:34%;animation:mistDrift 34s ease-in-out infinite alternate;}
.mist-b{top:58%;height:28%;opacity:.32;animation:mistDrift 46s ease-in-out infinite alternate-reverse;}
@keyframes mistDrift{
  0%{transform:translate3d(-5%,0,0) scale(1);}
  100%{transform:translate3d(8%,-2%,0) scale(1.12);}
}

.petals{position:absolute;inset:0;overflow:hidden;pointer-events:none;z-index:2;}
.petal{
  position:absolute;top:-6vh;width:8px;height:6px;
  border-radius:70% 30% 60% 40%;
  background:linear-gradient(135deg,#ecc0bd,#d47b75 60%,#b85b58);
  opacity:.72;
  filter:blur(.15px);
  animation:petalFall linear infinite;
  will-change:transform;
}
@keyframes petalFall{
  0%{transform:translate3d(0,-8vh,0) rotate(0deg);opacity:0;}
  8%{opacity:.75;}
  50%{transform:translate3d(26px,52vh,0) rotate(170deg);}
  100%{transform:translate3d(-14px,112vh,0) rotate(350deg);opacity:.2;}
}

/* 顶部 HUD */
.hud-top{
  position:absolute;z-index:6;top:calc(var(--safe-t) + 14px);left:16px;right:16px;
  display:flex;align-items:flex-start;justify-content:space-between;gap:12px;
  pointer-events:none;
}
.profile{display:flex;align-items:center;gap:10px;min-width:0;}
.avatar{
  position:relative;width:50px;height:50px;flex:none;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  background:
    radial-gradient(circle at 34% 26%,#f4e6c8 0%,#d9c39d 40%,#98866a 100%);
  border:2px solid rgba(245,226,180,.88);
  box-shadow:0 4px 14px rgba(8,10,10,.55),inset 0 0 0 3px rgba(30,26,20,.38);
  font-family:var(--font-brush);font-size:25px;color:#2b241a;font-weight:700;
  overflow:hidden;
}
.avatar img{width:100%;height:100%;object-fit:cover;}
.avatar::after{
  content:"";position:absolute;inset:0;border-radius:50%;
  box-shadow:inset 0 0 12px rgba(50,38,20,.45);pointer-events:none;
}
.profile-meta{min-width:0;padding-top:2px;}
.profile-row{display:flex;align-items:baseline;gap:7px;white-space:nowrap;}
.nickname{
  font-size:16px;font-weight:700;letter-spacing:.5px;color:#fdf8ea;
  max-width:42vw;overflow:hidden;text-overflow:ellipsis;
  text-shadow:0 1px 8px rgba(0,0,0,.72);
}
.rank{
  font-size:10px;font-weight:700;color:#f4d38d;letter-spacing:.4px;
  padding:2px 6px;border-radius:99px;background:rgba(16,14,10,.55);
  border:1px solid rgba(242,211,141,.35);
}
.xp{
  position:relative;width:118px;max-width:34vw;height:5px;margin-top:7px;border-radius:99px;
  background:rgba(10,10,8,.58);box-shadow:inset 0 1px 2px rgba(0,0,0,.6);
  overflow:hidden;
}
.xp i{
  display:block;height:100%;width:0%;border-radius:99px;
  background:linear-gradient(90deg,#f0c983,#ffe6a8);
  box-shadow:0 0 8px rgba(255,209,128,.65);
  transition:width .5s ease;
}
.profile-sub{
  margin-top:5px;font-size:10px;letter-spacing:1.6px;color:rgba(255,248,231,.68);
  text-shadow:0 1px 6px rgba(0,0,0,.7);
}

.coin-chip{
  display:flex;align-items:center;gap:6px;flex:none;
  height:36px;padding:0 13px 0 9px;border-radius:99px;
  background:linear-gradient(180deg,rgba(28,25,20,.74),rgba(18,16,12,.62));
  border:1px solid rgba(245,213,142,.46);
  box-shadow:0 5px 16px rgba(0,0,0,.35),inset 0 1px 0 rgba(255,255,255,.13);
  color:#ffe3a3;font-weight:700;font-size:15px;letter-spacing:.3px;
  backdrop-filter:blur(7px);-webkit-backdrop-filter:blur(7px);
  text-shadow:0 1px 2px rgba(0,0,0,.5);
}
.coin-chip .mp-icon{
  width:21px;height:21px;color:#ffc24c;
  filter:drop-shadow(0 0 5px rgba(255,178,55,.5));
}

/* 书法标题 */
.title-lockup{
  position:absolute;z-index:5;left:22px;top:29%;
  display:flex;flex-direction:column;align-items:center;
  color:#f8f2e4;
  filter:drop-shadow(0 4px 16px rgba(0,0,0,.5));
}
.title-kicker{
  writing-mode:vertical-rl;text-orientation:upright;
  font-size:10px;letter-spacing:5px;color:rgba(247,236,215,.58);
  margin-bottom:10px;
}
.v-title{
  margin:0;display:flex;flex-direction:column;align-items:center;
  font-family:var(--font-brush);font-weight:700;
  font-size:clamp(38px,6.2vh,58px);line-height:1.05;letter-spacing:2px;
}
.v-title span{
  display:block;
  text-shadow:
    0 1px 0 rgba(0,0,0,.45),
    0 4px 18px rgba(0,0,0,.55),
    0 0 40px rgba(0,0,0,.28);
}
.v-title span:nth-child(2){margin-left:9px;}
.v-title span:nth-child(3){margin-left:-4px;}
.v-title span:nth-child(4){margin-left:8px;}
.seal{
  margin-top:14px;width:27px;height:27px;border-radius:5px;
  display:flex;align-items:center;justify-content:center;
  background:linear-gradient(160deg,#c34a37,#982c21);
  color:#f9e6cf;font-family:var(--font-brush);font-size:16px;line-height:1;
  box-shadow:0 2px 8px rgba(60,10,5,.45),inset 0 0 0 1px rgba(255,220,190,.25);
  transform:rotate(-4deg);
}
.title-sub{
  writing-mode:vertical-rl;text-orientation:upright;
  margin-top:13px;font-size:9px;letter-spacing:4px;
  color:rgba(248,238,218,.62);
}

/* 底部：操作提示 + 开始游戏 */
.home-bottom{
  position:absolute;z-index:7;left:18px;right:18px;
  bottom:calc(var(--safe-b) + 20px);
  display:flex;align-items:flex-end;justify-content:space-between;gap:12px;
}
.ctrl-hint{display:flex;flex-direction:column;align-items:center;gap:8px;flex:none;}
.ink-pad{
  width:76px;height:76px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  color:rgba(250,244,230,.88);
  background:
    radial-gradient(circle at 50% 45%,rgba(28,30,28,.42),rgba(12,13,12,.68) 70%);
  border:1px solid rgba(246,238,219,.30);
  box-shadow:
    0 6px 20px rgba(0,0,0,.36),
    inset 0 0 20px rgba(255,255,255,.07),
    inset 0 0 0 7px rgba(255,255,255,.035);
  backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);
}
.ink-pad .mp-icon{width:34px;height:34px;filter:drop-shadow(0 1px 5px rgba(0,0,0,.55));}
.hint-text{
  text-align:center;color:rgba(250,244,232,.82);
  font-size:10px;letter-spacing:1px;line-height:1.55;
  text-shadow:0 1px 6px rgba(0,0,0,.8);
}
.hint-text b{font-weight:600;color:#fff8ea;}
.hint-text span{display:block;color:rgba(250,244,232,.62);font-size:9px;letter-spacing:1.5px;}

.start-cluster{display:flex;flex-direction:column;align-items:flex-end;gap:10px;}
.best-line{
  padding-right:8px;font-size:11px;letter-spacing:1px;color:rgba(251,244,229,.76);
  text-shadow:0 1px 7px rgba(0,0,0,.8);
}
.best-line b{font-size:14px;color:#ffe4a8;font-weight:700;letter-spacing:.5px;}

.start-btn{
  position:relative;isolation:isolate;
  width:clamp(154px,20vh,212px);
  height:clamp(58px,7.6vh,78px);
  display:flex;align-items:center;justify-content:center;gap:9px;
  padding:0 22px;
  color:#2b1b08;
  border-radius:48% 52% 44% 56% / 58% 62% 38% 42%;
  background:
    radial-gradient(120% 160% at 28% 16%,#fff1bd 0%,#ffd577 30%,#ffb24c 58%,#e18d22 82%,#bb7414 100%);
  border:1px solid rgba(255,232,169,.75);
  box-shadow:
    0 14px 32px rgba(104,58,6,.42),
    0 3px 0 rgba(126,73,8,.32),
    inset 0 2px 5px rgba(255,252,225,.72),
    inset 0 -9px 18px rgba(150,84,10,.28);
  transform:rotate(-3.2deg);
  transition:transform .12s ease,filter .12s ease;
  animation:startPulse 3.2s ease-in-out infinite;
  touch-action:manipulation;
}
.start-btn::before{
  content:"";position:absolute;z-index:-1;inset:-9px -13px -8px -11px;
  border-radius:50%;background:radial-gradient(ellipse at 50% 52%,rgba(255,190,92,.38),rgba(255,170,60,0) 68%);
  filter:blur(7px);
}
.start-btn::after{
  content:"";position:absolute;z-index:-1;right:-9px;top:-9px;width:46px;height:25px;
  background:linear-gradient(130deg,rgba(255,226,153,.78),rgba(226,153,43,.2));
  border-radius:70% 30% 65% 35%;
  transform:rotate(16deg);filter:blur(.4px);opacity:.7;
}
.start-btn span{
  font-family:var(--font-brush);font-weight:700;font-size:clamp(23px,3.3vh,31px);
  letter-spacing:3px;line-height:1;text-shadow:0 1px 0 rgba(255,250,220,.55);
  white-space:nowrap;
}
.start-btn .mp-icon{width:16px;height:16px;color:#3c250c;opacity:.82;}
.start-btn:active{transform:rotate(-3.2deg) scale(.955);filter:brightness(.97);}
.start-btn:focus-visible{outline:2px solid #fff4cd;outline-offset:5px;}
@keyframes startPulse{
  0%,100%{box-shadow:0 14px 32px rgba(104,58,6,.42),0 3px 0 rgba(126,73,8,.32),inset 0 2px 5px rgba(255,252,225,.72),inset 0 -9px 18px rgba(150,84,10,.28),0 0 0 0 rgba(255,183,76,.28);}
  55%{box-shadow:0 14px 32px rgba(104,58,6,.42),0 3px 0 rgba(126,73,8,.32),inset 0 2px 5px rgba(255,252,225,.72),inset 0 -9px 18px rgba(150,84,10,.28),0 0 0 14px rgba(255,183,76,0);}
}

/* =========================================================
   游戏场景
   ========================================================= */
.game{background:#cfc9ba;touch-action:none;overflow:hidden;}
#stage{position:absolute;inset:0;display:block;width:100%;height:100%;touch-action:none;}

.game-hud{
  position:absolute;z-index:6;top:calc(var(--safe-t) + 14px);left:16px;right:16px;
  display:flex;align-items:flex-start;justify-content:space-between;gap:8px;
  pointer-events:none;
}
.game-hud .round-btn,.game-hud .coin-chip{pointer-events:auto;}

.round-btn{
  width:42px;height:42px;border-radius:50%;flex:none;
  display:flex;align-items:center;justify-content:center;
  color:rgba(255,249,236,.94);
  background:linear-gradient(180deg,rgba(28,26,21,.68),rgba(15,14,11,.6));
  border:1px solid rgba(246,232,204,.34);
  box-shadow:0 4px 14px rgba(0,0,0,.28),inset 0 1px 0 rgba(255,255,255,.14);
  backdrop-filter:blur(7px);-webkit-backdrop-filter:blur(7px);
  transition:transform .1s ease;
}
.round-btn:active{transform:scale(.92);}
.round-btn .mp-icon{width:22px;height:22px;}

.score-box{
  position:absolute;left:50%;top:0;transform:translateX(-50%);
  text-align:center;color:#fff9ec;pointer-events:none;
  text-shadow:0 2px 10px rgba(0,0,0,.55);
}
.score-label{font-size:9px;letter-spacing:4px;color:rgba(255,246,226,.62);}
.score-line{display:flex;align-items:baseline;justify-content:center;gap:3px;margin-top:2px;}
.score-line span{
  font-family:var(--font-brush);font-size:clamp(26px,4.2vh,36px);line-height:1;
  letter-spacing:1px;color:#fff7e4;font-weight:700;
}
.score-line em{font-style:normal;font-size:10px;letter-spacing:1px;color:rgba(255,243,219,.72);}

.game-coin{height:34px;font-size:14px;background:linear-gradient(180deg,rgba(28,25,20,.7),rgba(18,16,12,.58));}

/* 操作提示 */
.tutorial{
  position:absolute;z-index:5;left:50%;top:64%;transform:translateX(-50%);
  display:flex;align-items:center;gap:10px;white-space:nowrap;
  padding:9px 15px;border-radius:99px;
  background:rgba(16,15,12,.55);border:1px solid rgba(250,238,211,.18);
  color:rgba(255,249,236,.9);font-size:11px;letter-spacing:.6px;
  backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);
  box-shadow:0 6px 20px rgba(0,0,0,.22);
  opacity:0;pointer-events:none;
  transition:opacity .5s ease;
}
.tutorial.show{opacity:1;}
.tutorial.fade{opacity:0;}
.tut-item{display:flex;align-items:center;gap:5px;}
.tut-item .mp-icon{width:16px;height:16px;color:#ffd37d;}
.tut-sep{width:1px;height:13px;background:rgba(255,245,225,.24);}

/* 遮罩面板 */
.overlay{
  position:absolute;z-index:12;inset:0;
  display:flex;align-items:center;justify-content:center;
  padding:22px;
  background:
    radial-gradient(80% 60% at 50% 46%,rgba(8,8,6,.28),rgba(8,8,6,.72) 100%);
  backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);
  animation:fadeIn .22s ease both;
}
@keyframes fadeIn{from{opacity:0;}to{opacity:1;}}

.ink-panel{
  position:relative;width:min(88vw,372px);max-height:88vh;overflow:auto;
  padding:28px 24px 22px;
  border-radius:22px 18px 24px 17px;
  background:
    radial-gradient(120% 80% at 18% 0%,rgba(255,252,242,.96),rgba(241,232,214,.95) 42%,rgba(224,211,187,.96) 100%);
  border:1px solid rgba(255,250,236,.8);
  box-shadow:
    0 30px 70px rgba(0,0,0,.48),
    inset 0 0 0 1px rgba(92,74,45,.14),
    inset 0 0 46px rgba(126,102,59,.14);
  color:#2d261b;text-align:center;
  animation:panelUp .34s cubic-bezier(.2,.9,.25,1.15) both;
}
@keyframes panelUp{from{transform:translateY(16px) scale(.96);opacity:0;}to{transform:none;opacity:1;}}
.ink-panel::before{
  content:"";position:absolute;inset:9px;border-radius:16px 12px 18px 13px;
  border:1px solid rgba(82,64,38,.16);pointer-events:none;
}
.ink-panel::after{
  content:"";position:absolute;right:-28px;bottom:-34px;width:150px;height:110px;
  background:radial-gradient(ellipse at 50% 50%,rgba(38,34,27,.11),rgba(38,34,27,0) 70%);
  transform:rotate(-16deg);pointer-events:none;
}
.ink-panel.small{width:min(84vw,330px);padding:26px 24px 20px;}
.panel-kicker{
  font-size:9px;letter-spacing:5px;color:#8e7752;margin-bottom:8px;
}
.panel-title{
  margin:0;font-family:var(--font-brush);font-size:36px;font-weight:700;
  letter-spacing:5px;line-height:1.2;color:#282116;
}
.panel-note{margin:12px 0 18px;font-size:13px;letter-spacing:.6px;color:#6f6047;}
.panel-note b{color:#9a5d13;font-size:16px;}

.record-flag{
  display:inline-block;margin-top:10px;padding:3px 11px;border-radius:99px;
  font-size:10px;letter-spacing:2px;color:#fff5dd;
  background:linear-gradient(120deg,#bb4a33,#8f2e22);
  box-shadow:0 3px 9px rgba(120,35,24,.28);
  transform:rotate(-2deg);
}

.result-rows{margin:20px 0 22px;border-top:1px solid rgba(84,66,38,.15);}
.result-row{
  display:flex;align-items:baseline;justify-content:space-between;
  padding:12px 4px;border-bottom:1px solid rgba(84,66,38,.13);
  font-size:13px;color:#6a5c46;letter-spacing:.5px;
}
.result-row b{
  font-family:var(--font-brush);font-size:26px;line-height:1;
  color:#3a2d1b;font-weight:700;letter-spacing:1px;
}
.result-row b em{
  font-family:var(--font-ui);font-style:normal;font-size:10px;
  color:#8a795b;margin-left:3px;letter-spacing:0;
}
.result-row.subtle{color:#8b7d64;font-size:12px;}
.result-row.subtle b{font-size:20px;color:#6d6049;}

.gold-btn{
  width:100%;height:54px;border-radius:16px;
  display:flex;align-items:center;justify-content:center;gap:7px;
  background:linear-gradient(180deg,#ffd982,#ffb24d 52%,#e59029);
  color:#3a2409;font-size:17px;font-weight:700;letter-spacing:3px;
  border:1px solid rgba(255,231,165,.8);
  box-shadow:0 9px 20px rgba(151,94,18,.3),inset 0 2px 3px rgba(255,250,220,.66);
  transition:transform .1s ease,filter .1s ease;
}
.gold-btn .mp-icon{width:19px;height:19px;}
.gold-btn:active{transform:scale(.975);filter:brightness(.97);}
.text-btn{
  width:100%;height:46px;margin-top:6px;border-radius:13px;
  color:#7c6a4e;font-size:13px;letter-spacing:3px;
  transition:background .15s ease,color .15s ease;
}
.text-btn:active{background:rgba(90,70,40,.08);color:#4f4029;}

/* =========================================================
   适配
   ========================================================= */
@media (max-width:360px){
  .title-lockup{left:14px;top:27%;}
  .v-title{font-size:36px;}
  .hud-top{left:12px;right:12px;}
  .home-bottom{left:14px;right:14px;}
  .start-btn{width:148px;height:56px;padding:0 16px;}
  .start-btn span{font-size:22px;letter-spacing:2px;}
  .ink-pad{width:66px;height:66px;}
  .ink-pad .mp-icon{width:29px;height:29px;}
  .coin-chip{height:33px;padding:0 10px 0 7px;font-size:13px;}
}
@media (max-height:700px){
  .title-lockup{top:24%;}
  .v-title{font-size:34px;}
  .title-sub{display:none;}
  .seal{width:23px;height:23px;font-size:14px;margin-top:9px;}
  .ink-pad{width:62px;height:62px;}
  .start-btn{height:54px;width:150px;}
  .start-btn span{font-size:22px;}
  .home-bottom{bottom:calc(var(--safe-b) + 14px);}
  .best-line{display:none;}
}
@media (min-width:720px){
  .hud-top{left:5vw;right:5vw;top:calc(var(--safe-t) + 24px);}
  .home-bottom{left:5.5vw;right:5.5vw;bottom:calc(var(--safe-b) + 34px);}
  .title-lockup{left:7vw;top:30%;}
  .v-title{font-size:62px;}
  .profile .avatar{width:58px;height:58px;font-size:28px;}
  .nickname{font-size:18px;}
  .xp{width:150px;}
  .coin-chip{height:40px;font-size:16px;}
  .start-btn{width:220px;height:80px;}
  .start-btn span{font-size:32px;}
  .ink-pad{width:86px;height:86px;}
  .hint-text{font-size:11px;}
  .game-hud{left:5vw;right:5vw;top:calc(var(--safe-t) + 22px);}
  .score-box .score-line span{font-size:40px;}
}
@media (prefers-reduced-motion:reduce){
  .hero-art,.mist,.start-btn,.petal{animation:none !important;}
}
