:root {
  --ui: 12px;
  --tb: 64px;
  --font-title: "ZCOOL KuaiLe", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "WenQuanYi Zen Hei", sans-serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "WenQuanYi Zen Hei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2b2233;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  font-family: var(--font-body);
}

body {
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 170, 190, 0.10), transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(150, 200, 255, 0.10), transparent 45%),
    #2b2233;
}

#app { position: fixed; inset: 0; }

#game {
  position: absolute;
  display: block;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  outline: none;
}

#hud {
  position: absolute;
  display: flex;
  gap: calc(var(--ui) * 0.6);
  pointer-events: none;
  z-index: 3;
}

.hudbtn {
  pointer-events: auto;
  width: calc(var(--ui) * 3.1);
  height: calc(var(--ui) * 3.1);
  min-width: 34px;
  min-height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(60, 45, 70, 0.55);
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, background 0.2s;
}
.hudbtn:hover { background: rgba(60, 45, 70, 0.75); }
.hudbtn:active { transform: scale(0.92); }
.hudbtn svg { width: 58%; height: 58%; fill: #fff; stroke: #fff; }
.hudbtn svg rect, .hudbtn svg path:first-child { stroke: none; }
#btnMute .off { display: none; }
#btnMute.muted .on { display: none; }
#btnMute.muted .off { display: block; }
#hud.hidden-pause #btnPause { visibility: hidden; }

#overlay {
  position: absolute;
  pointer-events: none;
  z-index: 4;
  font-size: var(--ui);
}

.panel {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7em;
  padding-bottom: 7%;
}
.panel.show { display: flex; animation: pop 0.35s ease-out; }
.panel.center { justify-content: center; padding-bottom: 0; background: rgba(43, 34, 51, 0.45); pointer-events: auto; }

@keyframes pop {
  from { opacity: 0; transform: translateY(0.8em); }
  to { opacity: 1; transform: none; }
}

.panel button { pointer-events: auto; }

button.big, button.ghost {
  font-family: var(--font-title);
  cursor: pointer;
  touch-action: manipulation;
  border-radius: 999px;
  letter-spacing: 0.08em;
  transition: transform 0.1s, filter 0.2s;
}

button.big {
  font-size: 2.1em;
  padding: 0.32em 1.5em 0.38em;
  color: #fff;
  border: 0.14em solid #fff;
  background: linear-gradient(180deg, #ff9fae 0%, #ff6f91 100%);
  box-shadow: 0 0.22em 0 #c94f72, 0 0.5em 1.2em rgba(60, 20, 40, 0.35);
  animation: breathe 2.4s ease-in-out infinite;
}
button.big:hover { filter: brightness(1.06); }
button.big:active { transform: translateY(0.15em); box-shadow: 0 0.07em 0 #c94f72, 0 0.3em 0.8em rgba(60, 20, 40, 0.35); }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

button.ghost {
  font-size: 1.35em;
  padding: 0.3em 1.2em;
  color: #5b4466;
  background: rgba(255, 255, 255, 0.86);
  border: 0.12em solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0.2em 0.6em rgba(60, 20, 40, 0.2);
}
button.ghost:active { transform: scale(0.96); }

.hint {
  margin: 0.2em 1em 0;
  font-size: 1.05em;
  color: #6a5470;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.35em 0.9em;
  border-radius: 1em;
  text-align: center;
  line-height: 1.5;
  max-width: 92%;
}

.card {
  background: #fff8f0;
  border: 0.2em solid #fff;
  border-radius: 1.4em;
  padding: 1.4em 2.2em 1.6em;
  text-align: center;
  box-shadow: 0 0.6em 2em rgba(40, 20, 50, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6em;
  max-width: 90%;
}
.card h2 { margin: 0; font-family: var(--font-title); font-weight: normal; font-size: 2.2em; color: #e2557a; }
.card p { margin: 0 0 0.4em; color: #6a5470; font-size: 1.1em; }

#touch {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  pointer-events: none;
  z-index: 2;
}
#touch.on { display: block; }
#touch.hide { visibility: hidden; }

.tc {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.tleft { left: max(14px, env(safe-area-inset-left)); }
.tright { right: max(14px, env(safe-area-inset-right)); }

.tb {
  pointer-events: auto;
  width: var(--tb);
  height: var(--tb);
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 0;
  touch-action: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.tb svg { width: 48%; height: 48%; fill: #fff; }
.tb.small { width: calc(var(--tb) * 0.78); height: calc(var(--tb) * 0.78); margin-bottom: calc(var(--tb) * 0.55); }
.tb.jump { width: calc(var(--tb) * 1.3); height: calc(var(--tb) * 1.3); background: rgba(255, 111, 145, 0.45); }
.tb.jump span { color: #fff; font-family: var(--font-title); font-size: calc(var(--tb) * 0.42); }
.tb.down-on, .tb:active { background: rgba(255, 255, 255, 0.5); transform: scale(0.94); }
.tb.jump.down-on { background: rgba(255, 111, 145, 0.75); }

#touch.portrait .tc { bottom: auto; top: 50%; transform: translateY(-50%); }
#touch.portrait { background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0)); }

.noscript {
  color: #fff;
  text-align: center;
  margin-top: 40vh;
  font-size: 18px;
}

#pTitle { padding-left: 40%; padding-bottom: 9%; }
#pEnd { padding-bottom: 2.5%; }

/* phone landscape: controls live in side gutters, never over the player */
#touch.side .tc { top: 50%; bottom: auto; transform: translateY(-40%); justify-content: center; }
#touch.side .tleft {
  left: 0; width: var(--gut);
  display: grid; grid-template-columns: auto auto; gap: 8px; place-content: center;
}
#touch.side .tright { right: 0; width: var(--gut); display: flex; }
#touch.side [data-k=down] { grid-row: 1; grid-column: 1 / span 2; justify-self: center; margin-bottom: 0; }
#touch.side [data-k=left] { grid-row: 2; grid-column: 1; }
#touch.side [data-k=right] { grid-row: 2; grid-column: 2; }
