:root {
  --paper: rgba(255, 250, 244, 0.84);
  --ink: #2a180f;
  --muted: #6d5548;
  --line: rgba(96, 56, 34, 0.12);
  --accent: #a96038;
  --accent-deep: #6f3d23;
  --teal: #2d7c78;
  --gold: #f7c769;
  --shadow: 0 22px 48px rgba(98, 56, 31, 0.16);
  --ui-font: "Trebuchet MS", "Microsoft YaHei", sans-serif;
  --display-font: "Georgia", "Microsoft YaHei", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--ui-font);
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 205, 137, 0.34), transparent 22%),
    radial-gradient(circle at 78% 20%, rgba(79, 166, 160, 0.18), transparent 24%),
    radial-gradient(circle at 80% 84%, rgba(230, 158, 110, 0.16), transparent 24%),
    linear-gradient(180deg, #f7eedc 0%, #f2d8c5 52%, #efd0b8 100%);
  overflow: hidden;
  touch-action: manipulation;
}

button,
canvas {
  -webkit-tap-highlight-color: transparent;
}

.backdrop {
  position: fixed;
  border-radius: 999px;
  filter: blur(36px);
  opacity: 0.5;
  pointer-events: none;
}

.backdrop-a {
  width: 220px;
  height: 220px;
  left: -84px;
  top: 64px;
  background: rgba(245, 175, 99, 0.26);
}

.backdrop-b {
  width: 240px;
  height: 240px;
  right: -100px;
  bottom: 40px;
  background: rgba(78, 157, 151, 0.2);
}

.app-shell {
  width: min(100vw - 8px, 760px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 6px 0 calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 6px;
}

.hero-card,
.arena-card,
.controls-card {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-card {
  padding: 12px 12px 10px;
  border-radius: 24px;
  transition: padding 180ms ease;
}

body.playing .hero-card {
  padding-top: 10px;
  padding-bottom: 8px;
}

body.playing .hero-copy {
  max-height: 0;
  opacity: 0;
  margin: 0;
  overflow: hidden;
}

.arena-card {
  min-height: 0;
  border-radius: 26px;
  overflow: hidden;
}

.controls-card {
  padding: 10px;
  border-radius: 24px;
  background: rgba(255, 250, 246, 0.72);
}

h1,
h2,
p,
strong {
  margin: 0;
}

.hero-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.hero-copy-wrap {
  min-width: 0;
}

.eyebrow {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(45, 124, 120, 0.12);
  color: var(--teal);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin-top: 6px;
  font-family: var(--display-font);
  font-size: clamp(1.5rem, 7vw, 2.2rem);
  line-height: 0.92;
}

.hero-copy {
  margin-top: 8px;
  max-width: 34rem;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
  transition: max-height 180ms ease, opacity 180ms ease, margin 180ms ease;
}

.hero-tools {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.tool-btn,
.primary-btn,
.ghost-btn,
.control-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.tool-btn,
.ghost-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, #fffaf5, #efddcc);
  color: var(--accent-deep);
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(100, 61, 38, 0.12);
}

.primary-btn {
  min-height: 42px;
  border-radius: 14px;
  background: linear-gradient(180deg, #d17b4e, var(--accent));
  color: #fffdf8;
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(88, 45, 24, 0.2);
}

.ghost-btn:disabled {
  opacity: 0.44;
  cursor: default;
}

.hero-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.board-wrap {
  position: relative;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 4px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(249, 228, 205, 0.22)),
    rgba(255, 250, 244, 0.6);
}

#gameCanvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 18px;
  background: linear-gradient(180deg, #f8eddd 0%, #f6decb 100%);
  touch-action: none;
}

.hud-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.hud-overlay {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  z-index: 4;
}

.hud-pill {
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 252, 248, 0.86);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.hud-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
}

.hud-pill strong {
  display: block;
  margin-top: 4px;
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overlay-panel {
  position: absolute;
  inset: 66px 12px 12px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 22px;
  text-align: center;
  color: #fff8f0;
  background: linear-gradient(180deg, rgba(45, 25, 16, 0.14), rgba(45, 25, 16, 0.46));
  border-radius: 18px;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.overlay-panel.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-badge {
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.overlay-panel h2 {
  font-family: var(--display-font);
  font-size: clamp(1.4rem, 6vw, 2rem);
  line-height: 0.96;
}

.overlay-panel p {
  max-width: 300px;
  line-height: 1.5;
  font-size: 0.9rem;
}

.tap-guide {
  position: relative;
  width: 112px;
  height: 72px;
}

.tap-ring,
.tap-finger {
  position: absolute;
}

.tap-ring {
  left: 24px;
  top: 8px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255, 252, 247, 0.72);
  animation: tap-ring 1.2s ease-out infinite;
}

.ring-b {
  animation-delay: 0.6s;
}

.tap-finger {
  left: 42px;
  top: 28px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fffdf8, #f5dcc5);
  box-shadow: 0 10px 20px rgba(34, 18, 10, 0.22);
  animation: tap-finger 1.2s ease-in-out infinite;
}

@keyframes tap-ring {
  0% {
    transform: scale(0.7);
    opacity: 0.75;
  }

  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}

@keyframes tap-finger {
  0%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(6px);
  }
}

.toast-message {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 5;
  width: min(calc(100% - 24px), 340px);
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(39, 22, 13, 0.8);
  color: #fff7ef;
  font-size: 0.82rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.item-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.item-slot {
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(255, 252, 247, 0.78);
  border: 1px solid rgba(96, 56, 34, 0.1);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.item-slot.active {
  transform: translateY(-2px);
  background: rgba(255, 248, 233, 0.98);
  border-color: rgba(169, 96, 56, 0.28);
}

.item-slot.boost-active {
  background: rgba(226, 255, 248, 0.96);
  border-color: rgba(45, 124, 120, 0.28);
}

.item-slot.giant-active {
  background: rgba(255, 245, 222, 0.98);
  border-color: rgba(219, 151, 58, 0.3);
}

.item-name {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
}

.item-slot strong {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
}

.control-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.control-btn {
  min-height: 60px;
  border-radius: 20px;
  color: #533116;
  font-size: 1rem;
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(133, 92, 24, 0.16);
}

.lane-btn {
  background: linear-gradient(180deg, #fffaf5, #ecd7c2);
}

.jump-btn {
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 250, 230, 0.5), transparent 18%),
    linear-gradient(180deg, #ffe48f, var(--gold));
}

.slide-btn {
  background: linear-gradient(180deg, #ffb78f, #ef8457);
  color: #fff9f3;
}

.control-wide {
  grid-column: 1 / -1;
  min-height: 54px;
}

body:not(.playing) .jump-btn {
  animation: idle-pulse 1.45s ease-in-out infinite;
}

@keyframes idle-pulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.015);
  }
}

.controls-note {
  margin-top: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 560px) {
  .hero-row {
    flex-direction: column;
  }

  .hero-tools {
    width: 100%;
  }

  .tool-btn {
    width: 100%;
  }

  .hud-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .control-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .overlay-panel {
    inset: 118px 10px 10px;
    padding: 18px;
  }
}
