* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2a6c, #3a1c71, #1a2a6c);
    padding: 20px;
    overflow: hidden;
}

.game-container {
    display: flex;
    width: 100%;
    max-width: 1200px;
    background: rgba(10, 15, 30, 0.85);
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    position: relative;
    border: 2px solid #4a4af0;
    overflow: hidden;
    padding: 20px;
}

.game-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(74, 74, 240, 0.1) 0%, transparent 70%);
    z-index: 0;
}

/* 左侧棋盘区域 */
.game-board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 0.4vw;
    background: linear-gradient(135deg, #e7c08a 0%, #c89d5c 100%); /* 木制暖色渐变 */
    width: 100%;
    max-width: 90vmin;
    aspect-ratio: 1/1;
    border-radius: 12px;
    box-shadow: 0 0 32px 0 #b48a4a, inset 0 0 20px #a97c3b;
    border: 2px solid #b48a4a;
    min-width: 300px;
    min-height: 300px;
    padding: 0.7vw;
    box-sizing: border-box;
    /* 木纹SVG叠加 */
    position: relative;
    overflow: visible;
}
.game-board::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: url('data:image/svg+xml;utf8,<svg width="100%25" height="100%25" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><path d="M0 100 Q50 110 100 100 T200 100" fill="none" stroke="%23b48a4a" stroke-width="2" opacity="0.13"/><path d="M0 120 Q60 130 120 120 T200 120" fill="none" stroke="%23b48a4a" stroke-width="1.5" opacity="0.09"/><path d="M0 80 Q40 70 100 80 T200 80" fill="none" stroke="%23b48a4a" stroke-width="1.2" opacity="0.08"/></svg>');
    background-size: cover;
    border-radius: 12px;
}

/* 右侧控制面板 */
.game-sidebar {
    width: 240px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

h1 {
    color: #fff;
    text-align: center;
    margin-bottom: 15px;
    font-size: 2.5rem;
    letter-spacing: 2px;
    font-family: 'Fredoka One', cursive;
}

.game-info {
    background: rgba(0, 40, 80, 0.8);
    padding: 10px;
    border-radius: 10px;
    color: white;
    border: 1px solid #00b3ff;
    box-shadow: 0 5px 15px rgba(0, 179, 255, 0.3);
    margin-bottom: 10px;
}

.score-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 255, 234, 0.2);
}

.score-item {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 45px;
}

.score-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #00ffea;
    font-size: 24px;
    text-shadow: 0 0 10px rgba(0, 255, 234, 0.8);
    margin-top: -10px;
}

.score-value {
    font-family: 'Fredoka One', cursive;
    font-size: 1.8rem;
    font-weight: normal;
    color: #ffeb3b;
    transform: perspective(500px) rotateX(5deg);
    transition: transform 0.3s ease;
    min-width: 50px;
    text-align: left;
}

.score-value:hover {
    transform: perspective(500px) rotateX(5deg) scale(1.1);
}

.next-balls-box {
    background: rgba(0, 0, 0, 0.6);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #4fc3f7;
    text-align: center;
    margin-bottom: 10px;
}

.next-balls-box h3 {
    color: #4fc3f7;
    margin-bottom: 6px;
    font-size: 1rem;
}

#next-balls-list {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-top: 10px;
    min-height: 40px;
}

.next-ball {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.4), 
                0 5px 10px rgba(0, 0, 0, 0.6);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 1px;
    border: 2px solid #fff;
    position: relative;
    overflow: hidden;
}

.next-ball::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 16%;
    width: 38%;
    height: 18%;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 50% 45% 40% 50%/60% 60% 40% 40%;
    transform: rotate(-22deg);
    filter: blur(0.5px);
    pointer-events: none;
}

.next-ball.color-red { background: linear-gradient(135deg, #ff416c, #ff4b2b); }
.next-ball.color-blue { background: linear-gradient(135deg, #2196f3, #21cbf3); }
.next-ball.color-green { background: linear-gradient(135deg, #00b09b, #96c93d); }
.next-ball.color-yellow { background: linear-gradient(135deg, #ffd700, #ffb347); }
.next-ball.color-purple { background: linear-gradient(135deg, #8e2de2, #4a00e0); }
.next-ball.color-black { background: linear-gradient(135deg, #333, #000); }
.next-ball.color-white { background: linear-gradient(135deg, #eee, #ccc); }

.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 10px;
}

.controls-row {
    display: contents;
}

.controls button {
    min-width: 0;
    font-size: 1.1rem;
}

#undo-btn:disabled {
    background: #bdbdbd;
    color: #fff;
    cursor: not-allowed;
    box-shadow: none;
    border: 1px solid #ccc;
}

button {
    padding: 14px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(to right, #00c6ff, #0072ff);
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: rotate(30deg);
    transition: all 0.5s;
}

button:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    background: linear-gradient(to right, #00d2ff, #3a7bd5);
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: translateY(2px);
}

.instructions {
    background: rgba(0, 0, 0, 0.6);
    color: #e0e0e0;
    padding: 20px;
    border-radius: 15px;
    font-size: 0.95rem;
    line-height: 1.6;
    flex: 1;
    border: 1px solid #4fc3f7;
    box-shadow: 0 5px 15px rgba(79, 195, 247, 0.2);
}

.instructions h3 {
    color: #4fc3f7;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.3rem;
    text-shadow: 0 0 10px rgba(79, 195, 247, 0.7);
}

.instructions ul {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 12px;
    position: relative;
}

.instructions li::before {
    content: '•';
    color: #00f7ff;
    font-size: 1.5rem;
    position: absolute;
    left: -20px;
    top: -2px;
}

.game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    display: none;
    border-radius: 20px;
}

.game-over-content {
    background: rgba(10, 15, 30, 0.95);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    border: 2px solid #ff5252;
    box-shadow: 0 0 40px rgba(255, 82, 82, 0.5);
}

.game-over h2 {
    color: #ff5252;
    font-size: 3.5rem;
    margin-bottom: 30px;
    text-shadow: 0 0 15px rgba(255, 82, 82, 0.8);
}

.game-over p {
    color: white;
    font-size: 2.2rem;
    margin-bottom: 40px;
}

.game-over-content button {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    margin-top: 18px;
    min-width: 160px;
}

/* 棋盘元素样式 */
.cell {
    width: 100%;
    aspect-ratio: 1/1;
    background: rgba(255, 255, 255, 0.13);
    border-radius: 6px; /* 更小圆角 */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: visible; /* 允许内容溢出，阴影不被裁切 */
    z-index: 1;
    box-shadow: 0 0 0 2px #b48a4a, 0 0 0 4px rgba(180,138,74,0.13); /* 更深的木色线条 */
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
}

.cell:hover::before {
    opacity: 1;
}

.cell:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.07);
}

.cell.selected {
    box-shadow: 0 0 20px #00ffea;
    z-index: 10;
    transform: scale(1.1);
}

.ball {
    width: 92%; /* 更大 */
    height: 92%;
    border-radius: 50%;
    box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.4), 
                0 5px 10px rgba(0, 0, 0, 0.6);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s;
    z-index: 2;
}

.ball::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 16%;
    width: 38%;
    height: 18%;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 50% 45% 40% 50%/60% 60% 40% 40%;
    transform: rotate(-22deg);
    filter: blur(0.5px);
    pointer-events: none;
}

/* 球颜色样式 */
.ball.color-red { background: linear-gradient(135deg, #ff416c, #ff4b2b); }
.ball.color-blue { background: linear-gradient(135deg, #2196f3, #21cbf3); }
.ball.color-green { background: linear-gradient(135deg, #00b09b, #96c93d); }
.ball.color-yellow { background: linear-gradient(135deg, #ffd700, #ffb347); }
.ball.color-purple { background: linear-gradient(135deg, #8e2de2, #4a00e0); }
.ball.color-black { 
    background: linear-gradient(135deg, #333, #000); 
    box-shadow: inset 0 -6px 12px rgba(255, 255, 255, 0.2), 
                0 5px 10px rgba(0, 0, 0, 0.6);
}
.ball.color-white { 
    background: linear-gradient(135deg, #eee, #ccc);
    box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.3), 
                0 5px 10px rgba(0, 0, 0, 0.6);
}

.highlight {
    animation: highlight 0.5s ease-in-out 3;
}

@keyframes highlight {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.trail-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #00ffea;
    border-radius: 50%;
    z-index: 5;
    box-shadow: 0 0 8px #00ffea;
    animation: fadeTrail 1s forwards;
}

@keyframes fadeTrail {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.5); }
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #ffeb3b;
    border-radius: 50%;
    z-index: 20;
    animation: particleMove 1s forwards;
}

@keyframes particleMove {
    0% { opacity: 1; transform: translate(0, 0); }
    100% { opacity: 0; transform: translate(var(--tx), var(--ty)); }
}

/* 响应式设计 */
@media (max-width: 900px) {
    .game-container {
        flex-direction: column;
    }
    
    .game-sidebar {
        width: 100%;
        padding: 20px 10px;
    }
    
    .game-board-container {
        order: 2;
    }
    
    .controls {
        grid-template-columns: 1fr;
    }
    
    button.fullscreen {
        grid-column: span 1;
    }
    
    .game-board {
        max-width: 98vw;
        padding: 2vw;
        gap: 0.8vw; /* 保持移动端紧凑 */
    }
    .next-ball {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
        overflow: auto;
    }
    
    .game-container {
        flex-direction: column;
        min-height: 100vh;
        padding: 10px;
    }

    .game-board-container {
        order: 2;
        min-width: auto;
        padding: 5px;
    }

    .game-board {
        max-width: min(90vh, 100vw);
        min-height: 80vw;
        gap: 0.8vw;
        touch-action: manipulation;
    }

    .game-sidebar {
        width: 100%;
        order: 1;
        flex-shrink: 0;
        padding: 8px;
    }

    .score-container {
        flex-direction: row;
        justify-content: space-around;
    }

    .score-item {
        flex-direction: column;
        height: auto;
    }
}

@media (max-width: 480px) {
    .game-board {
        min-width: 140px; /* 原为180px */
        min-height: 140px;
        padding: 4px;
        gap: 2px;
    }
    .next-ball {
        width: 20px;
        height: 20px;
    }
}

/* 加分动画字体更大，阴影更明显 */
.score-float {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Fredoka One', cursive;
    font-weight: normal;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 1.1s cubic-bezier(.22,1.2,.36,1);
    animation: float 1.5s ease-in-out;
}

@keyframes float {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    40% { transform: translate(-50%, -50%) scale(0.9); }
    60% { transform: translate(-50%, -50%) scale(1.1); }
    80% { transform: translate(-50%, -50%) scale(0.95); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

.score-float.big {
    font-size: 3rem;
    color: #ffeb3b;
}

.score-float.small {
    font-size: 1.8rem;
    color: #4fc3f7;
}

.debug-modal {
    position: fixed;
    left: 0; top: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.45);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.debug-modal-content {
    background: #18304a;
    color: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px #000b;
    padding: 32px 28px 24px 28px;
    min-width: 260px;
    max-width: 90vw;
    text-align: center;
    border: 2px solid #4fc3f7;
}
.debug-modal-content label {
    display: block;
    margin: 12px 0 6px 0;
    font-size: 1.08rem;
}
.debug-modal-content input[type="number"],
.debug-modal-content select {
    width: 80%;
    padding: 7px 8px;
    border-radius: 6px;
    border: 1px solid #4fc3f7;
    margin-bottom: 12px;
    font-size: 1.08rem;
}
.debug-modal-content button {
    margin: 0 10px;
    padding: 8px 22px;
    font-size: 1.08rem;
    border-radius: 22px;
    border: none;
    background: linear-gradient(90deg,#00c6ff,#0072ff);
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px #0004;
    transition: background 0.2s;
}
.debug-modal-content button:hover {
    background: linear-gradient(90deg,#00d2ff,#3a7bd5);
}
.cell.no-path {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 音效按钮样式 */
#sound-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    font-size: 1.1rem;
    background: none;
    border: none;
    box-shadow: none;
    width: auto;
    margin: 10px auto;
}

#sound-btn:hover {
    transform: scale(1.1);
    background: none;
    box-shadow: none;
}

#sound-btn:active {
    transform: scale(0.95);
}

#sound-btn svg {
    width: 28px;
    height: 28px;
    fill: #4fc3f7;
}

#sound-btn .sound-on {
    display: none;
}

#sound-btn .sound-off {
    display: none;
}

#sound-btn.sound-enabled .sound-on {
    display: block;
}

#sound-btn.sound-disabled .sound-off {
    display: block;
}

/* 图标按钮通用样式 */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    font-size: 1.1rem;
    background: none;
    border: none;
    box-shadow: none;
    width: auto;
    margin: 10px auto;
}

.icon-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 10px 0;
}

.icon-btn:hover {
    transform: scale(1.1);
    background: none;
    box-shadow: none;
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn svg {
    width: 28px;
    height: 28px;
    fill: #4fc3f7;
}

/* 添加飞行动画相关样式 */
@keyframes flyToBoard {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    90% {
        transform: translate(var(--tx), var(--ty)) scale(var(--scale));
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(var(--scale));
        opacity: 0;
    }
}

.flying-ball {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    animation: flyToBoard 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.trail-dot {
    position: fixed;
    width: 8px;
    height: 8px;
    background: #00ffea;
    border-radius: 50%;
    z-index: 999;
    box-shadow: 0 0 8px #00ffea;
    animation: fadeTrail 0.5s forwards;
    pointer-events: none;
}

@keyframes fadeTrail {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.5); }
}