* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f0f0f0;
    font-family: Arial, sans-serif;
}

.container {
    text-align: center;
    padding: 20px;
}

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

.controls {
    margin-bottom: 20px;
}

.controls label {
    margin-right: 10px;
}

.controls input {
    width: 60px;
    padding: 5px;
    font-size: 1rem;
}

.dice-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin: 2rem auto;
}

.dice {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s;
}

.face {
    position: absolute;
    width: 100%;
    height: 100%;
    background: white;
    border: 2px solid #999;
    border-radius: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 10px;
}

.dot {
    width: 15px;
    height: 15px;
    background: #333;
    border-radius: 50%;
    align-self: center;
    justify-self: center;
}

/* 點數1的布局 */
.front .dot {
    grid-column: 2;
    grid-row: 2;
}

/* 點數2的布局 */
.back .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}
.back .dot:nth-child(2) {
    grid-column: 3;
    grid-row: 3;
}

/* 點數3的布局 */
.right .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}
.right .dot:nth-child(2) {
    grid-column: 2;
    grid-row: 2;
}
.right .dot:nth-child(3) {
    grid-column: 3;
    grid-row: 3;
}

/* 點數4的布局 */
.left .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}
.left .dot:nth-child(2) {
    grid-column: 1;
    grid-row: 3;
}
.left .dot:nth-child(3) {
    grid-column: 3;
    grid-row: 1;
}
.left .dot:nth-child(4) {
    grid-column: 3;
    grid-row: 3;
}

/* 點數5的布局 */
.top .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}
.top .dot:nth-child(2) {
    grid-column: 1;
    grid-row: 3;
}
.top .dot:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
}
.top .dot:nth-child(4) {
    grid-column: 3;
    grid-row: 1;
}
.top .dot:nth-child(5) {
    grid-column: 3;
    grid-row: 3;
}

/* 點數6的布局 */
.bottom .dot:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}
.bottom .dot:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}
.bottom .dot:nth-child(3) {
    grid-column: 1;
    grid-row: 3;
}
.bottom .dot:nth-child(4) {
    grid-column: 3;
    grid-row: 1;
}
.bottom .dot:nth-child(5) {
    grid-column: 3;
    grid-row: 2;
}
.bottom .dot:nth-child(6) {
    grid-column: 3;
    grid-row: 3;
}

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

button {
    padding: 10px 20px;
    font-size: 1.2rem;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

button:hover {
    background: #45a049;
}

button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

#results {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #333;
}
