.tdr-tool {
    max-width: 820px;
    margin: 24px auto;
    padding: 22px;
    color: #24364b;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.6;
    text-align: initial;
    white-space: normal;
    background: #ffffff;
    border: 1px solid #dce5ef;
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(24, 39, 58, 0.1);
}

.tdr-tool,
.tdr-tool * {
    box-sizing: border-box;
}

.tdr-tool .code-block,
.tdr-tool .adsbygoogle {
    display: none !important;
}

pre:has(.tdr-tool),
pre code:has(.tdr-tool) {
    margin: 0 !important;
    padding: 0 !important;
    color: inherit !important;
    font: inherit !important;
    white-space: normal !important;
    border: 0 !important;
    background: transparent !important;
    overflow: visible !important;
}

.tdr-tool .tdr-tool__header {
    margin: 0 0 18px;
    padding: 0;
    text-align: center;
}

.tdr-tool .tdr-tool__title {
    display: block;
    margin: 0 0 8px;
    padding: 0;
    color: #203c53;
    font-size: 34px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0;
}

.tdr-tool .tdr-tool__subtitle {
    display: block;
    max-width: 780px;
    margin: 0 auto;
    padding: 0;
    color: #4f5b68;
    font-size: 16px;
    line-height: 1.55;
    letter-spacing: 0;
}

.tdr-tool form.tdr-controls {
    display: block;
    max-width: 620px;
    margin: 0 auto 20px;
    padding: 0;
    text-align: center;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.tdr-tool label.tdr-controls__label {
    display: block;
    margin: 0 0 8px;
    padding: 0;
    color: #24364b;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
}

.tdr-tool .tdr-controls__row {
    display: grid;
    grid-template-columns: 86px minmax(150px, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    margin: 0;
    padding: 0;
}

.tdr-tool input.tdr-controls__number,
.tdr-tool input.tdr-controls__range,
.tdr-tool button.tdr-button {
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.tdr-tool input.tdr-controls__number {
    display: block;
    width: 100%;
    max-width: none;
    min-height: 38px;
    margin: 0;
    padding: 6px 8px;
    color: #1f2d3d;
    border: 1px solid #a8b6c5;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: none;
    text-align: center;
    appearance: auto;
}

.tdr-tool input.tdr-controls__number:focus {
    border-color: #2563eb;
    outline: 3px solid rgba(37, 99, 235, 0.18);
}

.tdr-tool input.tdr-controls__range {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    accent-color: #2563eb;
}

.tdr-tool button.tdr-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 38px;
    margin: 0;
    padding: 7px 14px;
    color: #ffffff;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    border: 0;
    border-radius: 6px;
    background: #1f5fbf;
    box-shadow: none;
    cursor: pointer;
    appearance: none;
    transition: background 0.18s ease, transform 0.18s ease;
}

.tdr-tool button.tdr-button:hover,
.tdr-tool button.tdr-button:focus {
    color: #ffffff;
    background: #174a98;
}

.tdr-tool button.tdr-button:focus {
    outline: 3px solid rgba(37, 99, 235, 0.22);
    outline-offset: 2px;
}

.tdr-tool button.tdr-button--secondary {
    color: #24364b;
    border: 1px solid #a8b6c5;
    background: #ffffff;
}

.tdr-tool button.tdr-button--secondary:hover,
.tdr-tool button.tdr-button--secondary:focus {
    color: #174a98;
    border-color: #7f94aa;
    background: #f3f7fb;
}

.tdr-tool button.tdr-button:active {
    transform: translateY(1px);
}

.tdr-tool button.tdr-button:disabled,
.tdr-tool input.tdr-controls__number:disabled,
.tdr-tool input.tdr-controls__range:disabled {
    opacity: 0.68;
    cursor: wait;
}

.tdr-tool .tdr-controls__hint {
    margin: 8px 0 0;
    padding: 0;
    color: #697789;
    font-size: 14px;
    line-height: 1.5;
}

.tdr-tool .tdr-dice {
    display: grid;
    grid-template-columns: repeat(var(--tdr-dice-columns, 1), 68px);
    gap: 12px;
    align-items: center;
    justify-content: center;
    justify-items: center;
    max-width: 720px;
    margin: 18px auto;
    padding: 6px 0;
}

.tdr-tool .tdr-die {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 68px;
    height: 68px;
    min-width: 68px;
    min-height: 68px;
    margin: 0;
    padding: 12px;
    border: 2px solid #cfcfcf;
    border-radius: 14px;
    background: #f8f8f8;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.92), 0 10px 18px rgba(22, 31, 44, 0.08);
}

.tdr-tool .tdr-die__pip {
    display: block;
    align-self: center;
    justify-self: center;
    width: 10px;
    height: 10px;
    min-width: 10px;
    min-height: 10px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    background: transparent;
}

.tdr-tool .tdr-die__pip.is-active {
    background: #111111;
    box-shadow: 0 0 0 1px #111111;
}

.tdr-tool.is-rolling .tdr-die {
    animation: tdr-shake 0.18s ease-in-out infinite;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.92), 0 12px 20px rgba(31, 95, 191, 0.16);
}

.tdr-tool.has-rolled:not(.is-rolling) .tdr-die {
    animation: tdr-pop 0.22s ease both;
}

@keyframes tdr-pop {
    0% {
        transform: translateY(8px) scale(0.96);
        opacity: 0.58;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes tdr-shake {
    0% {
        transform: translate(-1px, 0) rotate(-5deg);
    }
    50% {
        transform: translate(1px, -2px) rotate(5deg);
    }
    100% {
        transform: translate(-1px, 0) rotate(-5deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tdr-tool.is-rolling .tdr-die,
    .tdr-tool.has-rolled:not(.is-rolling) .tdr-die {
        animation: none;
    }
}

.tdr-tool .tdr-summary {
    display: block;
    margin: 16px 0 0;
    padding: 0;
}

.tdr-tool .tdr-total {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 0 10px;
    padding: 0;
}

.tdr-tool .tdr-total__label {
    color: #4f5b68;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
}

.tdr-tool .tdr-total__value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    margin: 0;
    padding: 3px 8px;
    color: #ffffff;
    border-radius: 6px;
    background: #203c53;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
}

.tdr-tool .tdr-table-wrap {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: auto;
}

.tdr-tool table.tdr-table {
    width: 100%;
    max-width: 620px;
    min-width: 520px;
    margin: 0 auto;
    color: #24364b;
    border-collapse: collapse;
    border-spacing: 0;
    background: #ffffff;
}

.tdr-tool table.tdr-table th,
.tdr-tool table.tdr-table td {
    min-width: 0;
    margin: 0;
    padding: 8px 7px;
    color: #24364b;
    border: 1px solid #333333;
    background: #ffffff;
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
    vertical-align: middle;
}

.tdr-tool table.tdr-table th {
    font-weight: 800;
}

.tdr-tool .tdr-guide {
    display: block;
    margin: 22px 0 0;
    padding: 18px 0 0;
    color: #3f4d5d;
    border-top: 1px solid #dce5ef;
    font-size: 15px;
    line-height: 1.8;
}

.tdr-tool .tdr-guide__heading {
    margin: 18px 0 6px;
    padding: 0;
    color: #203c53;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.4;
}

.tdr-tool .tdr-guide__heading:first-child {
    margin-top: 0;
}

.tdr-tool .tdr-guide p {
    margin: 0 0 12px;
    padding: 0;
}

.tdr-tool .tdr-guide ol {
    margin: 0 0 12px;
    padding-left: 24px;
}

.tdr-tool .tdr-guide li {
    margin: 0 0 4px;
    padding: 0;
}

.tdr-tool .tdr-guide code {
    padding: 2px 6px;
    color: #143b72;
    border-radius: 4px;
    background: #eef3f8;
}

@media (max-width: 720px) {
    .tdr-tool {
        margin: 18px auto;
        padding: 18px 14px;
    }

    .tdr-tool .tdr-tool__title {
        font-size: 28px;
    }

    .tdr-tool .tdr-tool__subtitle {
        font-size: 15px;
    }

    .tdr-tool .tdr-controls__row {
        grid-template-columns: 1fr;
    }

    .tdr-tool .tdr-dice {
        grid-template-columns: repeat(var(--tdr-dice-columns, 1), 58px);
        gap: 10px;
    }

    .tdr-tool .tdr-die {
        width: 58px;
        height: 58px;
        min-width: 58px;
        min-height: 58px;
        padding: 10px;
        border-radius: 12px;
    }

    .tdr-tool .tdr-die__pip {
        width: 8px;
        height: 8px;
        min-width: 8px;
        min-height: 8px;
    }

    .tdr-tool table.tdr-table th,
    .tdr-tool table.tdr-table td {
        padding: 7px 6px;
        font-size: 12px;
    }
}

@media (max-width: 380px) {
    .tdr-tool .tdr-dice {
        grid-template-columns: repeat(var(--tdr-dice-columns, 1), 50px);
        gap: 7px;
    }

    .tdr-tool .tdr-die {
        width: 50px;
        height: 50px;
        min-width: 50px;
        min-height: 50px;
        padding: 9px;
        border-radius: 10px;
    }

    .tdr-tool .tdr-die__pip {
        width: 7px;
        height: 7px;
        min-width: 7px;
        min-height: 7px;
    }
}
