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

body {
  font-family: "Segoe UI", Arial, sans-serif;
  display: flex;
  min-height: 100vh;
  background: #f4f4f9;
  color: #333;
}

/* ========== 侧边栏 ========== */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: #d6eaf8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 1.5rem 1.2rem 1rem;
  border-bottom: 1px solid #aed6f1;
}

.sidebar-header h2 {
  font-size: 1.3rem;
  color: #2c3e50;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: block;
  padding: 0.85rem 1.5rem;
  text-decoration: none;
  color: #2c3e50;
  font-size: 1rem;
  border-left: 4px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}

.nav-item:hover {
  background: #aed6f1;
}

.nav-item.active {
  background: #aed6f1;
  border-left-color: #2980b9;
  font-weight: 600;
}

/* ========== 主内容区 ========== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.main-content main {
  flex: 1;
  padding: 2rem;
  width: 100%;
}

.main-content main h2 {
  margin-bottom: 0.75rem;
  color: #2c3e50;
}

.main-content main p {
  line-height: 1.7;
  color: #555;
}

/* ========== 5×5 棋盘 ========== */
.game-layout {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  justify-content: space-between;
  width: 100%;
}

.board-wrapper {
  position: relative;
  flex-shrink: 0;
  margin: 40px auto 0 auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  width: 650px;
  height: 650px;
  border: 3px solid #2c3e50;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.cell {
  background: transparent;
  border: 1px solid #ccc;
  cursor: pointer;
  transition: background 0.15s;
}

.cell:hover {
  background: #f0f0f0;
}

.btn-clear-board {
  position: absolute;
  top: -38px;
  right: 0;
  background: #e74c3c;
  border: none;
  color: white;
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-clear-board:hover {
  background: #c0392b;
}

.cell-selected {
  outline: 3px solid #2980b9;
  outline-offset: -3px;
  z-index: 1;
}

.cell-filled {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ========== 单元格设置面板 ========== */
.cell-settings-panel {
  width: 240px;
  min-width: 240px;
  background: #d6eaf8;
  border-radius: 6px;
  padding: 1.2rem;
  border: 1px solid #aed6f1;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #aed6f1;
}

.panel-header h3 {
  font-size: 1.1rem;
  color: #2c3e50;
  margin: 0;
  padding: 0;
  border: none;
}

.btn-add-format {
  background: #2980b9;
  border: none;
  color: white;
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-add-format:hover {
  background: #1c6ea4;
}

.cell-settings-panel p {
  color: #7f8c8d;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ========== 格式列表 ========== */
.format-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.format-empty {
  color: #aaa !important;
  font-size: 0.85rem !important;
  text-align: center;
  padding: 1rem 0;
}

.format-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid #d0e8f8;
  border-left: 4px solid #f9e4b7;
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
}

.format-card-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.format-color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.format-level {
  font-size: 0.9rem;
  color: #333;
  font-weight: 500;
}

.btn-edit-format {
  background: #e8f0fe;
  border: 1px solid #b8d4f0;
  color: #2980b9;
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.2s;
}

.btn-edit-format:hover {
  background: #c8dcf8;
}

/* ========== 格式编辑弹窗 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: 10px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: modalFadeIn 0.25s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
  font-size: 1.15rem;
  color: #2c3e50;
  margin: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.2rem;
  transition: color 0.2s;
}

.modal-close-btn:hover {
  color: #333;
}

.modal-body {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.form-group input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
  border-color: #2980b9;
}

.level-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.level-range select {
  flex: 1;
  padding: 0.5rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.level-range select:focus {
  border-color: #2980b9;
}

.level-separator {
  font-size: 1.1rem;
  color: #888;
  font-weight: 500;
}

.form-group input[type="color"] {
  width: 60px;
  height: 36px;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  padding: 2px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e0e0;
}

.btn-save {
  background: #2980b9;
  border: none;
  color: white;
  font-size: 0.9rem;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-save:hover {
  background: #1c6ea4;
}

/* ========== 单元格选择格式弹窗 ========== */
.cell-info-text {
  color: #7f8c8d;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  text-align: center;
}

.format-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.format-picker-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  background: #f8f8f8;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.format-picker-item:hover {
  border-color: #aed6f1;
  background: #eaf4fb;
}

.format-picker-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.format-picker-level {
  font-size: 0.95rem;
  color: #333;
  font-weight: 500;
}

/* ========== 设置页 ========== */
.settings-page {
  padding: 2rem 0;
}

.btn-clear-cache {
  background: #e74c3c;
  border: none;
  color: white;
  font-size: 0.95rem;
  padding: 0.6rem 1.4rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-clear-cache:hover {
  background: #c0392b;
}

/* ========== 曲库页 ========== */
.music-page {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.music-search-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 1rem;
}

.music-search-bar input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid #ccc;
  border-right: none;
  border-radius: 6px 0 0 6px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.btn-filter-toggle {
  background: #2980b9;
  border: 1px solid #2980b9;
  color: white;
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-radius: 0 6px 6px 0;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-filter-toggle:hover {
  background: #1c6ea4;
}

.music-search-bar input:focus {
  border-color: #2980b9;
}

/* ========== 筛选下拉 ========== */
.filter-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: #fff;
  border: 1px solid #d0e8f8;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  padding: 1rem;
  width: 280px;
  z-index: 200;
}

.filter-dropdown.show {
  display: block;
}

.filter-section {
  margin-bottom: 0.8rem;
}

.filter-section:last-child {
  margin-bottom: 0;
}

.filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.4rem;
}

.filter-dropdown .level-range {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.filter-dropdown .level-range select {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.filter-dropdown .level-range .level-separator {
  font-size: 1rem;
  color: #888;
}

.filter-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-check {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: #444;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border: 1px solid #d0e8f8;
  border-radius: 4px;
  background: #f8fbff;
  transition: background 0.15s;
}

.filter-check:hover {
  background: #eaf4fb;
}

.filter-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #2980b9;
  cursor: pointer;
}

.music-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding-right: 0.3rem;
}

.music-empty {
  text-align: center;
  color: #aaa;
  padding: 2rem 0;
}

.music-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid #b8d4e8;
  border-radius: 8px;
  background: #fff;
  transition: background 0.15s, border-color 0.15s;
}

.row-check-wrapper {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

.music-row:hover {
  background: #eaf4fb;
  border-color: #8ab8d4;
}

.music-cover {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #eee;
}

.music-title {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #2c3e50;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music-diffs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
  margin-left: auto;
}

.diff-badge {
  background: #e8f0fe;
  color: #2980b9;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.diff-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
  user-select: none;
}

.diff-check-label input[type="checkbox"] {
  width: 13px;
  height: 13px;
  accent-color: #2980b9;
  cursor: pointer;
  margin: 0;
}

.diff-badge strong {
  color: #1a5276;
}
