.builtin-widget {
    margin: 1.5rem 0;
    padding: 1.2rem;
    border-radius: 24px;
    background: #f8fafc;
    border: 1px solid #dbe3ee;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

.bf-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.bf-tab,
.bf-action {
    border: none;
    border-radius: 999px;
    padding: 0.65rem 1rem;
    background: white;
    color: #334155;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid #cbd5e1;
    transition: all 0.2s ease;
}

.bf-tab:hover,
.bf-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.bf-tab.active,
.bf-action {
    background: #0f172a;
    color: white;
    border-color: #0f172a;
}

.bf-panel {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 1rem;
}

.bf-input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.bf-input-grid label {
    display: grid;
    gap: 0.35rem;
    font-weight: 700;
    color: #334155;
}

.bf-input-grid input,
.bf-input-grid select {
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 0.65rem 0.75rem;
    font: inherit;
}

.bf-char-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 1rem 0;
}

.bf-char-cell {
    min-width: 42px;
    padding: 0.45rem 0.35rem;
    text-align: center;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
}

.bf-char-cell strong {
    display: block;
    font-size: 1.1rem;
    color: #0f172a;
}

.bf-char-cell span {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
}

.bf-char-cell.selected {
    background: #eff6ff;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.35);
}

.bf-code {
    display: inline-block;
    margin: 0.6rem 0;
    padding: 0.55rem 0.8rem;
    border-radius: 14px;
    background: #0f172a;
    color: white;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
}

.bf-result-box {
    margin: 0.75rem 0;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #14532d;
    font-weight: 700;
}

.bf-result-box strong {
    font-size: 1.3rem;
}

.bf-explain {
    color: #475569;
    margin-bottom: 0;
}

.bf-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.8rem;
}

.bf-status-grid div {
    padding: 1rem;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.bf-status-grid span {
    display: block;
    color: #64748b;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.bf-status-grid strong {
    display: block;
    overflow-wrap: anywhere;
    color: #0f172a;
}

.bf-random-display {
    margin: 1rem auto;
    width: 110px;
    height: 110px;
    display: grid;
    place-items: center;
    border-radius: 28px;
    background: #eff6ff;
    border: 2px solid #93c5fd;
    color: #1e3a8a;
    font-size: 2.6rem;
    font-weight: 900;
}

.bf-random-display.roll {
    animation: bfPop 0.25s ease;
}

@keyframes bfPop {
    0% { transform: scale(0.88); }
    70% { transform: scale(1.08); }
    100% { transform: scale(1); }
}
