/* ============================================
   关卡列表页(level-cell) + 已通关悬浮预览
   ============================================ */

/* 每章恰好 10 关,固定列数,让每行都填满:
   宽屏:5 列 × 2 行;窄屏:2 列 × 5 行 */
.level-list {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin: 20px 0 30px;
    padding: 4px;
}

.level-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    color: #fff;
    background: linear-gradient(135deg, #c56b1a 0%, #e76f2c 100%);
    border: 2px solid rgba(255, 200, 130, .4);
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    transition: transform .2s, box-shadow .25s, border-color .25s;
    box-shadow: 0 4px 12px rgba(180, 100, 30, .3), inset 0 1px 0 rgba(255,255,255,.15);
    height: 160px;
    overflow: hidden;
}

.level-cover {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    background: linear-gradient(135deg, #6b3a10 0%, #a15c1a 100%);
    overflow: hidden;
}
.level-cover .cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    opacity: 0;
    transition: opacity .35s ease, filter .5s ease;
}
.level-cover .cover-img.loaded { opacity: 1; }

.level-info {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3px 4px 4px;
    gap: 0;
    line-height: 1.1;
}

.level-cell:not(.locked):hover {
    transform: translateY(-3px) scale(1.04);
    border-color: rgba(255, 235, 180, .85);
    box-shadow: 0 8px 22px rgba(255, 140, 40, .55), inset 0 1px 0 rgba(255,255,255,.15);
}

.level-num {
    font-size: 1.05em;
    font-weight: 900;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0,0,0,.35);
    line-height: 1.1;
}
.level-size {
    font-size: .6em;
    color: rgba(255, 255, 255, .8);
    letter-spacing: 1px;
    margin-top: 0;
    font-family: 'Consolas', 'Courier New', monospace;
    line-height: 1.1;
}
.level-record {
    font-size: .58em;
    color: rgba(255, 255, 255, .7);
    margin-top: 0;
    font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: .5px;
    line-height: 1.15;
}

/* 已通关关卡 */
.level-cell.completed {
    background: linear-gradient(135deg, #1e6f5c 0%, #2a9d8f 100%);
    border-color: rgba(120, 240, 200, .5);
}
.level-cell.completed:hover {
    box-shadow: 0 8px 22px rgba(46, 200, 150, .55), inset 0 1px 0 rgba(255,255,255,.15);
}
.level-badge {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    background: #fff8ec;
    color: #1e6f5c;
    border-radius: 50%;
    font-size: .8em;
    font-weight: 900;
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
}

/* 未解锁关卡 */
.level-cell.locked {
    background: linear-gradient(135deg, #1a1e2e 0%, #24232b 100%);
    border-color: rgba(100, 100, 110, .3);
    cursor: not-allowed;
    filter: grayscale(.7);
    opacity: .55;
}
.level-lock {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 1.1em;
    opacity: .85;
}

/* ---------- 已通关关卡:悬浮完整缩略图预览(桌面 hover) ---------- */
/* 面板宽度由 JS 按图片真实纵横比动态设定,消除左右空白 */
.level-preview {
    --preview-h: 220px;
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(6px) scale(.9);
    transform-origin: bottom center;
    height: var(--preview-h);
    width: calc(var(--preview-h) * 0.75);
    max-width: 80vw;
    padding: 0;
    background: #0f1220;
    border: 2px solid rgba(255, 220, 160, .55);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .55),
                0 0 0 1px rgba(255, 200, 120, .15),
                inset 0 1px 0 rgba(255, 255, 255, .08);
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    transition: opacity .22s ease, transform .22s ease;
    z-index: 20;
}
/* 底部小三角(指向卡片) */
.level-preview::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(255, 220, 160, .55);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35));
}
.level-preview .preview-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    background: #0f1220;
    filter: none;
}

/* 仅在真正的 hover 设备上触发(避免触屏点击后一直挂着) */
@media (hover: hover) {
    .level-cell.completed:hover {
        overflow: visible;
        z-index: 10;
    }
    .level-cell.completed:hover .level-preview {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
    .level-list { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .level-cell { padding: 0; height: 210px; }
    .level-info { padding: 5px 4px 6px; }
    .level-num { font-size: 1.25em; }
    .level-size { font-size: .72em; }
    .level-record { font-size: .68em; }
    .level-preview { --preview-h: 160px; }
}