/* ========== Reset & Base ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #e0e0e0;
}

/* ========== Header ========== */
.header {
    text-align: center;
    padding: 30px 20px 20px;
    background: linear-gradient(90deg, #e94560, #ff6b6b);
    color: #fff;
    box-shadow: 0 4px 20px rgba(233,69,96,0.3);
}
.header h1 {
    font-size: 28px;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.header p { opacity: 0.85; margin-top: 6px; font-size: 14px; }

/* ========== Tab Navigation ========== */
.tabs {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 16px 20px 0;
    flex-wrap: wrap;
    max-width: 900px;
    margin: 0 auto;
}
.tab-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 20px 20px 0 0;
    background: rgba(255,255,255,0.08);
    color: #aaa;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.25s;
}
.tab-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.tab-btn.active {
    background: #fff;
    color: #1a1a2e;
    font-weight: bold;
}

/* ========== Main Container ========== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

.panel {
    display: none;
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 24px;
    margin-top: -2px;
    animation: fadeIn 0.3s ease;
}
.panel.active { display: block; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========== Form Elements ========== */
.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.form-group {
    flex: 1;
    min-width: 140px;
}
.form-group label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

input, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    background: rgba(0,0,0,0.25);
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
input:focus, select:focus { border-color: #e94560; }
select option { background: #1a1a2e; color: #fff; }

button.btn-go {
    padding: 10px 28px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #e94560, #ff6b6b);
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}
button.btn-go:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(233,69,96,0.4); }
button.btn-go:active { transform: translateY(0); }
button.btn-go:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ========== Result Area ========== */
.result-area {
    margin-top: 18px;
    min-height: 60px;
}
.result-box {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    padding: 16px 20px;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.7;
    font-size: 14px;
    border-left: 3px solid #e94560;
}
.result-box.error { border-left-color: #ff4444; }

.result-img {
    max-width: 100%;
    border-radius: 10px;
    margin-top: 8px;
}
/* ========== Loading ========== */
.loading-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    gap: 12px;
}
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(233,69,96,0.2);
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-text {
    color: #e94560;
    font-style: italic;
}

/* ========== Song Card ========== */
.song-card {
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 16px;
    margin-top: 10px;
    display: flex;
    gap: 16px;
    align-items: center;
}
.song-cover {
    width: 90px;
    height: 90px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255,255,255,0.08);
}
.song-info h3 { color: #fff; font-size: 17px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.song-info p { color: #aaa; font-size: 13px; margin: 2px 0; }
.song-levels { margin-top: 6px; }

.song-audio {
    border-radius: 6px;
    outline: none;
}

/* ========== Detail Button ========== */
.btn-detail {
    background: rgba(233,69,96,0.15);
    border: 1px solid rgba(233,69,96,0.3);
    color: #e94560;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-detail:hover {
    background: rgba(233,69,96,0.25);
    border-color: #e94560;
}

/* ========== reCAPTCHA 暗色适配 ========== */
#recaptcha-container {
    margin-top: 12px !important;
}
#recaptcha-container .g-recaptcha {
    display: flex !important;
    justify-content: center;
}

/* ========== Song Type Badge (DX / 标准) ========== */
.type-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.5px;
    vertical-align: middle;
    margin-right: 6px;
    flex-shrink: 0;
}
.type-dx {
    background: #fff;
    color: #e94560;
}
.type-sd {
    background: #3b82f6;
    color: #fff;
}

/* ========== Level Tags ========== */
.level-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    margin-right: 4px;
    color: #000;
}
.lv-bas { background: #45c125; }
.lv-adv { background: #ffba00; }
.lv-exp { background: #ff5a66; }
.lv-mst { background: #8631c8; }
.lv-re   { background: #d9c5e9; color: #333 !important; }

/* ========== Fortune Panel ========== */
.fortune-box { text-align: center; }
.fortune-rp {
    font-size: 48px;
    font-weight: bold;
    color: #e94560;
    margin: 10px 0;
}
.fortune-list {
    text-align: left;
    max-width: 400px;
    margin: 12px auto;
}
.fortune-list div { padding: 4px 0; font-size: 14px; }
.yi { color: #45c125; }
.ji { color: #ff5a66; }

/* ========== Search Result List ========== */
.search-item {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
}
.search-item:hover { background: rgba(255,255,255,0.06); }
.search-item:last-child { border-bottom: none; }

/* ========== Rich Search Result (LXNS) ========== */
.search-list { display: flex; flex-direction: column; gap: 4px; }
.search-item-rich {
    display: flex;
    gap: 12px;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    align-items: center;
}
.search-item-rich:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.15);
}
.search-cover {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255,255,255,0.04);
}
.search-body { flex: 1; min-width: 0; }
.search-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.search-title-row strong {
    color: #fff;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-meta {
    color: #888;
    font-size: 12px;
    margin-bottom: 4px;
}
.search-levels { display: flex; gap: 3px; flex-wrap: wrap; }

/* ========== Song Detail: Charter Table & Aliases ========== */
.song-section {
    margin-top: 14px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 8px;
}
.section-title-sm {
    color: #ccc;
    font-size: 13px;
    font-weight: normal;
    margin: 0 0 8px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.charter-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.charter-table th,
.charter-table td {
    padding: 7px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    text-align: left;
}
.charter-table th {
    color: #888;
    font-weight: normal;
    font-size: 12px;
}
.charter-table tr:last-child td { border-bottom: none; }

.alias-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.alias-tag {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(100,149,237,0.15);
    color: #7eb3ff;
    border-radius: 20px;
    font-size: 12px;
}

/* ========== Difficulty Search Table ========== */
.ds-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.ds-table th,
.ds-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    text-align: left;
}
.ds-table th {
    color: #888;
    font-weight: normal;
    font-size: 12px;
}
.ds-table tr:hover { background: rgba(255,255,255,0.04); }

/* ========== Help Text ========== */
.help-text {
    font-size: 13px;
    color: #999;
    line-height: 1.8;
}

/* ========== Home Page (首页) ========== */
.home-hero {
    text-align: center;
    padding: 30px 20px 24px;
}
.home-icon {
    font-size: 56px;
    margin-bottom: 10px;
    animation: homeBounce 2s ease-in-out infinite;
}
@keyframes homeBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.home-hero h2 {
    font-size: 26px;
    color: #fff;
    margin-bottom: 6px;
}
.home-subtitle {
    color: #aaa;
    font-size: 14px;
}

/* 功能卡片网格 */
.home-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}
.home-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 18px 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    display: block;
}
.home-card:hover {
    background: rgba(233,69,96,0.1);
    border-color: rgba(233,69,96,0.3);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(233,69,96,0.15);
}
.home-card-icon {
    font-size: 32px;
    margin-bottom: 8px;
}
.home-card h3 {
    font-size: 15px;
    color: #fff;
    margin-bottom: 4px;
}
.home-card p {
    font-size: 12px;
    color: #888;
    line-height: 1.5;
}

/* 首页区块 */
.home-section {
    margin-bottom: 22px;
}
.home-section-title {
    font-size: 17px;
    color: #fff;
    margin-bottom: 10px;
    padding-left: 10px;
    border-left: 3px solid #e94560;
}
.home-info-box {
    background: rgba(0,0,0,0.25);
    border-radius: 10px;
    padding: 18px 20px;
    font-size: 14px;
    line-height: 1.8;
    color: #ccc;
}
.home-info-box p { margin-bottom: 8px; }
.home-info-box p:last-child { margin-bottom: 0; }
.home-info-box ul {
    margin: 8px 0;
    padding-left: 20px;
}
.home-info-box li {
    margin-bottom: 4px;
    color: #bbb;
}
.home-info-box code {
    background: rgba(233,69,96,0.12);
    color: #e94560;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12px;
    word-break: break-all;
}
.home-info-box strong { color: #fff; }

/* 搜索引擎列表 */
.search-engine-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
    margin: 10px 0;
}
.se-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    border-left: 3px solid #e94560;
}
.se-name {
    font-weight: bold;
    color: #e94560;
    white-space: nowrap;
    font-size: 13px;
}
.se-keywords {
    color: #999;
    font-size: 12px;
}

/* 页脚备注 */
.home-footer-note {
    margin-top: 14px;
    padding: 10px 14px;
    background: rgba(233,69,96,0.08);
    border-radius: 6px;
    font-size: 12px;
    color: #888;
    border: 1px solid rgba(233,69,96,0.12);
}

/* ========== Best 成绩单 - 浏览器端渲染（HTML 卡片） ========== */

/* 浏览器模式提示文字 */
/* ============================================================
   Best 成绩单 - 浏览器端渲染（固定尺寸 + 视觉缩放）
   截图目标始终固定 1200px，视觉显示用 transform 缩放
   ============================================================ */

/* 缩放外层容器：仅用于视觉缩放（transform 不影响截图尺寸） */
.best-scaling-wrap {
    --best-scale: min(1.5, calc(100vw / 800px));
    width: 1200px; /* 自然宽度，transform 缩放后视觉宽度 = 1200 * scale */
    transform: scale(var(--best-scale));
    transform-origin: top left;
}
/* 父容器需预留缩放后的实际高度（transform 不占布局空间） */
#res-best:has(.best-scaling-wrap) {
    max-width: 100%;
}

/* 截图目标：固定宽度，html2canvas 始终截取此尺寸 */
#best-screenshot-target {
    width: 1200px;
    max-width: none !important;
}

/* ===== 内部元素全部使用固定 px 值（视觉缩放由外层 transform 统一处理） ===== */

.best-browser-hint {
    font-size: 12px;
    color: #45c125;
    margin: -6px 0 8px 0;
    padding-left: 2px;
}
#best-render-mode[value="server"] ~ * .best-browser-hint,
.best-browser-hint[style*="display:none"] { /* 由 JS 控制显隐 */ }

/* 结果区域：允许横向滚动 */
#res-best {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.best-browser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0,0,0,0.35);
    border-radius: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 6px;
}
.best-header-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.best-nickname {
    font-size: 16px;
    font-weight: bold;
    color: #fff;
}
.best-rating-text {
    font-size: 13px;
    color: #aaa;
}
.best-plate {
    font-size: 13px;
    color: #ffd23c;
    font-weight: bold;
}

.best-section-label {
    font-size: 11px;
    color: #888;
    margin: 10px 0 6px;
    padding-left: 2px;
}

/* 卡片网格（固定每行5首，每张固定宽度） */
.best-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    margin-bottom: 4px;
}

/* 单张卡片 */
.best-card {
    border-radius: 6px;
    padding: 5px;
    display: flex;
    gap: 5px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: transform 0.15s, box-shadow 0.15s;
    overflow: hidden;
}
.best-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

/* 封面图 */
.best-cover {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(0,0,0,0.15);
}

/* 文字信息区 */
.best-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    line-height: 1.2;
}

/* 第1行：类型 + 难度 */
.best-row1 {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 1px;
}
.best-type-badge {
    display: inline-block;
    padding: 0 3px;
    border-radius: 2px;
    font-size: 8px;
    font-weight: bold;
    letter-spacing: 0.3px;
    line-height: 1.35;
}
.best-type-badge.type-dx { background: rgba(40,40,40,0.9); color: #e63c54; }
.best-type-badge.type-sd { background: rgba(30,80,180,0.85); color: #fff; }
.best-diff {
    font-size: 8px;
    color: rgba(255,255,255,0.65);
}

/* 第2行：曲名 + 评分等级 */
.best-row2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 3px;
    margin-bottom: 1px;
}
.best-title {
    font-size: 9px;
    color: #fff;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.best-rate {
    font-size: 8px;
    color: #ffd23c;
    font-weight: bold;
    flex-shrink: 0;
}

/* 第3行：达成率 */
.best-row3 {
    font-size: 9px;
    color: rgba(255,255,255,0.9);
    font-weight: bold;
}

/* 第4行：DX 分数 */
.best-row4 {
    font-size: 8px;
    color: #e94560;
}

/* 第5行：FC / FS */
.best-row5 {
    display: flex;
    gap: 4px;
}
.best-fc {
    font-size: 7px;
    color: #ffd23c;
    font-weight: bold;
}
.best-fs {
    font-size: 7px;
    color: #64c8ff;
    font-weight: bold;
}

/* 右下角 Rating */
.best-ra {
    text-align: right;
    font-size: 8px;
    color: #ffd23c;
    font-weight: bold;
    margin-top: auto;
}

/* SD/DX 分隔线 */
.best-separator {
    text-align: center;
    margin: 10px 0 6px;
    position: relative;
}
.best-separator::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: #ffd23c;
}
.best-separator span {
    position: relative;
    background: rgba(18,18,35,1);
    padding: 2px 10px;
    font-size: 10px;
    color: #ffd23c;
    font-weight: bold;
    border: 1px solid #ffd23c;
    border-radius: 3px;
}

/* 底部备注 */
.best-footer-note {
    text-align: center;
    font-size: 9px;
    color: #555;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* 浏览器渲染结果外层容器（用于截图） */
#res-best .best-result-wrap {
    position: relative;
}

/* 生成图片下载按钮 */
.btn-best-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    padding: 10px 24px;
    border: 1px solid #e94560;
    border-radius: 8px;
    background: rgba(233,69,96,0.1);
    color: #e94560;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}
.btn-best-download:hover {
    background: #e94560;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(233,69,96,0.35);
}
.btn-best-download:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.btn-best-download .btn-icon {
    font-size: 15px;
}
/* 下载按钮 loading 转圈动画 */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(233,69,96,0.3);
    border-top-color: #e94560;
    border-radius: 50%;
    animation: btnSpin 0.7s linear infinite;
    vertical-align: middle;
}
@keyframes btnSpin {
    to { transform: rotate(360deg); }
}
