:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --ink: #080706;
  --paper: #eadfd2;
  --paper-deep: #c9b8a8;
  --grass: #8fb8aa;
  --dirt: #cbb5aa;
  --red: #cf6043;
  --gold: #ffd33f;
  --brown: #6b4637;
  --shadow: rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  min-height: 100svh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 217, 101, 0.16), transparent 28rem),
    radial-gradient(circle at 76% 86%, rgba(77, 50, 36, 0.34), transparent 24rem),
    linear-gradient(155deg, #13100e, #3d322b 48%, #171412);
}

button {
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
}

.phone-shell {
  width: min(100vw, 430px);
  height: min(100svh, 860px);
  padding: 8px;
}

.game-frame {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 650px;
  overflow: hidden;
  border: 3px solid #111;
  background: #e9ddd0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  user-select: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hidden {
  display: none !important;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.menu-screen {
  padding: max(20px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
}

.menu-left {
  position: absolute;
  top: max(26px, env(safe-area-inset-top));
  left: 12px;
  z-index: 2;
  display: grid;
  gap: 18px;
  width: 54px;
}

.square-icon,
.notice,
.scroll-btn,
.rank-board,
.bag {
  display: grid;
  place-items: center;
  border: 3px solid #0b0b0a;
  box-shadow: 0 3px 0 #2b2725, 0 6px 12px rgba(0, 0, 0, 0.16);
}

.square-icon {
  width: 50px;
  height: 50px;
  background: #9ca2a5;
}

.portrait span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #111;
  border-radius: 4px 4px 12px 12px;
  color: #362216;
  background: #f3ddc8;
  font-weight: 900;
}

.cog {
  position: relative;
  border-radius: 8px;
  background: #9eaaa9;
}

.cog::before,
.cog::after {
  position: absolute;
  content: "";
  border: 7px solid #4f5658;
  border-radius: 50%;
}

.cog::before {
  inset: 10px;
}

.cog::after {
  inset: 18px;
  border-color: #d9dedc;
}

.notice,
.scroll-btn {
  width: 54px;
  min-height: 40px;
  color: #111;
  background: #fff0b2;
  font-size: 18px;
  font-weight: 900;
}

.scroll-btn {
  min-height: 48px;
  background: #fff06c;
}

.coin-pill,
.bun-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 152px;
  height: 48px;
  padding: 0 18px 0 8px;
  border: 3px solid transparent;
  border-radius: 999px;
  color: #ffe25b;
  background:
    linear-gradient(90deg, #493024, #5b3828 80%, rgba(91, 56, 40, 0)),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 4px);
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.26));
  font-weight: 900;
}

.coin-pill i,
.reward i {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 4px solid #b87700;
  border-radius: 50%;
  color: #7b4c00;
  background: radial-gradient(circle at 34% 28%, #fff36b, #ffc400 62%, #df8d00);
  font-style: normal;
  font-weight: 900;
  text-shadow: 0 1px 0 #fff4a0;
}

.coin-pill strong {
  min-width: 54px;
  font-size: 29px;
  text-align: center;
}

.menu-coin {
  position: absolute;
  top: max(38px, env(safe-area-inset-top));
  left: 88px;
}

.game-title {
  position: absolute;
  top: 150px;
  right: 24px;
  left: 70px;
  margin: 0;
  color: #b54745;
  font-size: clamp(46px, 13vw, 64px);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  letter-spacing: 0;
  text-shadow:
    0 3px 0 #fff2c7,
    0 5px 0 rgba(0, 0, 0, 0.24);
}

.rank-title {
  position: absolute;
  top: 238px;
  right: 0;
  left: 0;
  z-index: 2;
  color: #fff17a;
  font-size: 31px;
  font-weight: 900;
  text-align: center;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000,
    0 4px 0 rgba(0, 0, 0, 0.28);
}

.stars {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.menu-screen > .stars {
  position: absolute;
  top: 288px;
  right: 0;
  left: 0;
}

.star {
  position: relative;
  display: block;
  width: 43px;
  height: 43px;
  transform: rotate(-6deg);
}

.star::before {
  position: absolute;
  inset: 0;
  content: "★";
  color: #776319;
  font-size: 48px;
  line-height: 43px;
  text-align: center;
  text-shadow:
    -2px -2px 0 #7a6210,
    2px -2px 0 #7a6210,
    -2px 2px 0 #7a6210,
    2px 2px 0 #7a6210;
}

.star.on::before {
  color: #ffd42f;
  text-shadow:
    -2px -2px 0 #fff6cf,
    2px -2px 0 #fff6cf,
    -2px 2px 0 #fff6cf,
    2px 2px 0 #fff6cf,
    0 3px 0 #a36b00;
}

.menu-illustration {
  position: absolute;
  top: 338px;
  left: 50%;
  width: min(78vw, 320px);
  height: 238px;
  transform: translateX(-50%);
}

.paper-grid {
  position: absolute;
  top: 36px;
  left: 50%;
  width: 220px;
  height: 104px;
  border: 6px solid rgba(103, 76, 60, 0.8);
  background:
    linear-gradient(90deg, transparent 32%, rgba(103, 76, 60, 0.55) 33% 35%, transparent 36% 65%, rgba(103, 76, 60, 0.55) 66% 68%, transparent 69%),
    linear-gradient(0deg, transparent 47%, rgba(103, 76, 60, 0.55) 49% 52%, transparent 54%),
    #f8f0d8;
  transform: translateX(-50%) perspective(240px) rotateX(54deg);
  box-shadow: 0 16px 0 rgba(98, 110, 83, 0.22);
}

.big-dou {
  position: absolute;
  top: 36px;
  left: 50%;
  color: #030303;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 136px;
  font-weight: 900;
  line-height: 1;
  transform: translateX(-50%);
  text-shadow: 0 10px 0 rgba(0, 0, 0, 0.16);
}

.name-brush {
  position: absolute;
  bottom: 14px;
  left: 50%;
  color: #b37a2b;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 64px;
  font-weight: 900;
  transform: translateX(-50%) skew(-8deg);
}

.spear-shape {
  position: absolute;
  top: 118px;
  left: 50%;
  width: 8px;
  height: 138px;
  border: 2px solid #111;
  background: #f4f4f4;
  transform: translateX(-50%) rotate(-27deg);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}

.spear-shape::before {
  position: absolute;
  top: -28px;
  left: -12px;
  width: 28px;
  height: 34px;
  content: "";
  clip-path: polygon(50% 0, 100% 72%, 52% 100%, 0 72%);
  background: #d8e3e6;
  border: 2px solid #111;
}

.spear-shape::after {
  position: absolute;
  top: 42px;
  left: 2px;
  width: 20px;
  height: 22px;
  content: "";
  background: #db4b39;
  clip-path: polygon(0 0, 100% 26%, 18% 100%);
}

.start-btn,
.claim-btn,
.recruit-btn {
  border: 4px solid #050505;
  color: #fff;
  background: #c4684a;
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.18),
    inset 0 -8px 0 rgba(0, 0, 0, 0.16),
    0 6px 0 #050505,
    0 10px 14px rgba(0, 0, 0, 0.18);
  font-weight: 900;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000;
}

.start-btn {
  position: absolute;
  right: 56px;
  bottom: 136px;
  left: 96px;
  min-height: 82px;
  border-radius: 4px;
  font-size: clamp(31px, 9vw, 45px);
}

.menu-footer {
  position: absolute;
  right: 18px;
  bottom: 26px;
  left: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

.rank-board,
.bag {
  min-width: 78px;
  min-height: 62px;
  padding: 8px 10px;
  color: #111;
  background: #d2b28a;
  font-size: 16px;
  font-weight: 900;
  pointer-events: auto;
}

.bag {
  border-radius: 20px 20px 12px 12px;
  color: #ffca35;
  background: #a96829;
  text-shadow:
    -1px -1px 0 #111,
    1px -1px 0 #111,
    -1px 1px 0 #111,
    1px 1px 0 #111;
}

.battle-hud {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: 0;
  left: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 84px 100px 1fr 64px;
  align-items: center;
  gap: 5px;
  height: 96px;
  padding: 0 8px;
  pointer-events: auto;
}

.battle-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pause-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, #d8d3c9 0 58%, #92877e 60%);
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.22));
}

.pause-btn span {
  position: absolute;
  top: 12px;
  width: 8px;
  height: 22px;
  border: 2px solid #6d3a31;
  border-radius: 4px;
  background: #fff7ef;
}

.pause-btn span:first-child {
  left: 13px;
}

.pause-btn span:last-child {
  right: 13px;
}

.exit-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid #111;
  border-radius: 50%;
  color: #4c2119;
  background: radial-gradient(circle, #f5e7d8 0 58%, #a99b90 60%);
  font-size: 20px;
  font-weight: 900;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.22));
}

.bun-pill {
  min-width: 96px;
  height: 44px;
  padding: 0 12px 0 0;
  color: #ffe65e;
  font-size: 27px;
  text-shadow: 0 2px 0 #111;
}

.bun-pill i,
.recruit-btn i {
  display: block;
  width: 42px;
  height: 28px;
  border: 3px solid #111;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 35%, #fff, #f6ebd5 68%, #ad8b4c);
  box-shadow: inset 0 -4px 0 rgba(81, 52, 26, 0.2);
}

.stage-title {
  align-self: center;
  color: #fff;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000,
    0 4px 0 rgba(0, 0, 0, 0.25);
}

.stage-title strong {
  display: block;
  color: #4b1e13;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 29px;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6);
}

.stage-title b {
  display: block;
  margin-top: -4px;
  font-size: 25px;
}

.heart-row {
  display: flex;
  justify-content: flex-end;
  gap: 3px;
}

.heart {
  display: block;
  width: 18px;
  height: 22px;
  color: #e54549;
  font-size: 20px;
  font-style: normal;
  font-weight: 900;
  line-height: 20px;
  text-shadow:
    -1px -1px 0 #111,
    1px -1px 0 #111,
    -1px 1px 0 #111,
    1px 1px 0 #111;
}

.heart.off {
  color: #665d5a;
  opacity: 0.35;
}

.battle-dock {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  height: 144px;
  border-top: 5px solid #111;
  background:
    linear-gradient(rgba(255, 246, 235, 0.78), rgba(235, 220, 207, 0.92)),
    repeating-linear-gradient(0deg, rgba(87, 67, 56, 0.08) 0 2px, transparent 2px 22px);
}

.camp-mark {
  position: absolute;
  top: 10px;
  left: 0;
  display: grid;
  place-items: center;
  width: 58px;
  height: 66px;
  border: 4px solid #111;
  color: #fff;
  background: linear-gradient(#9e4d31 0 28%, #343334 29%);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 34px;
  font-weight: 900;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000;
  transform: skew(-8deg);
}

.bench {
  position: absolute;
  top: 16px;
  right: 15px;
  left: 60px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  height: 48px;
}

.card {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  height: 48px;
  border: 2px solid #4e4d49;
  background: #f7f5eb;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
  touch-action: none;
}

.card.empty {
  background: rgba(245, 244, 234, 0.7);
}

.card.dragging {
  opacity: 0.38;
}

.card.hero {
  background: #fffef8;
  box-shadow:
    inset 0 0 0 2px #ffde3a,
    inset 0 -3px 0 rgba(0, 0, 0, 0.12),
    0 0 12px rgba(255, 213, 0, 0.55);
}

.glyph {
  color: #111;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(30px, 10vw, 42px);
  font-weight: 900;
  line-height: 1;
  transform: rotate(var(--rot, -3deg));
}

.glyph.gold {
  color: #bd7b22;
}

.level-dot,
.tool-dot {
  position: absolute;
  right: 4px;
  top: 3px;
  color: #111;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.tool-dot {
  right: 5px;
  top: auto;
  bottom: 4px;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: #9aa5a2;
  transform: rotate(-24deg);
}

.recruit-btn {
  position: absolute;
  right: 116px;
  bottom: 10px;
  left: 132px;
  display: grid;
  place-items: center;
  min-height: 50px;
  border-radius: 6px;
  background: #c56b4a;
}

.recruit-btn:disabled {
  background:
    linear-gradient(90deg, #9b614b 0 67%, #41484a 68%),
    #9b614b;
}

.recruit-btn span {
  display: block;
  font-size: 31px;
  line-height: 1;
}

.recruit-btn b {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000;
}

.recruit-btn i {
  width: 18px;
  height: 12px;
  border-width: 2px;
}

.recruit-btn em {
  font-style: normal;
}

.toast {
  position: absolute;
  top: 102px;
  left: 50%;
  z-index: 8;
  max-width: calc(100% - 36px);
  padding: 6px 14px 7px;
  border: 3px solid #111;
  border-radius: 5px;
  color: #fff;
  background: rgba(38, 31, 25, 0.88);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
}

.result-screen {
  display: grid;
  align-content: start;
  justify-items: center;
  padding-top: max(70px, env(safe-area-inset-top));
  background: rgba(225, 238, 240, 0.76);
}

.result-flag {
  min-width: 260px;
  padding: 20px 20px 22px;
  color: #111;
  background: #69808c;
  clip-path: polygon(8% 14%, 82% 8%, 100% 50%, 82% 90%, 8% 86%, 0 50%);
  font-size: 48px;
  font-weight: 900;
  text-align: center;
  text-shadow:
    -2px -2px 0 #96a7b0,
    2px -2px 0 #96a7b0,
    -2px 2px 0 #96a7b0,
    2px 2px 0 #96a7b0;
}

.result-flag.win {
  color: #ffe856;
  background: #eb7875;
  text-shadow:
    -3px -3px 0 #111,
    3px -3px 0 #111,
    -3px 3px 0 #111,
    3px 3px 0 #111;
}

.result-scroll {
  width: min(78vw, 310px);
  min-height: 112px;
  margin-top: 12px;
  padding: 12px 10px 10px;
  border: 4px solid #111;
  color: #fff36b;
  background: #080706;
  text-align: center;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}

.result-scroll h2,
.result-scroll p {
  margin: 0;
  font-weight: 900;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000;
}

.result-scroll h2 {
  color: #fff;
  font-size: 29px;
}

.result-scroll p {
  margin-top: 2px;
  font-size: 28px;
}

.stars.large {
  margin-top: 8px;
}

.stars.large .star {
  width: 38px;
  height: 38px;
}

.stars.large .star::before {
  font-size: 42px;
  line-height: 38px;
}

.result-field {
  position: relative;
  display: grid;
  place-items: center;
  width: min(72vw, 300px);
  height: 156px;
  margin-top: 14px;
}

.result-field::before {
  position: absolute;
  inset: 22px 10px 8px;
  content: "";
  border-radius: 50%;
  background: rgba(128, 154, 154, 0.25);
  transform: rotate(-7deg);
}

.result-field span {
  z-index: 1;
  color: #050505;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 116px;
  font-weight: 900;
  text-shadow: 0 11px 0 rgba(0, 0, 0, 0.14);
}

.result-field b {
  position: absolute;
  bottom: 18px;
  left: 50%;
  z-index: 2;
  color: #111;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 38px;
  transform: translateX(-50%);
}

.reward {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
  color: #fff;
  font-size: 40px;
  font-weight: 900;
  text-shadow:
    -3px -3px 0 #000,
    3px -3px 0 #000,
    -3px 3px 0 #000,
    3px 3px 0 #000;
}

.claim-btn {
  width: min(58vw, 250px);
  min-height: 64px;
  margin-top: 18px;
  border-radius: 5px;
  background: #565b68;
  font-size: 42px;
}

@media (max-height: 700px) {
  .phone-shell {
    padding: 0;
  }

  .game-frame {
    min-height: 100svh;
  }

  .game-title {
    top: 130px;
  }

  .rank-title {
    top: 216px;
  }

  .menu-screen > .stars {
    top: 260px;
  }

  .menu-illustration {
    top: 300px;
    transform: translateX(-50%) scale(0.88);
  }

  .start-btn {
    bottom: 110px;
  }
}
