/* RESET */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'MedievalSharp', cursive; /* The Fantasy Font */
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #0d0d0d;
    background-image: radial-gradient(circle at center, #1a1a1a 0%, #000000 100%); /* Vignette effect */
    color: white;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* 3D WORLD */
#dice-box {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 60vh;
    z-index: 0;
    pointer-events: none;
}

#dice-box canvas {
    width: 100% !important;
    height: 100% !important;
}

/* UI CONTAINER */
.container {
    position: relative;
    z-index: 10;
    max-width: 600px;
    margin: 0 auto;
    padding: 15px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;
}
.container > * { pointer-events: auto; }

/* HEADER */
.header-row {
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 0 20px;
}

h1 {
    text-shadow: 0 0 10px #a200ff; /* Magical glow text */
    font-size: 1.8rem;
    letter-spacing: 2px;
}

/* THEME SELECTOR */
#theme-select {
    background: rgba(0,0,0,0.8);
    color: #ffd700;
    border: 1px solid #ffd700;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    outline: none;
}

/* RESULT BOX - PARCHMENT STYLE */
.result-box {
    text-align: center;
    background: rgba(20, 10, 30, 0.85);
    padding: 15px;
    border-radius: 12px;
    border: 2px solid #4a3b59;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    margin-bottom: 10px;
}

#result-display {
    font-size: 3.5rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

#breakdown-display {
    color: #dcdcdc;
    font-size: 1.1rem;
    margin-top: 5px;
    min-height: 20px;
    white-space: normal;
    word-wrap: break-word;
    max-height: 80px;
    overflow-y: auto;
}

/* STAGING AREA */
#staging-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 40px;
    padding: 10px;
    margin-bottom: 10px;
}

/* STAGING TOKENS - Mini Runes */
.die-token {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4b0082, #240046);
    color: #ffd700;
    border: 1px solid #ffd700;
    /* Hexagon Shape */
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    font-size: 0.9rem;
}

@keyframes popIn { 0% { transform: scale(0) rotate(180deg); } 100% { transform: scale(1) rotate(0deg); } }

/* THE SPELL BAR (Compact Version) */
.dice-grid {
    display: flex;
    flex-wrap: wrap; /* Wraps to 2 lines if screen is too narrow */
    justify-content: center; /* Centers them perfectly */
    gap: 8px;
    margin-bottom: 15px;
}

.die-btn {
    /* Fixed Size: Half as big as before */
    width: 50px;
    height: 50px;
    
    background: linear-gradient(135deg, #2a2a2a, #111);
    color: #d4af37;
    border: none;
    /* The Magical Hexagon Shape */
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    
    font-weight: bold;
    font-size: 0.9rem; /* Smaller font to fit */
    cursor: pointer;
    transition: all 0.2s;
    
    /* Center text vertically and horizontally */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Remove padding so text centers nicely */
}

.die-btn:hover {
    background: linear-gradient(135deg, #4b0082, #800080);
    color: white;
    transform: translateY(-2px);
    filter: drop-shadow(0 0 5px #a200ff);
}

.die-btn:active {
    transform: scale(0.9);
}

/* Fake golden border effect using an inset shadow logic won't work with clip-path 
   So we add a glow instead */
.die-btn:hover {
    background: linear-gradient(135deg, #4b0082, #800080);
    color: white;
    transform: translateY(-3px);
    filter: drop-shadow(0 0 5px #a200ff);
}

.die-btn:active {
    transform: scale(0.9);
}

/* CONTROLS */
.controls {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

#roll-btn {
    background: linear-gradient(to bottom, #d4af37, #aa8822); /* Gold Bar */
    border: 2px solid #5c4810;
    color: #1a0f00;
    font-size: 1.8rem;
    padding: 18px;
    border-radius: 8px;
    text-transform: uppercase;
    box-shadow: 0 4px 0 #5c4810; /* 3D Clicky Button feel */
    transition: transform 0.1s;
}

#roll-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #5c4810;
}

.clear-btn {
    background: #3a1c1c;
    border: 1px solid #ff4444;
    color: #ffaaaa;
    border-radius: 8px;
    font-size: 1rem;
}