* {
    transition: all 0.3s;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f5f5f5;
    font-family: monospace;
    overflow: hidden;
}

.container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 20px;
}

/* External moles container - 左上角小盒子 */
.external-moles-container {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 100px;
    padding: 10px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
    align-items: center;
}

/* Container title */
.container-title {
    font-size: 14px;
    text-align: left;
    margin-bottom: 8px;
    font-weight: bold;
}

/* 收缩/展开功能 */
.external-moles-toggle {
    position: absolute;
    top: 25px;
    left: 40px;
    width: 20px;
    height: 10px;
    background-color: #333;
    color: white;
    border-radius: 80%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 10px;
    z-index: 101;
}

.external-moles-container.collapsed {
    height: 40px;
    overflow: hidden;
}

/* Face container - 椭圆形 */
.face {
    position: relative;
    width: 95vw; /* 横向延展 */
    height: 75vw; /* 高度小于宽度，形成椭圆 */
    max-width: 600px;
    max-height: 450px;
    background-color: #ffe6cc;
    border-radius: 50%;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    z-index: 10; /* 确保脸部在耳朵上方 */
    overflow: visible;
}

/* All face features */
.feature {
    position: absolute;
    transition: all 0.3s ease;
    cursor: grab;
}

.feature:active {
    cursor: grabbing;
}

/* Eyes */
.eye {
    width: 15%;
    height: 15%;
    background-color: white;
    border: none;
    border-radius: 50%;
    position: absolute;
}

.eye::after {
    content: '';
    position: absolute;
    width: 40%;
    height: 40%;
    background-color: black;
    border-radius: 50%;
    top: 30%;
    left: 30%;
}

.left-eye {
    top: 40%;
    left: 30%;
}

.right-eye {
    top: 40%;
    left: 55%;
}

/* Eyebrows */
.eyebrow {
    width: 15%;
    height: 3%;
    background-color: #333;
    border-radius: 10px;
    position: absolute;
    z-index: 15;
}

.left-eyebrow {
    top: 30%;
    left: 30%;
    transform: rotate(10deg);
}

.right-eyebrow {
    top: 30%;
    left: 55%;
    transform: rotate(-10deg);
}

/* 耳朵样式 - 半圆形并嵌入脸部 */
.ear {
    width: 12%;
    height: 28%;
    top: 35%;
    background-color: #ffccaa;
    position: absolute;
    border-radius: 40%;
    z-index: 5; /* 确保耳朵在脸部下方 */
    overflow: visible;
}

.left-ear {
    left: -5%;
    border-top-left-radius: 70% 60%;
    border-bottom-left-radius: 60% 50%;
    border-top-right-radius: 30% 40%;
    border-bottom-right-radius: 20% 30%;
}

.right-ear {
    right: -5%;
    border-top-right-radius: 70% 60%;
    border-bottom-right-radius: 60% 50%;
    border-top-left-radius: 30% 40%;
    border-bottom-left-radius: 20% 30%;
}

/* Nose */
.nose {
    width: 9%;
    height: 18%;
    background-color: #ffccaa;
    border-radius: 50%;
    position: absolute;
    top: 55%;
    left: 45%;
}

/* Mouth */
.mouth {
    width: 30%;
    height: 10%;
    border-bottom: 3px solid black;
    border-radius: 0 0 50% 50%;
    position: absolute;
    top: 70%;
    left: 35%;
    z-index: 15;
}

/* Moles */
.mole {
    position: absolute;
    transition: all 0.3s ease;
    cursor: grab;
    z-index: 20;
}

.mole:active {
    cursor: grabbing;
}

/* External moles */
.external-mole {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 30px;
    height: 30px;
    background-color: rgba(1, 22, 39, .078);
    border-radius: 50%;
}

.external-mole:hover {
    transform: scale(1.1);
    background-color: rgba(255, 255, 255, 0.8);
}

/* 拖动时的样式 */
.dragging {
    opacity: 0.8;
    z-index: 1000;
}

.over-face {
    background-color: rgba(200, 255, 200, 0.7);
}

/* Mole shapes */
.mole-circle {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #333;
    display: block;
}

.mole-moon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: transparent;
    box-shadow: 3px 0 0 0 #333;
    transform: rotate(45deg);
    display: block;
}

.mole-triangle {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 15px solid #333;
    display: block;
}

.mole-star {
    width: 15px;  
    height: 15px;
    background-color: #333;
    position: relative;
    display: block;
    clip-path: polygon(50% 0%, 
                      61% 35%, 
                      98% 35%, 
                      68% 57%, 
                      79% 91%, 
                      50% 70%, 
                      21% 91%, 
                      32% 57%, 
                      2% 35%, 
                      39% 35%);
}

.mole-square {
    width: 10px;
    height: 10px;
    background-color: #333;
    display: block;
}

/* 信息按钮和弹窗 */
.info-button {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: #333;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

.info-button:hover {
    transform: scale(1.1);
    background-color: #555;
}

.info-popup {
    position: absolute;
    bottom: 70px;
    right: 20px;
    width: 250px;
    height: 300px;
    overflow-y: auto;
    background-color: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 200;
    transform: scale(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease;
}

.info-popup.visible {
    transform: scale(1);
}

.close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #666;
}

/* Reset按钮样式 */
.reset-button {
    position: absolute;
    bottom: 20px;
    right: 70px; /* 放在info按钮旁边 */
    width: 40px;
    height: 40px;
    background-color: #6bdaff;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

.reset-button:hover {
    transform: scale(1.1);
    background-color: #FF8787;
}

/* 重力按钮样式 */
.gravity-button {
    position: absolute;
    bottom: 20px;
    right: 220px;
    width: 40px;
    height: 40px;
    background-color: #4CAF50;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 100;
    transition: all 0.3s ease;
}

.gravity-button:hover {
    transform: scale(1.1);
    background-color: #2E8B57;
}

@media (max-width: 480px) {
    .gravity-button {
        width: 35px;
        height: 35px;
        right: 195px;
    }
    
    .randomize-button {
        width: 35px;
        height: 35px;
        right: 240px;
    }
}

/* 肤色选择器容器 */
.skin-color-container {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 80px;
    padding: 10px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
    transition: all 0.3s ease;
}

.skin-color-container.collapsed {
    height: 40px;
    overflow: hidden;
}

.skin-color-title {
    font-size: 14px;
    text-align: center;
    margin-bottom: 8px;
    font-weight: bold;
}

/* Toggle button for skin color container */
.skin-color-toggle {
    position: absolute;
    top: 25px;
    left: 32px;
    width: 20px;
    height: 10px;
    background-color: #333;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 10px;
    z-index: 101;
}

.skin-color-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.color-btn {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    margin: 2px;
    cursor: pointer;
    border: 1px solid #ccc;
    transition: transform 0.2s;
}

.color-btn:hover {
    transform: scale(1.2);
    border: 1px solid #333;
}

.color-btn.active {
    border: 2px solid #333;
    transform: scale(1.1);
}

.custom-color {
    display: flex;
    justify-content: center;
    margin-top: 5px;
}

#custom-color-picker {
    width: 80%;
    height: 25px;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* 截图按钮样式 */
.capture-button {
    position: absolute;
    bottom: 20px;
    right: 120px; /* 放在其他按钮旁边 */
    width: 40px;
    height: 40px;
    background-color: #6495ED;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 100;
}
  
.capture-button:hover {
    transform: scale(1.1);
    background-color: #4169E1;
}

/* 查看历史按钮 */
.view-history-button {
    position: absolute;
    bottom: 20px;
    right: 170px;
    width: 40px;
    height: 40px;
    background-color: #9370DB;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

.view-history-button:hover {
    transform: scale(1.1);
    background-color: #8A2BE2;
}
  
/* 故事面板样式 */
.story-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 80%;
    max-width: 500px;
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 300;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
  
.story-panel.visible {
    transform: translate(-50%, -50%) scale(1);
}
  
.preview-container {
    width: 100%;
    text-align: center;
}
  
.preview-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 5px;
    border: 1px solid #ddd;
}
  
#story-input {
    width: 100%;
    height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    resize: none;
    font-family: inherit;
}
  
#save-story {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    align-self: center;
}
  
/* 历史记录面板样式 */
.history-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 90%;
    max-width: 800px;
    height: 80%;
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 300;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}
  
.history-panel.visible {
    transform: translate(-50%, -50%) scale(1);
}
  
.history-container {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
    padding: 10px 0;
}
  
.history-item {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
  
.history-item img {
    width: 100%;
    height: 150px;
    object-fit: contain;
    border-radius: 5px;
}
  
.history-item p {
    flex: 1;
    font-size: 14px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
  
.history-date {
    color: #777;
    font-size: 12px;
}
  
.history-actions {
    display: flex;
    justify-content: space-between;
}
  
.history-actions button {
    padding: 5px 10px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}
  
.view-btn {
    background-color: #2196F3;
    color: white;
}
  
.delete-btn {
    background-color: #f44336;
    color: white;
}

.empty-history {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    color: #777;
}

/* 单个查看面板 */
.view-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 600px;
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.view-panel img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 5px;
}

.story-text {
    white-space: pre-wrap;
    line-height: 1.5;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .face {
        width: 80vw;
        height: 60vw;
    }
    
    .external-moles-container {
        width: 80px;
    }
    
    .info-popup {
        width: 200px;
        height: 300px;
    }
    
    .story-panel, .history-panel {
        width: 95%;
    }
}

@media (max-width: 480px) {
    .face {
        width: 90vw;
        height: 70vw;
    }
    
    .external-moles-container, .skin-color-container {
        width: 70px;
    }
    
    .view-history-button, .capture-button, .reset-button, .info-button {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .view-history-button {
        right: 150px;
    }
    
    .capture-button {
        right: 105px;
    }
    
    .reset-button {
        right: 60px;
    }
}

/* 适应超宽屏 - 让脸部铺满整个页面 */
@media (min-aspect-ratio: 16/9) {
    .face {
        width: 95vw;
        height: 95vh;
        max-width: none;
        max-height: none;
    }
    
    /* 调整按钮位置，防止被脸部遮挡 */
    .view-history-button,
    .capture-button,
    .reset-button,
    .info-button {
        z-index: 101;
    }
    
    /* 确保耳朵位置正确 */
    .left-ear {
        left: -2%;
    }
    
    .right-ear {
        right: -2%;
    }
}

.zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.zoom-button {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}