* {
    box-sizing: border-box;
    user-select: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #000000;
    font-family: 'Courier New', Courier, monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
}

#game-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* IN 和 OUT 标签现在绝对定位到外层，更精准美观 */
.port-label {
    position: absolute;
    font-weight: bold;
    font-size: 18px;
    letter-spacing: 1px;
}

#label-in {
    left: -50px;
    top: 15px;
} /* 对齐左上角第一个格子 */

#label-out {
    right: -60px;
    bottom: 15px;
} /* 对齐右下角最后一个格子 */

#board-container {
    position: relative;
    width: 500px;
    height: 500px;
    border: 4px solid #000;
    background-color: #111; /* 底色变暗，配合遮罩 */
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

#board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    width: 100%;
    height: 100%;
    gap: 0; /* 确保无缝拼接 */
}

.cell {
    width: 100%;
    height: 100%;
    /* 移除了原本的 dashed 边框，让暗区完全融为一体 */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    background-color: #fff; /* 亮区底色 */
}

.cell svg {
    width: 100%;
    height: 100%;
    transition: transform 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* 独立暗区遮罩：深邃且无边框 */
.cell::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: #080808;
    transition: opacity 0.4s ease;
    z-index: 10;
    pointer-events: auto;
    opacity: 1;
}

.cell.lit::after {
    opacity: 0;
    pointer-events: none;
}

/* 玩家黑点 */
#player {
    position: absolute;
    width: 4%;
    height: 4%;
    background-color: #000;
    border: 2px solid #fff;
    border-radius: 50%;
    top: 3%;
    left: 3%;
    transition: left 0.15s linear, top 0.15s linear;
    z-index: 20;
    display: block;
    pointer-events: none;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}

/* 终点黑点提示 */
#goal-spot {
    position: absolute;
    width: 4%;
    height: 4%;
    background-color: #000;
    border: 2px dashed #999;
    border-radius: 50%;
    top: 93%; /* 对齐右下角格子中心 */
    left: 93%;
    z-index: 5;
    pointer-events: none;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.9);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(0.9);
        opacity: 0.5;
    }
}

/* 新手引导文字 */
#tutorial-text {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #000;
    padding: 12px 20px;
    font-size: 15px;
    font-family: Consolas, "Segoe UI", Arial, sans-serif; /* 换成Consolas和无衬线字体 */
    font-weight: bold;
    z-index: 30;
    pointer-events: none;
    text-align: left;
    transition: top 0.4s ease, left 0.4s ease, opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    border-radius: 4px;
}

.enter-hint {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    color: #d32f2f;
    text-align: right;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* 成功结算画面 */
#success-screen {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#success-screen.show {
    opacity: 1;
    pointer-events: auto;
}

#success-screen h1 {
    color: #fff;
    font-size: 36px;
    margin-bottom: 30px;
    letter-spacing: 4px;
}

#success-screen button {
    background-color: #fff;
    color: #000;
    border: 2px solid #fff;
    padding: 12px 30px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

#success-screen button:hover {
    background-color: #000;
    color: #fff;
}
