/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    width: 90%;
    margin: 2rem;
}

/* 标题区域 */
.title-section {
    text-align: center;
    margin-bottom: 2rem;
}

.title-section h1 {
    font-size: 2.5rem;
    color: #4a5568;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.title-section p {
    font-size: 1.1rem;
    color: #718096;
    opacity: 0.8;
}

/* 骰子区域 */
.dice-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    gap: 2rem;
}

.dice-container {
    perspective: 1000px;
}

.dice {
    width: 100px;
    height: 100px;
    background: #fff;
    border: 3px solid #e2e8f0;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transition: transform 0.6s ease, box-shadow 0.3s ease;
    transform-style: preserve-3d;
}

.dice:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.dice.rolling {
    animation: roll 0.6s ease infinite;
}

@keyframes roll {
    0% { transform: rotateX(0deg) rotateY(0deg); }
    25% { transform: rotateX(90deg) rotateY(90deg); }
    50% { transform: rotateX(180deg) rotateY(180deg); }
    75% { transform: rotateX(270deg) rotateY(270deg); }
    100% { transform: rotateX(360deg) rotateY(360deg); }
}

.dot-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dot {
    width: 12px;
    height: 12px;
    background: #4a5568;
    border-radius: 50%;
    position: absolute;
    opacity: 0;
}

/* 骰子点数显示 */
.dice[data-value="1"] #dot4 { opacity: 1; }
.dice[data-value="2"] #dot1, .dice[data-value="2"] #dot7 { opacity: 1; }
.dice[data-value="3"] #dot1, .dice[data-value="3"] #dot4, .dice[data-value="3"] #dot7 { opacity: 1; }
.dice[data-value="4"] #dot1, .dice[data-value="4"] #dot2, .dice[data-value="4"] #dot6, .dice[data-value="4"] #dot7 { opacity: 1; }
.dice[data-value="5"] #dot1, .dice[data-value="5"] #dot2, .dice[data-value="5"] #dot4, .dice[data-value="5"] #dot6, .dice[data-value="5"] #dot7 { opacity: 1; }
.dice[data-value="6"] #dot1, .dice[data-value="6"] #dot2, .dice[data-value="6"] #dot3, .dice[data-value="6"] #dot5, .dice[data-value="6"] #dot6, .dice[data-value="6"] #dot7 { opacity: 1; }

/* 骰子初始状态 */
.dice-initial {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.dice:not(.rolling):hover .dice-initial {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.02);
}

.dice.rolling .dice-initial {
    opacity: 0;
    pointer-events: none;
}

.initial-content {
    text-align: center;
    animation: pulse 2s infinite;
}

.dice-icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
    display: block;
}

.dice-text {
    font-size: 0.9rem;
    color: #667eea;
    font-weight: 600;
    letter-spacing: 0.5px;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 当骰子显示结果时隐藏初始界面 */
.dice[data-value]:not([data-value="1"]) .dice-initial {
    opacity: 0;
    pointer-events: none;
}

/* 点位位置 */
#dot1 { top: 20%; left: 20%; }
#dot2 { top: 20%; left: 50%; }
#dot3 { top: 20%; right: 20%; }
#dot4 { top: 50%; left: 50%; }
#dot5 { bottom: 20%; left: 20%; }
#dot6 { bottom: 20%; left: 50%; }
#dot7 { bottom: 20%; right: 20%; }

.roll-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.roll-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(102, 126, 234, 0.4);
}

.roll-button:active {
    transform: translateY(0);
}

/* 结果显示区域 */
.result-section {
    margin: 2rem 0;
    text-align: center;
}

.result-box {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 2px solid #e6fffa;
    animation: popIn 0.6s ease;
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.result-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.result-title {
    font-size: 1.8rem;
    color: #2d3748;
    margin-bottom: 0.5rem;
}

.result-description {
    font-size: 1.1rem;
    color: #718096;
    line-height: 1.5;
}

/* 历史记录 */
.history-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f7fafc;
    border-radius: 10px;
}

.history-section h3 {
    margin-bottom: 1rem;
    color: #4a5568;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: white;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.history-item .food-icon {
    font-size: 1.2rem;
    margin-right: 0.5rem;
}

.history-item .food-name {
    flex: 1;
    text-align: left;
}

.history-item .timestamp {
    font-size: 0.8rem;
    color: #a0aec0;
}

.clear-history {
    background: #e2e8f0;
    color: #4a5568;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.clear-history:hover {
    background: #cbd5e0;
}

/* 设置区域 */
.settings-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f7fafc;
    border-radius: 10px;
}

.settings-section h3 {
    margin-bottom: 1rem;
    color: #4a5568;
}

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
}

.settings-options input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.settings-button {
    background: #edf2f7;
    color: #4a5568;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-button:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h3 {
    color: #4a5568;
}

.close-button {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #a0aec0;
    padding: 0.25rem 0.5rem;
}

.close-button:hover {
    color: #718096;
}

.modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

.food-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.category {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
}

.category h4 {
    margin-bottom: 1rem;
    color: #4a5568;
}

.food-items {
    margin-bottom: 1rem;
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: #f7fafc;
    border-radius: 5px;
    cursor: pointer;
}

.food-item:hover {
    background: #edf2f7;
}

.food-item .food-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.food-item .remove-btn {
    color: #e53e3e;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
}

.add-food {
    display: flex;
    gap: 0.5rem;
}

.add-food input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
}

.add-food button {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.modal-button {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.modal-button.primary {
    background: #667eea;
    color: white;
    border: none;
}

.modal-button:not(.primary) {
    background: #edf2f7;
    color: #4a5568;
    border: none;
}


/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
        margin: 1rem;
    }
    
    .title-section h1 {
        font-size: 2rem;
    }
    
    .dice {
        width: 80px;
        height: 80px;
    }
    
    .food-categories {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        padding: 1rem;
    }
}

/* 动画效果 */
.fade-in {
    animation: fadeIn 0.6s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-up {
    animation: slideUp 0.6s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 工具类 */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.flex {
    display: flex;
}

.justify-center {
    justify-content: center;
}

.items-center {
    align-items: center;
}
