/* ==========================================================================
   maimai 手势音乐节奏游戏 - 深色霓虹风样式
   所有颜色统一由 :root 中的 CSS 变量控制，便于整体换肤
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 全局变量与基础
   -------------------------------------------------------------------------- */
:root {
  --bg: #0b0b14;        /* 页面背景 */
  --card: #17172a;      /* 卡片/面板背景 */
  --text: #ffffff;      /* 主文字 */
  --subtext: #9aa0b5;   /* 次要文字 */
  --accent: #ff3b6b;    /* 主强调色（红） */
  --cyan: #00d4ff;      /* 次强调色（青） */
  --hold: #ffd54a;      /* 长按音符（黄） */
  --star: #c58bff;      /* 星星（紫） */

  /* 由上方基础色派生的辅助变量（避免散落硬编码） */
  --overlay-bg: rgba(0, 0, 0, 0.7);         /* 遮罩半透明黑 */
  --cyan-soft: rgba(0, 212, 255, 0.35);     /* --cyan 描边 */
  --accent-soft: rgba(255, 59, 107, 0.55);  /* --accent 发光 */
  --hud-bg: rgba(23, 23, 42, 0.72);         /* HUD 半透明背景（--card 派生） */
  --track-bg: rgba(255, 255, 255, 0.12);    /* 滑杆轨道 */
  --divider: rgba(255, 255, 255, 0.12);     /* 分隔线 */
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
button,
input {
  font-family: inherit;
}

/* 统一隐藏规则：任何带 hidden 属性的元素都不显示 */
[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   2. 覆盖层通用（#tutorial / #settings / #result）
   -------------------------------------------------------------------------- */
#tutorial,
#settings,
#result,
#pause {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  z-index: 10;
}

/* 面板通用样式 */
.panel {
  position: relative;
  background: var(--card);
  border: 1px solid var(--cyan-soft);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 212, 255, 0.08);
}

/* 若区块未加 .panel 类，也让其直接子内容拥有面板观感（结构不改的前提下） */
#tutorial > :not(#btn-tutorial-back),
#settings > .settings-body,
#result > :not(#btn-settings-back) {
  background: var(--card);
  border: 1px solid var(--cyan-soft);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 212, 255, 0.08);
  width: 100%;
  max-width: 480px;
}

#tutorial h2,
#settings h2,
#result h2 {
  font-size: 22px;
  letter-spacing: 2px;
  margin-bottom: 20px;
}

/* --------------------------------------------------------------------------
   3. #menu 开始菜单
   -------------------------------------------------------------------------- */
#menu {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px 24px;
  text-align: center;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 59, 107, 0.16), transparent 55%),
    radial-gradient(circle at 80% 100%, rgba(0, 212, 255, 0.14), transparent 55%),
    var(--bg);
}

#menu h1 {
  color: var(--accent);
  font-size: 40px;
  letter-spacing: 2px;
  line-height: 1.2;
  text-shadow: 0 0 18px var(--accent-soft);
}

#menu .sub {
  color: var(--subtext);
  font-size: 14px;
  letter-spacing: 6px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

#menu .menu-rules {
  list-style: none;
  max-width: 420px;
  text-align: left;
  margin: 10px auto;
}

#menu .menu-rules li {
  color: var(--subtext);
  line-height: 1.8;
  padding-left: 22px;
  position: relative;
  font-size: 14px;
}

/* 每条规则前的霓虹小圆点 */
#menu .menu-rules li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.75em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-soft);
}

#menu .menu-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}

/* 通用按钮基样式 */
button {
  cursor: pointer;
  border-radius: 10px;
  padding: 10px 22px;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease,
    background 0.15s ease;
}

/* 描边样式按钮：教程 / 设置 */
#btn-tutorial,
#btn-settings,
#btn-tutorial-back,
#btn-settings-back,
#btn-calibrate,
#btn-recalibrate {
  background: transparent;
  border: 1px solid var(--cyan-soft);
  color: var(--cyan);
}

#btn-tutorial:hover,
#btn-settings:hover,
#btn-tutorial-back:hover,
#btn-settings-back:hover,
#btn-calibrate:hover,
#btn-recalibrate:hover {
  transform: scale(1.05);
  filter: brightness(1.25);
  box-shadow: 0 0 14px rgba(0, 212, 255, 0.35);
}

/* 主按钮：实心 --accent */
#btn-start,
#btn-restart {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  padding: 14px 38px;
  letter-spacing: 2px;
  box-shadow: 0 0 20px var(--accent-soft);
}

#btn-start:hover,
#btn-restart:hover {
  transform: scale(1.05);
  filter: brightness(1.12);
  box-shadow: 0 0 28px var(--accent-soft);
}

button:active {
  transform: scale(0.97);
}

/* --------------------------------------------------------------------------
   4. #settings 设置
   -------------------------------------------------------------------------- */
#settings .settings-body {
  position: relative;
}

/* 返回按钮：右上角小号描边 */
#btn-settings-back,
#btn-tutorial-back {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 6px 14px;
  font-size: 13px;
  z-index: 2;
}

/* 每个设置行：label 在上、滑杆在下，值显示在右侧 */
.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "label value"
    "slider slider";
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 22px;
}

.setting-row label {
  grid-area: label;
  color: var(--text);
  font-size: 14px;
  letter-spacing: 1px;
}

.setting-row input[type="range"] {
  grid-area: slider;
  width: 100%;
}

.setting-row > span {
  grid-area: value;
  color: var(--subtext);
  font-size: 14px;
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 自定义滑杆 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--track-bg);
  outline: none;
}

/* 轨道（Firefox） */
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--track-bg);
}

/* 滑块（WebKit） */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--card);
  box-shadow: 0 0 10px var(--accent-soft);
  cursor: pointer;
  margin-top: -6px;
}

/* 滑块（Firefox） */
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--card);
  box-shadow: 0 0 10px var(--accent-soft);
  cursor: pointer;
}

/* 延迟校准区块 */
.calibrate {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--divider);
  text-align: center;
}

.calibrate h3 {
  color: var(--hold);
  font-size: 16px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.calibrate .calibrate-tip {
  color: var(--subtext);
  font-size: 13px;
  margin-bottom: 16px;
}

.calibrate #btn-calibrate {
  margin-bottom: 16px;
}

.calibrate #btn-recalibrate {
  margin-left: 8px;
  margin-bottom: 16px;
}

/* 鼓点指示器占位（后续 JS 在这里显示鼓点） */
#beat-indicator {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

/* 反馈文字（快 / 慢） */
#calibrate-feedback {
  min-height: 34px;
  font-size: 26px;
  font-weight: 700;
  color: var(--cyan);
  text-align: center;
  margin-top: 10px;
  text-shadow: 0 0 14px rgba(0, 212, 255, 0.35);
}

/* 最终结果 */
#calibrate-result {
  color: var(--subtext);
  font-size: 13px;
  text-align: center;
  margin-top: 6px;
}

/* --------------------------------------------------------------------------
   5. #game 游戏
   -------------------------------------------------------------------------- */
#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}


#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* HUD：固定顶部居中，横向排列 4 列判定成绩 */
#hud {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 40px;
  padding: 12px 32px;
  border-radius: 16px;
  background: var(--hud-bg);
  border: 1px solid var(--divider);
  backdrop-filter: blur(6px);
  z-index: 5;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* 单个判定列：名字在上、数字在下，水平居中 */
.judge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 64px;
}

/* 判定名：小字号 + 加宽字距 */
.judge-name {
  font-size: 13px;
  letter-spacing: 2px;
  font-weight: 600;
  line-height: 1.4;
}

/* 判定计数：大字号加粗居中 */
.judge-count {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 四种判定颜色（名字与数字同色） */
.judge-perfect,
#hud #judge-perfect {
  color: #ff3b6b; /* perfect = 红 #ff3b6b */
  text-shadow: 0 0 12px rgba(255, 59, 107, 0.45);
}

.judge-great,
#hud #judge-great {
  color: #ffd54a; /* great = 黄 #ffd54a */
  text-shadow: 0 0 12px rgba(255, 213, 74, 0.45);
}

.judge-good,
#hud #judge-good {
  color: #3ddc84; /* good = 绿 #3ddc84 */
  text-shadow: 0 0 12px rgba(61, 220, 132, 0.45);
}

.judge-miss,
#hud #judge-miss {
  color: #4a90e2; /* miss = 蓝 #4a90e2 */
  text-shadow: 0 0 12px rgba(74, 144, 226, 0.45);
}

/* 命中时屏幕中央弹出的大字反馈（后续模块控制内容） */
#hud #judge-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--cyan);
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0 18px rgba(0, 212, 255, 0.5);
}

/* 分数：左上角固定，大字号白/青色 */
#score-box {
  position: fixed;
  top: 24px;
  left: 24px;
  padding: 10px 20px;
  border-radius: 12px;
  background: var(--hud-bg);
  border: 1px solid var(--divider);
  backdrop-filter: blur(6px);
  color: var(--cyan);
  font-size: 34px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px rgba(0, 212, 255, 0.45);
  z-index: 5;
  pointer-events: none;
}

/* 连击：屏幕中央，纵向排列 */
#combo-box {
  position: fixed;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  z-index: 5;
  pointer-events: none;
}

#combo-num {
  color: var(--hold); /* 黄 #ffd54a */
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(255, 213, 74, 0.5);
}

#combo-box .combo-label {
  color: var(--subtext);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 6px;
  margin-top: 4px;
}

/* 连击数字弹一下 */
@keyframes pop {
  0% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

#combo-num.pop {
  animation: pop 0.15s ease-out 1;
}

/* --------------------------------------------------------------------------
   6. #result 结算
   -------------------------------------------------------------------------- */
#result {
  z-index: 20;
}

#result > * {
  text-align: center;
}

#result h2 {
  color: var(--accent);
  font-size: 26px;
  letter-spacing: 3px;
  text-shadow: 0 0 18px var(--accent-soft);
}

#result #result-body {
  color: var(--subtext);
  margin: 20px 0 26px;
  font-size: 15px;
  line-height: 1.9;
  flex-direction: column;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   教程正文
   -------------------------------------------------------------------------- */
.tutorial-body {
  color: var(--subtext);
  font-size: 14px;
  line-height: 1.9;
}

/* --------------------------------------------------------------------------
   暂停
   -------------------------------------------------------------------------- */
#pause {
  z-index: 25; /* 盖在最上层 */
}

#pause .panel {
  text-align: center;
  max-width: 320px;
}

#pause h2 {
  color: var(--cyan);
  font-size: 22px;
  letter-spacing: 3px;
  margin-bottom: 20px;
}

#pause .pause-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#pause .pause-buttons button {
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
}

#btn-resume {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 2px;
}

#btn-pause-restart,
#btn-quit {
  background: transparent;
  border: 1px solid var(--cyan-soft);
  color: var(--cyan);
}

#btn-pause {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 15;
  padding: 8px 18px;
  font-size: 14px;
  background: var(--hud-bg);
  border: 1px solid var(--divider);
  color: var(--text);
  backdrop-filter: blur(6px);
}
