:root {
  --primary-color: #ff5ea3;
  --primary-light: #ffb2d1;
  --secondary-color: #37b8ff;
  --text-color: #333;
  --bg-color: #f9f9f9;
  --card-bg: #ffffff;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
}

#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loader {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--primary-color);
  border-bottom-color: var(--secondary-color);
  animation: spin 1.5s linear infinite;
  margin-bottom: 20px;
}

.loader-inner {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-left-color: var(--primary-light);
  border-right-color: var(--primary-light);
  animation: spin 1s linear infinite reverse;
  position: absolute;
  top: 10px;
  left: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  text-align: center;
}

.loading-text p {
  margin: 8px 0;
  color: var(--text-color);
}

.loading-tip {
  font-size: 0.9rem;
  color: #777;
  margin-top: 12px;
}

.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

header h1 {
  color: var(--primary-color);
  font-size: 2.2rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 10px;
}

#search-container {
  background-color: var(--card-bg);
  border-radius: var(--radius);
  padding: 25px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
}

.search-box {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

input[type="text"] {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #eee;
  border-radius: var(--radius);
  font-size: 1rem;
  transition: var(--transition);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(255, 94, 163, 0.1);
}

.btn {
  cursor: pointer;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  transition: var(--transition);
  font-size: 1rem;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: #ff3d8d;
  transform: translateY(-2px);
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: white;
}

.btn-secondary:hover {
  background-color: #20a9f0;
  transform: translateY(-2px);
}

.hint {
  color: #777;
  font-size: 0.9rem;
  margin-top: 15px;
}

.search-results {
  max-height: 60vh;
  overflow-y: auto;
  border-radius: var(--radius);
  background-color: #f5f5f5;
  margin-top: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-results:empty {
  display: none;
}

.search-results div {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  transition: var(--transition);
}

.search-results div:hover {
  background-color: var(--primary-light);
  color: white;
}

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

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  width: 95%;
  max-width: 1200px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 150;
  display: none;
}

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

.modal-content {
  padding: 20px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: #666;
  transition: var(--transition);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  position: relative;
}

.close-btn:hover {
  color: var(--primary-color);
  background-color: rgba(255, 94, 163, 0.1);
}

.close-btn::after {
  content: "关闭";
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: #666;
  opacity: 0;
  transition: var(--transition);
}

.close-btn:hover::after {
  opacity: 1;
}

.chart-container {
  margin-top: 20px;
  text-align: center;
}

.chart-container img {
  max-width: 100%;
  border-radius: var(--radius);
}

.credits-list {
  list-style-type: none;
  margin-top: 10px;
}

.credits-list li {
  margin-bottom: 10px;
}

.credits-list a {
  color: var(--secondary-color);
  text-decoration: none;
}

.credits-list a:hover {
  text-decoration: underline;
}

footer {
  text-align: center;
  margin-top: 40px;
  color: #777;
  font-size: 0.9rem;
}

/* 歌曲信息模态框样式 */
#info-modal {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  padding: 0;
}

.modal-header {
  position: sticky;
  top: 0;
  background-color: var(--card-bg);
  z-index: 2;
}

/* 上部分：基本信息区域 */
.info-top-section {
  overflow-y: auto;
  max-height: 40vh;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

/* 下部分：封面和表格区域 */
.info-bottom-section {
  overflow-y: auto;
  max-height: 40vh;
  padding: 20px;
}

/* 封面和表格布局 */
.song-info-display {
  display: flex;
  gap: 20px;
}

/* 封面容器 */
.cover-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 15px;
}

.cover-container img {
  max-width: 300px;
  max-height: 300px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 难度信息样式 */
.difficulty-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.difficulty-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: white;
  white-space: nowrap;
}

/* 表格样式优化 */
.chart-info-container {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chart-info-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 0;
  table-layout: fixed;
}

.chart-info-table th {
  background-color: var(--primary-light);
  color: var(--primary-color);
  font-weight: 600;
  padding: 8px 4px;
  text-align: center;
  font-size: 0.85rem;
}

.chart-info-table td {
  padding: 8px 4px;
  border: 1px solid #eee;
  text-align: center;
  font-size: 0.85rem;
}

/* 设置列宽 */
.chart-info-table th:nth-child(1),
.chart-info-table td:nth-child(1) {
  width: 18%;
}

.chart-info-table th:nth-child(2),
.chart-info-table td:nth-child(2) {
  width: 45%;
  white-space: normal;
  word-break: break-all;
}

.chart-info-table th:nth-child(3),
.chart-info-table td:nth-child(3) {
  width: 15%;
}

.chart-info-table th:nth-child(4),
.chart-info-table td:nth-child(4) {
  width: 22%;
  white-space: normal;
  word-break: break-all;
}

/* 难度行样式 */
.chart-info-table tr.basic-row {
  background-color: rgba(76, 175, 80, 0.15);
}

.chart-info-table tr.basic-row td:first-child {
  background-color: #4CAF50;
  color: white;
  font-weight: 500;
}

.chart-info-table tr.advanced-row {
  background-color: rgba(255, 193, 7, 0.15);
}

.chart-info-table tr.advanced-row td:first-child {
  background-color: #FFC107;
  color: #333;
  font-weight: 500;
}

.chart-info-table tr.expert-row {
  background-color: rgba(244, 67, 54, 0.15);
}

.chart-info-table tr.expert-row td:first-child {
  background-color: #F44336;
  color: white;
  font-weight: 500;
}

.chart-info-table tr.master-row {
  background-color: rgba(156, 39, 176, 0.15);
}

.chart-info-table tr.master-row td:first-child {
  background-color: #9C27B0;
  color: white;
  font-weight: 500;
}

.chart-info-table tr.remaster-row {
  background-color: rgba(156, 39, 176, 0.08);
}

.chart-info-table tr.remaster-row td:first-child {
  background-color: #FFFFFF;
  color: #9C27B0;
  border: 1px solid #9C27B0;
  font-weight: 500;
}

.chart-info-table tr:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* 难度标签颜色 */
.difficulty-badge.basic {
  background: #4CAF50;
}

.difficulty-badge.advanced {
  background: #FFC107;
  color: #333;
}

.difficulty-badge.expert {
  background: #F44336;
}

.difficulty-badge.master {
  background: #9C27B0;
  opacity: 0.85;
}

.difficulty-badge.remaster {
  background: #FFFFFF;
  color: #9C27B0;
  border: 1px solid #9C27B0;
}

/* 移除拟合定数样式，因为现在集成到难度标签中 */
.fit-diff-info {
  display: none;
}

/* 别名标签样式 */
.alias-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.alias-tag {
  background: #f0f0f0;
  padding: 4px 10px;
  border-radius: 15px;
  font-size: 0.9rem;
  color: #666;
}

/* 定数变化折线图样式 */
.ds-change-chart-container {
    width: 100%;
    height: 400px;
    padding: 10px;
    margin-top: 15px;
    border-radius: var(--radius);
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* 调整选项卡内容在活动时的样式 */
.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 使折线图在选项卡中全宽显示 */
#ds-change.tab-content.active {
    width: 100%;
}

/* 定数变化选项卡样式 */
.song-tabs {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: #666;
    transition: var(--transition);
    font-weight: 500;
    font-size: 1.1rem;  /* 增大字体大小 */
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-btn:hover:not(.active) {
    color: var(--primary-light);
    border-bottom-color: var(--primary-light);
}

.tab-content {
    display: none;
}

.no-data {
    text-align: center;
    padding: 15px;
    color: #999;
    font-style: italic;
}

@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .search-box {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
  }
  
  /* 修复手机端基本信息样式 */
  #basic-info .modal-content {
    display: block;
  }
  
  .song-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .song-info-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  
  .info-item {
    gap: 2px;
  }
  
  .info-label {
    font-size: 0.75rem;
  }
  
  .info-value {
    font-size: 0.8rem;
  }
  
  .difficulty-badge {
    padding: 4px 8px;
    font-size: 0.8rem;
  }
  
  .chart-info-container {
    margin: 0 -10px;
    padding: 0 10px;
    width: calc(100% + 20px);
  }
  
  .chart-info-table {
    margin-top: 10px;
    min-width: 100%;
  }
  
  /* 调整列宽比例 */
  .chart-info-table th:nth-child(1),
  .chart-info-table td:nth-child(1) {
    width: 18%;
  }
  
  .chart-info-table th:nth-child(2),
  .chart-info-table td:nth-child(2) {
    width: 45%;
  }
  
  .chart-info-table th:nth-child(3),
  .chart-info-table td:nth-child(3) {
    width: 15%;
  }
  
  .chart-info-table th:nth-child(4),
  .chart-info-table td:nth-child(4) {
    width: 22%;
  }
  
  .song-info-card {
    padding: 15px;
    margin-bottom: 15px;
  }
  
  .song-info-card h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
  }
}

/* 基本信息网格布局优化 */
.song-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 0.9rem;
    color: #666;
}

.info-value {
    font-size: 1rem;
    color: var(--text-color);
    font-weight: 500;
}

/* 歌曲信息卡片样式 */
.song-info-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #eee;
}

.song-info-card:last-child {
    margin-bottom: 0;
}

.song-info-card h3 {
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-light);
}

/* 移除底部关闭按钮 */
.modal-footer {
    display: none;
}

/* 桌面端布局优化 */
@media (min-width: 1024px) {
    .modal-content {
        display: grid;
        grid-template-columns: 1fr 1.2fr;
        gap: 20px;
        padding: 20px;
    }

    .song-info-card {
        margin-bottom: 0;
    }

    /* 基本信息卡片占据左侧 */
    .song-info-card:first-child {
        grid-column: 1;
        grid-row: 1;
    }

    /* 难度与谱面信息卡片占据右侧 */
    .song-info-card:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    /* 别名信息卡片占据最下方 */
    .song-info-card:nth-child(3) {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    /* 调整基本信息布局 */
    .song-info-grid {
        grid-template-columns: 0.8fr 1.1fr 1.1fr;
        gap: 15px;
    }

    /* 调整封面大小 */
    .cover-container img {
        max-width: 180px;
        max-height: 180px;
    }

    /* 优化表格显示 */
    .chart-info-container {
        margin: 20px 0 0 0;
        padding: 0;
    }

    .chart-info-table {
        margin-top: 0;
    }

    .info-item {
        gap: 6px;
    }

    .info-label {
        font-size: 0.9rem;
    }

    .info-value {
        font-size: 1rem;
    }
    
    /* 桌面端调整定数变化展示 */
    #ds-change .song-info-card {
        grid-column: 1 / -1;
        grid-row: 1;
    }
}