* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    padding: 30px;
}

.dice-selection h2, .dice-display h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.dice-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
}

.dice-btn {
    padding: 10px 20px;
    border: 2px solid #dee2e6;
    background: white;
    border-radius: 25px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dice-btn:hover, .dice-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.dice-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    perspective: 1000px;
}

.dice {
    width: 150px;
    height: 150px;
    position: relative;
    transform-style: preserve-3d;
    transform: translateZ(0);
    transition: transform 0.5s ease-out;
}

.dice-face {
    position: absolute;
    width: 100%;
    height: 100%;
    background: white;
    border: 2px solid #333;
    border-radius: 10px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    padding: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    backface-visibility: hidden;
}

/* 特殊布局 */
.dice-face-1 {
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translateZ(75px);
}

.dice-face-2 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    transform: rotateX(180deg) translateZ(75px);
}

.dice-face-2 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: start;
}

.dice-face-2 .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    align-self: end;
}

.dice-face-3 {
    transform: rotateY(-90deg) translateZ(75px);
}

.dice-face-3 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: start;
}

.dice-face-3 .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 2;
    justify-self: center;
    align-self: center;
}

.dice-face-3 .dot:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: end;
}

.dice-face-4 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    transform: rotateY(90deg) translateZ(75px);
}

.dice-face-4 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: start;
}

.dice-face-4 .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
}

.dice-face-4 .dot:nth-child(3) {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    align-self: end;
}

.dice-face-4 .dot:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    align-self: end;
}

.dice-face-5 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    transform: rotateX(90deg) translateZ(75px);
}

.dice-face-5 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.dice-face-5 .dot:nth-child(2) {
    grid-column: 3;
    grid-row: 1;
}

.dice-face-5 .dot:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}

.dice-face-5 .dot:nth-child(4) {
    grid-column: 1;
    grid-row: 3;
}

.dice-face-5 .dot:nth-child(5) {
    grid-column: 3;
    grid-row: 3;
}

.dice-face-6 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    transform: rotateX(-90deg) translateZ(75px);
}

.dice-face-6 .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: start;
}

.dice-face-6 .dot:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    align-self: center;
}

.dice-face-6 .dot:nth-child(3) {
    grid-column: 1;
    grid-row: 3;
    justify-self: start;
    align-self: end;
}

.dice-face-6 .dot:nth-child(4) {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
}

.dice-face-6 .dot:nth-child(5) {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    align-self: center;
}

.dice-face-6 .dot:nth-child(6) {
    grid-column: 2;
    grid-row: 3;
    justify-self: end;
    align-self: end;
}

.dot {
    width: 20px;
    height: 20px;
    background: #333;
    border-radius: 50%;
    display: inline-block;
}

.result-display {
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    font-weight: bold;
    color: #ff6b6b;
    margin-bottom: 30px;
}

.result-placeholder {
    color: #6c757d;
    font-style: italic;
    font-size: 1.2em;
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

#roll-btn, #reset-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

#roll-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#reset-btn {
    background: #6c757d;
    color: white;
}

#roll-btn:hover, #reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.instructions {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 20px;
    margin: 20px 30px 30px;
    border-radius: 0 8px 8px 0;
}

.instructions h3 {
    color: #1976d2;
    margin-bottom: 10px;
}

.instructions ul {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
    color: #333;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 10px;
    }
    
    header {
        padding: 20px 15px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .main-content {
        padding: 20px 15px;
    }
    
    .dice {
        width: 120px;
        height: 120px;
    }
    
    .dice-options {
        justify-content: center;
    }
    
    .dice-btn {
        padding: 8px 15px;
        font-size: 0.9em;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    #roll-btn, #reset-btn {
        width: 100%;
        max-width: 200px;
    }
}