.die-roller {
    --dr-ink: #2f1d0f;
    --dr-muted: #6f5844;
    --dr-panel: #fff9ef;
    --dr-panel-strong: #f5e6c7;
    --dr-border: #d8bf94;
    --dr-accent: #8f3f16;
    --dr-accent-strong: #c45a17;
    --dr-success: #1d5c40;
    --dr-error: #962b18;
    margin: 1.5rem 0;
    padding: 1.5rem;
    border: 1px solid var(--dr-border);
    border-radius: 20px;
    background:
        radial-gradient(circle at top right, rgba(196, 90, 23, 0.18), transparent 34%),
        linear-gradient(135deg, #fffdf7 0%, #f5ecd9 100%);
    box-shadow: 0 20px 45px rgba(47, 29, 15, 0.12);
    color: var(--dr-ink);
}

.die-roller--busy {
    opacity: 0.7;
    pointer-events: none;
}

.die-roller__title {
    margin: 0 0 1rem;
    font-family: Georgia, "Palatino Linotype", serif;
    font-size: clamp(1.5rem, 3vw, 2.1rem);
    line-height: 1.1;
}

.die-roller__intro {
    margin: 0 0 1.1rem;
    color: var(--dr-muted);
    max-width: 62ch;
}

.die-roller__form {
    display: grid;
    gap: 1rem;
}

.die-roller__dice-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
}

.die-roller__die-card {
    padding: 1rem;
    border: 1px solid rgba(143, 63, 22, 0.18);
    border-radius: 16px;
    background: rgba(255, 250, 240, 0.82);
}

.die-roller__die-card-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.85rem;
    text-align: center;
}

.die-roller__die-card--custom {
    background:
        radial-gradient(circle at top right, rgba(196, 90, 23, 0.18), transparent 38%),
        rgba(255, 247, 232, 0.92);
}

.die-roller__die-card-title {
    margin: 0;
    font-size: 1rem;
}

.die-roller__die-figure {
    flex: 0 0 auto;
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.die-roller__die-image {
    display: block;
    width: auto;
    height: 80px;
    max-width: 100%;
    max-height: 100%;
}

.die-roller__die-svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.die-roller__die-shadow {
    fill: rgba(62, 33, 9, 0.16);
}

.die-roller__die-facet {
    stroke: rgba(88, 49, 17, 0.78);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.25;
}

.die-roller__die-facet--light {
    fill: #ffe6b0;
}

.die-roller__die-facet--mid {
    fill: #f3c36e;
}

.die-roller__die-facet--accent {
    fill: #e9a94f;
}

.die-roller__die-facet--dark {
    fill: #cb7d32;
}

.die-roller__die-rim-fill {
    fill: rgba(255, 248, 230, 0.14);
}

.die-roller__die-rim {
    fill: none;
    stroke: rgba(88, 49, 17, 0.88);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.4;
}

.die-roller__die-line {
    fill: none;
    stroke: rgba(88, 49, 17, 0.68);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.3;
}

.die-roller__die-line--soft {
    stroke: rgba(88, 49, 17, 0.42);
}

.die-roller__die-glint {
    fill: none;
    stroke: rgba(255, 255, 255, 0.55);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 3.1;
}

.die-roller__die-label {
    fill: var(--dr-ink);
    font-family: Georgia, "Palatino Linotype", serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-anchor: middle;
    dominant-baseline: middle;
}

.die-roller__die-label--small {
    font-size: 16px;
}

.die-roller__die-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.die-roller__die-fields--triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.die-roller__field {
    display: grid;
    gap: 0.45rem;
}

.die-roller__field--wide {
    grid-column: 1 / -1;
}

.die-roller__field--schema {
    width: min(100%, 22rem);
    justify-self: start;
}

.die-roller__field-label {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dr-muted);
}

.die-roller__input {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border: 1px solid rgba(143, 63, 22, 0.24);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--dr-ink);
    font: inherit;
    box-sizing: border-box;
}

.die-roller__input:focus {
    outline: 2px solid rgba(196, 90, 23, 0.25);
    outline-offset: 1px;
    border-color: var(--dr-accent-strong);
}

.die-roller__select {
    min-height: 48px;
    padding-top: 0;
    padding-bottom: 0;
    padding-right: 2.4rem;
    line-height: 1.2;
    appearance: auto;
}

.die-roller__select--multiple {
    min-height: 9.5rem;
    padding: 0.45rem;
    padding-right: 0.45rem;
}

.die-roller__select--multiple option {
    padding: 0.4rem 0.55rem;
}

textarea.die-roller__input {
    min-height: 120px;
    resize: vertical;
}

.die-roller__button {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.9rem 1.3rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--dr-accent) 0%, var(--dr-accent-strong) 100%);
    color: #fff9f1;
    font: inherit;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: 0 12px 24px rgba(143, 63, 22, 0.24);
}

.die-roller__button:hover,
.die-roller__button:focus {
    filter: brightness(1.05);
}

.die-roller__button:disabled {
    opacity: 0.58;
    cursor: not-allowed;
    filter: none;
    box-shadow: none;
}

.die-roller__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.die-roller__button--secondary {
    background: linear-gradient(135deg, #f0d8ad 0%, #ddb06d 100%);
    color: #4a2b14;
    border-color: rgba(110, 58, 19, 0.42);
    box-shadow: 0 10px 18px rgba(110, 58, 19, 0.12);
}

.die-roller__button--secondary:hover,
.die-roller__button--secondary:focus {
    filter: brightness(1.04);
}

.die-roller__button--danger {
    background: linear-gradient(135deg, #8c2d1c 0%, #b84224 100%);
    color: #fff7f2;
    border-color: rgba(104, 27, 17, 0.36);
    box-shadow: 0 10px 18px rgba(104, 27, 17, 0.18);
}

.die-roller__button--danger:hover,
.die-roller__button--danger:focus {
    filter: brightness(1.04);
}

.die-roller__submission {
    margin-top: 1.25rem;
}

.die-roller__comment {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid rgba(143, 63, 22, 0.16);
    border-radius: 16px;
    background: rgba(255, 252, 244, 0.86);
}

.die-roller__comment-text {
    margin: 0;
}

.die-roller__notice {
    margin: 0 0 0.75rem;
    padding: 0.8rem 0.95rem;
    border-radius: 14px;
    font-weight: 600;
}

.die-roller__notice--success {
    background: rgba(29, 92, 64, 0.12);
    color: var(--dr-success);
}

.die-roller__notice--error {
    background: rgba(150, 43, 24, 0.1);
    color: var(--dr-error);
}

.die-roller__messages {
    margin-bottom: 1rem;
}

.die-roller__messages .die-roller__notice:last-child {
    margin-bottom: 0;
}

.die-roller__saved-tools {
    display: grid;
    gap: 0.55rem;
    padding: 1rem;
    border: 1px solid rgba(143, 63, 22, 0.16);
    border-radius: 18px;
    background: rgba(255, 252, 244, 0.86);
}

.die-roller__email-list {
    display: grid;
    gap: 0.75rem;
}

.die-roller__email-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
}

.die-roller__inline-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.die-roller__inline-controls .die-roller__select {
    flex: 1 1 18rem;
}

.die-roller__inline-controls .die-roller__select--multiple {
    flex-basis: 24rem;
}

.die-roller__help {
    margin: 0;
    color: var(--dr-muted);
    font-size: 0.95rem;
}

.die-roller__button--compact {
    min-width: 12.5rem;
    box-shadow: 0 10px 18px rgba(110, 58, 19, 0.12);
}

.die-roller__button--small {
    min-height: 42px;
    padding: 0.72rem 1rem;
    font-size: 0.95rem;
    box-shadow: 0 8px 16px rgba(143, 63, 22, 0.18);
}

.die-roller__field--checkbox {
    gap: 0.6rem;
}

.die-roller__checkbox-row {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.7rem;
    color: var(--dr-ink);
    font-weight: 600;
    line-height: 1.4;
}

.die-roller__checkbox-row input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0.12rem 0 0;
    accent-color: var(--dr-accent);
}

.die-roller__dialog {
    width: min(100% - 2rem, 38rem);
    max-width: 38rem;
    padding: 0;
    border: none;
    border-radius: 22px;
    background: transparent;
    color: inherit;
    box-shadow: none;
}

.die-roller__dialog::backdrop {
    background: rgba(47, 29, 15, 0.42);
    backdrop-filter: blur(4px);
}

.die-roller__dialog-card {
    display: grid;
    gap: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--dr-border);
    border-radius: 22px;
    background:
        radial-gradient(circle at top right, rgba(196, 90, 23, 0.16), transparent 34%),
        linear-gradient(135deg, #fffdf7 0%, #f4ead5 100%);
    box-shadow: 0 24px 48px rgba(47, 29, 15, 0.24);
}

.die-roller__dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.die-roller__dialog-title {
    margin: 0;
    font-size: 1.2rem;
}

.die-roller__dialog-text {
    margin: 0.35rem 0 0;
    color: var(--dr-muted);
}

.die-roller__dialog-close {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid rgba(74, 43, 20, 0.32);
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(240, 216, 173, 0.96) 100%);
    color: #3d2311;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 0.9;
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(47, 29, 15, 0.14);
}

.die-roller__dialog-close:hover,
.die-roller__dialog-close:focus {
    background: linear-gradient(135deg, #fffdf7 0%, #e7bc7d 100%);
    color: #2f1d0f;
    border-color: rgba(74, 43, 20, 0.46);
    filter: none;
}

.die-roller__dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.die-roller__results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
    margin-top: 1rem;
}

.die-roller__result-card {
    padding: 1rem;
    border: 1px solid rgba(143, 63, 22, 0.18);
    border-radius: 16px;
    background: rgba(255, 250, 240, 0.82);
}

.die-roller__result-title {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}

.die-roller__result-values,
.die-roller__result-total {
    margin: 0;
}

.die-roller__result-values {
    color: var(--dr-muted);
    word-break: break-word;
}

.die-roller__result-meta {
    margin: 0.5rem 0 0;
    color: var(--dr-muted);
    font-size: 0.92rem;
}

.die-roller__result-total {
    margin-top: 0.65rem;
    font-weight: 700;
}

.die-roller__summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.85rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(143, 63, 22, 0.16);
}

.die-roller__summary-label {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dr-muted);
}

@media (max-width: 640px) {
    .die-roller {
        padding: 1rem;
    }

    .die-roller__die-card-head {
        align-items: center;
    }

    .die-roller__die-fields,
    .die-roller__die-fields--triple {
        grid-template-columns: 1fr;
    }

    .die-roller__button {
        width: 100%;
        justify-self: stretch;
    }
 
    .die-roller__actions {
        display: grid;
    }

    .die-roller__email-row,
    .die-roller__inline-controls,
    .die-roller__dialog-actions {
        display: grid;
    }

    .die-roller__email-row {
        grid-template-columns: 1fr;
    }

    .die-roller__button--compact {
        width: 100%;
    }

    .die-roller__dialog {
        width: calc(100% - 1rem);
    }
}
