*,
*::before,
*::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 16px 26px;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: #5b3346;
  background:
    radial-gradient(900px 520px at 12% -8%, #fff2f8 0%, rgba(255, 242, 248, 0) 62%),
    radial-gradient(760px 480px at 106% 6%, #ffe0ee 0%, rgba(255, 224, 238, 0) 58%),
    linear-gradient(180deg, #fffafd 0%, #ffeef6 52%, #ffe3ef 100%);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 148, 184, 0.16) 1.4px, transparent 1.5px);
  background-size: 20px 20px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0) 72%);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0) 72%);
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.badge {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
  border-radius: 15px;
  background: linear-gradient(150deg, #ffd7e5, #ffaecb);
  box-shadow:
    0 7px 16px rgba(240, 86, 140, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  animation: bob 2.8s ease-in-out infinite;
}

.brand-text { min-width: 0; }

h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: #6a3550;
}

.sub {
  margin: 3px 0 0;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: #bd8ba0;
}

.stats { display: flex; gap: 7px; flex: none; }

.stat {
  min-width: 58px;
  padding: 5px 10px 6px;
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 13px;
  box-shadow:
    0 4px 12px rgba(200, 120, 155, 0.14),
    inset 0 0 0 1px rgba(255, 214, 229, 0.9);
}

.stat span {
  display: block;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: #c292a4;
}

.stat strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  color: #e2568a;
}

/* ---------- board ---------- */
.board {
  position: relative;
  padding: 8px;
  border-radius: 26px;
  background: linear-gradient(158deg, #ffd9e7 0%, #ffc3d8 58%, #ffb4cf 100%);
  box-shadow:
    0 18px 40px rgba(214, 96, 140, 0.24),
    0 2px 0 rgba(255, 255, 255, 0.85) inset,
    0 -3px 0 rgba(214, 96, 140, 0.12) inset;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 19px;
  background: #dff3c9;
  touch-action: none;
}

/* ---------- overlay ---------- */
.overlay {
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 19px;
  background: rgba(255, 247, 251, 0.55);
  -webkit-backdrop-filter: blur(5px) saturate(1.08);
  backdrop-filter: blur(5px) saturate(1.08);
  transition: opacity 0.22s ease, visibility 0.22s ease;
  z-index: 2;
}

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

.panel {
  width: min(100%, 320px);
  padding: 22px 22px 18px;
  text-align: center;
  border-radius: 22px;
  border: 1px solid #ffe0ec;
  background: linear-gradient(180deg, #ffffff 0%, #fff8fb 100%);
  box-shadow: 0 16px 34px rgba(190, 90, 130, 0.2);
  animation: pop 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.35);
}

.panel .emoji {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 5px 8px rgba(120, 60, 80, 0.16));
  animation: float 2.4s ease-in-out infinite;
}

.panel h2 {
  margin: 10px 0 6px;
  font-size: 18px;
  color: #6a3550;
}

.panel p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.85;
  color: #9c6d80;
}

.panel p b {
  color: #e2568a;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.panel .tips {
  margin-top: 10px;
  font-size: 11px;
  color: #c094a6;
  letter-spacing: 0.02em;
}

.panel .row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 15px;
  flex-wrap: wrap;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: #fff;
  padding: 12px 26px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff8ab3 0%, #f4497f 100%);
  box-shadow:
    0 9px 20px rgba(244, 73, 127, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  touch-action: manipulation;
}

.btn:hover { filter: brightness(1.04); }

.btn:active {
  transform: translateY(2px) scale(0.985);
  box-shadow: 0 3px 10px rgba(244, 73, 127, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn.ghost {
  color: #d9578a;
  background: #fff;
  box-shadow: 0 6px 14px rgba(214, 96, 140, 0.14), inset 0 0 0 1.5px #ffd3e2;
}

.btn:focus-visible,
.chip:focus-visible,
.dpad button:focus-visible {
  outline: 3px solid rgba(244, 73, 127, 0.35);
  outline-offset: 2px;
}

/* ---------- toolbar ---------- */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.chip {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: #c2557f;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 5px 12px rgba(214, 96, 140, 0.14), inset 0 0 0 1.5px #ffdbe8;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}

.chip:active { transform: translateY(1px) scale(0.985); }

.chip.primary {
  color: #fff;
  background: linear-gradient(180deg, #ff8ab3 0%, #f4497f 100%);
  box-shadow: 0 8px 18px rgba(244, 73, 127, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  min-width: 86px;
}

/* ---------- dpad ---------- */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 48px);
  gap: 7px;
  width: 100%;
  max-width: 232px;
  margin: 0 auto;
}

.dpad button {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-size: 15px;
  color: #d9578a;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 5px 12px rgba(214, 96, 140, 0.16), inset 0 0 0 1.5px #ffd7e5;
  transition: transform 0.1s ease, background 0.1s ease;
  touch-action: none;
  user-select: none;
}

.dpad button:active {
  transform: scale(0.94);
  background: #ffe3ee;
}

.dpad [data-dir="up"] { grid-area: 1 / 2 / 2 / 3; }
.dpad [data-dir="left"] { grid-area: 2 / 1 / 3 / 2; }
.dpad [data-dir="right"] { grid-area: 2 / 3 / 3 / 4; }
.dpad [data-dir="down"] { grid-area: 3 / 2 / 4 / 3; }

/* ---------- hint ---------- */
.hint {
  margin: 0;
  text-align: center;
  font-size: 11px;
  line-height: 1.9;
  color: #b98da0;
}

kbd {
  display: inline-block;
  margin: 0 1px;
  padding: 1px 5px;
  font: inherit;
  font-size: 10px;
  color: #c2688c;
  background: #fff;
  border-radius: 5px;
  box-shadow: 0 1.5px 0 #eac3d4;
}

/* ---------- motion ---------- */
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-4px) rotate(3deg); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.9) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (hover: hover) and (pointer: fine) {
  .dpad { display: none; }
}

@media (max-height: 720px) and (pointer: coarse) {
  .hint { display: none; }
  .dpad { grid-template-rows: repeat(3, 44px); }
  .board { padding: 6px; }
  .overlay { inset: 6px; }
}

@media (max-width: 420px) {
  body { padding: 14px 12px 20px; }
  h1 { font-size: 16px; }
  .badge { width: 38px; height: 38px; font-size: 20px; border-radius: 12px; }
  .brand { gap: 8px; }
  .stats { gap: 5px; }
  .stat { min-width: 44px; padding: 4px 6px 5px; border-radius: 11px; }
  .stat span { font-size: 8.5px; letter-spacing: 0.08em; }
  .stat strong { font-size: 15px; }
  .sub { font-size: 9px; letter-spacing: 0.14em; }
  .toolbar { gap: 6px; }
  .chip { padding: 8px 13px; font-size: 12px; }
  .chip.primary { min-width: 74px; }
  .hint { font-size: 10px; }
  .panel { padding: 20px 16px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
