/* ============================================================
   哥伦比娅Tap · 样式表
   ------------------------------------------------------------
   想改配色：只动下面 :root 里的几个变量就行。
   想改角色大小：搜 "--char-size"。
   ============================================================ */

:root {
  /* ---- 主题配色（改这里就能换整套颜色） ---- */
  --bg:        #fdf7f2;   /* 页面底色：暖白（渐变用，见 body） */
  --ink:       #6b5a64;   /* 普通文字：灰棕 */
  --accent:    #5b8ff9;   /* 主色：蓝（取自角色蝴蝶结） */
  --accent-2:  #ff6b9e;   /* 点缀色：玫红（取自发色） */
  --panel-bg:  #ffffff;   /* 设置面板底色 */

  /* ---- 角色大小（屏幕最小边的百分比，手机电脑自动适配） ---- */
  --char-size: 42vmin;
}

/* ---- 全局基础 ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  /* 背景：暖白打底，四角各晕开一团淡彩（粉 / 蓝 / 奶油 / 薄荷）。
       想换感觉就改下面四组 radial-gradient 的颜色值。 */
  background:
    radial-gradient(120vmax 80vmax at 8% -12%,  #ffe3ee 0%, rgba(255, 227, 238, 0) 60%),
    radial-gradient(90vmax 70vmax at 105% -5%,  #e2ecff 0%, rgba(226, 236, 255, 0) 55%),
    radial-gradient(110vmax 85vmax at 50% 118%, #ffefdb 0%, rgba(255, 239, 219, 0) 60%),
    radial-gradient(70vmax 60vmax at -10% 105%, #e8f7f0 0%, rgba(232, 247, 240, 0) 55%),
    var(--bg);
  /* 禁止长按选中文字、禁止双击缩放、禁止触摸滚动 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

/* ---- 舞台与各个图层（从下往上叠） ---- */
#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#fx {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;   /* 画布只负责显示，不拦截点击 */
}

#key-grid {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  display: grid;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#key-grid.is-visible { opacity: 1; }

.key-grid-cell {
  box-shadow: inset 0 0 0 0.5px rgba(107, 90, 100, 0.18);
}

#zoneflash {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

/* 点到格子时短暂出现的白色闪光，动画播放完 JS 会把它删掉 */
.zone-flash {
  position: absolute;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  animation: zone-flash 0.35s ease-out forwards;
}
@keyframes zone-flash {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ---- 角色 ---- */
#char-pos {
  position: absolute;
  left: 46%;            /* 角色左右距离 */
  top: 50%;               /* 角色上下距离 */
  transform: translate(-50%, -50%);
  z-index: 5;
  pointer-events: none;   /* 角色不拦截点击，点她也能发音 */
}

#char { width: var(--char-size); }

#char-inner { position: relative; width: 100%; }

#char-inner img {
  display: block;
  width: 100%;
  height: auto;
}

/* 张嘴图叠在闭口图上面，默认透明。
   JS 给 #char-inner 加 .is-singing 时张嘴图出现。 */
#img-open {
  position: absolute;
  inset: 0;
  opacity: 0;
}
#char-inner.is-singing #img-open { opacity: 1; }

/* ---- 右上角按钮 ---- */
#top-controls {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
  z-index: 10;
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  border: 1px solid rgba(107, 90, 100, 0.25);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease;
}
.ctrl-btn:hover { background: #ffffff; }
/* 关掉的功能按钮变灰 */
.ctrl-btn.is-off { opacity: 0.45; }

/* ---- UI 空闲自动隐藏（几秒不动屏幕，标题和按钮淡出） ---- */
.ui { transition: opacity 0.4s ease; }
body.hide-ui .ui { opacity: 0; pointer-events: none; }

/* ---- 设置面板 ---- */
#settings-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(107, 90, 100, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s;
}
#settings-overlay.is-open { opacity: 1; visibility: visible; }

#settings-panel {
  width: min(86vw, 340px);
  background: var(--panel-bg);
  border-radius: 16px;
  padding: 20px 20px 16px;
}
#settings-panel h2 {
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 12px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  border-bottom: 1px solid rgba(107, 90, 100, 0.08);
}
.setting-name { font-size: 14px; }
.setting-desc { font-size: 11px; opacity: 0.6; margin-top: 2px; }

/* 开关滑块（纯 CSS） */
.switch {
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(107, 90, 100, 0.25);
  position: relative;
  transition: background 0.2s ease;
}
.switch::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.2s ease;
}
.setting-row.is-on .switch { background: var(--accent); }
.setting-row.is-on .switch::after { left: 21px; }

.settings-hint {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.7;
  opacity: 0.6;
}

#settings-close {
  margin-top: 12px;
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 10px 0;
  font-size: 14px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}
