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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #3a2416;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #4A2C1A;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #f2e1c8;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: calc(9px + env(safe-area-inset-top));
  left: 11px;
  right: 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  z-index: 3;
  pointer-events: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 37px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 249, 238, 0.94);
  border: 1px solid rgba(122, 84, 50, 0.16);
  box-shadow: 0 5px 14px rgba(74, 44, 26, 0.14), inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #6b4a2e;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chip-coins {
  height: 40px;
  padding: 0 15px 0 8px;
  gap: 7px;
  color: #4A2C1A;
  background: linear-gradient(180deg, #FFFDF8, #FFF3E1);
  transition: transform 0.16s ease;
}

.chip-coins.bump {
  transform: scale(1.07);
}

.coin-ico {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 800;
  color: #8a5a12;
  background: radial-gradient(circle at 34% 28%, #FFF2B8 0%, #F8D26A 44%, #E4A62F 74%, #C68920 100%);
  box-shadow: inset 0 -2px 2px rgba(130, 80, 10, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.8), 0 1px 2px rgba(120, 70, 20, 0.25);
  text-shadow: 0 1px 0 rgba(255, 245, 190, 0.65);
}

.chip-num {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.chip-mini {
  height: 32px;
  padding: 0 11px;
  gap: 5px;
  font-size: 12px;
  color: #755137;
  background: rgba(255, 249, 238, 0.86);
}

.chip-mini .mp-icon {
  width: 15px;
  height: 15px;
  color: #C07A3E;
}

.chip-price .price-label {
  color: #A1805F;
  font-size: 10px;
  font-weight: 600;
}

.chip-price span:last-child {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------- toast / coach ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translate(-50%, 8px);
  max-width: 84%;
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(66, 41, 23, 0.9);
  color: #FFF6E6;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 8px 20px rgba(45, 25, 10, 0.28);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.coach {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.9);
  border: 1px solid rgba(140, 95, 55, 0.16);
  box-shadow: 0 5px 16px rgba(74, 44, 26, 0.16);
  color: #8A6244;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 4;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.coach .mp-icon {
  width: 15px;
  height: 15px;
  color: #E57A2E;
}

.coach.hide {
  opacity: 0;
  transform: translate(-50%, 8px);
}

/* ---------- bottom panel ---------- */
.panel {
  position: relative;
  flex: 0 0 auto;
  z-index: 6;
  padding: 5px 0 calc(10px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, #FFFBF3 0%, #FBF1E1 58%, #F6E8D4 100%);
  border-top: 1px solid rgba(126, 84, 46, 0.2);
  box-shadow: 0 -12px 30px rgba(78, 44, 18, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 138, 61, 0.5), rgba(255, 194, 120, 0.35), transparent);
}

.panel-grip {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  margin: 2px auto 3px;
  background: #E4D0B6;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 16px 6px;
}

.panel-title {
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #5A3820;
}

.panel-title::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 6px;
  border-radius: 50%;
  background: #FF8A3D;
  vertical-align: 1px;
  box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.16);
}

.panel-sold {
  font-size: 10.5px;
  color: #A1805F;
  font-weight: 600;
}

.panel-sold b {
  color: #D96B23;
  font-variant-numeric: tabular-nums;
}

.upgrades {
  display: flex;
  gap: 9px;
  padding: 2px 16px 3px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.upgrades::-webkit-scrollbar {
  display: none;
}

.card {
  scroll-snap-align: start;
  flex: 0 0 93px;
  height: 103px;
  padding: 8px 9px 8px;
  display: flex;
  flex-direction: column;
  text-align: left;
  font-family: inherit;
  color: inherit;
  border-radius: 15px;
  border: 1px solid rgba(140, 95, 55, 0.17);
  background: linear-gradient(180deg, #FFFEFB 0%, #FFF8EC 100%);
  box-shadow: 0 3px 9px rgba(110, 70, 35, 0.1), inset 0 1px 0 #fff;
  cursor: pointer;
  position: relative;
  transition: transform 0.08s ease, box-shadow 0.12s ease, opacity 0.2s ease;
}

.card:active {
  transform: scale(0.955);
  box-shadow: 0 1px 4px rgba(110, 70, 35, 0.12), inset 0 1px 0 #fff;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
}

.card-ic {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--tint, #FFE6D1);
  color: var(--accent, #E56C1D);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.card-ic .mp-icon {
  width: 17px;
  height: 17px;
}

.card-lv {
  font-size: 9.5px;
  font-weight: 800;
  color: #9A7C60;
  background: #F4E8D7;
  border-radius: 7px;
  padding: 2px 5px;
  font-variant-numeric: tabular-nums;
}

.card-name {
  margin-top: 3px;
  font-size: 11.8px;
  font-weight: 800;
  color: #4B301B;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.card-cost {
  margin-top: auto;
  height: 23px;
  padding: 0 7px;
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
  background: linear-gradient(180deg, #FFA65F 0%, #FF8433 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 4px rgba(210, 105, 38, 0.2);
  font-variant-numeric: tabular-nums;
}

.card-cost .dot {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFF2B8, #F8D26A 55%, #D99A2B);
  box-shadow: inset 0 -1px 1px rgba(140, 85, 15, 0.35);
}

.card.locked {
  opacity: 0.56;
}

.card.locked .card-cost {
  background: linear-gradient(180deg, #CDB69C 0%, #BFA88F 100%);
  box-shadow: none;
}

.card.maxed .card-cost {
  background: linear-gradient(180deg, #C7B39C 0%, #B59E85 100%);
  box-shadow: none;
}

.card.maxed .card-ic {
  filter: grayscale(0.35);
}

@media (max-height: 620px) {
  .card {
    height: 94px;
    flex-basis: 90px;
    padding: 6px 8px;
  }
  .card-name {
    font-size: 11px;
  }
  .card-ic {
    width: 24px;
    height: 24px;
  }
  .card-ic .mp-icon {
    width: 15px;
    height: 15px;
  }
  .panel-head {
    padding-bottom: 4px;
  }
}
