:root {
  --primary: #007AFF;
  /* iOS Blue */
  --success: #34C759;
  --fail: #FF3B30;
  --bg: #F2F2F7;
  --card-bg: #FFFFFF;
  --text: #000000;
  --picker-height: 200px;
  --item-height: 50px;

  /* 指板特定变量 */
  --string-color: #888;
  --fret-color: #999;

  --card-radius: 20px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  background-color: var(--bg);
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* --- 顶部：五线谱区域 --- */
#staff-area {
  flex: 1;
  /* 固定高度，不被挤压 */
  margin: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

#staff-container {
  width: 100%;
  background: var(--card-bg);
  margin-top: 10px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  position: relative;
}

svg {
  width: 100%;
  height: 100%;
  max-height: 220px;
  display: block;
  /* 消除SVG底部空隙 */
}

.settings-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #f0f0f0;
  border-radius: 50%;
  height: 36px;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  z-index: 10;
}

#completed-number-badge {
  position: absolute;
  top: -5px;
  left: -5px;
  background: var(--success);
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 12px;
  text-align: center;
}

/* --- 模式通用逻辑 --- */
#mode-picker-container,
#mode-fretboard-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 防止溢出 */
  border-top-left-radius: var(--card-radius);
  border-top-right-radius: var(--card-radius);
  box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.03);
}

/* === 模式 A: 滚轮选择器样式 === */
#status-area {
  text-align: center;
  background: #fff;
  padding: 10px 0 5px 0;
  border-top-left-radius: var(--card-radius);
  border-top-right-radius: var(--card-radius);
  box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.03);
  z-index: 5;
}

.hint-text {
  font-size: 1rem;
  font-weight: 500;
  color: #666;
  margin-bottom: 5px;
}

.hint-values {
  font-size: 1.3rem;
  font-weight: 700;
  color: #333;
}

.note-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 1rem;
  margin-left: 8px;
  vertical-align: middle;
}

#picker-wrapper {
  flex: 1;
  /* 占据剩余空间 */
  background: #fff;
  position: relative;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.picker-highlight {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: var(--item-height);
  margin-top: calc(var(--item-height) / -2);
  background: rgba(0, 0, 0, 0.04);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  pointer-events: none;
  z-index: 2;
}

.picker-mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom,
      rgba(255, 255, 255, 0.95) 0%,
      rgba(255, 255, 255, 0) 40%,
      rgba(255, 255, 255, 0) 60%,
      rgba(255, 255, 255, 0.95) 100%);
  pointer-events: none;
  z-index: 3;
}

.picker-col {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  padding: 0;
  margin: 0;
  list-style: none;
  text-align: center;
  position: relative;
  z-index: 1;
  scrollbar-width: none;
}

.picker-col::-webkit-scrollbar {
  display: none;
}

.picker-item {
  height: var(--item-height);
  line-height: var(--item-height);
  scroll-snap-align: center;
  font-size: 1.2rem;
  color: #bbb;
  transition: all 0.2s;
}

/* 占位符 */
.picker-col::before,
.picker-col::after {
  content: '';
  display: block;
  /* 动态计算占位高度，JS中可能需要微调，或者用 flex center */
  height: calc(50% - var(--item-height) / 2);
}

.col-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  color: #999;
  pointer-events: none;
  z-index: 4;
  font-weight: bold;
}

#action-area {
  background: #fff;
  padding: 10px 20px 30px 20px;
}

#btn-check {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#btn-check:active {
  opacity: 0.8;
}

/* === 模式 B: 指板可视化样式 === */
#info-bar {
  text-align: center;
  padding: 10px;
  color: #666;
  font-size: 0.9rem;
  background: var(--card-bg);
  border-top-left-radius: var(--card-radius);
  border-top-right-radius: var(--card-radius);
}

#fretboard-viewport {
  flex: 1;
  background: var(--card-bg);
  overflow-x: auto;
  /* 允许横向滑动 */
  overflow-y: hidden;
  position: relative;
  box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.1);
  scrollbar-width: none;
  width: 100%;
}

#fretboard-viewport::-webkit-scrollbar {
  display: none;
}

#fretboard-inner {
  height: 100%;
  position: relative;
  /* width 由 JS 计算 */
}

.guitar-string {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--string-color);
  pointer-events: none;
}

.fret-wire {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to right, var(--bg), var(--fret-color), var(--bg));
  pointer-events: none;
}

.inlay {
  position: absolute;
  background: rgba(0, 0, 0, 0.1);
  /* 在浅色背景下用深色半透明 */
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.fret-number {
  position: absolute;
  bottom: 10px;
  color: #999;
  font-size: 12px;
  font-weight: bold;
  transform: translateX(-50%);
  pointer-events: none;
}

.touch-zone {
  position: absolute;
  cursor: pointer;
  z-index: 10;
  /* 调试用: border: 1px solid rgba(0,0,0,0.1); */
}

.touch-zone:active {
  background: rgba(0, 122, 255, 0.1);
}

.marker {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  font-weight: bold;
  animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.marker.correct {
  background: var(--success);
}

.marker.wrong {
  background: var(--fail);
}

@keyframes popIn {
  from {
    transform: translate(-50%, -50%) scale(0);
  }

  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

/* === 设置弹窗 === */
#modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal {
  background: white;
  width: 85%;
  max-width: 320px;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal h3 {
  margin-top: 0;
  text-align: center;
  color: #333;
}

.setting-row {
  margin: 15px 0;
}

.setting-row label {
  display: block;
  margin-bottom: 8px;
  color: #666;
  font-size: 0.9rem;
  font-weight: 500;
}

.setting-row input,
.setting-row select {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  background: #f9f9f9;
}

.modal-actions {
  text-align: right;
  margin-top: 25px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 20px;
}

/* 动画工具类 */
.wrong-anim {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
    background-color: var(--primary);
  }

  25% {
    transform: translateX(-5px);
    background-color: var(--fail);
  }

  75% {
    transform: translateX(5px);
    background-color: var(--fail);
  }
}
