.btn-group {
    flex-wrap: wrap;
    justify-content: center;
}
@media (max-width: 768px) {
    #diceForm {
        flex-direction: column;
        align-items: center;
    }
    #diceForm > div {
        margin-bottom: 1rem;
    }
}
.success-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.success-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 200px;
}
.success-row .btn {
    flex: 1;
    width: 40px;
    max-width: 40px;
}
.btn-outline-primary {
    color: #a78bfa;
    border-color: #a78bfa;
}
.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active, .btn-outline-primary.active {
    background-color: #a78bfa;
    border-color: #a78bfa;
    color: #fff;
}
.btn-check:checked + .btn-outline-primary {
    background-color: #a78bfa;
    border-color: #a78bfa;
    color: #fff;
}
body {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  width: 90%;
  height: 100%;
  margin: 0 auto; /* Center the body content */
  padding: 20px 5%;
  position: relative;
  text-align: center;
  overflow-x: hidden;
  overflow-y: auto;
}

#dice-box {
  position: relative;
  top: 0;
  left: 0;
  box-sizing: border-box;
  width: 400px;
  height: 300px; /* Adjust this value as needed */
  margin-bottom: 20px;
  background-size: cover;
  border: 1px solid rgba(255, 255, 255, 0.1); /* Add a faint border */
  border-radius: 4px; /* Optional: add rounded corners */
}

#dice-box canvas {
  width: 400px;
  height: 300px;
  z-index: 1;
}

h1,
button#rollem {
  position: relative;
  z-index: 2;
}

button#rollem {
  cursor: pointer;
}

.dice-count-form {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 1rem;
}

.dice-count-form .btn-group {
    flex-wrap: wrap;
    justify-content: center;
    max-width: 600px;
}

.dice-count-form .btn {
    margin: 2px;
}

.dice-count-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.dice-count-row {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 500px;
}
.dice-count-row .btn {
    flex: 1;
    padding: 0.375rem 0;
    margin: 0;
    border-radius: 0;
}
.dice-count-row:first-child {
    border-top-left-radius: 0.25rem;
    border-top-right-radius: 0.25rem;
    overflow: hidden;
}
.dice-count-row:last-child {
    border-bottom-left-radius: 0.25rem;
    border-bottom-right-radius: 0.25rem;
    overflow: hidden;
}
.dice-count-row:first-child .btn:first-child {
    border-top-left-radius: 0.25rem;
}
.dice-count-row:first-child .btn:last-child {
    border-top-right-radius: 0.25rem;
}
.dice-count-row:last-child .btn:first-child {
    border-bottom-left-radius: 0.25rem;
}
.dice-count-row:last-child .btn:last-child {
    border-bottom-right-radius: 0.25rem;
}

.main-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 10px;
    max-width: 1400px;
    margin: 0 auto;
}

.controls-container {
    width: 50%;
    padding-right: 10px;
    box-sizing: border-box;
}

.dice-container {
    width: 50%;
    padding-left: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#dice-box {
    width: 100%;
    height: 0;
    padding-bottom: 75%; /* This creates a 4:3 aspect ratio */
    position: relative;
    border: none;  /* Remove the border */
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;  /* Add some space between the canvas and results */
}

#dice-box canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.chart-container {
    width: 100%;
    height: 400px;
    margin-top: 20px;
}

#rollResults {
    width: 100%;
    text-align: center;
    min-height: 125px; /* Reserve space for results */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Add responsive styles */
@media (max-width: 768px) {
    body {
        width: 95%;
        padding: 10px 2.5%;
    }
    
    .main-container {
        flex-direction: column;
        padding: 5px;
    }

    .controls-container,
    .dice-container {
        width: 100%;
        padding: 0;
        margin-bottom: 15px;
    }

    .dice-container {
        order: -1; /* Move dice container to the top */
    }

    .chart-container {
        order: 1; /* Move chart container to the bottom */
    }

    #dice-box {
        max-width: 400px;
        margin: 0 auto;
    }

    /* Move roll button to top of controls */
    .controls-container {
        display: flex;
        flex-direction: column;
    }

    .controls-container .text-center.mb-4 {
        order: -1; /* Move roll button to top */
        margin-bottom: 1.5rem !important; /* Increase spacing below button */
    }

    #diceCountForm {
        order: 0;
    }

    #diceForm {
        order: 1;
    }
}