:root {
  --ink: #21412c;
  --ink-deep: #142a1c;
  --leaf: #477a51;
  --leaf-dark: #2c5b36;
  --leaf-soft: #93bd8e;
  --mint: #b8d8c8;
  --mint-light: #e8f5df;
  --cream: #f5f4dc;
  --paper: #fff6dc;
  --court: #9fc291;
  --orange: #f28a3e;
  --gold: #ffd871;
  --red: #c96d5b;
  --blue: #6bb1d8;
  --shadow: rgba(24, 58, 34, 0.26);
  --outline: #285333;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 24% 18%, rgba(242, 255, 216, 0.5), transparent 23rem),
    radial-gradient(circle at 82% 14%, rgba(255, 246, 214, 0.28), transparent 19rem),
    linear-gradient(135deg, #8ab8a9 0%, #a9cfbd 45%, #86b7a8 100%);
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(100%, 1080px);
  display: grid;
  place-items: center;
}

.phone {
  position: relative;
  width: min(100%, 430px);
  min-height: min(920px, calc(100vh - 28px));
  border: 6px solid var(--outline);
  border-radius: 25px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(241, 249, 224, 0.36), transparent 18%),
    linear-gradient(180deg, #b8d9cc 0%, #a6cebd 48%, #98c4b0 100%);
  box-shadow: 0 22px 58px rgba(26, 62, 36, 0.35);
}

.phone::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(38, 86, 47, 0.18), transparent 18rem),
    linear-gradient(90deg, rgba(255,255,255,0.16), transparent 18%, transparent 82%, rgba(27, 72, 38, 0.1));
  z-index: 1;
}

.sky-piece {
  position: absolute;
  width: 130px;
  height: 18px;
  background: #e5f5c9;
  opacity: 0.8;
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
  z-index: 2;
  pointer-events: none;
}

.sky-piece-left {
  left: -30px;
  top: 120px;
  transform: rotate(180deg);
}

.sky-piece-right {
  right: -36px;
  top: 56px;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  min-height: 100%;
  padding: 18px;
}

.screen.is-active {
  display: flex;
  flex-direction: column;
}

.topbar,
.screen-head,
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
}

.coin-pill {
  min-width: 112px;
  height: 36px;
  padding: 4px 10px 4px 6px;
  border: 3px solid rgba(40, 83, 51, 0.7);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(236, 246, 213, 0.85);
  box-shadow: inset 0 -3px 0 rgba(47, 91, 55, 0.12);
}

.coin-icon,
.ball-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #a55720;
  background:
    linear-gradient(90deg, transparent 44%, #a55720 45%, #a55720 55%, transparent 56%),
    linear-gradient(0deg, transparent 44%, #a55720 45%, #a55720 55%, transparent 56%),
    radial-gradient(circle, #ffd65c 0 28%, #f3a23b 29% 100%);
  box-shadow: inset -3px -3px 0 rgba(141, 72, 23, 0.16);
}

.ball-icon {
  background:
    linear-gradient(90deg, transparent 44%, #8a481e 45%, #8a481e 55%, transparent 56%),
    linear-gradient(0deg, transparent 44%, #8a481e 45%, #8a481e 55%, transparent 56%),
    radial-gradient(circle, #ffad5a 0 100%);
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(40, 83, 51, 0.74);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(239, 246, 220, 0.92);
  display: grid;
  place-items: center;
  font-weight: 900;
  box-shadow: inset 0 -3px 0 rgba(47, 91, 55, 0.13);
}

.brand-wrap {
  margin-top: 30px;
  text-align: center;
}

.logo {
  margin: 0;
  color: #fffdf3;
  font-size: clamp(43px, 12vw, 56px);
  line-height: 1;
  letter-spacing: 0;
  font-weight: 950;
  text-shadow:
    0 5px 0 #1e4d2c,
    4px 0 0 #1e4d2c,
    -4px 0 0 #1e4d2c,
    0 -4px 0 #1e4d2c,
    0 10px 0 rgba(18, 60, 31, 0.28);
}

.logo span {
  position: relative;
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin: 0 -0.03em;
  vertical-align: -0.05em;
  border: 0.07em solid #8a481e;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 45%, #8a481e 46%, #8a481e 54%, transparent 55%),
    linear-gradient(0deg, transparent 45%, #8a481e 46%, #8a481e 54%, transparent 55%),
    #f28a3e;
  box-shadow:
    0 0 0 0.06em #fffdf3,
    0 0.1em 0 #1e4d2c;
}

.tagline {
  margin: 18px auto 0;
  color: var(--leaf-dark);
  font-weight: 900;
  font-size: 18px;
}

.hero-canvas {
  width: min(100%, 380px);
  aspect-ratio: 380 / 310;
  margin: 12px auto 0;
  display: block;
}

.primary-actions {
  display: grid;
  place-items: center;
  margin-top: auto;
}

.big-btn,
.small-btn,
.tile-btn,
.level-card {
  border: 3px solid rgba(40, 83, 51, 0.82);
  box-shadow:
    inset 0 -5px 0 rgba(84, 69, 19, 0.12),
    0 5px 0 rgba(39, 75, 45, 0.18);
  color: var(--ink);
  touch-action: manipulation;
}

.big-btn {
  min-height: 62px;
  border-radius: 18px;
  padding: 10px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 28px;
  font-weight: 950;
}

.big-btn.play {
  width: min(100%, 318px);
  background: linear-gradient(180deg, #ffe88b 0%, #ffc86d 100%);
  border-color: #8d6830;
}

.big-btn.shoot {
  min-width: 210px;
  background: linear-gradient(180deg, #ffcf75 0%, #f29945 100%);
  border-color: #945926;
}

.play-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--outline);
  background: #81c879;
  position: relative;
  flex: 0 0 auto;
}

.play-mark::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 5px;
  border-left: 11px solid #fff7d9;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.tile-btn {
  min-height: 86px;
  border-radius: 16px;
  background: rgba(239, 246, 220, 0.88);
  display: grid;
  place-items: center;
  gap: 5px;
  font-weight: 900;
}

.tile-icon {
  width: 40px;
  height: 40px;
  position: relative;
  display: inline-grid;
  place-items: center;
}

.map-icon {
  border: 3px solid var(--outline);
  border-radius: 5px;
  transform: skewY(-6deg);
}

.map-icon::before,
.map-icon::after {
  content: "";
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 3px;
  background: var(--outline);
}

.map-icon::before {
  left: 12px;
}

.map-icon::after {
  right: 12px;
}

.jersey-icon {
  border-radius: 10px 10px 8px 8px;
  color: #fff;
  background: var(--leaf);
  border: 3px solid var(--outline);
  font-size: 16px;
  font-weight: 950;
}

.jersey-icon::before,
.jersey-icon::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 18px;
  top: 7px;
  background: var(--leaf);
  border: 3px solid var(--outline);
  border-radius: 8px;
}

.jersey-icon::before {
  left: -10px;
  transform: rotate(18deg);
}

.jersey-icon::after {
  right: -10px;
  transform: rotate(-18deg);
}

.gear-icon {
  border: 7px solid var(--leaf);
  border-radius: 50%;
  outline: 3px solid var(--outline);
}

.gear-icon::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--outline);
}

.screen-head {
  padding-bottom: 18px;
}

.screen-head h2 {
  margin: 0;
  color: #fffdf3;
  font-size: 32px;
  font-weight: 950;
  text-shadow:
    0 4px 0 #1e4d2c,
    3px 0 0 #1e4d2c,
    -3px 0 0 #1e4d2c,
    0 -3px 0 #1e4d2c;
}

.arrow-left {
  width: 17px;
  height: 17px;
  border-left: 5px solid var(--outline);
  border-bottom: 5px solid var(--outline);
  transform: rotate(45deg);
  margin-left: 5px;
}

.head-spacer {
  width: 38px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 16px 0 auto;
}

.level-card {
  min-height: 128px;
  border-radius: 18px;
  padding: 13px 10px;
  background: rgba(239, 246, 220, 0.86);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 7px;
  position: relative;
  overflow: hidden;
}

.level-card.locked {
  filter: grayscale(0.5);
  opacity: 0.68;
}

.level-card h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.level-card p {
  margin: 0;
  font-size: 13px;
  font-weight: 900;
  color: var(--leaf-dark);
}

.stars {
  min-height: 28px;
  display: inline-flex;
  gap: 3px;
  align-items: center;
  justify-content: center;
}

.star {
  width: 24px;
  height: 24px;
  clip-path: polygon(50% 4%, 61% 35%, 94% 35%, 67% 55%, 77% 88%, 50% 68%, 23% 88%, 33% 55%, 6% 35%, 39% 35%);
  background: #b4c2a4;
  border: 1px solid rgba(0,0,0,0.1);
}

.star.filled {
  background: var(--gold);
  filter: drop-shadow(0 1px 0 #966c24);
}

.lock {
  width: 26px;
  height: 24px;
  border: 4px solid var(--outline);
  border-radius: 6px;
  position: relative;
}

.lock::before {
  content: "";
  position: absolute;
  left: 4px;
  top: -19px;
  width: 12px;
  height: 18px;
  border: 4px solid var(--outline);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
}

.pager-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding-bottom: 8px;
}

.pager-dots span {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(238, 248, 224, 0.5);
}

.pager-dots .active {
  background: #fff;
}

.game-hud {
  flex-wrap: nowrap;
  gap: 7px;
}

.game-hud .icon-btn {
  width: 35px;
  height: 35px;
  border-radius: 10px;
  flex: 0 0 auto;
}

.stat-card {
  min-width: 0;
  flex: 1 1 0;
  min-height: 52px;
  border: 3px solid rgba(40, 83, 51, 0.72);
  border-radius: 13px;
  background: rgba(239, 246, 220, 0.86);
  display: grid;
  place-items: center;
  padding: 4px;
  box-shadow: inset 0 -3px 0 rgba(47, 91, 55, 0.12);
}

.stat-card small {
  display: block;
  font-size: 11px;
  font-weight: 900;
  opacity: 0.78;
}

.stat-card strong {
  display: block;
  font-size: 20px;
  line-height: 1.05;
}

.canvas-wrap {
  position: relative;
  margin-top: 10px;
  min-height: 0;
}

#gameCanvas {
  width: 100%;
  aspect-ratio: 720 / 820;
  display: block;
  border: 4px solid var(--outline);
  border-radius: 18px;
  background: #b5d9cc;
  touch-action: none;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
}

.toast {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%) scale(0.92);
  min-width: 150px;
  padding: 10px 16px;
  border: 3px solid rgba(40, 83, 51, 0.78);
  border-radius: 999px;
  color: #fffdf3;
  background: rgba(61, 112, 69, 0.92);
  text-align: center;
  font-size: 22px;
  font-weight: 950;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  text-shadow: 0 2px 0 var(--outline);
}

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

.control-panel {
  margin-top: 10px;
  border: 3px solid rgba(40, 83, 51, 0.68);
  border-radius: 18px;
  background: rgba(239, 246, 220, 0.88);
  padding: 10px;
  display: grid;
  gap: 9px;
}

.range-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  font-weight: 950;
}

.range-row input {
  width: 100%;
  accent-color: var(--leaf);
}

.range-row strong {
  text-align: right;
}

.shot-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 10px;
  align-items: center;
}

.shot-actions .shoot {
  width: 100%;
  min-width: 0;
}

.small-btn {
  width: 100%;
  min-height: 54px;
  border-radius: 15px;
  padding: 8px 13px;
  background: rgba(242, 246, 220, 0.94);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 950;
  white-space: nowrap;
}

.retry-icon {
  width: 25px;
  height: 25px;
  border: 4px solid var(--leaf);
  border-left-color: transparent;
  border-radius: 50%;
  position: relative;
}

.retry-icon::before {
  content: "";
  position: absolute;
  right: -5px;
  top: 0;
  border-left: 9px solid var(--leaf);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.result-modal {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(41, 81, 50, 0.26);
  display: none;
  place-items: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.result-modal.is-open {
  display: grid;
}

.result-card {
  width: min(100%, 330px);
  border: 5px solid var(--outline);
  border-radius: 22px;
  background: linear-gradient(180deg, #f9f8e2, #e7f1ce);
  padding: 22px 18px 18px;
  text-align: center;
  box-shadow: 0 18px 36px rgba(24, 58, 34, 0.34);
}

.result-stars {
  min-height: 40px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.result-stars .star {
  width: 36px;
  height: 36px;
}

.result-card h2 {
  margin: 8px 0 4px;
  font-size: 34px;
  color: var(--ink);
}

.result-card p {
  margin: 0 0 18px;
  font-weight: 900;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
}

.result-actions .big-btn {
  min-width: 0;
  width: auto;
  min-height: 54px;
  font-size: 20px;
}

@media (max-height: 820px) {
  .phone {
    min-height: calc(100vh - 20px);
  }

  .screen {
    padding: 12px;
  }

  .brand-wrap {
    margin-top: 16px;
  }

  .hero-canvas {
    width: min(100%, 340px);
  }

  .menu-grid {
    margin-top: 12px;
  }

  .tile-btn {
    min-height: 74px;
  }
}

@media (max-width: 380px) {
  .phone {
    border-width: 4px;
    border-radius: 20px;
  }

  .screen {
    padding: 12px;
  }

  .big-btn {
    font-size: 24px;
  }

  .level-grid {
    gap: 10px;
  }

  .level-card {
    min-height: 116px;
    padding: 10px 6px;
  }

  .level-card h3 {
    font-size: 21px;
  }

  .stat-card strong {
    font-size: 18px;
  }

  .small-btn {
    padding: 8px 8px;
    gap: 5px;
    font-size: 16px;
  }

  .retry-icon {
    width: 22px;
    height: 22px;
    border-width: 4px;
  }
}
