:root {
    --bg-color: #fcfcfc;
    --text-main: #333;
    --line-color: rgba(0, 0, 0, 0.06);
    --accent-color: #788e85;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Songti SC", "Noto Serif SC", serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    touch-action: none;
}

.view {
    position: absolute;
    width: 100%;
    height: 100%;
    transition: opacity 0.8s ease;
    background-color: var(--bg-color);
}
.view.hidden { opacity: 0; pointer-events: none; z-index: 0; }
.view.active { opacity: 1; pointer-events: auto; z-index: 1; }

/* 首页及其他样式 */
#home-view { display: flex; justify-content: center; align-items: center; }
.menu { display: flex; gap: 40px; }
.nav-btn {
    background: none; border: none; font-size: 1.2rem;
    font-family: inherit; color: #666; cursor: pointer;
    transition: all 0.5s ease; letter-spacing: 0.2em;
}
.nav-btn:hover { color: #000; transform: scale(1.1); }

/* 详情页布局 */
#detail-view { display: flex; flex-direction: column; }
#back-btn {
    position: absolute; top: 20px; left: 20px;
    background: none; border: none; font-size: 0.8rem;
    color: #ccc; letter-spacing: 2px; cursor: pointer; z-index: 100;
}

/* 上半部分：插槽区 */
.top-section {
    flex: 6;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.slots-container { width: 100%; max-width: 95%; }

.slot {
    height: 40px;
    border-bottom: 1px solid var(--line-color);
    display: flex; align-items: center; justify-content: center;
    position: relative;
    margin-bottom: 5px;
    transition: border-color 0.3s ease;
    /* 必须加 relative，否则内部的长条无法绝对定位 */
}

/* 数字序号 */
.slot-number {
    position: absolute; left: 10px;
    font-size: 1rem; color: rgba(14, 9, 9, 0.15);
    font-family: sans-serif;
    z-index: 10; /* 确保数字浮在色块上方 */
    pointer-events: none;
}
/* 当插槽填满时，数字稍微变淡或变白以适应深色背景 */
.slot:has(.slotted) .slot-number { color: rgba(213, 207, 207, 0.5); }

/* 分割线 */
.divider {
    height: 1px; width: 80%; margin: 0 auto;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.08), transparent);
}

/* 下半部分：词语池 */
.bottom-section {
    flex: 4; background-color: #fafafa; position: relative;
}
#word-pool {
    height: 100%; display: flex; flex-wrap: wrap;
    justify-content: center; align-items: center;
    padding: 30px; gap: 20px;
}

/* --- 核心：圆圈与长条的变形逻辑 --- */

/* 1. 基础状态（在下方池子里）：圆形 */
.word-bubble {
    width: 68px;
    height: 68px;
    border-radius: 50%; /* 确保是圆的 */
    
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    
    display: flex; justify-content: center; align-items: center;
    font-size: 0.9rem; color: #555;
    
    cursor: grab;
    user-select: none; touch-action: none;
    position: relative; 
    z-index: 5;
    
    /* 关键：增加 width 和 borderRadius 的过渡动画 */
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
                height 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
                border-radius 0.3s,
                transform 0.2s, background-color 0.2s;
}

/* 彩色圆圈基础样式 */
.word-bubble.colored {
    color: #fff; border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* 2. 拖拽中状态：保持圆形，稍微放大 */
.word-bubble.dragging {
    position: fixed; z-index: 1000;
    width: 68px !important; /* 强制保持圆形尺寸 */
    height: 68px !important;
    border-radius: 50% !important;
    transform: scale(1.15) !important;
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
    cursor: grabbing;
}

/* 3. 放入插槽状态：变成长条 */
.word-bubble.slotted {
    position: absolute;
    top: 0; left: 0;
    
    /* 填满插槽 */
    width: 100%; 
    height: 100%;
    border-radius: 2px; /* 几乎直角，或者设为0 */
    
    box-shadow: none; border: none;
    z-index: 1; /* 在数字之下 */
    
    font-weight: normal;
    letter-spacing: 2px;
    color: #fff; /* 文字变白 */
    background: transparent; /* 颜色由内联样式 style 控制，这里设透明 */
}

/* 修正：如果是普通白色气泡放入后，需要给个底色 */
.word-bubble.slotted:not(.colored) {
    background-color: #333 !important; /* 黑底白字 */
}

/* --- 响应式适配：横屏模式 (Landscape) --- */
@media screen and (orientation: landscape) {

    /* 1. 主容器改为左右排列 */
    #detail-view {
        flex-direction: row; /* 从上下(column)变为左右(row) */
        align-items: center;
    }

    /* 2. 左侧 (原来的上方) */
    .top-section {
        flex: 1; /* 占据一半宽度 */
        height: 100%; /* 高度占满 */
        padding: 20px 40px; 
        /* 防止横屏高度不够，允许内部滚动 */
        overflow-y: auto; 
        
        /* 稍微调整布局方式，确保插槽居中 */
        justify-content: center; 
        align-items: center;
    }

    /* 调整插槽容器，让它在左侧更舒展 */
    .slots-container {
        width: 80%; 
        max-width: 500px;
        /* 给顶部留点位置，避免遮挡返回按钮 */
        margin-top: 40px; 
    }

    /* 3. 分割线 (改为垂直线) */
    .divider {
        width: 1px; /* 变成细竖线 */
        height: 80%; /* 高度 80% */
        margin: 0;   /* 取消原有 margin */
        
        /* 渐变方向改为垂直：从上到下 */
        background: linear-gradient(180deg, transparent, rgba(0,0,0,0.08), transparent);
    }

    /* 4. 右侧 (原来的下方词语池) */
    .bottom-section {
        flex: 1; /* 占据另一半宽度 */
        height: 100%;
        overflow-y: auto; /* 允许滚动 */
        
        /* 调整背景色过渡，或者保持一致 */
        border-left: 1px solid rgba(0,0,0,0.02);
    }

    #word-pool {
        padding: 40px;
        /* 词语在右侧居中排列 */
        align-content: center; 
    }
}