* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #06245e;
  /* 禁用文本选中与长按菜单，避免移动端误触 */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  -webkit-tap-highlight-color: transparent;
  /* 输入阶段由 JS 决定；默认禁止画布上的手势缩放/滚动干扰 */
  touch-action: none;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  /* 让画布铺满刘海屏/底部安全区 */
  width: 100dvw;
  height: 100dvh;
}

.home-back {
  position: fixed;
  z-index: 20;
  top: max(7px, env(safe-area-inset-top));
  left: max(5px, env(safe-area-inset-left));
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: rgba(244, 247, 255, 0.9);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 180ms ease, opacity 180ms ease;
}

.home-back svg { width: 33px; height: 33px; overflow: visible; }
.home-back path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.home-back path + path { stroke-width: 1.5; opacity: 0.62; }
.home-back:hover { opacity: 0.82; transform: translateX(-2px) rotate(-2deg); }
.home-back:active { transform: translateX(-4px) scale(0.94); }
.home-back:focus-visible { outline: 2px dashed rgba(244, 247, 255, 0.9); outline-offset: 3px; }

/* 背景音乐开关：48px 点击区 + 内部居中 34px 圆，与返回箭头视觉边缘对齐 */
.sound-toggle {
  position: fixed;
  z-index: 20;
  top: max(7px, env(safe-area-inset-top));
  /* 返回箭头实际视觉左端比点击区左边缘再偏右约 16px；
     让圆圈右边缘与箭头左边缘到屏幕边缘的距离一致 */
  right: calc(max(5px, env(safe-area-inset-left)) + 9.5px);
  width: 48px;
  height: 48px;
  display: block;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 180ms ease, transform 180ms ease;
}
/* 音符字符：绝对锁定在圆圈正中，纯白，略大 */
.sound-toggle .ico {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
}
.sound-toggle .ico svg { display: block; width: 100%; height: 100%; overflow: visible; }
.sound-toggle .ico path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sound-toggle::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 7px;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(244, 247, 255, 0.9);
  border-radius: 49% 44% 47% 51%;
  background: rgba(6, 36, 94, 0.35);
  transition: background 180ms ease;
}
.sound-toggle:hover::before { background: rgba(6, 36, 94, 0.55); }
.sound-toggle:active { transform: scale(0.92); }
.sound-toggle:focus-visible { outline: 2px dashed rgba(244, 247, 255, 0.9); outline-offset: 3px; }
.sound-toggle.off { opacity: 0.62; }
.sound-toggle.off::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* 隐藏输入框：占位唤起键盘，但不在画面中可见 */
#hidden-input {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  outline: 0;
  opacity: 0;
  background: transparent;
  color: transparent;
  pointer-events: none; /* 不截获触摸，由画布统一处理聚焦 */
  font-size: 16px; /* 防止 iOS 聚焦时缩放 */
}
