:root {
    --bg-color: #f8f9fa;
    --court-color: #f3e5ab; /* 浅木色 */
    --primary-color: #e67e22; /* 篮球橙 */
    --even-color: #3498db; /* 蓝色表示平稳 */
    --odd-color: #e74c3c;  /* 红色表示突出 */
    --block-size: 30px;
    --gap: 4px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    overflow: hidden;
}

#game-container {
    width: 100vw;
    height: 100dvh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #dff9fb 0%, #ffffff 100%);
}

/* 任务栏样式 */
#goal-board {
    height: 80px;
    background: #2c3e50;
    color: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 2rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 10;
}

.goal-item {
    font-size: 1.2rem;
    font-weight: bold;
}

.goal-item .count {
    color: #f1c40f;
    margin-left: 10px;
    font-size: 1.5rem;
}

#level-display {
    background: rgba(255,255,255,0.2);
    padding: 5px 15px;
    border-radius: 20px;
}

/* 比赛场地 */
#game-field {
    flex: 1;
    position: relative;
    background-color: var(--court-color);
    background-image: 
        radial-gradient(circle at 50% 50%, transparent 150px, rgba(0,0,0,0.05) 151px, transparent 152px),
        linear-gradient(90deg, transparent 49%, rgba(0,0,0,0.05) 50%, transparent 51%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 40px;
}

/* 篮筐样式 */
#baskets-container {
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 0 16px;
    box-sizing: border-box;
    gap: 150px;
    margin-bottom: 50px;
}

.basket {
    width: 180px;
    height: 120px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.basket-rim {
    width: 120px;
    height: 15px;
    background: var(--primary-color);
    border-radius: 10px;
    position: relative;
    z-index: 2;
}

.even-basket .basket-rim {
    background: var(--even-color);
}

.odd-basket .basket-rim {
    background: var(--odd-color);
    clip-path: none;
    border-radius: 10px;
}

.even-basket .basket-rim::before,
.even-basket .basket-rim::after,
.odd-basket .basket-rim::after {
    content: '';
    position: absolute;
    top: -12px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    z-index: 3;
}

.even-basket .basket-rim::before {
    left: 20px;
    border-bottom: 14px solid var(--even-color);
}

.even-basket .basket-rim::after {
    right: 20px;
    border-bottom: 14px solid var(--even-color);
}

.odd-basket .basket-rim::after {
    left: 50%;
    transform: translateX(-50%);
    border-bottom: 16px solid var(--odd-color);
}

.basket-net {
    width: 100px;
    height: 100px;
    background-image: 
        linear-gradient(45deg, transparent 45%, #ddd 45%, #ddd 55%, transparent 55%),
        linear-gradient(-45deg, transparent 45%, #ddd 45%, #ddd 55%, transparent 55%);
    background-size: 15px 15px;
    border: 2px solid #ccc;
    border-top: none;
    border-radius: 0 0 50px 50px;
    opacity: 0.8;
}

.even-basket .basket-net {
    border-color: rgba(52, 152, 219, 0.6);
}

.odd-basket .basket-net {
    border-color: rgba(231, 76, 60, 0.6);
}

.basket-label {
    margin-top: 10px;
    font-weight: bold;
    color: #34495e;
}

.even-basket .basket-label {
    color: #1f4f8d;
}

.odd-basket .basket-label {
    color: #a93226;
}

/* 运算符停靠栏 */
#operator-dock {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.op-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.op-btn.active {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

/* 提示气泡 */
#hint-bubble {
    position: absolute;
    bottom: 20px; /* 移到场地底部，避免挡住篮筐 */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 25px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    z-index: 100;
    max-width: 80%;
    text-align: center;
    border: 2px solid var(--primary-color);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translate(-50%, 20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* 数字池区域 */
#number-pool {
    height: auto;
    min-height: 280px;
    background: #ecf0f1;
    border-top: 5px solid #bdc3c7;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 14px 30px;
}

#combine-zone {
    width: 100%;
    max-width: 980px;
    height: auto;
    min-height: 240px;
    background: rgba(255, 255, 255, 0.9);
    border: 3px dashed #d7dbdd;
    border-radius: 24px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 14px 20px;
    gap: 10px;
    overflow: visible;
    position: relative;
}

.op-zone {
    height: 34px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    letter-spacing: 0.5px;
    border: 2px dashed rgba(44, 62, 80, 0.2);
    background: rgba(255, 255, 255, 0.55);
    color: rgba(44, 62, 80, 0.55);
    width: 100%;
    pointer-events: none;
}

.op-zone.active {
    border-color: rgba(44, 62, 80, 0.4);
    background: rgba(255, 255, 255, 0.92);
    color: rgba(44, 62, 80, 0.95);
}

.op-zone-add.active { box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2) inset; }
.op-zone-mul.active { box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.2) inset; }

#combine-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: bold;
    color: #2c3e50;
}

.combine-title {
    background: #2c3e50;
    color: #fff;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.95rem;
}

.combine-hint {
    font-size: 0.95rem;
    color: #7f8c8d;
}

#pool-conveyor {
    display: flex;
    gap: 24px;
    row-gap: 20px;
    flex-wrap: wrap;
    overflow-x: hidden;
    overflow-y: visible;
    padding: 12px 6px 6px 6px;
    width: 100%;
    align-items: center;
}

/* 数字球样式 */
.number-ball {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    font-weight: bold;
    font-size: 1.2rem;
    color: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

.number-ball:active { cursor: grabbing; }
.number-ball.dragging { opacity: 0.5; transform: scale(0.9); }

.even-ball {
    background: radial-gradient(circle at 30% 30%, var(--even-color), #2980b9);
}

/* 奇数球：带凸起 (独角兽) */
.odd-ball {
    background: radial-gradient(circle at 30% 30%, var(--odd-color), #c0392b);
}

.even-ball::before,
.even-ball::after {
    content: '';
    position: absolute;
    top: -12px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 18px solid var(--even-color);
    filter: drop-shadow(0 -2px 2px rgba(0,0,0,0.2));
    z-index: 2;
}

.even-ball::before { left: 18%; }
.even-ball::after { right: 18%; }

/* 独角兽凸起 */
.odd-ball::after {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 20px solid var(--odd-color);
    filter: drop-shadow(0 -2px 2px rgba(0,0,0,0.2));
    z-index: 2;
}

/* 组合球标识 */
.combo-ball {
    border: 3px solid rgba(255,255,255,0.5);
    box-shadow: 0 0 15px rgba(255,255,255,0.3);
}

.expr-label {
    position: absolute;
    bottom: -26px;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 160px;
    text-align: center;
    color: #34495e;
    font-size: 0.8rem;
    font-weight: normal;
    z-index: 5;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

/* 原始球标识（不可投篮） */
.raw-ball {
    filter: saturate(0.8);
}

/* 胜利弹窗 */
/* --- Phase 2: 对战模式样式 --- */
#battle-field {
    width: 90%;
    max-width: 800px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    max-height: calc(100dvh - (var(--lab-shell-safe-top, 64px) + env(safe-area-inset-top) + 48px));
    overflow: auto;
}

#battle-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.character {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.avatar {
    font-size: 3rem;
}

.vs {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

#expression-container {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 2rem;
    font-weight: bold;
    flex-wrap: wrap;
    justify-content: center;
}

.num-block {
    width: 60px;
    height: 60px;
    background: white;
    border: 3px solid #ddd;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.num-block.even-block {
    background: rgba(52, 152, 219, 0.15);
    border-color: var(--even-color);
    color: #2c3e50;
}

.num-block.odd-block {
    background: rgba(231, 76, 60, 0.15);
    border-color: var(--odd-color);
    color: #2c3e50;
}

.op-slot {
    width: 50px;
    height: 50px;
    border: 2px dashed #bbb;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.op-slot:hover {
    border-color: var(--primary-color);
    background: rgba(230, 126, 34, 0.1);
}

.op-slot.filled {
    border-style: solid;
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.battle-op-btn {
    padding: 15px 30px;
    font-size: 1.5rem;
    border: none;
    border-radius: 10px;
    background: #ecf0f1;
    cursor: pointer;
    transition: all 0.2s;
}

.battle-op-btn:hover {
    background: #bdc3c7;
}

.battle-op-btn.active {
    background: var(--primary-color);
    color: white;
}

#battle-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#turn-indicator {
    font-weight: bold;
    color: #2c3e50;
}

.hidden {
    display: none !important;
}

/* --- 菜单与配置弹窗 --- */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(44, 62, 80, 0.95);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    padding: calc(var(--lab-shell-safe-top, 64px) + env(safe-area-inset-top) + 16px) 16px 24px;
    box-sizing: border-box;
    overflow-y: auto;
}

.menu-btns {
    display: flex;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.menu-btn {
    width: 200px;
    height: 150px;
    background: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
}

.menu-btn:hover {
    transform: translateY(-5px);
}

.menu-btn .icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.menu-btn .text {
    color: #2c3e50;
    font-weight: bold;
}

.setup-form {
    background: white;
    color: #2c3e50;
    padding: 30px;
    border-radius: 20px;
    width: min(350px, calc(100vw - 32px));
    max-height: calc(100dvh - (var(--lab-shell-safe-top, 64px) + env(safe-area-inset-top) + 48px));
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (max-width: 420px) {
    #goal-board {
        height: 72px;
        padding: 0 12px;
    }

    .goal-item {
        font-size: 1rem;
    }

    .goal-item .count {
        margin-left: 6px;
        font-size: 1.25rem;
    }

    #level-display {
        padding: 4px 10px;
        font-size: 0.9rem;
    }

    #game-field {
        padding-top: 24px;
    }

    #baskets-container {
        gap: 48px;
        margin-bottom: 28px;
    }

    .basket {
        width: 140px;
        height: 105px;
    }

    .basket-rim {
        width: 96px;
        height: 14px;
        border-radius: 9px;
    }

    .even-basket .basket-rim::before,
    .even-basket .basket-rim::after,
    .odd-basket .basket-rim::after {
        top: -10px;
        border-left-width: 8px;
        border-right-width: 8px;
    }

    .even-basket .basket-rim::before,
    .even-basket .basket-rim::after {
        border-bottom-width: 12px;
    }

    .odd-basket .basket-rim::after {
        border-bottom-width: 14px;
    }

    .basket-net {
        width: 80px;
        height: 82px;
        background-size: 13px 13px;
        border-radius: 0 0 44px 44px;
    }

    .basket-label {
        margin-top: 8px;
        font-size: 12px;
    }

    .menu-btn {
        width: min(170px, calc(50vw - 28px));
        height: 128px;
        border-radius: 18px;
    }

    .menu-btn .icon {
        font-size: 2.6rem;
    }

    .setup-form {
        padding: 20px;
        border-radius: 18px;
    }

    #battle-field {
        width: calc(100vw - 32px);
        padding: 18px;
        border-radius: 18px;
        gap: 18px;
    }

    .avatar {
        font-size: 2.4rem;
    }

    .vs {
        font-size: 1.5rem;
    }

    #expression-container {
        gap: 10px;
        font-size: 1.5rem;
    }

    .num-block {
        width: 48px;
        height: 48px;
        border-width: 2px;
        border-radius: 10px;
    }

    .op-slot {
        width: 40px;
        height: 40px;
    }

    .battle-op-btn {
        padding: 12px 18px;
        font-size: 1.25rem;
        border-radius: 10px;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.type-hint {
    font-size: 0.9rem;
    color: #7f8c8d;
    background: #f8f9fb;
    border-radius: 10px;
    padding: 10px 12px;
}

.radio-group {
    display: flex;
    gap: 10px;
}

.radio-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 10px;
    cursor: pointer;
}

.radio-btn.active {
    border-color: var(--primary-color);
    background: rgba(230, 126, 34, 0.1);
    color: var(--primary-color);
    font-weight: bold;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
}

.text-btn {
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    text-decoration: underline;
}

/* 优先级高亮动画 */
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(230, 126, 34, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(230, 126, 34, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(230, 126, 34, 0); }
}

.highlight-win {
    animation: pulse 1.5s infinite;
    border-color: #27ae60 !important;
}

#victory-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
}

#next-level-btn {
    margin-top: 20px;
    padding: 10px 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    cursor: pointer;
}

/* 动画 */
@keyframes swish {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2) translateY(20px); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}

.swish-anim {
    animation: swish 0.5s forwards;
}

@keyframes rebound {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.rebound-anim {
    animation: rebound 0.3s 2;
}
