/* 禁止双击选中和缩放 */
* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 禁用移动端点击高亮 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f0f0;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-user-select: none;
}

.container {
    text-align: center;
    background: white;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem;
}

.dice-count-control {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    height: 50px;
    position: relative;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}

.count-btn {
    background: #f0f0f0;
    color: #669900;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 15px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: absolute;
    z-index: 1;
}

.count-btn:hover {
    background: #f0f0f0;
    box-shadow: 0 0 10px rgba(102,153,0,0.3),
                0 0 20px rgba(102,153,0,0.2),
                0 0 30px rgba(102,153,0,0.1);
}

.count-btn:active {
    box-shadow: 0 0 5px rgba(102,153,0,0.2);
}

.count-btn.disabled {
    color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.count-btn.disabled:hover {
    background: #f0f0f0;
    box-shadow: none;
}

.count-btn.decrease {
    left: 20px;
}

.count-btn.increase {
    right: 20px;
}

.dice-count {
    font-size: 1.6rem;
    color: #666;
    font-weight: 500;
    width: 100%;
    text-align: center;
    letter-spacing: 0.2rem;
    padding: 0 40px;
    box-sizing: border-box;
}

h1 {
    color: #333;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.dice-container {
    perspective: 1000px;
    width: 100%;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    padding: 5px;
    margin: 0;
    min-height: 400px;
    overflow: visible;
}

.dice-wrapper {
    display: flex;
    flex-wrap: nowrap;
    gap: 14px;
    justify-content: center;
    align-items: center;
    width: 900px;
    margin: auto;
    padding: 5px;
}

/* 当只有一个骰子时的样式 */
.dice-wrapper:only-child {
    display: flex;
    justify-content: center;
    align-items: center;
}

.dice-wrapper > :only-child {
    margin: 0 auto;
}

.dice {
    width: 89px;
    height: 89px;
    position: relative;
    transform-style: preserve-3d;
    cursor: pointer;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.face {
    position: absolute;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 10px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
    backface-visibility: visible;
}

.dots {
    width: 100%;
    height: 100%;
    padding: 41px;
    box-sizing: border-box;
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
}

.dot {
    position: absolute;
    width: 23px;
    height: 23px;
    border-radius: 50%;
    background-color: black;
    box-shadow: inset 0 3px 4px rgba(0, 0, 0, 0.4),
                inset 0 -3px 4px rgba(255, 255, 255, 0.3),
                0 1px 2px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.3);
}

.dot.red {
    background-color: #DD0000;
    border: 1px solid rgba(150, 0, 0, 0.4);
    box-shadow: inset 0 3px 4px rgba(100, 0, 0, 0.5),
                inset 0 -3px 4px rgba(255, 100, 100, 0.3),
                0 1px 2px rgba(100, 0, 0, 0.3);
}

/* 6点（back面）的点需要反转阴影方向 */
.back .dot {
    box-shadow: inset 0 -3px 4px rgba(0, 0, 0, 0.4),
                inset 0 3px 4px rgba(255, 255, 255, 0.3),
                0 1px 2px rgba(0, 0, 0, 0.2);
}

/* 点的位置 */
.dot.center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.dot.top-left {
    top: 12%;
    left: 12%;
}

.dot.top-right {
    top: 12%;
    right: 12%;
}

.dot.middle-left {
    top: 50%;
    left: 12%;
    transform: translateY(-50%);
}

.dot.middle-right {
    top: 50%;
    right: 12%;
    transform: translateY(-50%);
}

.dot.bottom-left {
    bottom: 12%;
    left: 12%;
}

.dot.bottom-right {
    bottom: 12%;
    right: 12%;
}

/* 骰子面的位置 - 修正为标准立方体 */
.front {
    transform: rotateY(0deg) translateZ(44.5px);
}

.back {
    transform: rotateY(180deg) translateZ(44.5px);
}

.right {
    transform: rotateY(90deg) translateZ(44.5px);
}

.left {
    transform: rotateY(-90deg) translateZ(44.5px);
}

.top {
    transform: rotateX(90deg) translateZ(44.5px);
}

.bottom {
    transform: rotateX(-90deg) translateZ(44.5px);
}

/* 不同点数的布局 */
/* 1点 - 居中 */
.face[data-dots="1"] .dots {
    padding: 43px;
}
.face[data-dots="1"] .dot:nth-child(1) { 
    grid-area: 2 / 2;
}

/* 2点 - 对角线 */
.face[data-dots="2"] .dots {
    padding: 43px;
}
.face[data-dots="2"] .dot:nth-child(1) { 
    grid-area: 1 / 1;
}
.face[data-dots="2"] .dot:nth-child(2) { 
    grid-area: 3 / 3;
}

/* 3点 - 对角线加中心 */
.face[data-dots="3"] .dots {
    padding: 43px;
}
.face[data-dots="3"] .dot:nth-child(1) { 
    grid-area: 1 / 1;
}
.face[data-dots="3"] .dot:nth-child(2) { 
    grid-area: 2 / 2;
}
.face[data-dots="3"] .dot:nth-child(3) { 
    grid-area: 3 / 3;
}

/* 4点 - 四角 */
.face[data-dots="4"] .dots {
    padding: 43px;
}
.face[data-dots="4"] .dot:nth-child(1) { 
    grid-area: 1 / 1;
}
.face[data-dots="4"] .dot:nth-child(2) { 
    grid-area: 1 / 3;
}
.face[data-dots="4"] .dot:nth-child(3) { 
    grid-area: 3 / 1;
}
.face[data-dots="4"] .dot:nth-child(4) { 
    grid-area: 3 / 3;
}

/* 5点 - 四角加中心 */
.face[data-dots="5"] .dots {
    padding: 43px;
}
.face[data-dots="5"] .dot:nth-child(1) { 
    grid-area: 1 / 1;
}
.face[data-dots="5"] .dot:nth-child(2) { 
    grid-area: 1 / 3;
}
.face[data-dots="5"] .dot:nth-child(3) { 
    grid-area: 2 / 2;
}
.face[data-dots="5"] .dot:nth-child(4) { 
    grid-area: 3 / 1;
}
.face[data-dots="5"] .dot:nth-child(5) { 
    grid-area: 3 / 3;
}

/* 6点 - 两列三行 */
.face[data-dots="6"] .dots {
    padding: 43px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.face[data-dots="6"] .dot:nth-child(1) { 
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
}
.face[data-dots="6"] .dot:nth-child(2) { 
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
}
.face[data-dots="6"] .dot:nth-child(3) { 
    grid-column: 1;
    grid-row: 3;
    justify-self: start;
}
.face[data-dots="6"] .dot:nth-child(4) { 
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
}
.face[data-dots="6"] .dot:nth-child(5) { 
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
}
.face[data-dots="6"] .dot:nth-child(6) { 
    grid-column: 3;
    grid-row: 3;
    justify-self: end;
}

.roll-button {
    background: linear-gradient(145deg, #73ac00, #669900);
    color: white;
    border: none;
    padding: 1.2rem 3rem;
    font-size: 1.4rem;
    font-weight: normal;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    box-shadow: 0 2px 8px rgba(102,153,0,0.2);
    letter-spacing: 0.05em;
    min-width: 200px;
    margin: 0 auto;
}

.roll-button:hover {
    background: linear-gradient(145deg, #7ab800, #6da600);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102,153,0,0.3);
}

.roll-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(102,153,0,0.2);
}

.dice-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.result {
    margin: 1rem 0;
    font-size: 1.2rem;
    color: #666;
    min-height: 1.2rem;
    line-height: 1.2;
}

/* 动画类 */
.rolling {
    animation: roll 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes roll {
    0% { 
        transform: rotateX(0) rotateY(0) rotateZ(0);
    }
    15% { 
        transform: rotateX(180deg) rotateY(90deg) rotateZ(180deg);
    }
    30% { 
        transform: rotateX(360deg) rotateY(180deg) rotateZ(360deg);
    }
    45% { 
        transform: rotateX(540deg) rotateY(270deg) rotateZ(540deg);
    }
    60% { 
        transform: rotateX(720deg) rotateY(360deg) rotateZ(720deg);
    }
    75% { 
        transform: rotateX(900deg) rotateY(450deg) rotateZ(900deg);
    }
    90% { 
        transform: rotateX(1080deg) rotateY(540deg) rotateZ(1080deg);
    }
    100% { 
        transform: rotateX(1080deg) rotateY(540deg) rotateZ(1080deg);
    }
}

.controls-area {
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
}

@media (min-width: 601px) {
    .dice-wrapper {
        gap: min(52px, 5vw);
        width: min(900px, 95vw);
        padding: 20px;
    }

    .dice {
        width: 98px;
        height: 98px;
    }

    .front { transform: rotateY(0deg) translateZ(49px); }
    .back { transform: rotateY(180deg) translateZ(49px); }
    .right { transform: rotateY(90deg) translateZ(49px); }
    .left { transform: rotateY(-90deg) translateZ(49px); }
    .top { transform: rotateX(90deg) translateZ(49px); }
    .bottom { transform: rotateX(-90deg) translateZ(49px); }
}

@media (max-width: 720px) {
    .dice-wrapper {
        width: min(750px, 95vw);
        gap: 29px;
        padding: 15px;
    }
    
    .dice {
        width: 78px;
        height: 78px;
    }
    
    .front { transform: rotateY(0deg) translateZ(39px); }
    .back { transform: rotateY(180deg) translateZ(39px); }
    .right { transform: rotateY(90deg) translateZ(39px); }
    .left { transform: rotateY(-90deg) translateZ(39px); }
    .top { transform: rotateX(90deg) translateZ(39px); }
    .bottom { transform: rotateX(-90deg) translateZ(39px); }
    
    .roll-button {
        padding: 1rem 2.5rem;
        font-size: 1.2rem;
        min-width: 180px;
    }
    
    .dice-icon {
        width: 24px;
        height: 24px;
    }
    
    .dot {
        width: 21px;
        height: 21px;
    }
    
    .dots {
        padding: 37px;
    }
}

@media (max-width: 480px) {
    .dice-wrapper {
        flex-wrap: wrap;
        width: 100%;
        gap: 23px;
        padding: 15px;
    }
    
    .dice {
        width: calc((100vw - 138px) / 3);
        height: calc((100vw - 138px) / 3);
    }
    
    .front { transform: rotateY(0deg) translateZ(calc((100vw - 138px) / 6)); }
    .back { transform: rotateY(180deg) translateZ(calc((100vw - 138px) / 6)); }
    .right { transform: rotateY(90deg) translateZ(calc((100vw - 138px) / 6)); }
    .left { transform: rotateY(-90deg) translateZ(calc((100vw - 138px) / 6)); }
    .top { transform: rotateX(90deg) translateZ(calc((100vw - 138px) / 6)); }
    .bottom { transform: rotateX(-90deg) translateZ(calc((100vw - 138px) / 6)); }
    
    .roll-button {
        padding: 0.9rem 2rem;
        font-size: 1.1rem;
        min-width: 160px;
    }
    
    .dice-icon {
        width: 22px;
        height: 22px;
    }
    
    .dot {
        width: 18px;
        height: 18px;
    }
    
    .dots {
        padding: 34px;
    }
} 