:root {
    --bg-color: #f0f2f5;
    --container-bg: rgba(255, 255, 255, 0.9);
    --text-color: #333;
    --accent-color: #4a90e2;
    --dice-bg: #fff;
    --dot-color: #333;
    --button-bg: #4a90e2;
    --button-text: #fff;
}

body.dark-mode {
    --bg-color: #1a1a1a;
    --container-bg: rgba(45, 45, 45, 0.9);
    --text-color: #f0f2f5;
    --accent-color: #64b5f6;
    --dice-bg: #333;
    --dot-color: #f0f2f5;
    --button-bg: #64b5f6;
    --button-text: #1a1a1a;
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
}

#theme-btn {
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 20px;
}

.container {
    background: var(--container-bg);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    text-align: center;
    max-width: 400px;
    width: 90%;
    backdrop-filter: blur(10px);
}

h1 {
    margin-bottom: 30px;
    font-weight: 600;
}

.dice-wrapper {
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
}

.dice {
    width: 100px;
    height: 100px;
    background-color: var(--dice-bg);
    border-radius: 15px;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1), 0 5px 15px rgba(0,0,0,0.2);
    display: grid;
    grid-template-areas: 
        "a . b"
        "c d e"
        "f . g";
    padding: 15px;
    box-sizing: border-box;
    transition: transform 0.5s ease;
}

.dot {
    width: 18px;
    height: 18px;
    background-color: var(--dot-color);
    border-radius: 50%;
    align-self: center;
    justify-self: center;
}

/* 주사위 눈 배치 */
.dice[data-value="1"] .dot { grid-area: d; }

.dice[data-value="2"] .dot:nth-child(1) { grid-area: a; }
.dice[data-value="2"] .dot:nth-child(2) { grid-area: g; }

.dice[data-value="3"] .dot:nth-child(1) { grid-area: a; }
.dice[data-value="3"] .dot:nth-child(2) { grid-area: d; }
.dice[data-value="3"] .dot:nth-child(3) { grid-area: g; }

.dice[data-value="4"] .dot:nth-child(1) { grid-area: a; }
.dice[data-value="4"] .dot:nth-child(2) { grid-area: b; }
.dice[data-value="4"] .dot:nth-child(3) { grid-area: f; }
.dice[data-value="4"] .dot:nth-child(4) { grid-area: g; }

.dice[data-value="5"] .dot:nth-child(1) { grid-area: a; }
.dice[data-value="5"] .dot:nth-child(2) { grid-area: b; }
.dice[data-value="5"] .dot:nth-child(3) { grid-area: d; }
.dice[data-value="5"] .dot:nth-child(4) { grid-area: f; }
.dice[data-value="5"] .dot:nth-child(5) { grid-area: g; }

.dice[data-value="6"] .dot:nth-child(1) { grid-area: a; }
.dice[data-value="6"] .dot:nth-child(2) { grid-area: b; }
.dice[data-value="6"] .dot:nth-child(3) { grid-area: c; }
.dice[data-value="6"] .dot:nth-child(4) { grid-area: e; }
.dice[data-value="6"] .dot:nth-child(5) { grid-area: f; }
.dice[data-value="6"] .dot:nth-child(6) { grid-area: g; }

button {
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    font-family: inherit;
}

button:active {
    transform: scale(0.95);
}

button:hover {
    opacity: 0.9;
}

#result-text {
    margin-top: 20px;
    font-size: 1.2em;
    font-weight: 600;
    color: var(--accent-color);
}

@keyframes roll {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(720deg); }
}

.rolling {
    animation: roll 0.5s ease-out;
}
