/* css/board.css */
#screen-game {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 10px;
}

/* 左侧面板 */
#left-panel {
    width: 180px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 10px;
    font-size: 13px;
    color: #c8c8c8;
    flex-shrink: 0;
}

#left-panel::-webkit-scrollbar {
    width: 4px;
}

#left-panel::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 2px;
}

#owned-cards-list .card-tier-title {
    color: #a08c64;
    margin-top: 6px;
    font-size: 14px;
}

#owned-cards-list .owned-card-name {
    margin-left: 6px;
    line-height: 1.8;
}

.owned-card-name.tier-01 {
    color: #5082dc;
}

.owned-card-name.tier-02 {
    color: #50b464;
}

.owned-card-name.tier-03 {
    color: #c85050;
}

/* 中央棋盘 */
#board-area {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
}

#next-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 70px;
    padding: 8px 6px;
    margin-right: 8px;
}

.next-label {
    color: #64321e;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
    background: #f0e6d2;
    padding: 2px 10px;
    border-radius: 6px;
    border: 2px solid #a05228;
}

.next-cell {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    margin: 2px 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.15s;
}

/* 棋盘网格 */
#game-board {
    position: relative;
    display: grid;
    border: 4px solid #a07850;
    border-radius: 8px;
    background: #28201a;
    box-shadow:
        0 0 20px rgba(139, 105, 20, 0.3),
        inset 0 0 30px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.board-cell {
    position: relative;
    border: 1px solid rgba(60, 50, 45, 0.5);
    width: 44px;
    height: 44px;
}

/* 方块样式 */
.block {
    position: absolute;
    inset: 1px;
    border-radius: 4px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: none;
    z-index: 2;
}

/* 各颜色方块 */
.block-blue {
    background-image: url('../assets/images/blocks/blue_block.png');
    background-color: transparent;
}

.block-green {
    background-image: url('../assets/images/blocks/green_block.png');
    background-color: transparent;
}

.block-purple {
    background-image: url('../assets/images/blocks/purple_block.png');
    background-color: transparent;
}

.block-yellow {
    background-image: url('../assets/images/blocks/yellow_block.png');
    background-color: transparent;
}

.block-red {
    background-image: url('../assets/images/blocks/red_block.png');
    background-color: transparent;
}

.block-stone {
    background-image: url('../assets/images/blocks/stone.png');
    background-color: transparent;
}

.block-bloom {
    background-image: url('../assets/images/blocks/bloom.png');
    background-color: transparent;
}

/* 有图片时用图片覆盖 */
.block.has-img {
    background-size: 100% 100%;
}

/* 标记覆盖 */
.block-overlay-mark {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: rgba(150, 0, 200, 0.35);
    border: 2px solid rgba(200, 50, 255, 0.6);
    border-radius: 4px;
    pointer-events: none;
}

/* 薄荷覆盖 */
.block-overlay-mint {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: rgba(0, 255, 100, 0.25);
    border: 2px dashed rgba(0, 200, 80, 0.6);
    border-radius: 4px;
    pointer-events: none;
}

/* 迷雾 */
.block-smoke {
    position: absolute;
    inset: 0;
    z-index: 4;
    background: rgba(80, 80, 80, 0.85);
    border-radius: 4px;
    pointer-events: none;
}

/* 幽灵预览 */
.ghost-block {
    position: absolute;
    inset: 1px;
    border-radius: 4px;
    opacity: 0.25;
    z-index: 1;
    pointer-events: none;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* 消除高亮 */
.block-highlight {
    animation: highlightFlash 0.4s ease-in-out infinite alternate;
}

@keyframes highlightFlash {
    from { filter: brightness(1); }
    to { filter: brightness(2) drop-shadow(0 0 6px white); }
}

/* 消除预判微弱光晕 (50% alpha 白光) */
.block-predict-glow::after {
    content: '';
    position: absolute;
    inset: -2px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: inherit;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    pointer-events: none;
    z-index: 10;
}

/* 当前活动方块 */
.block-active {
    z-index: 5;
    filter: brightness(1.15);
}

/* 右侧 HUD */
#right-panel {
    width: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px;
    flex-shrink: 0;
}

#btn-pause {
    align-self: flex-end;
}

#score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(50, 40, 40, 0.9);
    border: 3px solid #ffd700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-label {
    color: #c8c8c8;
    font-size: 14px;
}

#score-value {
    color: #fff;
    font-size: 24px;
    font-weight: bold;
}

#card-progress-bar {
    width: 120px;
    height: 8px;
    background: #3c3c3c;
    border-radius: 4px;
    overflow: hidden;
}

#card-progress-fill {
    height: 100%;
    width: 0%;
    background: #ffd700;
    border-radius: 4px;
    transition: width 0.3s;
}

#card-progress-label {
    font-size: 13px;
    color: #a0a0a0;
}

#char-name-display {
    font-size: 14px;
    color: #c8b4ff;
}

/* 技能按钮 */
#skill-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.skill-btn {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid #c8c8c8;
    background: #3c3c3c;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, background 0.2s;
}

.skill-btn.ready {
    background: #50b450;
    border-color: #78e078;
}

.skill-btn.ready-q {
    background: #64c8ff;
    border-color: #96e0ff;
}

.skill-letter {
    font-size: 28px;
    font-weight: bold;
    color: #fff;
    z-index: 2;
    pointer-events: none;
}

.skill-cooldown-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: rgba(0, 0, 0, 0.5);
    transition: height 0.25s linear;
    z-index: 1;
}

.skill-cd-text {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    color: #ffc850;
    white-space: nowrap;
}

#btn-skill-q {
    width: 56px;
    height: 56px;
}

#btn-skill-q .skill-letter {
    font-size: 22px;
}

/* 移动端虚拟按键 */
#mobile-controls {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: none;
    /* JS会在需要时显示 */
    justify-content: space-between;
    padding: 0 20px;
    z-index: 50;
    pointer-events: none;
}

.ctrl-left-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px 35px; /* Bigger gaps between buttons */
    pointer-events: auto;
    justify-items: center;
}

#ctrl-left { grid-column: 1; grid-row: 1; }
#ctrl-right { grid-column: 2; grid-row: 1; }
#ctrl-down { grid-column: 1 / 3; grid-row: 2; margin-top: 5px; }

.ctrl-right-group {
    display: flex;
    align-items: flex-end; /* Align right buttons to the bottom */
    pointer-events: auto;
}

.ctrl-btn {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 28px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

.ctrl-rotate {
    width: 90px;
    height: 90px;
    font-size: 38px;
    margin-bottom: 20px; /* Push it up a bit from bottom edge */
}

/* 响应式 */
@media (max-width: 900px) {
    #left-panel {
        display: none;
    }

    #right-panel {
        width: 100px;
    }

    #score-circle {
        width: 80px;
        height: 80px;
    }

    #score-value {
        font-size: 18px;
    }

    .skill-btn {
        width: 50px;
        height: 50px;
    }

    .skill-letter {
        font-size: 20px;
    }

    #btn-skill-q {
        width: 42px;
        height: 42px;
    }

    #mobile-controls {
        display: flex;
    }

    .next-cell {
        width: 36px;
        height: 36px;
    }

    .board-cell {
        width: 34px;
        height: 34px;
    }
}

@media (max-width: 600px) {
    #right-panel {
        width: 70px;
        gap: 6px;
    }

    #score-circle {
        width: 60px;
        height: 60px;
    }

    .score-label {
        font-size: 10px;
    }

    #score-value {
        font-size: 14px;
    }

    .skill-btn {
        width: 40px;
        height: 40px;
    }

    .skill-letter {
        font-size: 16px;
    }

    #next-preview {
        width: 50px;
    }

    .next-cell {
        width: 30px;
        height: 30px;
    }
    .ctrl-btn {
        width: 68px;
        height: 68px;
        font-size: 26px;
    }

    .ctrl-rotate {
        width: 82px;
        height: 82px;
        font-size: 34px;
        margin-bottom: 15px;
    }

    .ctrl-left-group {
        gap: 10px 25px;
    }

    .board-cell {
        width: clamp(20px, 8vw, 30px);
        height: clamp(20px, 8vw, 30px);
    }
}

/* 手机横屏模式 */
@media (max-height: 500px) and (orientation: landscape) {
    .board-cell {
        width: 20px !important;
        height: 20px !important;
    }

    #left-panel, #right-panel {
        transform: scale(0.6);
        transform-origin: center;
        padding: 0;
    }

    #mobile-controls {
        display: flex;
        bottom: 50% !important;
        transform: translateY(50%);
        padding: 0 10px;
    }

    .ctrl-left-group {
        flex-direction: column;
        justify-content: center;
    }
}